UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

72 lines (71 loc) 3.03 kB
"use client"; import { rem } from "../../core/utils/units-converters/rem.mjs"; import { getRadius } from "../../core/utils/get-size/get-size.mjs"; import { createVarsResolver } from "../../core/styles-api/create-vars-resolver/create-vars-resolver.mjs"; import { getThemeColor } from "../../core/MantineProvider/color-functions/get-theme-color/get-theme-color.mjs"; import { getContrastColor } from "../../core/MantineProvider/color-functions/get-contrast-color/get-contrast-color.mjs"; import { getAutoContrastValue } from "../../core/MantineProvider/color-functions/get-auto-contrast-value/get-auto-contrast-value.mjs"; import { useProps } from "../../core/MantineProvider/use-props/use-props.mjs"; import { useStyles } from "../../core/styles-api/use-styles/use-styles.mjs"; import { factory } from "../../core/factory/factory.mjs"; import { Box } from "../../core/Box/Box.mjs"; import { getPositionVariables } from "./get-position-variables/get-position-variables.mjs"; import Indicator_module_default from "./Indicator.module.mjs"; import { jsx, jsxs } from "react/jsx-runtime"; //#region packages/@mantine/core/src/components/Indicator/Indicator.tsx const defaultProps = { position: "top-end", offset: 0, showZero: true }; const varsResolver = createVarsResolver((theme, { color, position, offset, size, radius, zIndex, autoContrast }) => ({ root: { "--indicator-color": color ? getThemeColor(color, theme) : void 0, "--indicator-text-color": getAutoContrastValue(autoContrast, theme) ? getContrastColor({ color, theme, autoContrast }) : void 0, "--indicator-size": rem(size), "--indicator-radius": radius === void 0 ? void 0 : getRadius(radius), "--indicator-z-index": zIndex?.toString(), ...getPositionVariables(position, offset) } })); const Indicator = factory((_props) => { const props = useProps("Indicator", defaultProps, _props); const { classNames, className, style, styles, unstyled, vars, children, position, offset, inline, label, radius, color, withBorder, disabled, processing, zIndex, autoContrast, maxValue, showZero, mod, attributes, ...others } = props; const getStyles = useStyles({ name: "Indicator", classes: Indicator_module_default, props, className, style, classNames, styles, unstyled, attributes, vars, varsResolver }); const shouldHideZero = !showZero && (label === 0 || label === "0"); const formattedLabel = maxValue !== void 0 && typeof label === "number" && label > maxValue ? `${maxValue}+` : label; return /* @__PURE__ */ jsxs(Box, { ...getStyles("root"), mod: [{ inline }, mod], ...others, children: [!disabled && !shouldHideZero && /* @__PURE__ */ jsx(Box, { mod: { "with-label": !!label, "with-border": withBorder, processing }, ...getStyles("indicator"), children: formattedLabel }), children] }); }); Indicator.classes = Indicator_module_default; Indicator.varsResolver = varsResolver; Indicator.displayName = "@mantine/core/Indicator"; //#endregion export { Indicator }; //# sourceMappingURL=Indicator.mjs.map