@mantine/core 9.0.1 → 9.1.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/Blockquote/Blockquote.cjs +5 -6
- package/cjs/components/Blockquote/Blockquote.cjs.map +1 -1
- package/cjs/components/Flex/Flex.cjs +7 -2
- package/cjs/components/Flex/Flex.cjs.map +1 -1
- package/cjs/components/FloatingIndicator/FloatingIndicator.cjs +1 -2
- package/cjs/components/FloatingIndicator/FloatingIndicator.cjs.map +1 -1
- package/cjs/components/MaskInput/MaskInput.cjs +24 -0
- package/cjs/components/MaskInput/MaskInput.cjs.map +1 -0
- package/cjs/components/MaskInput/use-mask-input-props.cjs +29 -0
- package/cjs/components/MaskInput/use-mask-input-props.cjs.map +1 -0
- package/cjs/components/Rating/Rating.cjs +1 -2
- package/cjs/components/Rating/Rating.cjs.map +1 -1
- package/cjs/components/SemiCircleProgress/SemiCircleProgress.cjs +2 -0
- package/cjs/components/SemiCircleProgress/SemiCircleProgress.cjs.map +1 -1
- package/cjs/components/Slider/Marks/Marks.cjs +3 -2
- package/cjs/components/Slider/Marks/Marks.cjs.map +1 -1
- package/cjs/components/Slider/Marks/is-mark-filled.cjs +2 -1
- package/cjs/components/Slider/Marks/is-mark-filled.cjs.map +1 -1
- package/cjs/components/Slider/Slider/Slider.cjs +12 -3
- package/cjs/components/Slider/Slider/Slider.cjs.map +1 -1
- package/cjs/components/Slider/Track/Track.cjs +3 -2
- package/cjs/components/Slider/Track/Track.cjs.map +1 -1
- package/cjs/components/Tabs/Tabs.cjs +3 -1
- package/cjs/components/Tabs/Tabs.cjs.map +1 -1
- package/cjs/components/Tabs/Tabs.context.cjs.map +1 -1
- package/cjs/components/Tabs/TabsPanel/TabsPanel.cjs +2 -1
- package/cjs/components/Tabs/TabsPanel/TabsPanel.cjs.map +1 -1
- package/cjs/components/Textarea/Autosize.cjs +1 -0
- package/cjs/components/Textarea/Autosize.cjs.map +1 -1
- package/cjs/components/Tree/FlatTreeNode.cjs +102 -0
- package/cjs/components/Tree/FlatTreeNode.cjs.map +1 -0
- package/cjs/components/Tree/Tree.cjs +10 -2
- package/cjs/components/Tree/Tree.cjs.map +1 -1
- package/cjs/components/Tree/Tree.module.cjs.map +1 -1
- package/cjs/components/Tree/TreeNode.cjs +65 -27
- package/cjs/components/Tree/TreeNode.cjs.map +1 -1
- package/cjs/components/Tree/filter-tree-data/filter-tree-data.cjs +23 -0
- package/cjs/components/Tree/filter-tree-data/filter-tree-data.cjs.map +1 -0
- package/cjs/components/Tree/flatten-tree-data/flatten-tree-data.cjs +28 -0
- package/cjs/components/Tree/flatten-tree-data/flatten-tree-data.cjs.map +1 -0
- package/cjs/components/Tree/get-children-nodes-values/get-children-nodes-values.cjs +1 -0
- package/cjs/components/Tree/merge-async-children/merge-async-children.cjs +32 -0
- package/cjs/components/Tree/merge-async-children/merge-async-children.cjs.map +1 -0
- package/cjs/components/Tree/move-tree-node/move-tree-node.cjs +78 -0
- package/cjs/components/Tree/move-tree-node/move-tree-node.cjs.map +1 -0
- package/cjs/components/Tree/use-tree-node-drag-drop.cjs +96 -0
- package/cjs/components/Tree/use-tree-node-drag-drop.cjs.map +1 -0
- package/cjs/components/Tree/use-tree.cjs +176 -26
- package/cjs/components/Tree/use-tree.cjs.map +1 -1
- package/cjs/core/Box/Box.cjs +6 -2
- package/cjs/core/Box/Box.cjs.map +1 -1
- package/cjs/core/InlineStyles/InlineStyles.cjs +14 -2
- package/cjs/core/InlineStyles/InlineStyles.cjs.map +1 -1
- package/cjs/core/InlineStyles/hash-styles.cjs +15 -0
- package/cjs/core/InlineStyles/hash-styles.cjs.map +1 -0
- package/cjs/core/MantineProvider/Mantine.context.cjs +4 -0
- package/cjs/core/MantineProvider/Mantine.context.cjs.map +1 -1
- package/cjs/core/MantineProvider/MantineProvider.cjs +3 -2
- package/cjs/core/MantineProvider/MantineProvider.cjs.map +1 -1
- package/cjs/core/MantineProvider/color-functions/default-variant-colors-resolver/default-variant-colors-resolver.cjs +3 -4
- package/cjs/core/MantineProvider/color-functions/default-variant-colors-resolver/default-variant-colors-resolver.cjs.map +1 -1
- package/cjs/index.cjs +16 -0
- package/esm/components/Blockquote/Blockquote.mjs +5 -6
- package/esm/components/Blockquote/Blockquote.mjs.map +1 -1
- package/esm/components/Flex/Flex.mjs +7 -2
- package/esm/components/Flex/Flex.mjs.map +1 -1
- package/esm/components/FloatingIndicator/FloatingIndicator.mjs +1 -2
- package/esm/components/FloatingIndicator/FloatingIndicator.mjs.map +1 -1
- package/esm/components/MaskInput/MaskInput.mjs +23 -0
- package/esm/components/MaskInput/MaskInput.mjs.map +1 -0
- package/esm/components/MaskInput/use-mask-input-props.mjs +28 -0
- package/esm/components/MaskInput/use-mask-input-props.mjs.map +1 -0
- package/esm/components/Rating/Rating.mjs +1 -2
- package/esm/components/Rating/Rating.mjs.map +1 -1
- package/esm/components/SemiCircleProgress/SemiCircleProgress.mjs +2 -0
- package/esm/components/SemiCircleProgress/SemiCircleProgress.mjs.map +1 -1
- package/esm/components/Slider/Marks/Marks.mjs +3 -2
- package/esm/components/Slider/Marks/Marks.mjs.map +1 -1
- package/esm/components/Slider/Marks/is-mark-filled.mjs +2 -1
- package/esm/components/Slider/Marks/is-mark-filled.mjs.map +1 -1
- package/esm/components/Slider/Slider/Slider.mjs +12 -3
- package/esm/components/Slider/Slider/Slider.mjs.map +1 -1
- package/esm/components/Slider/Track/Track.mjs +3 -2
- package/esm/components/Slider/Track/Track.mjs.map +1 -1
- package/esm/components/Tabs/Tabs.context.mjs.map +1 -1
- package/esm/components/Tabs/Tabs.mjs +3 -1
- package/esm/components/Tabs/Tabs.mjs.map +1 -1
- package/esm/components/Tabs/TabsPanel/TabsPanel.mjs +2 -1
- package/esm/components/Tabs/TabsPanel/TabsPanel.mjs.map +1 -1
- package/esm/components/Textarea/Autosize.mjs +1 -0
- package/esm/components/Textarea/Autosize.mjs.map +1 -1
- package/esm/components/Tree/FlatTreeNode.mjs +101 -0
- package/esm/components/Tree/FlatTreeNode.mjs.map +1 -0
- package/esm/components/Tree/Tree.mjs +11 -3
- package/esm/components/Tree/Tree.mjs.map +1 -1
- package/esm/components/Tree/Tree.module.mjs.map +1 -1
- package/esm/components/Tree/TreeNode.mjs +65 -27
- package/esm/components/Tree/TreeNode.mjs.map +1 -1
- package/esm/components/Tree/filter-tree-data/filter-tree-data.mjs +22 -0
- package/esm/components/Tree/filter-tree-data/filter-tree-data.mjs.map +1 -0
- package/esm/components/Tree/flatten-tree-data/flatten-tree-data.mjs +28 -0
- package/esm/components/Tree/flatten-tree-data/flatten-tree-data.mjs.map +1 -0
- package/esm/components/Tree/get-children-nodes-values/get-children-nodes-values.mjs +1 -1
- package/esm/components/Tree/merge-async-children/merge-async-children.mjs +32 -0
- package/esm/components/Tree/merge-async-children/merge-async-children.mjs.map +1 -0
- package/esm/components/Tree/move-tree-node/move-tree-node.mjs +78 -0
- package/esm/components/Tree/move-tree-node/move-tree-node.mjs.map +1 -0
- package/esm/components/Tree/use-tree-node-drag-drop.mjs +96 -0
- package/esm/components/Tree/use-tree-node-drag-drop.mjs.map +1 -0
- package/esm/components/Tree/use-tree.mjs +177 -27
- package/esm/components/Tree/use-tree.mjs.map +1 -1
- package/esm/core/Box/Box.mjs +7 -3
- package/esm/core/Box/Box.mjs.map +1 -1
- package/esm/core/InlineStyles/InlineStyles.mjs +14 -2
- package/esm/core/InlineStyles/InlineStyles.mjs.map +1 -1
- package/esm/core/InlineStyles/hash-styles.mjs +15 -0
- package/esm/core/InlineStyles/hash-styles.mjs.map +1 -0
- package/esm/core/MantineProvider/Mantine.context.mjs +4 -1
- package/esm/core/MantineProvider/Mantine.context.mjs.map +1 -1
- package/esm/core/MantineProvider/MantineProvider.mjs +3 -2
- package/esm/core/MantineProvider/MantineProvider.mjs.map +1 -1
- package/esm/core/MantineProvider/color-functions/default-variant-colors-resolver/default-variant-colors-resolver.mjs +3 -4
- package/esm/core/MantineProvider/color-functions/default-variant-colors-resolver/default-variant-colors-resolver.mjs.map +1 -1
- package/esm/index.mjs +9 -2
- package/lib/components/MaskInput/MaskInput.d.ts +68 -0
- package/lib/components/MaskInput/index.d.ts +7 -0
- package/lib/components/MaskInput/use-mask-input-props.d.ts +428 -0
- package/lib/components/Slider/Marks/Marks.d.ts +2 -1
- package/lib/components/Slider/Marks/is-mark-filled.d.ts +2 -1
- package/lib/components/Slider/Slider/Slider.d.ts +2 -0
- package/lib/components/Slider/Track/Track.d.ts +2 -1
- package/lib/components/Tabs/Tabs.context.d.ts +1 -0
- package/lib/components/Tabs/Tabs.d.ts +2 -0
- package/lib/components/Tree/FlatTreeNode.d.ts +31 -0
- package/lib/components/Tree/Tree.d.ts +21 -1
- package/lib/components/Tree/TreeNode.d.ts +6 -2
- package/lib/components/Tree/filter-tree-data/filter-tree-data.d.ts +4 -0
- package/lib/components/Tree/flatten-tree-data/flatten-tree-data.d.ts +15 -0
- package/lib/components/Tree/index.d.ts +9 -0
- package/lib/components/Tree/merge-async-children/merge-async-children.d.ts +2 -0
- package/lib/components/Tree/move-tree-node/move-tree-node.d.ts +11 -0
- package/lib/components/Tree/use-tree-node-drag-drop.d.ts +18 -0
- package/lib/components/Tree/use-tree.d.ts +19 -1
- package/lib/components/index.d.ts +1 -0
- package/lib/core/InlineStyles/InlineStyles.d.ts +2 -1
- package/lib/core/InlineStyles/hash-styles.d.ts +2 -0
- package/lib/core/InlineStyles/index.d.ts +1 -0
- package/lib/core/MantineProvider/Mantine.context.d.ts +2 -0
- package/lib/core/MantineProvider/MantineProvider.d.ts +3 -1
- package/lib/core/MantineProvider/index.d.ts +1 -1
- package/package.json +5 -5
- package/styles/Tree.css +66 -0
- package/styles/Tree.layer.css +66 -0
- package/styles.css +66 -0
- package/styles.layer.css +66 -0
|
@@ -20,13 +20,12 @@ const varsResolver = require_create_vars_resolver.createVarsResolver((theme, { c
|
|
|
20
20
|
theme,
|
|
21
21
|
colorScheme: "dark"
|
|
22
22
|
});
|
|
23
|
-
const lightParsed = require_parse_theme_color.parseThemeColor({
|
|
24
|
-
color: color || theme.primaryColor,
|
|
25
|
-
theme,
|
|
26
|
-
colorScheme: "light"
|
|
27
|
-
});
|
|
28
23
|
return { root: {
|
|
29
|
-
"--bq-bg-light": require_rgba.rgba(
|
|
24
|
+
"--bq-bg-light": require_rgba.rgba(require_parse_theme_color.parseThemeColor({
|
|
25
|
+
color: color || theme.primaryColor,
|
|
26
|
+
theme,
|
|
27
|
+
colorScheme: "light"
|
|
28
|
+
}).value, .07),
|
|
30
29
|
"--bq-bg-dark": require_rgba.rgba(darkParsed.value, .06),
|
|
31
30
|
"--bq-bd": require_get_theme_color.getThemeColor(color, theme),
|
|
32
31
|
"--bq-icon-size": require_rem.rem(iconSize),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Blockquote.cjs","names":["createVarsResolver","parseThemeColor","rgba","getThemeColor","rem","getRadius","factory","useProps","useStyles","Box","classes"],"sources":["../../../src/components/Blockquote/Blockquote.tsx"],"sourcesContent":["import {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getRadius,\n getThemeColor,\n MantineColor,\n MantineRadius,\n parseThemeColor,\n rem,\n rgba,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../core';\nimport classes from './Blockquote.module.css';\n\nexport type BlockquoteStylesNames = 'root' | 'icon' | 'cite';\nexport type BlockquoteCssVariables = {\n root: '--bq-bg-light' | '--bq-bg-dark' | '--bq-bd' | '--bq-icon-size' | '--bq-radius';\n};\n\nexport interface BlockquoteProps\n extends BoxProps, StylesApiProps<BlockquoteFactory>, ElementProps<'blockquote', 'cite'> {\n /** Blockquote icon, displayed at the top left side */\n icon?: React.ReactNode;\n\n /** Controls icon `width` and `height`, numbers are converted to rem @default 40 */\n iconSize?: number | string;\n\n /** Key of `theme.colors` or any valid CSS color @default theme.primaryColor */\n color?: MantineColor;\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius` @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** Reference to a cited quote */\n cite?: React.ReactNode;\n}\n\nexport type BlockquoteFactory = Factory<{\n props: BlockquoteProps;\n ref: HTMLQuoteElement;\n stylesNames: BlockquoteStylesNames;\n vars: BlockquoteCssVariables;\n}>;\n\nconst defaultProps = {\n iconSize: 48,\n} satisfies Partial<BlockquoteProps>;\n\nconst varsResolver = createVarsResolver<BlockquoteFactory>((theme, { color, iconSize, radius }) => {\n const darkParsed = parseThemeColor({\n color: color || theme.primaryColor,\n theme,\n colorScheme: 'dark',\n });\n\n const lightParsed = parseThemeColor({\n color: color || theme.primaryColor,\n theme,\n colorScheme: 'light',\n });\n\n return {\n root: {\n '--bq-bg-light': rgba(lightParsed.value, 0.07),\n '--bq-bg-dark': rgba(darkParsed.value, 0.06),\n '--bq-bd': getThemeColor(color, theme),\n '--bq-icon-size': rem(iconSize),\n '--bq-radius': getRadius(radius),\n },\n };\n});\n\nexport const Blockquote = factory<BlockquoteFactory>((_props) => {\n const props = useProps('Blockquote', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n children,\n icon,\n iconSize,\n cite,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<BlockquoteFactory>({\n name: 'Blockquote',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n return (\n <Box component=\"blockquote\" {...getStyles('root')} {...others}>\n {icon && <span {...getStyles('icon')}>{icon}</span>}\n {children}\n {cite && <cite {...getStyles('cite')}>{cite}</cite>}\n </Box>\n );\n});\n\nBlockquote.classes = classes;\nBlockquote.varsResolver = varsResolver;\nBlockquote.displayName = '@mantine/core/Blockquote';\n\nexport namespace Blockquote {\n export type Props = BlockquoteProps;\n export type StylesNames = BlockquoteStylesNames;\n export type CssVariables = BlockquoteCssVariables;\n export type Factory = BlockquoteFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkDA,MAAM,eAAe,EACnB,UAAU,IACX;AAED,MAAM,eAAeA,6BAAAA,oBAAuC,OAAO,EAAE,OAAO,UAAU,aAAa;CACjG,MAAM,aAAaC,0BAAAA,gBAAgB;EACjC,OAAO,SAAS,MAAM;EACtB;EACA,aAAa;EACd,CAAC;
|
|
1
|
+
{"version":3,"file":"Blockquote.cjs","names":["createVarsResolver","parseThemeColor","rgba","getThemeColor","rem","getRadius","factory","useProps","useStyles","Box","classes"],"sources":["../../../src/components/Blockquote/Blockquote.tsx"],"sourcesContent":["import {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getRadius,\n getThemeColor,\n MantineColor,\n MantineRadius,\n parseThemeColor,\n rem,\n rgba,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../core';\nimport classes from './Blockquote.module.css';\n\nexport type BlockquoteStylesNames = 'root' | 'icon' | 'cite';\nexport type BlockquoteCssVariables = {\n root: '--bq-bg-light' | '--bq-bg-dark' | '--bq-bd' | '--bq-icon-size' | '--bq-radius';\n};\n\nexport interface BlockquoteProps\n extends BoxProps, StylesApiProps<BlockquoteFactory>, ElementProps<'blockquote', 'cite'> {\n /** Blockquote icon, displayed at the top left side */\n icon?: React.ReactNode;\n\n /** Controls icon `width` and `height`, numbers are converted to rem @default 40 */\n iconSize?: number | string;\n\n /** Key of `theme.colors` or any valid CSS color @default theme.primaryColor */\n color?: MantineColor;\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius` @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** Reference to a cited quote */\n cite?: React.ReactNode;\n}\n\nexport type BlockquoteFactory = Factory<{\n props: BlockquoteProps;\n ref: HTMLQuoteElement;\n stylesNames: BlockquoteStylesNames;\n vars: BlockquoteCssVariables;\n}>;\n\nconst defaultProps = {\n iconSize: 48,\n} satisfies Partial<BlockquoteProps>;\n\nconst varsResolver = createVarsResolver<BlockquoteFactory>((theme, { color, iconSize, radius }) => {\n const darkParsed = parseThemeColor({\n color: color || theme.primaryColor,\n theme,\n colorScheme: 'dark',\n });\n\n const lightParsed = parseThemeColor({\n color: color || theme.primaryColor,\n theme,\n colorScheme: 'light',\n });\n\n return {\n root: {\n '--bq-bg-light': rgba(lightParsed.value, 0.07),\n '--bq-bg-dark': rgba(darkParsed.value, 0.06),\n '--bq-bd': getThemeColor(color, theme),\n '--bq-icon-size': rem(iconSize),\n '--bq-radius': getRadius(radius),\n },\n };\n});\n\nexport const Blockquote = factory<BlockquoteFactory>((_props) => {\n const props = useProps('Blockquote', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n children,\n icon,\n iconSize,\n cite,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<BlockquoteFactory>({\n name: 'Blockquote',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n return (\n <Box component=\"blockquote\" {...getStyles('root')} {...others}>\n {icon && <span {...getStyles('icon')}>{icon}</span>}\n {children}\n {cite && <cite {...getStyles('cite')}>{cite}</cite>}\n </Box>\n );\n});\n\nBlockquote.classes = classes;\nBlockquote.varsResolver = varsResolver;\nBlockquote.displayName = '@mantine/core/Blockquote';\n\nexport namespace Blockquote {\n export type Props = BlockquoteProps;\n export type StylesNames = BlockquoteStylesNames;\n export type CssVariables = BlockquoteCssVariables;\n export type Factory = BlockquoteFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkDA,MAAM,eAAe,EACnB,UAAU,IACX;AAED,MAAM,eAAeA,6BAAAA,oBAAuC,OAAO,EAAE,OAAO,UAAU,aAAa;CACjG,MAAM,aAAaC,0BAAAA,gBAAgB;EACjC,OAAO,SAAS,MAAM;EACtB;EACA,aAAa;EACd,CAAC;AAQF,QAAO,EACL,MAAM;EACJ,iBAAiBC,aAAAA,KARDD,0BAAAA,gBAAgB;GAClC,OAAO,SAAS,MAAM;GACtB;GACA,aAAa;GACd,CAAC,CAIoC,OAAO,IAAK;EAC9C,gBAAgBC,aAAAA,KAAK,WAAW,OAAO,IAAK;EAC5C,WAAWC,wBAAAA,cAAc,OAAO,MAAM;EACtC,kBAAkBC,YAAAA,IAAI,SAAS;EAC/B,eAAeC,iBAAAA,UAAU,OAAO;EACjC,EACF;EACD;AAEF,MAAa,aAAaC,gBAAAA,SAA4B,WAAW;CAC/D,MAAM,QAAQC,kBAAAA,SAAS,cAAc,cAAc,OAAO;CAC1D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,UACA,MACA,UACA,MACA,YACA,GAAG,WACD;CAEJ,MAAM,YAAYC,mBAAAA,UAA6B;EAC7C,MAAM;EACN,SAAA,0BAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,QACE,iBAAA,GAAA,kBAAA,MAACC,YAAAA,KAAD;EAAK,WAAU;EAAa,GAAI,UAAU,OAAO;EAAE,GAAI;YAAvD;GACG,QAAQ,iBAAA,GAAA,kBAAA,KAAC,QAAD;IAAM,GAAI,UAAU,OAAO;cAAG;IAAY,CAAA;GAClD;GACA,QAAQ,iBAAA,GAAA,kBAAA,KAAC,QAAD;IAAM,GAAI,UAAU,OAAO;cAAG;IAAY,CAAA;GAC/C;;EAER;AAEF,WAAW,UAAUC,0BAAAA;AACrB,WAAW,eAAe;AAC1B,WAAW,cAAc"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
const require_filter_props = require("../../core/utils/filter-props/filter-props.cjs");
|
|
4
|
+
const require_Mantine_context = require("../../core/MantineProvider/Mantine.context.cjs");
|
|
4
5
|
const require_MantineThemeProvider = require("../../core/MantineProvider/MantineThemeProvider/MantineThemeProvider.cjs");
|
|
5
6
|
const require_use_props = require("../../core/MantineProvider/use-props/use-props.cjs");
|
|
6
7
|
const require_use_styles = require("../../core/styles-api/use-styles/use-styles.cjs");
|
|
7
8
|
const require_InlineStyles = require("../../core/InlineStyles/InlineStyles.cjs");
|
|
9
|
+
const require_hash_styles = require("../../core/InlineStyles/hash-styles.cjs");
|
|
8
10
|
const require_parse_style_props = require("../../core/Box/style-props/parse-style-props/parse-style-props.cjs");
|
|
9
11
|
const require_use_random_classname = require("../../core/Box/use-random-classname/use-random-classname.cjs");
|
|
10
12
|
const require_polymorphic_factory = require("../../core/factory/polymorphic-factory.cjs");
|
|
@@ -29,7 +31,7 @@ const Flex = require_polymorphic_factory.polymorphicFactory((_props) => {
|
|
|
29
31
|
vars
|
|
30
32
|
});
|
|
31
33
|
const theme = require_MantineThemeProvider.useMantineTheme();
|
|
32
|
-
const
|
|
34
|
+
const randomClassName = require_use_random_classname.useRandomClassName();
|
|
33
35
|
const parsedStyleProps = require_parse_style_props.parseStyleProps({
|
|
34
36
|
styleProps: {
|
|
35
37
|
gap,
|
|
@@ -43,10 +45,13 @@ const Flex = require_polymorphic_factory.polymorphicFactory((_props) => {
|
|
|
43
45
|
theme,
|
|
44
46
|
data: require_flex_props.FLEX_STYLE_PROPS_DATA
|
|
45
47
|
});
|
|
48
|
+
const deduplicateInlineStyles = require_Mantine_context.useMantineDeduplicateInlineStyles();
|
|
49
|
+
const responsiveClassName = deduplicateInlineStyles && parsedStyleProps.hasResponsiveStyles ? require_hash_styles.hashStyleProps(parsedStyleProps.styles, parsedStyleProps.media) : randomClassName;
|
|
46
50
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [parsedStyleProps.hasResponsiveStyles && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_InlineStyles.InlineStyles, {
|
|
47
51
|
selector: `.${responsiveClassName}`,
|
|
48
52
|
styles: parsedStyleProps.styles,
|
|
49
|
-
media: parsedStyleProps.media
|
|
53
|
+
media: parsedStyleProps.media,
|
|
54
|
+
deduplicate: deduplicateInlineStyles
|
|
50
55
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
|
|
51
56
|
...getStyles("root", {
|
|
52
57
|
className: responsiveClassName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flex.cjs","names":["polymorphicFactory","useProps","useStyles","useMantineTheme","useRandomClassName","parseStyleProps","FLEX_STYLE_PROPS_DATA","InlineStyles","Box","filterProps","classes"],"sources":["../../../src/components/Flex/Flex.tsx"],"sourcesContent":["import {\n Box,\n BoxProps,\n ElementProps,\n filterProps,\n InlineStyles,\n MantineSpacing,\n parseStyleProps,\n polymorphicFactory,\n PolymorphicFactory,\n StyleProp,\n StylesApiProps,\n useMantineTheme,\n useProps,\n useRandomClassName,\n useStyles,\n} from '../../core';\nimport { FLEX_STYLE_PROPS_DATA } from './flex-props';\nimport classes from './Flex.module.css';\n\nexport type FlexStylesNames = 'root';\n\nexport interface FlexProps extends BoxProps, StylesApiProps<FlexFactory>, ElementProps<'div'> {\n /** `gap` CSS property */\n gap?: StyleProp<MantineSpacing>;\n\n /** `row-gap` CSS property */\n rowGap?: StyleProp<MantineSpacing>;\n\n /** `column-gap` CSS property */\n columnGap?: StyleProp<MantineSpacing>;\n\n /** `align-items` CSS property */\n align?: StyleProp<React.CSSProperties['alignItems']>;\n\n /** `justify-content` CSS property */\n justify?: StyleProp<React.CSSProperties['justifyContent']>;\n\n /** `flex-wrap` CSS property */\n wrap?: StyleProp<React.CSSProperties['flexWrap']>;\n\n /** `flex-direction` CSS property */\n direction?: StyleProp<React.CSSProperties['flexDirection']>;\n}\n\nexport type FlexFactory = PolymorphicFactory<{\n props: FlexProps;\n defaultRef: HTMLDivElement;\n defaultComponent: 'div';\n stylesNames: FlexStylesNames;\n}>;\n\nexport const Flex = polymorphicFactory<FlexFactory>((_props) => {\n const props = useProps('Flex', null, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n gap,\n rowGap,\n columnGap,\n align,\n justify,\n wrap,\n direction,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<FlexFactory>({\n name: 'Flex',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n });\n\n const theme = useMantineTheme();\n const
|
|
1
|
+
{"version":3,"file":"Flex.cjs","names":["polymorphicFactory","useProps","useStyles","useMantineTheme","useRandomClassName","parseStyleProps","FLEX_STYLE_PROPS_DATA","useMantineDeduplicateInlineStyles","hashStyleProps","InlineStyles","Box","filterProps","classes"],"sources":["../../../src/components/Flex/Flex.tsx"],"sourcesContent":["import {\n Box,\n BoxProps,\n ElementProps,\n filterProps,\n hashStyleProps,\n InlineStyles,\n MantineSpacing,\n parseStyleProps,\n polymorphicFactory,\n PolymorphicFactory,\n StyleProp,\n StylesApiProps,\n useMantineDeduplicateInlineStyles,\n useMantineTheme,\n useProps,\n useRandomClassName,\n useStyles,\n} from '../../core';\nimport { FLEX_STYLE_PROPS_DATA } from './flex-props';\nimport classes from './Flex.module.css';\n\nexport type FlexStylesNames = 'root';\n\nexport interface FlexProps extends BoxProps, StylesApiProps<FlexFactory>, ElementProps<'div'> {\n /** `gap` CSS property */\n gap?: StyleProp<MantineSpacing>;\n\n /** `row-gap` CSS property */\n rowGap?: StyleProp<MantineSpacing>;\n\n /** `column-gap` CSS property */\n columnGap?: StyleProp<MantineSpacing>;\n\n /** `align-items` CSS property */\n align?: StyleProp<React.CSSProperties['alignItems']>;\n\n /** `justify-content` CSS property */\n justify?: StyleProp<React.CSSProperties['justifyContent']>;\n\n /** `flex-wrap` CSS property */\n wrap?: StyleProp<React.CSSProperties['flexWrap']>;\n\n /** `flex-direction` CSS property */\n direction?: StyleProp<React.CSSProperties['flexDirection']>;\n}\n\nexport type FlexFactory = PolymorphicFactory<{\n props: FlexProps;\n defaultRef: HTMLDivElement;\n defaultComponent: 'div';\n stylesNames: FlexStylesNames;\n}>;\n\nexport const Flex = polymorphicFactory<FlexFactory>((_props) => {\n const props = useProps('Flex', null, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n gap,\n rowGap,\n columnGap,\n align,\n justify,\n wrap,\n direction,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<FlexFactory>({\n name: 'Flex',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n });\n\n const theme = useMantineTheme();\n const randomClassName = useRandomClassName();\n const parsedStyleProps = parseStyleProps({\n styleProps: { gap, rowGap, columnGap, align, justify, wrap, direction },\n theme,\n data: FLEX_STYLE_PROPS_DATA,\n });\n\n const deduplicateInlineStyles = useMantineDeduplicateInlineStyles();\n const responsiveClassName =\n deduplicateInlineStyles && parsedStyleProps.hasResponsiveStyles\n ? hashStyleProps(parsedStyleProps.styles, parsedStyleProps.media)\n : randomClassName;\n\n return (\n <>\n {parsedStyleProps.hasResponsiveStyles && (\n <InlineStyles\n selector={`.${responsiveClassName}`}\n styles={parsedStyleProps.styles}\n media={parsedStyleProps.media}\n deduplicate={deduplicateInlineStyles}\n />\n )}\n <Box\n {...getStyles('root', {\n className: responsiveClassName,\n style: filterProps(parsedStyleProps.inlineStyles),\n })}\n {...others}\n />\n </>\n );\n});\n\nFlex.classes = classes;\nFlex.displayName = '@mantine/core/Flex';\n\nexport namespace Flex {\n export type Props = FlexProps;\n export type StylesNames = FlexStylesNames;\n export type Factory = FlexFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsDA,MAAa,OAAOA,4BAAAA,oBAAiC,WAAW;CAC9D,MAAM,QAAQC,kBAAAA,SAAS,QAAQ,MAAM,OAAO;CAC5C,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,KACA,QACA,WACA,OACA,SACA,MACA,WACA,YACA,GAAG,WACD;CAEJ,MAAM,YAAYC,mBAAAA,UAAuB;EACvC,MAAM;EACN,SAAA,oBAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,QAAQC,6BAAAA,iBAAiB;CAC/B,MAAM,kBAAkBC,6BAAAA,oBAAoB;CAC5C,MAAM,mBAAmBC,0BAAAA,gBAAgB;EACvC,YAAY;GAAE;GAAK;GAAQ;GAAW;GAAO;GAAS;GAAM;GAAW;EACvE;EACA,MAAMC,mBAAAA;EACP,CAAC;CAEF,MAAM,0BAA0BC,wBAAAA,mCAAmC;CACnE,MAAM,sBACJ,2BAA2B,iBAAiB,sBACxCC,oBAAAA,eAAe,iBAAiB,QAAQ,iBAAiB,MAAM,GAC/D;AAEN,QACE,iBAAA,GAAA,kBAAA,MAAA,kBAAA,UAAA,EAAA,UAAA,CACG,iBAAiB,uBAChB,iBAAA,GAAA,kBAAA,KAACC,qBAAAA,cAAD;EACE,UAAU,IAAI;EACd,QAAQ,iBAAiB;EACzB,OAAO,iBAAiB;EACxB,aAAa;EACb,CAAA,EAEJ,iBAAA,GAAA,kBAAA,KAACC,YAAAA,KAAD;EACE,GAAI,UAAU,QAAQ;GACpB,WAAW;GACX,OAAOC,qBAAAA,YAAY,iBAAiB,aAAa;GAClD,CAAC;EACF,GAAI;EACJ,CAAA,CACD,EAAA,CAAA;EAEL;AAEF,KAAK,UAAUC,oBAAAA;AACf,KAAK,cAAc"}
|
|
@@ -12,8 +12,7 @@ let _mantine_hooks = require("@mantine/hooks");
|
|
|
12
12
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
13
13
|
//#region packages/@mantine/core/src/components/FloatingIndicator/FloatingIndicator.tsx
|
|
14
14
|
const varsResolver = require_create_vars_resolver.createVarsResolver((theme, { transitionDuration }, { shouldReduceMotion }) => {
|
|
15
|
-
|
|
16
|
-
return { root: { "--transition-duration": duration } };
|
|
15
|
+
return { root: { "--transition-duration": (theme.respectReducedMotion ? shouldReduceMotion : false) ? "0ms" : typeof transitionDuration === "number" ? `${transitionDuration}ms` : transitionDuration || "150ms" } };
|
|
17
16
|
});
|
|
18
17
|
const FloatingIndicator = require_factory.factory((_props) => {
|
|
19
18
|
const props = require_use_props.useProps("FloatingIndicator", null, _props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingIndicator.cjs","names":["createVarsResolver","factory","useProps","useStyles","useFloatingIndicator","Box","classes"],"sources":["../../../src/components/FloatingIndicator/FloatingIndicator.tsx"],"sourcesContent":["import { useRef } from 'react';\nimport { useMergedRef, useReducedMotion } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../core';\nimport { useFloatingIndicator } from './use-floating-indicator';\nimport classes from './FloatingIndicator.module.css';\n\nexport type FloatingIndicatorStylesNames = 'root';\nexport type FloatingIndicatorCssVariables = {\n root: '--transition-duration';\n};\n\nexport interface FloatingIndicatorProps\n extends BoxProps, StylesApiProps<FloatingIndicatorFactory>, ElementProps<'div'> {\n /** Target element over which the indicator is displayed.\n * The indicator will be positioned to match the target's size and position.\n * */\n target: HTMLElement | null | undefined;\n\n /** Parent container element that must have `position: relative`.\n * The indicator's position is calculated relative to this element.\n * */\n parent: HTMLElement | null | undefined;\n\n /** Transition duration in ms @default 150 */\n transitionDuration?: number | string;\n\n /** Controls whether the indicator should be hidden initially and displayed after the parent's transition ends.\n * Set to `true` when the parent container has CSS transitions (e.g., `transform: scale()`) to prevent\n * the indicator from appearing at the wrong position during the parent's animation.\n * @default false\n * */\n displayAfterTransitionEnd?: boolean;\n\n /** Called when the indicator starts transitioning to a new position */\n onTransitionStart?: () => void;\n\n /** Called when the indicator finishes transitioning to a new position */\n onTransitionEnd?: () => void;\n}\n\nexport type FloatingIndicatorFactory = Factory<{\n props: FloatingIndicatorProps;\n ref: HTMLDivElement;\n stylesNames: FloatingIndicatorStylesNames;\n vars: FloatingIndicatorCssVariables;\n ctx: { shouldReduceMotion: boolean };\n}>;\n\nconst varsResolver = createVarsResolver<FloatingIndicatorFactory>(\n (theme, { transitionDuration }, { shouldReduceMotion }) => {\n const reduceMotion = theme.respectReducedMotion ? shouldReduceMotion : false;\n const duration = reduceMotion\n ? '0ms'\n : typeof transitionDuration === 'number'\n ? `${transitionDuration}ms`\n : transitionDuration || '150ms';\n\n return {\n root: {\n '--transition-duration': duration,\n },\n };\n }\n);\n\nexport const FloatingIndicator = factory<FloatingIndicatorFactory>((_props) => {\n const props = useProps('FloatingIndicator', null, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n target,\n parent,\n transitionDuration,\n mod,\n displayAfterTransitionEnd,\n onTransitionStart,\n onTransitionEnd,\n attributes,\n ref,\n ...others\n } = props;\n\n const shouldReduceMotion = useReducedMotion();\n\n const getStyles = useStyles<FloatingIndicatorFactory>({\n name: 'FloatingIndicator',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n stylesCtx: { shouldReduceMotion },\n });\n\n const innerRef = useRef<HTMLDivElement>(null);\n const { initialized, hidden } = useFloatingIndicator({\n target,\n parent,\n ref: innerRef,\n displayAfterTransitionEnd,\n onTransitionStart,\n onTransitionEnd,\n });\n\n const mergedRef = useMergedRef(ref, innerRef);\n\n if (!target || !parent) {\n return null;\n }\n\n return (\n <Box ref={mergedRef} mod={[{ initialized, hidden }, mod]} {...getStyles('root')} {...others} />\n );\n});\n\nFloatingIndicator.displayName = '@mantine/core/FloatingIndicator';\nFloatingIndicator.classes = classes;\nFloatingIndicator.varsResolver = varsResolver;\n\nexport namespace FloatingIndicator {\n export type Props = FloatingIndicatorProps;\n export type StylesNames = FloatingIndicatorStylesNames;\n export type CssVariables = FloatingIndicatorCssVariables;\n export type Factory = FloatingIndicatorFactory;\n}\n"],"mappings":";;;;;;;;;;;;;AA0DA,MAAM,eAAeA,6BAAAA,oBAClB,OAAO,EAAE,sBAAsB,EAAE,yBAAyB;
|
|
1
|
+
{"version":3,"file":"FloatingIndicator.cjs","names":["createVarsResolver","factory","useProps","useStyles","useFloatingIndicator","Box","classes"],"sources":["../../../src/components/FloatingIndicator/FloatingIndicator.tsx"],"sourcesContent":["import { useRef } from 'react';\nimport { useMergedRef, useReducedMotion } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../core';\nimport { useFloatingIndicator } from './use-floating-indicator';\nimport classes from './FloatingIndicator.module.css';\n\nexport type FloatingIndicatorStylesNames = 'root';\nexport type FloatingIndicatorCssVariables = {\n root: '--transition-duration';\n};\n\nexport interface FloatingIndicatorProps\n extends BoxProps, StylesApiProps<FloatingIndicatorFactory>, ElementProps<'div'> {\n /** Target element over which the indicator is displayed.\n * The indicator will be positioned to match the target's size and position.\n * */\n target: HTMLElement | null | undefined;\n\n /** Parent container element that must have `position: relative`.\n * The indicator's position is calculated relative to this element.\n * */\n parent: HTMLElement | null | undefined;\n\n /** Transition duration in ms @default 150 */\n transitionDuration?: number | string;\n\n /** Controls whether the indicator should be hidden initially and displayed after the parent's transition ends.\n * Set to `true` when the parent container has CSS transitions (e.g., `transform: scale()`) to prevent\n * the indicator from appearing at the wrong position during the parent's animation.\n * @default false\n * */\n displayAfterTransitionEnd?: boolean;\n\n /** Called when the indicator starts transitioning to a new position */\n onTransitionStart?: () => void;\n\n /** Called when the indicator finishes transitioning to a new position */\n onTransitionEnd?: () => void;\n}\n\nexport type FloatingIndicatorFactory = Factory<{\n props: FloatingIndicatorProps;\n ref: HTMLDivElement;\n stylesNames: FloatingIndicatorStylesNames;\n vars: FloatingIndicatorCssVariables;\n ctx: { shouldReduceMotion: boolean };\n}>;\n\nconst varsResolver = createVarsResolver<FloatingIndicatorFactory>(\n (theme, { transitionDuration }, { shouldReduceMotion }) => {\n const reduceMotion = theme.respectReducedMotion ? shouldReduceMotion : false;\n const duration = reduceMotion\n ? '0ms'\n : typeof transitionDuration === 'number'\n ? `${transitionDuration}ms`\n : transitionDuration || '150ms';\n\n return {\n root: {\n '--transition-duration': duration,\n },\n };\n }\n);\n\nexport const FloatingIndicator = factory<FloatingIndicatorFactory>((_props) => {\n const props = useProps('FloatingIndicator', null, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n target,\n parent,\n transitionDuration,\n mod,\n displayAfterTransitionEnd,\n onTransitionStart,\n onTransitionEnd,\n attributes,\n ref,\n ...others\n } = props;\n\n const shouldReduceMotion = useReducedMotion();\n\n const getStyles = useStyles<FloatingIndicatorFactory>({\n name: 'FloatingIndicator',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n stylesCtx: { shouldReduceMotion },\n });\n\n const innerRef = useRef<HTMLDivElement>(null);\n const { initialized, hidden } = useFloatingIndicator({\n target,\n parent,\n ref: innerRef,\n displayAfterTransitionEnd,\n onTransitionStart,\n onTransitionEnd,\n });\n\n const mergedRef = useMergedRef(ref, innerRef);\n\n if (!target || !parent) {\n return null;\n }\n\n return (\n <Box ref={mergedRef} mod={[{ initialized, hidden }, mod]} {...getStyles('root')} {...others} />\n );\n});\n\nFloatingIndicator.displayName = '@mantine/core/FloatingIndicator';\nFloatingIndicator.classes = classes;\nFloatingIndicator.varsResolver = varsResolver;\n\nexport namespace FloatingIndicator {\n export type Props = FloatingIndicatorProps;\n export type StylesNames = FloatingIndicatorStylesNames;\n export type CssVariables = FloatingIndicatorCssVariables;\n export type Factory = FloatingIndicatorFactory;\n}\n"],"mappings":";;;;;;;;;;;;;AA0DA,MAAM,eAAeA,6BAAAA,oBAClB,OAAO,EAAE,sBAAsB,EAAE,yBAAyB;AAQzD,QAAO,EACL,MAAM,EACJ,0BATiB,MAAM,uBAAuB,qBAAqB,SAEnE,QACA,OAAO,uBAAuB,WAC5B,GAAG,mBAAmB,MACtB,sBAAsB,SAKzB,EACF;EAEJ;AAED,MAAa,oBAAoBC,gBAAAA,SAAmC,WAAW;CAC7E,MAAM,QAAQC,kBAAAA,SAAS,qBAAqB,MAAM,OAAO;CACzD,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,QACA,QACA,oBACA,KACA,2BACA,mBACA,iBACA,YACA,KACA,GAAG,WACD;CAIJ,MAAM,YAAYC,mBAAAA,UAAoC;EACpD,MAAM;EACN,SAAA,iCAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW,EAAE,qBAAA,GAAA,eAAA,mBAd8B,EAcV;EAClC,CAAC;CAEF,MAAM,YAAA,GAAA,MAAA,QAAkC,KAAK;CAC7C,MAAM,EAAE,aAAa,WAAWC,+BAAAA,qBAAqB;EACnD;EACA;EACA,KAAK;EACL;EACA;EACA;EACD,CAAC;CAEF,MAAM,aAAA,GAAA,eAAA,cAAyB,KAAK,SAAS;AAE7C,KAAI,CAAC,UAAU,CAAC,OACd,QAAO;AAGT,QACE,iBAAA,GAAA,kBAAA,KAACC,YAAAA,KAAD;EAAK,KAAK;EAAW,KAAK,CAAC;GAAE;GAAa;GAAQ,EAAE,IAAI;EAAE,GAAI,UAAU,OAAO;EAAE,GAAI;EAAU,CAAA;EAEjG;AAEF,kBAAkB,cAAc;AAChC,kBAAkB,UAAUC,iCAAAA;AAC5B,kBAAkB,eAAe"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_use_props = require("../../core/MantineProvider/use-props/use-props.cjs");
|
|
4
|
+
const require_factory = require("../../core/factory/factory.cjs");
|
|
5
|
+
const require_InputBase = require("../InputBase/InputBase.cjs");
|
|
6
|
+
const require_use_mask_input_props = require("./use-mask-input-props.cjs");
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
//#region packages/@mantine/core/src/components/MaskInput/MaskInput.tsx
|
|
9
|
+
const defaultProps = {};
|
|
10
|
+
const MaskInput = require_factory.factory((props) => {
|
|
11
|
+
const { maskRef, elementProps } = require_use_mask_input_props.useMaskInputProps(require_use_props.useProps("MaskInput", defaultProps, props));
|
|
12
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_InputBase.InputBase, {
|
|
13
|
+
component: "input",
|
|
14
|
+
ref: maskRef,
|
|
15
|
+
...elementProps,
|
|
16
|
+
__staticSelector: "MaskInput"
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
MaskInput.classes = require_InputBase.InputBase.classes;
|
|
20
|
+
MaskInput.displayName = "@mantine/core/MaskInput";
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.MaskInput = MaskInput;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=MaskInput.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaskInput.cjs","names":["factory","useMaskInputProps","useProps","InputBase"],"sources":["../../../src/components/MaskInput/MaskInput.tsx"],"sourcesContent":["import { BoxProps, ElementProps, factory, Factory, StylesApiProps, useProps } from '../../core';\nimport { __BaseInputProps, __InputStylesNames, InputVariant } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { useMaskInputProps } from './use-mask-input-props';\n\nexport interface MaskInputProps\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<MaskInputFactory>,\n ElementProps<'input', 'size'> {\n /** Mask pattern string or array of string literals and RegExp objects */\n mask: string | Array<string | RegExp>;\n\n /** Override or extend the default token map */\n tokens?: Record<string, RegExp>;\n\n /** Called before masking on each keystroke, can return overrides for mask options */\n modify?: (\n value: string\n ) => Partial<Pick<MaskInputProps, 'mask' | 'tokens' | 'slotChar' | 'separate'>> | undefined;\n\n /** When true, raw and display values are decoupled */\n separate?: boolean;\n\n /** Character displayed in unfilled slots, `\"_\"` by default */\n slotChar?: string | null;\n\n /** Show mask pattern even when field is empty and unfocused */\n alwaysShowMask?: boolean;\n\n /** Show mask placeholder on focus, `true` by default */\n showMaskOnFocus?: boolean;\n\n /** Transform each character before validation and insertion */\n transform?: (char: string) => string;\n\n /** Clear value on blur when mask is incomplete, `false` by default */\n autoClear?: boolean;\n\n /** Called on every change with raw and masked values */\n onChangeRaw?: (rawValue: string, maskedValue: string) => void;\n\n /** Called when all required mask slots are filled */\n onComplete?: (maskedValue: string, rawValue: string) => void;\n\n /** Escape hatch for advanced cursor/value manipulation */\n beforeMaskedStateChange?: (states: {\n previousState: { value: string; selection: { start: number; end: number } | null };\n currentState: { value: string; selection: { start: number; end: number } | null };\n nextState: { value: string; selection: { start: number; end: number } | null };\n }) => { value: string; selection: { start: number; end: number } | null };\n}\n\nexport type MaskInputFactory = Factory<{\n props: MaskInputProps;\n variant: InputVariant;\n ref: HTMLInputElement;\n stylesNames: __InputStylesNames;\n}>;\n\nconst defaultProps = {} satisfies Partial<MaskInputProps>;\n\nexport const MaskInput = factory<MaskInputFactory>((props) => {\n const _props = useProps('MaskInput', defaultProps, props);\n const { maskRef, elementProps } = useMaskInputProps(_props);\n\n return (\n <InputBase\n component=\"input\"\n ref={maskRef}\n {...(elementProps as any)}\n __staticSelector=\"MaskInput\"\n />\n );\n});\n\nMaskInput.classes = InputBase.classes;\nMaskInput.displayName = '@mantine/core/MaskInput';\n"],"mappings":";;;;;;;;AA6DA,MAAM,eAAe,EAAE;AAEvB,MAAa,YAAYA,gBAAAA,SAA2B,UAAU;CAE5D,MAAM,EAAE,SAAS,iBAAiBC,6BAAAA,kBADnBC,kBAAAA,SAAS,aAAa,cAAc,MAAM,CACE;AAE3D,QACE,iBAAA,GAAA,kBAAA,KAACC,kBAAAA,WAAD;EACE,WAAU;EACV,KAAK;EACL,GAAK;EACL,kBAAiB;EACjB,CAAA;EAEJ;AAEF,UAAU,UAAUA,kBAAAA,UAAU;AAC9B,UAAU,cAAc"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
let _mantine_hooks = require("@mantine/hooks");
|
|
4
|
+
//#region packages/@mantine/core/src/components/MaskInput/use-mask-input-props.ts
|
|
5
|
+
function useMaskInputProps(props) {
|
|
6
|
+
const { mask, tokens, modify, separate, slotChar, alwaysShowMask, showMaskOnFocus, transform, autoClear, onChangeRaw, onComplete, beforeMaskedStateChange, ref, ...elementProps } = props;
|
|
7
|
+
const { ref: maskCallbackRef } = (0, _mantine_hooks.useMask)({
|
|
8
|
+
mask,
|
|
9
|
+
tokens,
|
|
10
|
+
modify,
|
|
11
|
+
separate,
|
|
12
|
+
slotChar,
|
|
13
|
+
alwaysShowMask,
|
|
14
|
+
showMaskOnFocus,
|
|
15
|
+
transform,
|
|
16
|
+
autoClear,
|
|
17
|
+
onChangeRaw,
|
|
18
|
+
onComplete,
|
|
19
|
+
beforeMaskedStateChange
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
maskRef: (0, _mantine_hooks.useMergedRef)(ref, maskCallbackRef),
|
|
23
|
+
elementProps
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.useMaskInputProps = useMaskInputProps;
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=use-mask-input-props.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-mask-input-props.cjs","names":[],"sources":["../../../src/components/MaskInput/use-mask-input-props.ts"],"sourcesContent":["import { useMask, useMergedRef } from '@mantine/hooks';\nimport type { MaskInputProps } from './MaskInput';\n\nexport function useMaskInputProps(props: MaskInputProps & { ref?: React.Ref<HTMLInputElement> }) {\n const {\n mask,\n tokens,\n modify,\n separate,\n slotChar,\n alwaysShowMask,\n showMaskOnFocus,\n transform,\n autoClear,\n onChangeRaw,\n onComplete,\n beforeMaskedStateChange,\n ref,\n ...elementProps\n } = props;\n\n const { ref: maskCallbackRef } = useMask({\n mask,\n tokens,\n modify,\n separate,\n slotChar,\n alwaysShowMask,\n showMaskOnFocus,\n transform,\n autoClear,\n onChangeRaw,\n onComplete,\n beforeMaskedStateChange,\n });\n\n const maskRef = useMergedRef(ref, maskCallbackRef);\n\n return { maskRef, elementProps };\n}\n"],"mappings":";;;;AAGA,SAAgB,kBAAkB,OAA+D;CAC/F,MAAM,EACJ,MACA,QACA,QACA,UACA,UACA,gBACA,iBACA,WACA,WACA,aACA,YACA,yBACA,KACA,GAAG,iBACD;CAEJ,MAAM,EAAE,KAAK,qBAAA,GAAA,eAAA,SAA4B;EACvC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAIF,QAAO;EAAE,UAAA,GAAA,eAAA,cAFoB,KAAK,gBAAgB;EAEhC;EAAc"}
|
|
@@ -116,9 +116,8 @@ const Rating = require_factory.factory((_props) => {
|
|
|
116
116
|
const items = Array(_count).fill(0).map((_, index) => {
|
|
117
117
|
const integerValue = index + 1;
|
|
118
118
|
const fractionItems = Array.from(new Array(index === 0 ? _fractions + 1 : _fractions));
|
|
119
|
-
const isGroupActive = !readOnly && Math.ceil(hovered) === integerValue;
|
|
120
119
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
121
|
-
"data-active":
|
|
120
|
+
"data-active": !readOnly && Math.ceil(hovered) === integerValue || void 0,
|
|
122
121
|
...getStyles("symbolGroup"),
|
|
123
122
|
children: fractionItems.map((__, fractionIndex) => {
|
|
124
123
|
const fractionValue = decimalUnit * (index === 0 ? fractionIndex : fractionIndex + 1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rating.cjs","names":["createVarsResolver","getSize","getThemeColor","factory","useProps","useStyles","useDirection","RatingItem","RatingProvider","Box","classes"],"sources":["../../../src/components/Rating/Rating.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { clamp, useId, useMergedRef, useUncontrolled } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getSize,\n getThemeColor,\n MantineColor,\n MantineSize,\n StylesApiProps,\n useDirection,\n useProps,\n useStyles,\n} from '../../core';\nimport { RatingProvider } from './Rating.context';\nimport { RatingItem } from './RatingItem/RatingItem';\nimport classes from './Rating.module.css';\n\nfunction roundValueTo(value: number, to: number) {\n const rounded = Math.round(value / to) * to;\n const precision = `${to}`.split('.')[1]?.length || 0;\n return Number(rounded.toFixed(precision));\n}\n\nexport type RatingStylesNames =\n | 'root'\n | 'starSymbol'\n | 'input'\n | 'label'\n | 'symbolBody'\n | 'symbolGroup';\n\nexport type RatingCssVariables = {\n root: '--rating-size' | '--rating-color';\n};\n\nexport interface RatingProps\n extends BoxProps, StylesApiProps<RatingFactory>, ElementProps<'div', 'onChange'> {\n /** Uncontrolled component default value */\n defaultValue?: number;\n\n /** Controlled component value */\n value?: number;\n\n /** Called when value changes */\n onChange?: (value: number) => void;\n\n /** Icon displayed for unselected rating items. Can be a function that receives the rating value. */\n emptySymbol?: React.ReactNode | ((value: number) => React.ReactNode);\n\n /** Icon displayed for selected rating items. Can be a function that receives the rating value. */\n fullSymbol?: React.ReactNode | ((value: number) => React.ReactNode);\n\n /** Number of fractions each item can be divided into, default is 1 */\n fractions?: number;\n\n /** Controls component size @default 'sm' */\n size?: MantineSize | number | (string & {});\n\n /** Number of rating items (stars), default is 5 */\n count?: number;\n\n /** Called when rating item is hovered. Receives -1 when hover ends. */\n onHover?: (value: number) => void;\n\n /** Function to generate aria-label for each rating value. Receives the rating value as argument, default is (value) => String(value) */\n getSymbolLabel?: (index: number) => string;\n\n /** Name attribute for form submission. If not provided, a unique id will be generated. */\n name?: string;\n\n /** When true, rating cannot be changed by user interaction, default is false */\n readOnly?: boolean;\n\n /** When true, clicking the same rating value clears the rating to 0, default is false */\n allowClear?: boolean;\n\n /** When true, only the clicked rating item is highlighted, not all items up to the selected value, default is false */\n highlightSelectedOnly?: boolean;\n\n /** Key of theme.colors or any CSS color value, default is 'yellow' */\n color?: MantineColor;\n}\n\nexport type RatingFactory = Factory<{\n props: RatingProps;\n ref: HTMLDivElement;\n stylesNames: RatingStylesNames;\n vars: RatingCssVariables;\n}>;\n\nconst defaultProps = {\n size: 'sm',\n getSymbolLabel: (value) => `${value}`,\n count: 5,\n fractions: 1,\n color: 'yellow',\n} satisfies Partial<RatingProps>;\n\nconst varsResolver = createVarsResolver<RatingFactory>((theme, { size, color }) => ({\n root: {\n '--rating-size': getSize(size, 'rating-size'),\n '--rating-color': getThemeColor(color, theme),\n },\n}));\n\nexport const Rating = factory<RatingFactory>((_props) => {\n const props = useProps('Rating', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n name,\n id,\n value,\n defaultValue,\n onChange,\n fractions,\n count,\n onMouseEnter,\n readOnly,\n allowClear,\n onMouseMove,\n onHover,\n onMouseLeave,\n onTouchStart,\n onTouchEnd,\n size,\n variant,\n getSymbolLabel,\n color,\n emptySymbol,\n fullSymbol,\n highlightSelectedOnly,\n attributes,\n ref,\n ...others\n } = props;\n\n const getStyles = useStyles<RatingFactory>({\n name: 'Rating',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { dir } = useDirection();\n\n const _name = useId(name);\n const _id = useId(id);\n const rootRef = useRef<HTMLDivElement>(null);\n\n const [_value, setValue] = useUncontrolled({\n value,\n defaultValue,\n finalValue: 0,\n onChange,\n });\n\n const [hovered, setHovered] = useState(-1);\n const [isOutside, setOutside] = useState(true);\n\n const _fractions = Math.floor(fractions);\n const _count = Math.floor(count);\n\n const decimalUnit = 1 / _fractions;\n const stableValueRounded = roundValueTo(_value, decimalUnit);\n const finalValue = hovered !== -1 ? hovered : stableValueRounded;\n\n const getRatingFromCoordinates = (x: number) => {\n if (!rootRef.current) {\n return 0;\n }\n\n const { left, right, width } = rootRef.current.getBoundingClientRect();\n const symbolWidth = width / _count;\n\n const hoverPosition = dir === 'rtl' ? right - x : x - left;\n const hoverValue = hoverPosition / symbolWidth;\n\n return clamp(roundValueTo(hoverValue + decimalUnit / 2, decimalUnit), decimalUnit, _count);\n };\n\n const handleMouseEnter = (event: React.MouseEvent<HTMLDivElement>) => {\n onMouseEnter?.(event);\n !readOnly && setOutside(false);\n };\n\n const handleMouseMove = (event: React.MouseEvent<HTMLDivElement>) => {\n onMouseMove?.(event);\n\n if (readOnly) {\n return;\n }\n\n const rounded = getRatingFromCoordinates(event.clientX);\n\n setHovered(rounded);\n rounded !== hovered && onHover?.(rounded);\n };\n\n const handleMouseLeave = (event: React.MouseEvent<HTMLDivElement>) => {\n onMouseLeave?.(event);\n\n if (readOnly) {\n return;\n }\n\n setHovered(-1);\n setOutside(true);\n hovered !== -1 && onHover?.(-1);\n };\n\n const handleTouchStart = (event: React.TouchEvent<HTMLDivElement>) => {\n const { touches } = event;\n if (touches.length !== 1) {\n return;\n }\n\n if (!readOnly) {\n const touch = touches[0];\n setValue(getRatingFromCoordinates(touch.clientX));\n }\n\n onTouchStart?.(event);\n };\n\n const handleTouchEnd = (event: React.TouchEvent<HTMLDivElement>) => {\n event.preventDefault();\n\n onTouchEnd?.(event);\n };\n\n const handleItemBlur = () => isOutside && setHovered(-1);\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement> | number) => {\n if (!readOnly) {\n if (typeof event === 'number') {\n setHovered(event);\n } else {\n setHovered(parseFloat(event.target.value));\n }\n }\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement> | number) => {\n if (!readOnly) {\n const newValue = typeof event === 'number' ? event : parseFloat(event.target.value);\n\n // If allowClear is true and clicking the same value, reset to 0\n if (allowClear && newValue === stableValueRounded) {\n setValue(0);\n } else {\n setValue(newValue);\n }\n }\n };\n\n const items = Array(_count)\n .fill(0)\n .map((_, index) => {\n const integerValue = index + 1;\n const fractionItems = Array.from(new Array(index === 0 ? _fractions + 1 : _fractions));\n const isGroupActive = !readOnly && Math.ceil(hovered) === integerValue;\n\n return (\n <div\n key={integerValue}\n data-active={isGroupActive || undefined}\n {...getStyles('symbolGroup')}\n >\n {fractionItems.map((__, fractionIndex) => {\n const fractionValue = decimalUnit * (index === 0 ? fractionIndex : fractionIndex + 1);\n const symbolValue = roundValueTo(integerValue - 1 + fractionValue, decimalUnit);\n\n return (\n <RatingItem\n key={`${integerValue}-${symbolValue}`}\n getSymbolLabel={getSymbolLabel}\n emptyIcon={emptySymbol}\n fullIcon={fullSymbol}\n full={\n highlightSelectedOnly ? symbolValue === finalValue : symbolValue <= finalValue\n }\n active={symbolValue === finalValue}\n checked={symbolValue === stableValueRounded}\n readOnly={readOnly}\n fractionValue={fractionValue}\n value={symbolValue}\n name={_name}\n onChange={handleChange}\n onBlur={handleItemBlur}\n onInputChange={handleInputChange}\n id={`${_id}-${index}-${fractionIndex}`}\n />\n );\n })}\n </div>\n );\n });\n\n return (\n <RatingProvider value={{ getStyles }}>\n <Box\n ref={useMergedRef(rootRef, ref)}\n {...getStyles('root')}\n onMouseMove={handleMouseMove}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onTouchStart={handleTouchStart}\n onTouchEnd={handleTouchEnd}\n variant={variant}\n size={size}\n id={_id}\n {...others}\n >\n {items}\n </Box>\n </RatingProvider>\n );\n});\n\nRating.classes = classes;\nRating.varsResolver = varsResolver;\nRating.displayName = '@mantine/core/Rating';\n\nexport namespace Rating {\n export type Props = RatingProps;\n export type StylesNames = RatingStylesNames;\n export type Factory = RatingFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,SAAS,aAAa,OAAe,IAAY;CAC/C,MAAM,UAAU,KAAK,MAAM,QAAQ,GAAG,GAAG;CACzC,MAAM,YAAY,GAAG,KAAK,MAAM,IAAI,CAAC,IAAI,UAAU;AACnD,QAAO,OAAO,QAAQ,QAAQ,UAAU,CAAC;;AAsE3C,MAAM,eAAe;CACnB,MAAM;CACN,iBAAiB,UAAU,GAAG;CAC9B,OAAO;CACP,WAAW;CACX,OAAO;CACR;AAED,MAAM,eAAeA,6BAAAA,oBAAmC,OAAO,EAAE,MAAM,aAAa,EAClF,MAAM;CACJ,iBAAiBC,iBAAAA,QAAQ,MAAM,cAAc;CAC7C,kBAAkBC,wBAAAA,cAAc,OAAO,MAAM;CAC9C,EACF,EAAE;AAEH,MAAa,SAASC,gBAAAA,SAAwB,WAAW;CACvD,MAAM,QAAQC,kBAAAA,SAAS,UAAU,cAAc,OAAO;CACtD,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,MACA,IACA,OACA,cACA,UACA,WACA,OACA,cACA,UACA,YACA,a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AAI,eAAe,YAAY;AAE/E,WACE,iBAAA,GAAA,kBAAA,KAACC,mBAAAA,YAAD;KAEkB;KAChB,WAAW;KACX,UAAU;KACV,MACE,wBAAwB,gBAAgB,aAAa,eAAe;KAEtE,QAAQ,gBAAgB;KACxB,SAAS,gBAAgB;KACf;KACK;KACf,OAAO;KACP,MAAM;KACN,UAAU;KACV,QAAQ;KACR,eAAe;KACf,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG;KACvB,EAjBK,GAAG,aAAa,GAAG,cAiBxB;KAEJ;GACE,EA9BC,aA8BD;GAER;AAEJ,QACE,iBAAA,GAAA,kBAAA,KAACC,uBAAAA,gBAAD;EAAgB,OAAO,EAAE,WAAW;YAClC,iBAAA,GAAA,kBAAA,KAACC,YAAAA,KAAD;GACE,MAAA,GAAA,eAAA,cAAkB,SAAS,IAAI;GAC/B,GAAI,UAAU,OAAO;GACrB,aAAa;GACb,cAAc;GACd,cAAc;GACd,cAAc;GACd,YAAY;GACH;GACH;GACN,IAAI;GACJ,GAAI;aAEH;GACG,CAAA;EACS,CAAA;EAEnB;AAEF,OAAO,UAAUC,sBAAAA;AACjB,OAAO,eAAe;AACtB,OAAO,cAAc"}
|
|
1
|
+
{"version":3,"file":"Rating.cjs","names":["createVarsResolver","getSize","getThemeColor","factory","useProps","useStyles","useDirection","RatingItem","RatingProvider","Box","classes"],"sources":["../../../src/components/Rating/Rating.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { clamp, useId, useMergedRef, useUncontrolled } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getSize,\n getThemeColor,\n MantineColor,\n MantineSize,\n StylesApiProps,\n useDirection,\n useProps,\n useStyles,\n} from '../../core';\nimport { RatingProvider } from './Rating.context';\nimport { RatingItem } from './RatingItem/RatingItem';\nimport classes from './Rating.module.css';\n\nfunction roundValueTo(value: number, to: number) {\n const rounded = Math.round(value / to) * to;\n const precision = `${to}`.split('.')[1]?.length || 0;\n return Number(rounded.toFixed(precision));\n}\n\nexport type RatingStylesNames =\n | 'root'\n | 'starSymbol'\n | 'input'\n | 'label'\n | 'symbolBody'\n | 'symbolGroup';\n\nexport type RatingCssVariables = {\n root: '--rating-size' | '--rating-color';\n};\n\nexport interface RatingProps\n extends BoxProps, StylesApiProps<RatingFactory>, ElementProps<'div', 'onChange'> {\n /** Uncontrolled component default value */\n defaultValue?: number;\n\n /** Controlled component value */\n value?: number;\n\n /** Called when value changes */\n onChange?: (value: number) => void;\n\n /** Icon displayed for unselected rating items. Can be a function that receives the rating value. */\n emptySymbol?: React.ReactNode | ((value: number) => React.ReactNode);\n\n /** Icon displayed for selected rating items. Can be a function that receives the rating value. */\n fullSymbol?: React.ReactNode | ((value: number) => React.ReactNode);\n\n /** Number of fractions each item can be divided into, default is 1 */\n fractions?: number;\n\n /** Controls component size @default 'sm' */\n size?: MantineSize | number | (string & {});\n\n /** Number of rating items (stars), default is 5 */\n count?: number;\n\n /** Called when rating item is hovered. Receives -1 when hover ends. */\n onHover?: (value: number) => void;\n\n /** Function to generate aria-label for each rating value. Receives the rating value as argument, default is (value) => String(value) */\n getSymbolLabel?: (index: number) => string;\n\n /** Name attribute for form submission. If not provided, a unique id will be generated. */\n name?: string;\n\n /** When true, rating cannot be changed by user interaction, default is false */\n readOnly?: boolean;\n\n /** When true, clicking the same rating value clears the rating to 0, default is false */\n allowClear?: boolean;\n\n /** When true, only the clicked rating item is highlighted, not all items up to the selected value, default is false */\n highlightSelectedOnly?: boolean;\n\n /** Key of theme.colors or any CSS color value, default is 'yellow' */\n color?: MantineColor;\n}\n\nexport type RatingFactory = Factory<{\n props: RatingProps;\n ref: HTMLDivElement;\n stylesNames: RatingStylesNames;\n vars: RatingCssVariables;\n}>;\n\nconst defaultProps = {\n size: 'sm',\n getSymbolLabel: (value) => `${value}`,\n count: 5,\n fractions: 1,\n color: 'yellow',\n} satisfies Partial<RatingProps>;\n\nconst varsResolver = createVarsResolver<RatingFactory>((theme, { size, color }) => ({\n root: {\n '--rating-size': getSize(size, 'rating-size'),\n '--rating-color': getThemeColor(color, theme),\n },\n}));\n\nexport const Rating = factory<RatingFactory>((_props) => {\n const props = useProps('Rating', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n name,\n id,\n value,\n defaultValue,\n onChange,\n fractions,\n count,\n onMouseEnter,\n readOnly,\n allowClear,\n onMouseMove,\n onHover,\n onMouseLeave,\n onTouchStart,\n onTouchEnd,\n size,\n variant,\n getSymbolLabel,\n color,\n emptySymbol,\n fullSymbol,\n highlightSelectedOnly,\n attributes,\n ref,\n ...others\n } = props;\n\n const getStyles = useStyles<RatingFactory>({\n name: 'Rating',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { dir } = useDirection();\n\n const _name = useId(name);\n const _id = useId(id);\n const rootRef = useRef<HTMLDivElement>(null);\n\n const [_value, setValue] = useUncontrolled({\n value,\n defaultValue,\n finalValue: 0,\n onChange,\n });\n\n const [hovered, setHovered] = useState(-1);\n const [isOutside, setOutside] = useState(true);\n\n const _fractions = Math.floor(fractions);\n const _count = Math.floor(count);\n\n const decimalUnit = 1 / _fractions;\n const stableValueRounded = roundValueTo(_value, decimalUnit);\n const finalValue = hovered !== -1 ? hovered : stableValueRounded;\n\n const getRatingFromCoordinates = (x: number) => {\n if (!rootRef.current) {\n return 0;\n }\n\n const { left, right, width } = rootRef.current.getBoundingClientRect();\n const symbolWidth = width / _count;\n\n const hoverPosition = dir === 'rtl' ? right - x : x - left;\n const hoverValue = hoverPosition / symbolWidth;\n\n return clamp(roundValueTo(hoverValue + decimalUnit / 2, decimalUnit), decimalUnit, _count);\n };\n\n const handleMouseEnter = (event: React.MouseEvent<HTMLDivElement>) => {\n onMouseEnter?.(event);\n !readOnly && setOutside(false);\n };\n\n const handleMouseMove = (event: React.MouseEvent<HTMLDivElement>) => {\n onMouseMove?.(event);\n\n if (readOnly) {\n return;\n }\n\n const rounded = getRatingFromCoordinates(event.clientX);\n\n setHovered(rounded);\n rounded !== hovered && onHover?.(rounded);\n };\n\n const handleMouseLeave = (event: React.MouseEvent<HTMLDivElement>) => {\n onMouseLeave?.(event);\n\n if (readOnly) {\n return;\n }\n\n setHovered(-1);\n setOutside(true);\n hovered !== -1 && onHover?.(-1);\n };\n\n const handleTouchStart = (event: React.TouchEvent<HTMLDivElement>) => {\n const { touches } = event;\n if (touches.length !== 1) {\n return;\n }\n\n if (!readOnly) {\n const touch = touches[0];\n setValue(getRatingFromCoordinates(touch.clientX));\n }\n\n onTouchStart?.(event);\n };\n\n const handleTouchEnd = (event: React.TouchEvent<HTMLDivElement>) => {\n event.preventDefault();\n\n onTouchEnd?.(event);\n };\n\n const handleItemBlur = () => isOutside && setHovered(-1);\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement> | number) => {\n if (!readOnly) {\n if (typeof event === 'number') {\n setHovered(event);\n } else {\n setHovered(parseFloat(event.target.value));\n }\n }\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement> | number) => {\n if (!readOnly) {\n const newValue = typeof event === 'number' ? event : parseFloat(event.target.value);\n\n // If allowClear is true and clicking the same value, reset to 0\n if (allowClear && newValue === stableValueRounded) {\n setValue(0);\n } else {\n setValue(newValue);\n }\n }\n };\n\n const items = Array(_count)\n .fill(0)\n .map((_, index) => {\n const integerValue = index + 1;\n const fractionItems = Array.from(new Array(index === 0 ? _fractions + 1 : _fractions));\n const isGroupActive = !readOnly && Math.ceil(hovered) === integerValue;\n\n return (\n <div\n key={integerValue}\n data-active={isGroupActive || undefined}\n {...getStyles('symbolGroup')}\n >\n {fractionItems.map((__, fractionIndex) => {\n const fractionValue = decimalUnit * (index === 0 ? fractionIndex : fractionIndex + 1);\n const symbolValue = roundValueTo(integerValue - 1 + fractionValue, decimalUnit);\n\n return (\n <RatingItem\n key={`${integerValue}-${symbolValue}`}\n getSymbolLabel={getSymbolLabel}\n emptyIcon={emptySymbol}\n fullIcon={fullSymbol}\n full={\n highlightSelectedOnly ? symbolValue === finalValue : symbolValue <= finalValue\n }\n active={symbolValue === finalValue}\n checked={symbolValue === stableValueRounded}\n readOnly={readOnly}\n fractionValue={fractionValue}\n value={symbolValue}\n name={_name}\n onChange={handleChange}\n onBlur={handleItemBlur}\n onInputChange={handleInputChange}\n id={`${_id}-${index}-${fractionIndex}`}\n />\n );\n })}\n </div>\n );\n });\n\n return (\n <RatingProvider value={{ getStyles }}>\n <Box\n ref={useMergedRef(rootRef, ref)}\n {...getStyles('root')}\n onMouseMove={handleMouseMove}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onTouchStart={handleTouchStart}\n onTouchEnd={handleTouchEnd}\n variant={variant}\n size={size}\n id={_id}\n {...others}\n >\n {items}\n </Box>\n </RatingProvider>\n );\n});\n\nRating.classes = classes;\nRating.varsResolver = varsResolver;\nRating.displayName = '@mantine/core/Rating';\n\nexport namespace Rating {\n export type Props = RatingProps;\n export type StylesNames = RatingStylesNames;\n export type Factory = RatingFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,SAAS,aAAa,OAAe,IAAY;CAC/C,MAAM,UAAU,KAAK,MAAM,QAAQ,GAAG,GAAG;CACzC,MAAM,YAAY,GAAG,KAAK,MAAM,IAAI,CAAC,IAAI,UAAU;AACnD,QAAO,OAAO,QAAQ,QAAQ,UAAU,CAAC;;AAsE3C,MAAM,eAAe;CACnB,MAAM;CACN,iBAAiB,UAAU,GAAG;CAC9B,OAAO;CACP,WAAW;CACX,OAAO;CACR;AAED,MAAM,eAAeA,6BAAAA,oBAAmC,OAAO,EAAE,MAAM,aAAa,EAClF,MAAM;CACJ,iBAAiBC,iBAAAA,QAAQ,MAAM,cAAc;CAC7C,kBAAkBC,wBAAAA,cAAc,OAAO,MAAM;CAC9C,EACF,EAAE;AAEH,MAAa,SAASC,gBAAAA,SAAwB,WAAW;CACvD,MAAM,QAAQC,kBAAAA,SAAS,U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AAkB;IACxC,MAAM,gBAAgB,eAAe,UAAU,IAAI,gBAAgB,gBAAgB;IACnF,MAAM,cAAc,aAAa,eAAe,IAAI,eAAe,YAAY;AAE/E,WACE,iBAAA,GAAA,kBAAA,KAACC,mBAAAA,YAAD;KAEkB;KAChB,WAAW;KACX,UAAU;KACV,MACE,wBAAwB,gBAAgB,aAAa,eAAe;KAEtE,QAAQ,gBAAgB;KACxB,SAAS,gBAAgB;KACf;KACK;KACf,OAAO;KACP,MAAM;KACN,UAAU;KACV,QAAQ;KACR,eAAe;KACf,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG;KACvB,EAjBK,GAAG,aAAa,GAAG,cAiBxB;KAEJ;GACE,EA9BC,aA8BD;GAER;AAEJ,QACE,iBAAA,GAAA,kBAAA,KAACC,uBAAAA,gBAAD;EAAgB,OAAO,EAAE,WAAW;YAClC,iBAAA,GAAA,kBAAA,KAACC,YAAAA,KAAD;GACE,MAAA,GAAA,eAAA,cAAkB,SAAS,IAAI;GAC/B,GAAI,UAAU,OAAO;GACrB,aAAa;GACb,cAAc;GACd,cAAc;GACd,cAAc;GACd,YAAY;GACH;GACH;GACN,IAAI;GACJ,GAAI;aAEH;GACG,CAAA;EACS,CAAA;EAEnB;AAEF,OAAO,UAAUC,sBAAAA;AACjB,OAAO,eAAe;AACtB,OAAO,cAAc"}
|
|
@@ -65,6 +65,8 @@ const SemiCircleProgress = require_factory.factory((_props) => {
|
|
|
65
65
|
"data-orientation": orientation,
|
|
66
66
|
children: label
|
|
67
67
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
68
|
+
width: size,
|
|
69
|
+
height: size / 2,
|
|
68
70
|
viewBox: `0 0 ${size} ${size / 2}`,
|
|
69
71
|
...getStyles("svg"),
|
|
70
72
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SemiCircleProgress.cjs","names":["createVarsResolver","getThemeColor","rem","factory","useProps","useStyles","Box","classes"],"sources":["../../../src/components/SemiCircleProgress/SemiCircleProgress.tsx"],"sourcesContent":["import { clamp } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n rem,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../core';\nimport classes from './SemiCircleProgress.module.css';\n\nexport type SemiCircleProgressStylesNames =\n | 'root'\n | 'svg'\n | 'emptySegment'\n | 'filledSegment'\n | 'label';\n\nexport type SemiCircleProgressCssVariables = {\n root:\n | '--scp-filled-segment-color'\n | '--scp-empty-segment-color'\n | '--scp-rotation'\n | '--scp-transition-duration'\n | '--scp-thickness';\n};\n\nexport interface SemiCircleProgressProps\n extends BoxProps, StylesApiProps<SemiCircleProgressFactory>, ElementProps<'div'> {\n /** Progress value from `0` to `100` */\n value: number;\n\n /** Width of the component and diameter of the full circle in px. The visible SVG height will be size/2 @default 200 */\n size?: number;\n\n /** Stroke width of the circle segments in px @default 12 */\n thickness?: number;\n\n /** Orientation of the circle @default 'up' */\n orientation?: 'up' | 'down';\n\n /** Direction from which the circle is filled @default 'left-to-right' */\n fillDirection?: 'right-to-left' | 'left-to-right';\n\n /** Key of `theme.colors` or any valid CSS color value @default theme.primaryColor */\n filledSegmentColor?: MantineColor;\n\n /** Key of `theme.colors` or any valid CSS color value @default 'gray.2' in light mode, 'dark.4' in dark mode */\n emptySegmentColor?: MantineColor;\n\n /** Transition duration for the filled segment progress changes in ms. Does not affect color transitions @default 0 */\n transitionDuration?: number;\n\n /** Label rendered inside the circle */\n label?: React.ReactNode;\n\n /** Label position relative to the circle center @default 'bottom' */\n labelPosition?: 'center' | 'bottom';\n}\n\nexport type SemiCircleProgressFactory = Factory<{\n props: SemiCircleProgressProps;\n ref: HTMLDivElement;\n stylesNames: SemiCircleProgressStylesNames;\n vars: SemiCircleProgressCssVariables;\n}>;\n\nconst defaultProps = {\n size: 200,\n thickness: 12,\n orientation: 'up',\n fillDirection: 'left-to-right',\n labelPosition: 'bottom',\n} satisfies Partial<SemiCircleProgressProps>;\n\nfunction getRotation({\n orientation,\n fillDirection,\n}: Pick<SemiCircleProgressProps, 'orientation' | 'fillDirection'>) {\n if (orientation === 'down') {\n if (fillDirection === 'right-to-left') {\n return 'rotate(180deg) rotateY(180deg)';\n }\n return 'rotate(180deg)';\n }\n if (fillDirection === 'left-to-right') {\n return 'rotateY(180deg)';\n }\n\n return undefined;\n}\n\nconst varsResolver = createVarsResolver<SemiCircleProgressFactory>(\n (\n theme,\n {\n filledSegmentColor,\n emptySegmentColor,\n orientation,\n fillDirection,\n transitionDuration,\n thickness,\n }\n ) => ({\n root: {\n '--scp-filled-segment-color': filledSegmentColor\n ? getThemeColor(filledSegmentColor, theme)\n : undefined,\n '--scp-empty-segment-color': emptySegmentColor\n ? getThemeColor(emptySegmentColor, theme)\n : undefined,\n '--scp-rotation': getRotation({ orientation, fillDirection }),\n '--scp-transition-duration': transitionDuration ? `${transitionDuration}ms` : undefined,\n '--scp-thickness': rem(thickness),\n },\n })\n);\n\nexport const SemiCircleProgress = factory<SemiCircleProgressFactory>((_props) => {\n const props = useProps('SemiCircleProgress', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n size,\n thickness,\n value,\n orientation,\n fillDirection,\n filledSegmentColor,\n emptySegmentColor,\n transitionDuration,\n label,\n labelPosition,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<SemiCircleProgressFactory>({\n name: 'SemiCircleProgress',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const coordinateForCircle = size / 2;\n const radius = (size - 2 * thickness) / 2;\n const circumference = Math.PI * radius;\n const semiCirclePercentage = clamp(value, 0, 100) * (circumference / 100);\n\n return (\n <Box size={size} {...getStyles('root')} {...others}>\n {label && (\n <div {...getStyles('label')} data-position={labelPosition} data-orientation={orientation}>\n {label}\n </div>\n )}\n\n <svg viewBox={`0 0 ${size} ${size / 2}`} {...getStyles('svg')}>\n <circle\n cx={coordinateForCircle}\n cy={coordinateForCircle}\n r={radius}\n fill=\"none\"\n stroke=\"var(--scp-empty-segment-color)\"\n strokeWidth={thickness}\n strokeDasharray={circumference}\n {...getStyles('emptySegment', { style: { strokeDashoffset: circumference } })}\n />\n\n <circle\n cx={coordinateForCircle}\n cy={coordinateForCircle}\n r={radius}\n fill=\"none\"\n stroke=\"var(--scp-filled-segment-color)\"\n strokeWidth={thickness}\n strokeDasharray={circumference}\n {...getStyles('filledSegment', { style: { strokeDashoffset: semiCirclePercentage } })}\n />\n </svg>\n </Box>\n );\n});\n\nSemiCircleProgress.displayName = '@mantine/core/SemiCircleProgress';\nSemiCircleProgress.classes = classes;\nSemiCircleProgress.varsResolver = varsResolver;\n\nexport namespace SemiCircleProgress {\n export type Props = SemiCircleProgressProps;\n export type StylesNames = SemiCircleProgressStylesNames;\n export type CssVariables = SemiCircleProgressCssVariables;\n export type Factory = SemiCircleProgressFactory;\n}\n"],"mappings":";;;;;;;;;;;;;AAyEA,MAAM,eAAe;CACnB,MAAM;CACN,WAAW;CACX,aAAa;CACb,eAAe;CACf,eAAe;CAChB;AAED,SAAS,YAAY,EACnB,aACA,iBACiE;AACjE,KAAI,gBAAgB,QAAQ;AAC1B,MAAI,kBAAkB,gBACpB,QAAO;AAET,SAAO;;AAET,KAAI,kBAAkB,gBACpB,QAAO;;AAMX,MAAM,eAAeA,6BAAAA,oBAEjB,OACA,EACE,oBACA,mBACA,aACA,eACA,oBACA,iBAEE,EACJ,MAAM;CACJ,8BAA8B,qBAC1BC,wBAAAA,cAAc,oBAAoB,MAAM,GACxC,KAAA;CACJ,6BAA6B,oBACzBA,wBAAAA,cAAc,mBAAmB,MAAM,GACvC,KAAA;CACJ,kBAAkB,YAAY;EAAE;EAAa;EAAe,CAAC;CAC7D,6BAA6B,qBAAqB,GAAG,mBAAmB,MAAM,KAAA;CAC9E,mBAAmBC,YAAAA,IAAI,UAAU;CAClC,EACF,EACF;AAED,MAAa,qBAAqBC,gBAAAA,SAAoC,WAAW;CAC/E,MAAM,QAAQC,kBAAAA,SAAS,sBAAsB,cAAc,OAAO;CAClE,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,MACA,WACA,OACA,aACA,eACA,oBACA,mBACA,oBACA,OACA,eACA,YACA,GAAG,WACD;CAEJ,MAAM,YAAYC,mBAAAA,UAAqC;EACrD,MAAM;EACN,SAAA,kCAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,sBAAsB,OAAO;CACnC,MAAM,UAAU,OAAO,IAAI,aAAa;CACxC,MAAM,gBAAgB,KAAK,KAAK;CAChC,MAAM,wBAAA,GAAA,eAAA,OAA6B,OAAO,GAAG,IAAI,IAAI,gBAAgB;AAErE,QACE,iBAAA,GAAA,kBAAA,MAACC,YAAAA,KAAD;EAAW;EAAM,GAAI,UAAU,OAAO;EAAE,GAAI;YAA5C,CACG,SACC,iBAAA,GAAA,kBAAA,KAAC,OAAD;GAAK,GAAI,UAAU,QAAQ;GAAE,iBAAe;GAAe,oBAAkB;aAC1E;GACG,CAAA,EAGR,iBAAA,GAAA,kBAAA,MAAC,OAAD;GAAK,SAAS,OAAO,KAAK,GAAG,OAAO;GAAK,GAAI,UAAU,MAAM;
|
|
1
|
+
{"version":3,"file":"SemiCircleProgress.cjs","names":["createVarsResolver","getThemeColor","rem","factory","useProps","useStyles","Box","classes"],"sources":["../../../src/components/SemiCircleProgress/SemiCircleProgress.tsx"],"sourcesContent":["import { clamp } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n rem,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../core';\nimport classes from './SemiCircleProgress.module.css';\n\nexport type SemiCircleProgressStylesNames =\n | 'root'\n | 'svg'\n | 'emptySegment'\n | 'filledSegment'\n | 'label';\n\nexport type SemiCircleProgressCssVariables = {\n root:\n | '--scp-filled-segment-color'\n | '--scp-empty-segment-color'\n | '--scp-rotation'\n | '--scp-transition-duration'\n | '--scp-thickness';\n};\n\nexport interface SemiCircleProgressProps\n extends BoxProps, StylesApiProps<SemiCircleProgressFactory>, ElementProps<'div'> {\n /** Progress value from `0` to `100` */\n value: number;\n\n /** Width of the component and diameter of the full circle in px. The visible SVG height will be size/2 @default 200 */\n size?: number;\n\n /** Stroke width of the circle segments in px @default 12 */\n thickness?: number;\n\n /** Orientation of the circle @default 'up' */\n orientation?: 'up' | 'down';\n\n /** Direction from which the circle is filled @default 'left-to-right' */\n fillDirection?: 'right-to-left' | 'left-to-right';\n\n /** Key of `theme.colors` or any valid CSS color value @default theme.primaryColor */\n filledSegmentColor?: MantineColor;\n\n /** Key of `theme.colors` or any valid CSS color value @default 'gray.2' in light mode, 'dark.4' in dark mode */\n emptySegmentColor?: MantineColor;\n\n /** Transition duration for the filled segment progress changes in ms. Does not affect color transitions @default 0 */\n transitionDuration?: number;\n\n /** Label rendered inside the circle */\n label?: React.ReactNode;\n\n /** Label position relative to the circle center @default 'bottom' */\n labelPosition?: 'center' | 'bottom';\n}\n\nexport type SemiCircleProgressFactory = Factory<{\n props: SemiCircleProgressProps;\n ref: HTMLDivElement;\n stylesNames: SemiCircleProgressStylesNames;\n vars: SemiCircleProgressCssVariables;\n}>;\n\nconst defaultProps = {\n size: 200,\n thickness: 12,\n orientation: 'up',\n fillDirection: 'left-to-right',\n labelPosition: 'bottom',\n} satisfies Partial<SemiCircleProgressProps>;\n\nfunction getRotation({\n orientation,\n fillDirection,\n}: Pick<SemiCircleProgressProps, 'orientation' | 'fillDirection'>) {\n if (orientation === 'down') {\n if (fillDirection === 'right-to-left') {\n return 'rotate(180deg) rotateY(180deg)';\n }\n return 'rotate(180deg)';\n }\n if (fillDirection === 'left-to-right') {\n return 'rotateY(180deg)';\n }\n\n return undefined;\n}\n\nconst varsResolver = createVarsResolver<SemiCircleProgressFactory>(\n (\n theme,\n {\n filledSegmentColor,\n emptySegmentColor,\n orientation,\n fillDirection,\n transitionDuration,\n thickness,\n }\n ) => ({\n root: {\n '--scp-filled-segment-color': filledSegmentColor\n ? getThemeColor(filledSegmentColor, theme)\n : undefined,\n '--scp-empty-segment-color': emptySegmentColor\n ? getThemeColor(emptySegmentColor, theme)\n : undefined,\n '--scp-rotation': getRotation({ orientation, fillDirection }),\n '--scp-transition-duration': transitionDuration ? `${transitionDuration}ms` : undefined,\n '--scp-thickness': rem(thickness),\n },\n })\n);\n\nexport const SemiCircleProgress = factory<SemiCircleProgressFactory>((_props) => {\n const props = useProps('SemiCircleProgress', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n size,\n thickness,\n value,\n orientation,\n fillDirection,\n filledSegmentColor,\n emptySegmentColor,\n transitionDuration,\n label,\n labelPosition,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<SemiCircleProgressFactory>({\n name: 'SemiCircleProgress',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const coordinateForCircle = size / 2;\n const radius = (size - 2 * thickness) / 2;\n const circumference = Math.PI * radius;\n const semiCirclePercentage = clamp(value, 0, 100) * (circumference / 100);\n\n return (\n <Box size={size} {...getStyles('root')} {...others}>\n {label && (\n <div {...getStyles('label')} data-position={labelPosition} data-orientation={orientation}>\n {label}\n </div>\n )}\n\n <svg width={size} height={size / 2} viewBox={`0 0 ${size} ${size / 2}`} {...getStyles('svg')}>\n <circle\n cx={coordinateForCircle}\n cy={coordinateForCircle}\n r={radius}\n fill=\"none\"\n stroke=\"var(--scp-empty-segment-color)\"\n strokeWidth={thickness}\n strokeDasharray={circumference}\n {...getStyles('emptySegment', { style: { strokeDashoffset: circumference } })}\n />\n\n <circle\n cx={coordinateForCircle}\n cy={coordinateForCircle}\n r={radius}\n fill=\"none\"\n stroke=\"var(--scp-filled-segment-color)\"\n strokeWidth={thickness}\n strokeDasharray={circumference}\n {...getStyles('filledSegment', { style: { strokeDashoffset: semiCirclePercentage } })}\n />\n </svg>\n </Box>\n );\n});\n\nSemiCircleProgress.displayName = '@mantine/core/SemiCircleProgress';\nSemiCircleProgress.classes = classes;\nSemiCircleProgress.varsResolver = varsResolver;\n\nexport namespace SemiCircleProgress {\n export type Props = SemiCircleProgressProps;\n export type StylesNames = SemiCircleProgressStylesNames;\n export type CssVariables = SemiCircleProgressCssVariables;\n export type Factory = SemiCircleProgressFactory;\n}\n"],"mappings":";;;;;;;;;;;;;AAyEA,MAAM,eAAe;CACnB,MAAM;CACN,WAAW;CACX,aAAa;CACb,eAAe;CACf,eAAe;CAChB;AAED,SAAS,YAAY,EACnB,aACA,iBACiE;AACjE,KAAI,gBAAgB,QAAQ;AAC1B,MAAI,kBAAkB,gBACpB,QAAO;AAET,SAAO;;AAET,KAAI,kBAAkB,gBACpB,QAAO;;AAMX,MAAM,eAAeA,6BAAAA,oBAEjB,OACA,EACE,oBACA,mBACA,aACA,eACA,oBACA,iBAEE,EACJ,MAAM;CACJ,8BAA8B,qBAC1BC,wBAAAA,cAAc,oBAAoB,MAAM,GACxC,KAAA;CACJ,6BAA6B,oBACzBA,wBAAAA,cAAc,mBAAmB,MAAM,GACvC,KAAA;CACJ,kBAAkB,YAAY;EAAE;EAAa;EAAe,CAAC;CAC7D,6BAA6B,qBAAqB,GAAG,mBAAmB,MAAM,KAAA;CAC9E,mBAAmBC,YAAAA,IAAI,UAAU;CAClC,EACF,EACF;AAED,MAAa,qBAAqBC,gBAAAA,SAAoC,WAAW;CAC/E,MAAM,QAAQC,kBAAAA,SAAS,sBAAsB,cAAc,OAAO;CAClE,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,MACA,WACA,OACA,aACA,eACA,oBACA,mBACA,oBACA,OACA,eACA,YACA,GAAG,WACD;CAEJ,MAAM,YAAYC,mBAAAA,UAAqC;EACrD,MAAM;EACN,SAAA,kCAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,sBAAsB,OAAO;CACnC,MAAM,UAAU,OAAO,IAAI,aAAa;CACxC,MAAM,gBAAgB,KAAK,KAAK;CAChC,MAAM,wBAAA,GAAA,eAAA,OAA6B,OAAO,GAAG,IAAI,IAAI,gBAAgB;AAErE,QACE,iBAAA,GAAA,kBAAA,MAACC,YAAAA,KAAD;EAAW;EAAM,GAAI,UAAU,OAAO;EAAE,GAAI;YAA5C,CACG,SACC,iBAAA,GAAA,kBAAA,KAAC,OAAD;GAAK,GAAI,UAAU,QAAQ;GAAE,iBAAe;GAAe,oBAAkB;aAC1E;GACG,CAAA,EAGR,iBAAA,GAAA,kBAAA,MAAC,OAAD;GAAK,OAAO;GAAM,QAAQ,OAAO;GAAG,SAAS,OAAO,KAAK,GAAG,OAAO;GAAK,GAAI,UAAU,MAAM;aAA5F,CACE,iBAAA,GAAA,kBAAA,KAAC,UAAD;IACE,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,MAAK;IACL,QAAO;IACP,aAAa;IACb,iBAAiB;IACjB,GAAI,UAAU,gBAAgB,EAAE,OAAO,EAAE,kBAAkB,eAAe,EAAE,CAAC;IAC7E,CAAA,EAEF,iBAAA,GAAA,kBAAA,KAAC,UAAD;IACE,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,MAAK;IACL,QAAO;IACP,aAAa;IACb,iBAAiB;IACjB,GAAI,UAAU,iBAAiB,EAAE,OAAO,EAAE,kBAAkB,sBAAsB,EAAE,CAAC;IACrF,CAAA,CACE;KACF;;EAER;AAEF,mBAAmB,cAAc;AACjC,mBAAmB,UAAUC,kCAAAA;AAC7B,mBAAmB,eAAe"}
|
|
@@ -7,7 +7,7 @@ const require_is_mark_filled = require("./is-mark-filled.cjs");
|
|
|
7
7
|
let react = require("react");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
//#region packages/@mantine/core/src/components/Slider/Marks/Marks.tsx
|
|
10
|
-
function Marks({ marks, min, max, disabled, value, offset, inverted }) {
|
|
10
|
+
function Marks({ marks, min, max, disabled, value, offset, inverted, startPointValue }) {
|
|
11
11
|
const { getStyles } = require_Slider_context.useSliderContext();
|
|
12
12
|
if (!marks) return null;
|
|
13
13
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: marks.map((mark, index) => {
|
|
@@ -27,7 +27,8 @@ function Marks({ marks, min, max, disabled, value, offset, inverted }) {
|
|
|
27
27
|
mark,
|
|
28
28
|
value,
|
|
29
29
|
offset,
|
|
30
|
-
inverted
|
|
30
|
+
inverted,
|
|
31
|
+
startPointValue
|
|
31
32
|
}),
|
|
32
33
|
disabled
|
|
33
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Marks.cjs","names":["useSliderContext","Box","getPosition","isMarkFilled"],"sources":["../../../../src/components/Slider/Marks/Marks.tsx"],"sourcesContent":["import { Box } from '../../../core';\nimport { useSliderContext } from '../Slider.context';\nimport { SliderMark } from '../SliderMark';\nimport { getPosition } from '../utils/get-position/get-position';\nimport { isMarkFilled } from './is-mark-filled';\n\nexport interface MarksProps {\n marks: SliderMark[] | undefined;\n min: number;\n max: number;\n value: number;\n offset: number | undefined;\n disabled: boolean | undefined;\n inverted: boolean | undefined;\n}\n\nexport function Marks({
|
|
1
|
+
{"version":3,"file":"Marks.cjs","names":["useSliderContext","Box","getPosition","isMarkFilled"],"sources":["../../../../src/components/Slider/Marks/Marks.tsx"],"sourcesContent":["import { Box } from '../../../core';\nimport { useSliderContext } from '../Slider.context';\nimport { SliderMark } from '../SliderMark';\nimport { getPosition } from '../utils/get-position/get-position';\nimport { isMarkFilled } from './is-mark-filled';\n\nexport interface MarksProps {\n marks: SliderMark[] | undefined;\n min: number;\n max: number;\n value: number;\n offset: number | undefined;\n disabled: boolean | undefined;\n inverted: boolean | undefined;\n startPointValue?: number;\n}\n\nexport function Marks({\n marks,\n min,\n max,\n disabled,\n value,\n offset,\n inverted,\n startPointValue,\n}: MarksProps) {\n const { getStyles } = useSliderContext();\n\n if (!marks) {\n return null;\n }\n\n const items = marks.map((mark, index) => {\n if (mark.hidden) {\n return null;\n }\n\n return (\n <Box\n {...getStyles('markWrapper')}\n __vars={{ '--mark-offset': `${getPosition({ value: mark.value, min, max })}%` }}\n key={index}\n >\n <Box\n {...getStyles('mark')}\n mod={{\n filled: isMarkFilled({ mark, value, offset, inverted, startPointValue }),\n disabled,\n }}\n />\n {mark.label && <div {...getStyles('markLabel')}>{mark.label}</div>}\n </Box>\n );\n });\n\n return <div>{items}</div>;\n}\n\nMarks.displayName = '@mantine/core/SliderMarks';\n"],"mappings":";;;;;;;;;AAiBA,SAAgB,MAAM,EACpB,OACA,KACA,KACA,UACA,OACA,QACA,UACA,mBACa;CACb,MAAM,EAAE,cAAcA,uBAAAA,kBAAkB;AAExC,KAAI,CAAC,MACH,QAAO;AA0BT,QAAO,iBAAA,GAAA,kBAAA,KAAC,OAAD,EAAA,UAvBO,MAAM,KAAK,MAAM,UAAU;AACvC,MAAI,KAAK,OACP,QAAO;AAGT,SACE,iBAAA,GAAA,MAAA,eAACC,YAAAA,KAAD;GACE,GAAI,UAAU,cAAc;GAC5B,QAAQ,EAAE,iBAAiB,GAAGC,qBAAAA,YAAY;IAAE,OAAO,KAAK;IAAO;IAAK;IAAK,CAAC,CAAC,IAAI;GAC/E,KAAK;GAUD,EARJ,iBAAA,GAAA,kBAAA,KAACD,YAAAA,KAAD;GACE,GAAI,UAAU,OAAO;GACrB,KAAK;IACH,QAAQE,uBAAAA,aAAa;KAAE;KAAM;KAAO;KAAQ;KAAU;KAAiB,CAAC;IACxE;IACD;GACD,CAAA,EACD,KAAK,SAAS,iBAAA,GAAA,kBAAA,KAAC,OAAD;GAAK,GAAI,UAAU,YAAY;aAAG,KAAK;GAAY,CAAA,CAC9D;GAER,EAEuB,CAAA;;AAG3B,MAAM,cAAc"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region packages/@mantine/core/src/components/Slider/Marks/is-mark-filled.ts
|
|
3
|
-
function isMarkFilled({ mark, offset, value, inverted = false }) {
|
|
3
|
+
function isMarkFilled({ mark, offset, value, inverted = false, startPointValue }) {
|
|
4
|
+
if (typeof startPointValue === "number" && !inverted) return mark.value >= startPointValue && mark.value <= value || mark.value <= startPointValue && mark.value >= value;
|
|
4
5
|
return inverted ? typeof offset === "number" ? mark.value <= offset || mark.value >= value : mark.value >= value : typeof offset === "number" ? mark.value >= offset && mark.value <= value : mark.value <= value;
|
|
5
6
|
}
|
|
6
7
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-mark-filled.cjs","names":[],"sources":["../../../../src/components/Slider/Marks/is-mark-filled.ts"],"sourcesContent":["interface IsMarkFilled {\n mark: { value: number; label?: any };\n offset?: number;\n value: number;\n inverted?: boolean;\n}\n\nexport function isMarkFilled({
|
|
1
|
+
{"version":3,"file":"is-mark-filled.cjs","names":[],"sources":["../../../../src/components/Slider/Marks/is-mark-filled.ts"],"sourcesContent":["interface IsMarkFilled {\n mark: { value: number; label?: any };\n offset?: number;\n value: number;\n inverted?: boolean;\n startPointValue?: number;\n}\n\nexport function isMarkFilled({\n mark,\n offset,\n value,\n inverted = false,\n startPointValue,\n}: IsMarkFilled) {\n if (typeof startPointValue === 'number' && !inverted) {\n return (\n (mark.value >= startPointValue && mark.value <= value) ||\n (mark.value <= startPointValue && mark.value >= value)\n );\n }\n\n return inverted\n ? typeof offset === 'number'\n ? mark.value <= offset || mark.value >= value\n : mark.value >= value\n : typeof offset === 'number'\n ? mark.value >= offset && mark.value <= value\n : mark.value <= value;\n}\n"],"mappings":";;AAQA,SAAgB,aAAa,EAC3B,MACA,QACA,OACA,WAAW,OACX,mBACe;AACf,KAAI,OAAO,oBAAoB,YAAY,CAAC,SAC1C,QACG,KAAK,SAAS,mBAAmB,KAAK,SAAS,SAC/C,KAAK,SAAS,mBAAmB,KAAK,SAAS;AAIpD,QAAO,WACH,OAAO,WAAW,WAChB,KAAK,SAAS,UAAU,KAAK,SAAS,QACtC,KAAK,SAAS,QAChB,OAAO,WAAW,WAChB,KAAK,SAAS,UAAU,KAAK,SAAS,QACtC,KAAK,SAAS"}
|
|
@@ -47,7 +47,7 @@ const varsResolver = require_create_vars_resolver.createVarsResolver((theme, { s
|
|
|
47
47
|
} }));
|
|
48
48
|
const Slider = require_factory.factory((_props) => {
|
|
49
49
|
const props = require_use_props.useProps("Slider", defaultProps, _props);
|
|
50
|
-
const { classNames, styles, value, onChange, onChangeEnd, size, min, max, domain, step, precision: _precision, defaultValue, name, marks, label, labelTransitionProps, labelAlwaysOn, thumbLabel, showLabelOnHover, thumbChildren, disabled, unstyled, scale, inverted, orientation, className, style, vars, hiddenInputProps, restrictToMarks, thumbProps, attributes, ref, ...others } = props;
|
|
50
|
+
const { classNames, styles, value, onChange, onChangeEnd, size, min, max, domain, step, precision: _precision, defaultValue, name, marks, label, labelTransitionProps, labelAlwaysOn, thumbLabel, showLabelOnHover, thumbChildren, disabled, unstyled, scale, inverted, startPointValue, orientation, className, style, vars, hiddenInputProps, restrictToMarks, thumbProps, attributes, ref, ...others } = props;
|
|
51
51
|
const getStyles = require_use_styles.useStyles({
|
|
52
52
|
name: "Slider",
|
|
53
53
|
props,
|
|
@@ -85,6 +85,14 @@ const Slider = require_factory.factory((_props) => {
|
|
|
85
85
|
const scaledValue = scale(_value);
|
|
86
86
|
const _label = typeof label === "function" ? label(scaledValue) : label;
|
|
87
87
|
const precision = _precision ?? require_get_precision.getPrecision(step);
|
|
88
|
+
const hasStartPoint = typeof startPointValue === "number" && !inverted;
|
|
89
|
+
const startPosition = hasStartPoint ? require_get_position.getPosition({
|
|
90
|
+
value: startPointValue,
|
|
91
|
+
min: domainMin,
|
|
92
|
+
max: domainMax
|
|
93
|
+
}) : 0;
|
|
94
|
+
const trackOffset = hasStartPoint ? Math.min(position, startPosition) : 0;
|
|
95
|
+
const trackFilled = hasStartPoint ? Math.abs(position - startPosition) : position;
|
|
88
96
|
const handleChange = (0, react.useCallback)(({ x }) => {
|
|
89
97
|
if (!disabled) {
|
|
90
98
|
const clampedValue = (0, _mantine_hooks.clamp)(require_get_change_value.getChangeValue({
|
|
@@ -217,12 +225,13 @@ const Slider = require_factory.factory((_props) => {
|
|
|
217
225
|
orientation,
|
|
218
226
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Track.Track, {
|
|
219
227
|
inverted,
|
|
220
|
-
offset:
|
|
221
|
-
filled:
|
|
228
|
+
offset: trackOffset,
|
|
229
|
+
filled: trackFilled,
|
|
222
230
|
marks,
|
|
223
231
|
min: domainMin,
|
|
224
232
|
max: domainMax,
|
|
225
233
|
value: scaledValue,
|
|
234
|
+
startPointValue: hasStartPoint ? startPointValue : void 0,
|
|
226
235
|
disabled,
|
|
227
236
|
containerProps: {
|
|
228
237
|
ref: container,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.cjs","names":["createVarsResolver","getSize","getThemeColor","getRadius","rem","factory","useProps","useStyles","useDirection","getPosition","getPrecision","getChangeValue","findClosestNumber","getNextMarkValue","getFloatingValue","getPreviousMarkValue","getFirstMarkValue","getLastMarkValue","SliderProvider","SliderRoot","Track","Thumb","classes"],"sources":["../../../../src/components/Slider/Slider/Slider.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { clamp, useMergedRef, useMove, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n findClosestNumber,\n getRadius,\n getSize,\n getThemeColor,\n MantineColor,\n MantineRadius,\n MantineSize,\n rem,\n StylesApiProps,\n useDirection,\n useProps,\n useStyles,\n} from '../../../core';\nimport { TransitionOverride } from '../../Transition';\nimport { SliderCssVariables, SliderProvider, SliderStylesNames } from '../Slider.context';\nimport { SliderMark } from '../SliderMark';\nimport { SliderRoot } from '../SliderRoot/SliderRoot';\nimport { Thumb } from '../Thumb/Thumb';\nimport { Track } from '../Track/Track';\nimport { getChangeValue } from '../utils/get-change-value/get-change-value';\nimport { getFloatingValue } from '../utils/get-floating-value/get-floating-value';\nimport { getPosition } from '../utils/get-position/get-position';\nimport { getPrecision } from '../utils/get-precision/get-precision';\nimport {\n getFirstMarkValue,\n getLastMarkValue,\n getNextMarkValue,\n getPreviousMarkValue,\n} from '../utils/get-step-mark-value/get-step-mark-value';\nimport classes from '../Slider.module.css';\n\nexport interface SliderProps\n extends BoxProps, StylesApiProps<SliderFactory>, ElementProps<'div', 'onChange'> {\n /** Key of `theme.colors` or any valid CSS color, controls color of track and thumb @default theme.primaryColor */\n color?: MantineColor;\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius`, numbers are converted to rem @default 'xl' */\n radius?: MantineRadius;\n\n /** Controls size of the track @default 'md' */\n size?: MantineSize | (string & {}) | number;\n\n /** Minimal possible value @default 0 */\n min?: number;\n\n /** Maximum possible value @default 100 */\n max?: number;\n\n /** Domain of the slider, defines the selectable value range independently of min/max. Useful when you want to display a wider track range (min/max) but restrict actual selection to a subset (domain). @default [min, max] */\n domain?: [number, number];\n\n /** Number by which value will be incremented/decremented with thumb drag and arrows @default 1 */\n step?: number;\n\n /** Number of significant digits after the decimal point */\n precision?: number;\n\n /** Controlled component value */\n value?: number;\n\n /** Uncontrolled component default value */\n defaultValue?: number;\n\n /** Called when value changes */\n onChange?: (value: number) => void;\n\n /** Called when user stops dragging slider or changes value with arrows */\n onChangeEnd?: (value: number) => void;\n\n /** Hidden input name, use with uncontrolled component */\n name?: string;\n\n /** Marks displayed on the track */\n marks?: SliderMark[];\n\n /** Function to generate label or any react node to render instead, set to null to disable label */\n label?: React.ReactNode | ((value: number) => React.ReactNode);\n\n /** Props passed down to the `Transition` component @default { transition: 'fade', duration: 0 } */\n labelTransitionProps?: TransitionOverride;\n\n /** Determines whether the label should be visible when the slider is not being dragged or hovered @default false */\n labelAlwaysOn?: boolean;\n\n /** Thumb `aria-label` */\n thumbLabel?: string;\n\n /** Determines whether the label should be displayed when the slider is hovered @default true */\n showLabelOnHover?: boolean;\n\n /** Content rendered inside thumb */\n thumbChildren?: React.ReactNode;\n\n /** Disables slider */\n disabled?: boolean;\n\n /** Thumb `width` and `height`, by default value is computed based on `size` prop */\n thumbSize?: number | string;\n\n /** A transformation function to change the scale of the slider */\n scale?: (value: number) => number;\n\n /** Determines whether track value representation should be inverted @default false */\n inverted?: boolean;\n\n /** Slider orientation @default 'horizontal' */\n orientation?: 'horizontal' | 'vertical';\n\n /** Props passed down to the hidden input */\n hiddenInputProps?: React.ComponentProps<'input'>;\n\n /** Determines whether the selection should be only allowed from the given marks array @default false */\n restrictToMarks?: boolean;\n\n /** Props passed down to thumb element */\n thumbProps?: React.ComponentProps<'div'>;\n}\n\nexport type SliderFactory = Factory<{\n props: SliderProps;\n ref: HTMLDivElement;\n stylesNames: SliderStylesNames;\n vars: SliderCssVariables;\n}>;\n\nconst defaultProps = {\n radius: 'xl',\n min: 0,\n max: 100,\n step: 1,\n marks: [],\n label: (f) => f,\n labelTransitionProps: { transition: 'fade', duration: 0 },\n thumbLabel: '',\n showLabelOnHover: true,\n scale: (v) => v,\n size: 'md',\n} satisfies Partial<SliderProps>;\n\nconst varsResolver = createVarsResolver<SliderFactory>(\n (theme, { size, color, thumbSize, radius }) => ({\n root: {\n '--slider-size': getSize(size, 'slider-size'),\n '--slider-color': color ? getThemeColor(color, theme) : undefined,\n '--slider-radius': radius === undefined ? undefined : getRadius(radius),\n '--slider-thumb-size':\n thumbSize !== undefined ? rem(thumbSize) : 'calc(var(--slider-size) * 2)',\n },\n })\n);\n\nexport const Slider = factory<SliderFactory>((_props) => {\n const props = useProps('Slider', defaultProps, _props);\n const {\n classNames,\n styles,\n value,\n onChange,\n onChangeEnd,\n size,\n min,\n max,\n domain,\n step,\n precision: _precision,\n defaultValue,\n name,\n marks,\n label,\n labelTransitionProps,\n labelAlwaysOn,\n thumbLabel,\n showLabelOnHover,\n thumbChildren,\n disabled,\n unstyled,\n scale,\n inverted,\n orientation,\n className,\n style,\n vars,\n hiddenInputProps,\n restrictToMarks,\n thumbProps,\n attributes,\n ref,\n ...others\n } = props;\n\n const getStyles = useStyles<SliderFactory>({\n name: 'Slider',\n props,\n classes,\n classNames,\n className,\n styles,\n style,\n attributes,\n vars,\n varsResolver,\n unstyled,\n });\n\n const { dir } = useDirection();\n const [hovered, setHovered] = useState(false);\n const [_value, setValue] = useUncontrolled({\n value: typeof value === 'number' ? clamp(value, min, max) : value,\n defaultValue: typeof defaultValue === 'number' ? clamp(defaultValue, min, max) : defaultValue,\n finalValue: clamp(0, min, max),\n onChange,\n });\n\n const valueRef = useRef(_value);\n const onChangeEndRef = useRef(onChangeEnd);\n\n useEffect(() => {\n onChangeEndRef.current = onChangeEnd;\n }, [onChangeEnd]);\n\n const root = useRef<HTMLDivElement>(null);\n const thumb = useRef<HTMLDivElement>(null);\n const [domainMin, domainMax] = domain || [min, max];\n const position = getPosition({ value: _value, min: domainMin, max: domainMax });\n const scaledValue = scale!(_value);\n const _label = typeof label === 'function' ? label(scaledValue) : label;\n const precision = _precision ?? getPrecision(step);\n\n const handleChange = useCallback(\n ({ x }: { x: number }) => {\n if (!disabled) {\n const nextValue = getChangeValue({\n value: x,\n min: domainMin,\n max: domainMax,\n step,\n precision,\n });\n const clampedValue = clamp(nextValue, min!, max!);\n setValue(\n restrictToMarks && marks?.length\n ? findClosestNumber(\n clampedValue,\n marks.map((mark) => mark.value)\n )\n : clampedValue\n );\n valueRef.current = clampedValue;\n }\n },\n [disabled, min, max, domainMin, domainMax, step, precision, setValue, marks, restrictToMarks]\n );\n\n const handleScrubEnd = useCallback(() => {\n if (!disabled && onChangeEndRef.current) {\n const finalValue =\n restrictToMarks && marks?.length\n ? findClosestNumber(\n valueRef.current,\n marks.map((mark) => mark.value)\n )\n : valueRef.current;\n onChangeEndRef.current(finalValue);\n }\n }, [disabled, marks, restrictToMarks]);\n\n const { ref: container, active } = useMove(\n ({ x, y }) => handleChange({ x: orientation === 'vertical' ? 1 - y : x }),\n { onScrubEnd: handleScrubEnd },\n dir\n );\n\n const callOnChangeEnd = useCallback(\n (value: number) => {\n if (!disabled && onChangeEndRef.current) {\n onChangeEndRef.current(value);\n }\n },\n [disabled]\n );\n\n const handleTrackKeydownCapture = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (!disabled) {\n switch (event.key) {\n case 'ArrowUp': {\n event.preventDefault();\n thumb.current?.focus();\n\n if (restrictToMarks && marks) {\n const nextValue = getNextMarkValue(_value, marks);\n setValue(nextValue);\n callOnChangeEnd(nextValue);\n break;\n }\n\n const nextValue = getFloatingValue(\n Math.min(Math.max(_value + step, domainMin), domainMax),\n precision\n );\n setValue(nextValue);\n callOnChangeEnd(nextValue);\n break;\n }\n\n case 'ArrowRight': {\n event.preventDefault();\n thumb.current?.focus();\n\n if (restrictToMarks && marks) {\n const nextValue =\n dir === 'rtl' ? getPreviousMarkValue(_value, marks) : getNextMarkValue(_value, marks);\n setValue(nextValue);\n callOnChangeEnd(nextValue);\n break;\n }\n\n const nextValue = getFloatingValue(\n Math.min(Math.max(dir === 'rtl' ? _value - step : _value + step, domainMin), domainMax),\n precision\n );\n setValue(nextValue);\n callOnChangeEnd(nextValue);\n break;\n }\n\n case 'ArrowDown': {\n event.preventDefault();\n thumb.current?.focus();\n\n if (restrictToMarks && marks) {\n const nextValue = getPreviousMarkValue(_value, marks);\n setValue(nextValue);\n callOnChangeEnd(nextValue);\n break;\n }\n\n const nextValue = getFloatingValue(\n Math.min(Math.max(_value - step, domainMin), domainMax),\n precision\n );\n setValue(nextValue);\n callOnChangeEnd(nextValue);\n break;\n }\n\n case 'ArrowLeft': {\n event.preventDefault();\n thumb.current?.focus();\n\n if (restrictToMarks && marks) {\n const nextValue =\n dir === 'rtl' ? getNextMarkValue(_value, marks) : getPreviousMarkValue(_value, marks);\n setValue(nextValue);\n callOnChangeEnd(nextValue);\n break;\n }\n\n const nextValue = getFloatingValue(\n Math.min(Math.max(dir === 'rtl' ? _value + step : _value - step, domainMin), domainMax),\n precision\n );\n setValue(nextValue);\n callOnChangeEnd(nextValue);\n break;\n }\n\n case 'Home': {\n event.preventDefault();\n thumb.current?.focus();\n\n if (restrictToMarks && marks) {\n setValue(getFirstMarkValue(marks));\n callOnChangeEnd(getFirstMarkValue(marks));\n break;\n }\n\n setValue(min);\n callOnChangeEnd(min);\n break;\n }\n\n case 'End': {\n event.preventDefault();\n thumb.current?.focus();\n\n if (restrictToMarks && marks) {\n setValue(getLastMarkValue(marks));\n callOnChangeEnd(getLastMarkValue(marks));\n break;\n }\n\n setValue(max);\n callOnChangeEnd(max);\n break;\n }\n\n default: {\n break;\n }\n }\n }\n };\n\n return (\n <SliderProvider value={{ getStyles }}>\n <SliderRoot\n {...others}\n ref={useMergedRef(ref, root)}\n onKeyDownCapture={handleTrackKeydownCapture}\n onMouseDownCapture={() => root.current?.focus()}\n size={size}\n disabled={disabled}\n orientation={orientation}\n >\n <Track\n inverted={inverted}\n offset={0}\n filled={position}\n marks={marks}\n min={domainMin}\n max={domainMax}\n value={scaledValue}\n disabled={disabled}\n containerProps={{\n ref: container,\n onMouseEnter: showLabelOnHover ? () => setHovered(true) : undefined,\n onMouseLeave: showLabelOnHover ? () => setHovered(false) : undefined,\n }}\n >\n <Thumb\n max={domainMax}\n min={domainMin}\n value={scaledValue}\n position={position}\n dragging={active}\n label={_label}\n ref={thumb as any}\n labelTransitionProps={labelTransitionProps}\n labelAlwaysOn={labelAlwaysOn}\n thumbLabel={thumbLabel}\n showLabelOnHover={showLabelOnHover}\n isHovered={hovered}\n disabled={disabled}\n orientation={orientation}\n {...thumbProps}\n >\n {thumbChildren}\n </Thumb>\n </Track>\n\n <input type=\"hidden\" name={name} value={scaledValue} {...hiddenInputProps} />\n </SliderRoot>\n </SliderProvider>\n );\n});\n\nSlider.classes = classes;\nSlider.varsResolver = varsResolver;\nSlider.displayName = '@mantine/core/Slider';\n\nexport namespace Slider {\n export type Props = SliderProps;\n export type StylesNames = SliderStylesNames;\n export type CssVariables = SliderCssVariables;\n export type Factory = SliderFactory;\n export type Mark = SliderMark;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqIA,MAAM,eAAe;CACnB,QAAQ;CACR,KAAK;CACL,KAAK;CACL,MAAM;CACN,OAAO,EAAE;CACT,QAAQ,MAAM;CACd,sBAAsB;EAAE,YAAY;EAAQ,UAAU;EAAG;CACzD,YAAY;CACZ,kBAAkB;CAClB,QAAQ,MAAM;CACd,MAAM;CACP;AAED,MAAM,eAAeA,6BAAAA,oBAClB,OAAO,EAAE,MAAM,OAAO,WAAW,cAAc,EAC9C,MAAM;CACJ,iBAAiBC,iBAAAA,QAAQ,MAAM,cAAc;CAC7C,kBAAkB,QAAQC,wBAAAA,cAAc,OAAO,MAAM,GAAG,KAAA;CACxD,mBAAmB,WAAW,KAAA,IAAY,KAAA,IAAYC,iBAAAA,UAAU,OAAO;CACvE,uBACE,cAAc,KAAA,IAAYC,YAAAA,IAAI,UAAU,GAAG;CAC9C,EACF,EACF;AAED,MAAa,SAASC,gBAAAA,SAAwB,WAAW;CACvD,MAAM,QAAQC,kBAAAA,SAAS,UAAU,cAAc,OAAO;CACtD,MAAM,EACJ,YACA,QACA,OACA,UACA,aACA,MACA,KACA,KACA,QACA,MACA,WAAW,YACX,cACA,MACA,OACA,OACA,sBACA,eACA,YACA,kBACA,eACA,UACA,UACA,OACA,UACA,aACA,WACA,OACA,MACA,kBACA,iBACA,YACA,YACA,KACA,GAAG,WACD;CAEJ,MAAM,YAAYC,mBAAAA,UAAyB;EACzC,MAAM;EACN;EACA,SAAA,sBAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,EAAE,QAAQC,0BAAAA,cAAc;CAC9B,MAAM,CAAC,SAAS,eAAA,GAAA,MAAA,UAAuB,MAAM;CAC7C,MAAM,CAAC,QAAQ,aAAA,GAAA,eAAA,iBAA4B;EACzC,OAAO,OAAO,UAA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D;EAAgB,OAAO,EAAE,WAAW;YAClC,iBAAA,GAAA,kBAAA,MAACC,mBAAAA,YAAD;GACE,GAAI;GACJ,MAAA,GAAA,eAAA,cAAkB,KAAK,KAAK;GAC5B,kBAAkB;GAClB,0BAA0B,KAAK,SAAS,OAAO;GACzC;GACI;GACG;aAPf,CASE,iBAAA,GAAA,kBAAA,KAACC,cAAAA,OAAD;IACY;IACV,QAAQ;IACR,QAAQ;IACD;IACP,KAAK;IACL,KAAK;IACL,OAAO;IACG;IACV,gBAAgB;KACd,KAAK;KACL,cAAc,yBAAyB,WAAW,KAAK,GAAG,KAAA;KAC1D,cAAc,yBAAyB,WAAW,MAAM,GAAG,KAAA;KAC5D;cAED,iBAAA,GAAA,kBAAA,KAACC,cAAAA,OAAD;KACE,KAAK;KACL,KAAK;KACL,OAAO;KACG;KACV,UAAU;KACV,OAAO;KACP,KAAK;KACiB;KACP;KACH;KACM;KAClB,WAAW;KACD;KACG;KACb,GAAI;eAEH;KACK,CAAA;IACF,CAAA,EAER,iBAAA,GAAA,kBAAA,KAAC,SAAD;IAAO,MAAK;IAAe;IAAM,OAAO;IAAa,GAAI;IAAoB,CAAA,CAClE;;EACE,CAAA;EAEnB;AAEF,OAAO,UAAUC,sBAAAA;AACjB,OAAO,eAAe;AACtB,OAAO,cAAc"}
|
|
1
|
+
{"version":3,"file":"Slider.cjs","names":["createVarsResolver","getSize","getThemeColor","getRadius","rem","factory","useProps","useStyles","useDirection","getPosition","getPrecision","getChangeValue","findClosestNumber","getNextMarkValue","getFloatingValue","getPreviousMarkValue","getFirstMarkValue","getLastMarkValue","SliderProvider","SliderRoot","Track","Thumb","classes"],"sources":["../../../../src/components/Slider/Slider/Slider.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { clamp, useMergedRef, useMove, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n findClosestNumber,\n getRadius,\n getSize,\n getThemeColor,\n MantineColor,\n MantineRadius,\n MantineSize,\n rem,\n StylesApiProps,\n useDirection,\n useProps,\n useStyles,\n} from '../../../core';\nimport { TransitionOverride } from '../../Transition';\nimport { SliderCssVariables, SliderProvider, SliderStylesNames } from '../Slider.context';\nimport { SliderMark } from '../SliderMark';\nimport { SliderRoot } from '../SliderRoot/SliderRoot';\nimport { Thumb } from '../Thumb/Thumb';\nimport { Track } from '../Track/Track';\nimport { getChangeValue } from '../utils/get-change-value/get-change-value';\nimport { getFloatingValue } from '../utils/get-floating-value/get-floating-value';\nimport { getPosition } from '../utils/get-position/get-position';\nimport { getPrecision } from '../utils/get-precision/get-precision';\nimport {\n getFirstMarkValue,\n getLastMarkValue,\n getNextMarkValue,\n getPreviousMarkValue,\n} from '../utils/get-step-mark-value/get-step-mark-value';\nimport classes from '../Slider.module.css';\n\nexport interface SliderProps\n extends BoxProps, StylesApiProps<SliderFactory>, ElementProps<'div', 'onChange'> {\n /** Key of `theme.colors` or any valid CSS color, controls color of track and thumb @default theme.primaryColor */\n color?: MantineColor;\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius`, numbers are converted to rem @default 'xl' */\n radius?: MantineRadius;\n\n /** Controls size of the track @default 'md' */\n size?: MantineSize | (string & {}) | number;\n\n /** Minimal possible value @default 0 */\n min?: number;\n\n /** Maximum possible value @default 100 */\n max?: number;\n\n /** Domain of the slider, defines the selectable value range independently of min/max. Useful when you want to display a wider track range (min/max) but restrict actual selection to a subset (domain). @default [min, max] */\n domain?: [number, number];\n\n /** Number by which value will be incremented/decremented with thumb drag and arrows @default 1 */\n step?: number;\n\n /** Number of significant digits after the decimal point */\n precision?: number;\n\n /** Controlled component value */\n value?: number;\n\n /** Uncontrolled component default value */\n defaultValue?: number;\n\n /** Called when value changes */\n onChange?: (value: number) => void;\n\n /** Called when user stops dragging slider or changes value with arrows */\n onChangeEnd?: (value: number) => void;\n\n /** Hidden input name, use with uncontrolled component */\n name?: string;\n\n /** Marks displayed on the track */\n marks?: SliderMark[];\n\n /** Function to generate label or any react node to render instead, set to null to disable label */\n label?: React.ReactNode | ((value: number) => React.ReactNode);\n\n /** Props passed down to the `Transition` component @default { transition: 'fade', duration: 0 } */\n labelTransitionProps?: TransitionOverride;\n\n /** Determines whether the label should be visible when the slider is not being dragged or hovered @default false */\n labelAlwaysOn?: boolean;\n\n /** Thumb `aria-label` */\n thumbLabel?: string;\n\n /** Determines whether the label should be displayed when the slider is hovered @default true */\n showLabelOnHover?: boolean;\n\n /** Content rendered inside thumb */\n thumbChildren?: React.ReactNode;\n\n /** Disables slider */\n disabled?: boolean;\n\n /** Thumb `width` and `height`, by default value is computed based on `size` prop */\n thumbSize?: number | string;\n\n /** A transformation function to change the scale of the slider */\n scale?: (value: number) => number;\n\n /** Determines whether track value representation should be inverted @default false */\n inverted?: boolean;\n\n /** Value at which the filled bar starts. When set, the bar extends from this point toward the current value. Ignored when `inverted` is set. */\n startPointValue?: number;\n\n /** Slider orientation @default 'horizontal' */\n orientation?: 'horizontal' | 'vertical';\n\n /** Props passed down to the hidden input */\n hiddenInputProps?: React.ComponentProps<'input'>;\n\n /** Determines whether the selection should be only allowed from the given marks array @default false */\n restrictToMarks?: boolean;\n\n /** Props passed down to thumb element */\n thumbProps?: React.ComponentProps<'div'>;\n}\n\nexport type SliderFactory = Factory<{\n props: SliderProps;\n ref: HTMLDivElement;\n stylesNames: SliderStylesNames;\n vars: SliderCssVariables;\n}>;\n\nconst defaultProps = {\n radius: 'xl',\n min: 0,\n max: 100,\n step: 1,\n marks: [],\n label: (f) => f,\n labelTransitionProps: { transition: 'fade', duration: 0 },\n thumbLabel: '',\n showLabelOnHover: true,\n scale: (v) => v,\n size: 'md',\n} satisfies Partial<SliderProps>;\n\nconst varsResolver = createVarsResolver<SliderFactory>(\n (theme, { size, color, thumbSize, radius }) => ({\n root: {\n '--slider-size': getSize(size, 'slider-size'),\n '--slider-color': color ? getThemeColor(color, theme) : undefined,\n '--slider-radius': radius === undefined ? undefined : getRadius(radius),\n '--slider-thumb-size':\n thumbSize !== undefined ? rem(thumbSize) : 'calc(var(--slider-size) * 2)',\n },\n })\n);\n\nexport const Slider = factory<SliderFactory>((_props) => {\n const props = useProps('Slider', defaultProps, _props);\n const {\n classNames,\n styles,\n value,\n onChange,\n onChangeEnd,\n size,\n min,\n max,\n domain,\n step,\n precision: _precision,\n defaultValue,\n name,\n marks,\n label,\n labelTransitionProps,\n labelAlwaysOn,\n thumbLabel,\n showLabelOnHover,\n thumbChildren,\n disabled,\n unstyled,\n scale,\n inverted,\n startPointValue,\n orientation,\n className,\n style,\n vars,\n hiddenInputProps,\n restrictToMarks,\n thumbProps,\n attributes,\n ref,\n ...others\n } = props;\n\n const getStyles = useStyles<SliderFactory>({\n name: 'Slider',\n props,\n classes,\n classNames,\n className,\n styles,\n style,\n attributes,\n vars,\n varsResolver,\n unstyled,\n });\n\n const { dir } = useDirection();\n const [hovered, setHovered] = useState(false);\n const [_value, setValue] = useUncontrolled({\n value: typeof value === 'number' ? clamp(value, min, max) : value,\n defaultValue: typeof defaultValue === 'number' ? clamp(defaultValue, min, max) : defaultValue,\n finalValue: clamp(0, min, max),\n onChange,\n });\n\n const valueRef = useRef(_value);\n const onChangeEndRef = useRef(onChangeEnd);\n\n useEffect(() => {\n onChangeEndRef.current = onChangeEnd;\n }, [onChangeEnd]);\n\n const root = useRef<HTMLDivElement>(null);\n const thumb = useRef<HTMLDivElement>(null);\n const [domainMin, domainMax] = domain || [min, max];\n const position = getPosition({ value: _value, min: domainMin, max: domainMax });\n const scaledValue = scale!(_value);\n const _label = typeof label === 'function' ? label(scaledValue) : label;\n const precision = _precision ?? getPrecision(step);\n\n const hasStartPoint = typeof startPointValue === 'number' && !inverted;\n const startPosition = hasStartPoint\n ? getPosition({ value: startPointValue!, min: domainMin, max: domainMax })\n : 0;\n const trackOffset = hasStartPoint ? Math.min(position, startPosition) : 0;\n const trackFilled = hasStartPoint ? Math.abs(position - startPosition) : position;\n\n const handleChange = useCallback(\n ({ x }: { x: number }) => {\n if (!disabled) {\n const nextValue = getChangeValue({\n value: x,\n min: domainMin,\n max: domainMax,\n step,\n precision,\n });\n const clampedValue = clamp(nextValue, min!, max!);\n setValue(\n restrictToMarks && marks?.length\n ? findClosestNumber(\n clampedValue,\n marks.map((mark) => mark.value)\n )\n : clampedValue\n );\n valueRef.current = clampedValue;\n }\n },\n [disabled, min, max, domainMin, domainMax, step, precision, setValue, marks, restrictToMarks]\n );\n\n const handleScrubEnd = useCallback(() => {\n if (!disabled && onChangeEndRef.current) {\n const finalValue =\n restrictToMarks && marks?.length\n ? findClosestNumber(\n valueRef.current,\n marks.map((mark) => mark.value)\n )\n : valueRef.current;\n onChangeEndRef.current(finalValue);\n }\n }, [disabled, marks, restrictToMarks]);\n\n const { ref: container, active } = useMove(\n ({ x, y }) => handleChange({ x: orientation === 'vertical' ? 1 - y : x }),\n { onScrubEnd: handleScrubEnd },\n dir\n );\n\n const callOnChangeEnd = useCallback(\n (value: number) => {\n if (!disabled && onChangeEndRef.current) {\n onChangeEndRef.current(value);\n }\n },\n [disabled]\n );\n\n const handleTrackKeydownCapture = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (!disabled) {\n switch (event.key) {\n case 'ArrowUp': {\n event.preventDefault();\n thumb.current?.focus();\n\n if (restrictToMarks && marks) {\n const nextValue = getNextMarkValue(_value, marks);\n setValue(nextValue);\n callOnChangeEnd(nextValue);\n break;\n }\n\n const nextValue = getFloatingValue(\n Math.min(Math.max(_value + step, domainMin), domainMax),\n precision\n );\n setValue(nextValue);\n callOnChangeEnd(nextValue);\n break;\n }\n\n case 'ArrowRight': {\n event.preventDefault();\n thumb.current?.focus();\n\n if (restrictToMarks && marks) {\n const nextValue =\n dir === 'rtl' ? getPreviousMarkValue(_value, marks) : getNextMarkValue(_value, marks);\n setValue(nextValue);\n callOnChangeEnd(nextValue);\n break;\n }\n\n const nextValue = getFloatingValue(\n Math.min(Math.max(dir === 'rtl' ? _value - step : _value + step, domainMin), domainMax),\n precision\n );\n setValue(nextValue);\n callOnChangeEnd(nextValue);\n break;\n }\n\n case 'ArrowDown': {\n event.preventDefault();\n thumb.current?.focus();\n\n if (restrictToMarks && marks) {\n const nextValue = getPreviousMarkValue(_value, marks);\n setValue(nextValue);\n callOnChangeEnd(nextValue);\n break;\n }\n\n const nextValue = getFloatingValue(\n Math.min(Math.max(_value - step, domainMin), domainMax),\n precision\n );\n setValue(nextValue);\n callOnChangeEnd(nextValue);\n break;\n }\n\n case 'ArrowLeft': {\n event.preventDefault();\n thumb.current?.focus();\n\n if (restrictToMarks && marks) {\n const nextValue =\n dir === 'rtl' ? getNextMarkValue(_value, marks) : getPreviousMarkValue(_value, marks);\n setValue(nextValue);\n callOnChangeEnd(nextValue);\n break;\n }\n\n const nextValue = getFloatingValue(\n Math.min(Math.max(dir === 'rtl' ? _value + step : _value - step, domainMin), domainMax),\n precision\n );\n setValue(nextValue);\n callOnChangeEnd(nextValue);\n break;\n }\n\n case 'Home': {\n event.preventDefault();\n thumb.current?.focus();\n\n if (restrictToMarks && marks) {\n setValue(getFirstMarkValue(marks));\n callOnChangeEnd(getFirstMarkValue(marks));\n break;\n }\n\n setValue(min);\n callOnChangeEnd(min);\n break;\n }\n\n case 'End': {\n event.preventDefault();\n thumb.current?.focus();\n\n if (restrictToMarks && marks) {\n setValue(getLastMarkValue(marks));\n callOnChangeEnd(getLastMarkValue(marks));\n break;\n }\n\n setValue(max);\n callOnChangeEnd(max);\n break;\n }\n\n default: {\n break;\n }\n }\n }\n };\n\n return (\n <SliderProvider value={{ getStyles }}>\n <SliderRoot\n {...others}\n ref={useMergedRef(ref, root)}\n onKeyDownCapture={handleTrackKeydownCapture}\n onMouseDownCapture={() => root.current?.focus()}\n size={size}\n disabled={disabled}\n orientation={orientation}\n >\n <Track\n inverted={inverted}\n offset={trackOffset}\n filled={trackFilled}\n marks={marks}\n min={domainMin}\n max={domainMax}\n value={scaledValue}\n startPointValue={hasStartPoint ? startPointValue : undefined}\n disabled={disabled}\n containerProps={{\n ref: container,\n onMouseEnter: showLabelOnHover ? () => setHovered(true) : undefined,\n onMouseLeave: showLabelOnHover ? () => setHovered(false) : undefined,\n }}\n >\n <Thumb\n max={domainMax}\n min={domainMin}\n value={scaledValue}\n position={position}\n dragging={active}\n label={_label}\n ref={thumb as any}\n labelTransitionProps={labelTransitionProps}\n labelAlwaysOn={labelAlwaysOn}\n thumbLabel={thumbLabel}\n showLabelOnHover={showLabelOnHover}\n isHovered={hovered}\n disabled={disabled}\n orientation={orientation}\n {...thumbProps}\n >\n {thumbChildren}\n </Thumb>\n </Track>\n\n <input type=\"hidden\" name={name} value={scaledValue} {...hiddenInputProps} />\n </SliderRoot>\n </SliderProvider>\n );\n});\n\nSlider.classes = classes;\nSlider.varsResolver = varsResolver;\nSlider.displayName = '@mantine/core/Slider';\n\nexport namespace Slider {\n export type Props = SliderProps;\n export type StylesNames = SliderStylesNames;\n export type CssVariables = SliderCssVariables;\n export type Factory = SliderFactory;\n export type Mark = SliderMark;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwIA,MAAM,eAAe;CACnB,QAAQ;CACR,KAAK;CACL,KAAK;CACL,MAAM;CACN,OAAO,EAAE;CACT,QAAQ,MAAM;CACd,sBAAsB;EAAE,YAAY;EAAQ,UAAU;EAAG;CACzD,YAAY;CACZ,kBAAkB;CAClB,QAAQ,MAAM;CACd,MAAM;CACP;AAED,MAAM,eAAeA,6BAAAA,oBAClB,OAAO,EAAE,MAAM,OAAO,WAAW,cAAc,EAC9C,MAAM;CACJ,iBAAiBC,iBAAAA,QAAQ,MAAM,cAAc;CAC7C,kBAAkB,QAAQC,wBAAAA,cAAc,OAAO,MAAM,GAAG,KAAA;CACxD,mBAAmB,WAAW,KAAA,IAAY,KAAA,IAAYC,iBAAAA,UAAU,OAAO;CACvE,uBACE,cAAc,KAAA,IAAYC,YAAAA,IAAI,UAAU,GAAG;CAC9C,EACF,EACF;AAED,MAAa,SAASC,gBAAAA,SAAwB,WAAW;CACvD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Ac,yBAAyB,WAAW,MAAM,GAAG,KAAA;KAC5D;cAED,iBAAA,GAAA,kBAAA,KAACC,cAAAA,OAAD;KACE,KAAK;KACL,KAAK;KACL,OAAO;KACG;KACV,UAAU;KACV,OAAO;KACP,KAAK;KACiB;KACP;KACH;KACM;KAClB,WAAW;KACD;KACG;KACb,GAAI;eAEH;KACK,CAAA;IACF,CAAA,EAER,iBAAA,GAAA,kBAAA,KAAC,SAAD;IAAO,MAAK;IAAe;IAAM,OAAO;IAAa,GAAI;IAAoB,CAAA,CAClE;;EACE,CAAA;EAEnB;AAEF,OAAO,UAAUC,sBAAAA;AACjB,OAAO,eAAe;AACtB,OAAO,cAAc"}
|
|
@@ -5,7 +5,7 @@ const require_Slider_context = require("../Slider.context.cjs");
|
|
|
5
5
|
const require_Marks = require("../Marks/Marks.cjs");
|
|
6
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
7
|
//#region packages/@mantine/core/src/components/Slider/Track/Track.tsx
|
|
8
|
-
function Track({ filled, children, offset, disabled, marksOffset, inverted, containerProps, ...others }) {
|
|
8
|
+
function Track({ filled, children, offset, disabled, marksOffset, inverted, startPointValue, containerProps, ...others }) {
|
|
9
9
|
const { getStyles } = require_Slider_context.useSliderContext();
|
|
10
10
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
|
|
11
11
|
...getStyles("trackContainer"),
|
|
@@ -34,7 +34,8 @@ function Track({ filled, children, offset, disabled, marksOffset, inverted, cont
|
|
|
34
34
|
...others,
|
|
35
35
|
offset: marksOffset,
|
|
36
36
|
disabled,
|
|
37
|
-
inverted
|
|
37
|
+
inverted,
|
|
38
|
+
startPointValue
|
|
38
39
|
})
|
|
39
40
|
]
|
|
40
41
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Track.cjs","names":["useSliderContext","Box","Marks"],"sources":["../../../../src/components/Slider/Track/Track.tsx"],"sourcesContent":["import { Box } from '../../../core';\nimport { Marks } from '../Marks/Marks';\nimport { useSliderContext } from '../Slider.context';\n\nexport interface TrackProps {\n filled: number;\n offset?: number;\n marksOffset?: number;\n marks: { value: number; label?: React.ReactNode }[] | undefined;\n min: number;\n max: number;\n value: number;\n children: React.ReactNode;\n disabled: boolean | undefined;\n inverted: boolean | undefined;\n containerProps?: React.ComponentProps<'div'>;\n}\n\nexport function Track({\n filled,\n children,\n offset,\n disabled,\n marksOffset,\n inverted,\n containerProps,\n ...others\n}: TrackProps) {\n const { getStyles } = useSliderContext();\n\n return (\n <Box {...getStyles('trackContainer')} mod={{ disabled }} {...containerProps}>\n <Box {...getStyles('track')} mod={{ inverted, disabled }}>\n <Box\n mod={{ inverted, disabled }}\n __vars={{\n '--slider-bar-width': `calc(${filled}% + 2 * var(--slider-size))`,\n '--slider-bar-offset': `calc(${offset}% - var(--slider-size))`,\n }}\n {...getStyles('bar')}\n />\n\n {children}\n\n <Marks
|
|
1
|
+
{"version":3,"file":"Track.cjs","names":["useSliderContext","Box","Marks"],"sources":["../../../../src/components/Slider/Track/Track.tsx"],"sourcesContent":["import { Box } from '../../../core';\nimport { Marks } from '../Marks/Marks';\nimport { useSliderContext } from '../Slider.context';\n\nexport interface TrackProps {\n filled: number;\n offset?: number;\n marksOffset?: number;\n marks: { value: number; label?: React.ReactNode }[] | undefined;\n min: number;\n max: number;\n value: number;\n startPointValue?: number;\n children: React.ReactNode;\n disabled: boolean | undefined;\n inverted: boolean | undefined;\n containerProps?: React.ComponentProps<'div'>;\n}\n\nexport function Track({\n filled,\n children,\n offset,\n disabled,\n marksOffset,\n inverted,\n startPointValue,\n containerProps,\n ...others\n}: TrackProps) {\n const { getStyles } = useSliderContext();\n\n return (\n <Box {...getStyles('trackContainer')} mod={{ disabled }} {...containerProps}>\n <Box {...getStyles('track')} mod={{ inverted, disabled }}>\n <Box\n mod={{ inverted, disabled }}\n __vars={{\n '--slider-bar-width': `calc(${filled}% + 2 * var(--slider-size))`,\n '--slider-bar-offset': `calc(${offset}% - var(--slider-size))`,\n }}\n {...getStyles('bar')}\n />\n\n {children}\n\n <Marks\n {...others}\n offset={marksOffset}\n disabled={disabled}\n inverted={inverted}\n startPointValue={startPointValue}\n />\n </Box>\n </Box>\n );\n}\n\nTrack.displayName = '@mantine/core/SliderTrack';\n"],"mappings":";;;;;;;AAmBA,SAAgB,MAAM,EACpB,QACA,UACA,QACA,UACA,aACA,UACA,iBACA,gBACA,GAAG,UACU;CACb,MAAM,EAAE,cAAcA,uBAAAA,kBAAkB;AAExC,QACE,iBAAA,GAAA,kBAAA,KAACC,YAAAA,KAAD;EAAK,GAAI,UAAU,iBAAiB;EAAE,KAAK,EAAE,UAAU;EAAE,GAAI;YAC3D,iBAAA,GAAA,kBAAA,MAACA,YAAAA,KAAD;GAAK,GAAI,UAAU,QAAQ;GAAE,KAAK;IAAE;IAAU;IAAU;aAAxD;IACE,iBAAA,GAAA,kBAAA,KAACA,YAAAA,KAAD;KACE,KAAK;MAAE;MAAU;MAAU;KAC3B,QAAQ;MACN,sBAAsB,QAAQ,OAAO;MACrC,uBAAuB,QAAQ,OAAO;MACvC;KACD,GAAI,UAAU,MAAM;KACpB,CAAA;IAED;IAED,iBAAA,GAAA,kBAAA,KAACC,cAAAA,OAAD;KACE,GAAI;KACJ,QAAQ;KACE;KACA;KACO;KACjB,CAAA;IACE;;EACF,CAAA;;AAIV,MAAM,cAAc"}
|