@mantine/core 9.0.2 → 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/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/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/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/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
package/cjs/core/Box/Box.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Box.cjs","names":["useMantineTheme","extractStyleProps","useMantineSxTransform","useRandomClassName","parseStyleProps","STYlE_PROPS_DATA","getBoxStyle","isNumberLike","getBoxMod","InlineStyles","polymorphic"],"sources":["../../../src/core/Box/Box.tsx"],"sourcesContent":["import cx from 'clsx';\nimport { polymorphic } from '../factory';\nimport { InlineStyles } from '../InlineStyles';\nimport {
|
|
1
|
+
{"version":3,"file":"Box.cjs","names":["useMantineTheme","extractStyleProps","useMantineSxTransform","useRandomClassName","parseStyleProps","STYlE_PROPS_DATA","useMantineDeduplicateInlineStyles","hashStyleProps","getBoxStyle","isNumberLike","getBoxMod","InlineStyles","polymorphic"],"sources":["../../../src/core/Box/Box.tsx"],"sourcesContent":["import cx from 'clsx';\nimport { polymorphic } from '../factory';\nimport { hashStyleProps, InlineStyles } from '../InlineStyles';\nimport {\n MantineBreakpoint,\n useMantineDeduplicateInlineStyles,\n useMantineSxTransform,\n useMantineTheme,\n} from '../MantineProvider';\nimport { isNumberLike } from '../utils';\nimport type { CssVarsProp, MantineStyleProp } from './Box.types';\nimport { getBoxMod } from './get-box-mod/get-box-mod';\nimport { getBoxStyle } from './get-box-style/get-box-style';\nimport {\n extractStyleProps,\n MantineStyleProps,\n parseStyleProps,\n STYlE_PROPS_DATA,\n} from './style-props';\nimport { useRandomClassName } from './use-random-classname/use-random-classname';\n\nexport type Mod = Record<string, any> | string;\nexport type BoxMod = Mod | Mod[] | BoxMod[];\n\nexport interface BoxProps extends MantineStyleProps {\n /** Class added to the root element, if applicable */\n className?: string;\n\n /** Inline style added to root component element, can subscribe to theme defined on MantineProvider */\n style?: MantineStyleProp;\n\n /** CSS variables defined on root component element */\n __vars?: CssVarsProp;\n\n /** `size` property passed down the HTML element */\n __size?: string;\n\n /** Breakpoint above which the component is hidden with `display: none` */\n hiddenFrom?: MantineBreakpoint;\n\n /** Breakpoint below which the component is hidden with `display: none` */\n visibleFrom?: MantineBreakpoint;\n\n /** Determines whether component should be hidden in light color scheme with `display: none` */\n lightHidden?: boolean;\n\n /** Determines whether component should be hidden in dark color scheme with `display: none` */\n darkHidden?: boolean;\n\n /** Element modifiers transformed into `data-` attributes, for example, `{ 'data-size': 'xl' }`, falsy values are removed */\n mod?: BoxMod;\n}\n\nexport type ElementProps<\n ElementType extends React.ElementType,\n PropsToOmit extends string = never,\n> = Omit<React.ComponentProps<ElementType>, 'style' | PropsToOmit>;\n\nexport interface BoxComponentProps extends BoxProps {\n /** Variant passed from parent component, sets `data-variant` */\n variant?: string;\n\n /** Size passed from parent component, sets `data-size` if value is not number like */\n size?: string | number;\n}\n\nfunction _Box({\n component,\n style,\n __vars,\n className,\n variant,\n mod,\n size,\n hiddenFrom,\n visibleFrom,\n lightHidden,\n darkHidden,\n renderRoot,\n __size,\n ref,\n ...others\n}: BoxComponentProps & { component: any; className: string; renderRoot: any; ref: any }) {\n const theme = useMantineTheme();\n const Element = component || 'div';\n const { styleProps, rest } = extractStyleProps(others);\n const useSxTransform = useMantineSxTransform();\n const transformedSx = useSxTransform?.()?.(styleProps.sx);\n const randomClassName = useRandomClassName();\n const parsedStyleProps = parseStyleProps({\n styleProps,\n theme,\n data: 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 const props = {\n ref,\n style: getBoxStyle({\n theme,\n style,\n vars: __vars,\n styleProps: parsedStyleProps.inlineStyles,\n }),\n className: cx(className, transformedSx, {\n [responsiveClassName]: parsedStyleProps.hasResponsiveStyles,\n 'mantine-light-hidden': lightHidden,\n 'mantine-dark-hidden': darkHidden,\n [`mantine-hidden-from-${hiddenFrom}`]: hiddenFrom,\n [`mantine-visible-from-${visibleFrom}`]: visibleFrom,\n }),\n 'data-variant': variant,\n 'data-size': isNumberLike(size) ? undefined : size || undefined,\n size: __size,\n ...getBoxMod(mod),\n ...rest,\n };\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\n {typeof renderRoot === 'function' ? renderRoot(props) : <Element {...props} />}\n </>\n );\n}\n\n_Box.displayName = '@mantine/core/Box';\n\nexport const Box = polymorphic<'div', BoxComponentProps>(_Box);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkEA,SAAS,KAAK,EACZ,WACA,OACA,QACA,WACA,SACA,KACA,MACA,YACA,aACA,aACA,YACA,YACA,QACA,KACA,GAAG,UACoF;CACvF,MAAM,QAAQA,6BAAAA,iBAAiB;CAC/B,MAAM,UAAU,aAAa;CAC7B,MAAM,EAAE,YAAY,SAASC,4BAAAA,kBAAkB,OAAO;CAEtD,MAAM,gBADiBC,wBAAAA,uBAAuB,IACN,GAAG,WAAW,GAAG;CACzD,MAAM,kBAAkBC,6BAAAA,oBAAoB;CAC5C,MAAM,mBAAmBC,0BAAAA,gBAAgB;EACvC;EACA;EACA,MAAMC,yBAAAA;EACP,CAAC;CAEF,MAAM,0BAA0BC,wBAAAA,mCAAmC;CACnE,MAAM,sBACJ,2BAA2B,iBAAiB,sBACxCC,oBAAAA,eAAe,iBAAiB,QAAQ,iBAAiB,MAAM,GAC/D;CAEN,MAAM,QAAQ;EACZ;EACA,OAAOC,sBAAAA,YAAY;GACjB;GACA;GACA,MAAM;GACN,YAAY,iBAAiB;GAC9B,CAAC;EACF,YAAA,GAAA,KAAA,SAAc,WAAW,eAAe;IACrC,sBAAsB,iBAAiB;GACxC,wBAAwB;GACxB,uBAAuB;IACtB,uBAAuB,eAAe;IACtC,wBAAwB,gBAAgB;GAC1C,CAAC;EACF,gBAAgB;EAChB,aAAaC,uBAAAA,aAAa,KAAK,GAAG,KAAA,IAAY,QAAQ,KAAA;EACtD,MAAM;EACN,GAAGC,oBAAAA,UAAU,IAAI;EACjB,GAAG;EACJ;AAED,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,EAGH,OAAO,eAAe,aAAa,WAAW,MAAM,GAAG,iBAAA,GAAA,kBAAA,KAAC,SAAD,EAAS,GAAI,OAAS,CAAA,CAC7E,EAAA,CAAA;;AAIP,KAAK,cAAc;AAEnB,MAAa,MAAMC,qCAAAA,YAAsC,KAAK"}
|
|
@@ -4,12 +4,24 @@ const require_Mantine_context = require("../MantineProvider/Mantine.context.cjs"
|
|
|
4
4
|
const require_styles_to_string = require("./styles-to-string/styles-to-string.cjs");
|
|
5
5
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
6
|
//#region packages/@mantine/core/src/core/InlineStyles/InlineStyles.tsx
|
|
7
|
-
function
|
|
7
|
+
function simpleHash(str) {
|
|
8
|
+
let hash = 5381;
|
|
9
|
+
for (let i = 0; i < str.length; i++) hash = (hash << 5) + hash + str.charCodeAt(i) & 4294967295;
|
|
10
|
+
return (hash >>> 0).toString(36);
|
|
11
|
+
}
|
|
12
|
+
function InlineStyles({ deduplicate, ...props }) {
|
|
8
13
|
const nonce = require_Mantine_context.useMantineStyleNonce();
|
|
14
|
+
const css = require_styles_to_string.stylesToString(props);
|
|
15
|
+
if (deduplicate) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", {
|
|
16
|
+
href: `mantine-${simpleHash(css)}`,
|
|
17
|
+
precedence: "mantine",
|
|
18
|
+
nonce: nonce?.(),
|
|
19
|
+
children: css
|
|
20
|
+
});
|
|
9
21
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", {
|
|
10
22
|
"data-mantine-styles": "inline",
|
|
11
23
|
nonce: nonce?.(),
|
|
12
|
-
dangerouslySetInnerHTML: { __html:
|
|
24
|
+
dangerouslySetInnerHTML: { __html: css }
|
|
13
25
|
});
|
|
14
26
|
}
|
|
15
27
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineStyles.cjs","names":["useMantineStyleNonce","stylesToString"],"sources":["../../../src/core/InlineStyles/InlineStyles.tsx"],"sourcesContent":["import { useMantineStyleNonce } from '../MantineProvider';\nimport { InlineStylesInput, stylesToString } from './styles-to-string/styles-to-string';\n\nexport interface InlineStylesProps\n extends InlineStylesInput, Omit<React.ComponentProps<'style'>, keyof InlineStylesInput> {}\n\nexport function InlineStyles(props:
|
|
1
|
+
{"version":3,"file":"InlineStyles.cjs","names":["useMantineStyleNonce","stylesToString"],"sources":["../../../src/core/InlineStyles/InlineStyles.tsx"],"sourcesContent":["import { useMantineStyleNonce } from '../MantineProvider';\nimport { InlineStylesInput, stylesToString } from './styles-to-string/styles-to-string';\n\nexport interface InlineStylesProps\n extends InlineStylesInput, Omit<React.ComponentProps<'style'>, keyof InlineStylesInput> {\n deduplicate?: boolean;\n}\n\nfunction simpleHash(str: string): string {\n let hash = 5381;\n for (let i = 0; i < str.length; i++) {\n hash = ((hash << 5) + hash + str.charCodeAt(i)) & 0xffffffff;\n }\n return (hash >>> 0).toString(36);\n}\n\nexport function InlineStyles({ deduplicate, ...props }: InlineStylesProps) {\n const nonce = useMantineStyleNonce();\n const css = stylesToString(props);\n\n if (deduplicate) {\n return (\n <style href={`mantine-${simpleHash(css)}`} precedence=\"mantine\" nonce={nonce?.()}>\n {css}\n </style>\n );\n }\n\n return (\n <style\n data-mantine-styles=\"inline\"\n nonce={nonce?.()}\n dangerouslySetInnerHTML={{ __html: css }}\n />\n );\n}\n"],"mappings":";;;;;;AAQA,SAAS,WAAW,KAAqB;CACvC,IAAI,OAAO;AACX,MAAK,IAAI,IAAI,GAAG,IAAI,IAAI,QAAQ,IAC9B,SAAS,QAAQ,KAAK,OAAO,IAAI,WAAW,EAAE,GAAI;AAEpD,SAAQ,SAAS,GAAG,SAAS,GAAG;;AAGlC,SAAgB,aAAa,EAAE,aAAa,GAAG,SAA4B;CACzE,MAAM,QAAQA,wBAAAA,sBAAsB;CACpC,MAAM,MAAMC,yBAAAA,eAAe,MAAM;AAEjC,KAAI,YACF,QACE,iBAAA,GAAA,kBAAA,KAAC,SAAD;EAAO,MAAM,WAAW,WAAW,IAAI;EAAI,YAAW;EAAU,OAAO,SAAS;YAC7E;EACK,CAAA;AAIZ,QACE,iBAAA,GAAA,kBAAA,KAAC,SAAD;EACE,uBAAoB;EACpB,OAAO,SAAS;EAChB,yBAAyB,EAAE,QAAQ,KAAK;EACxC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_css_object_to_string = require("./css-object-to-string/css-object-to-string.cjs");
|
|
3
|
+
//#region packages/@mantine/core/src/core/InlineStyles/hash-styles.ts
|
|
4
|
+
function djb2Hash(str) {
|
|
5
|
+
let hash = 5381;
|
|
6
|
+
for (let i = 0; i < str.length; i++) hash = (hash << 5) + hash + str.charCodeAt(i) & 4294967295;
|
|
7
|
+
return (hash >>> 0).toString(36);
|
|
8
|
+
}
|
|
9
|
+
function hashStyleProps(styles, media) {
|
|
10
|
+
return `__mdi__-${djb2Hash(`${styles ? require_css_object_to_string.cssObjectToString(styles) : ""}|${Array.isArray(media) ? media.map((m) => `${m.query}:${require_css_object_to_string.cssObjectToString(m.styles)}`).join("|") : ""}`)}`;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.hashStyleProps = hashStyleProps;
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=hash-styles.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash-styles.cjs","names":["cssObjectToString"],"sources":["../../../src/core/InlineStyles/hash-styles.ts"],"sourcesContent":["import { cssObjectToString } from './css-object-to-string/css-object-to-string';\nimport type { InlineStylesMediaQuery } from './styles-to-string/styles-to-string';\n\nfunction djb2Hash(str: string): string {\n let hash = 5381;\n for (let i = 0; i < str.length; i++) {\n hash = ((hash << 5) + hash + str.charCodeAt(i)) & 0xffffffff;\n }\n return (hash >>> 0).toString(36);\n}\n\nexport function hashStyleProps(\n styles: React.CSSProperties | undefined,\n media: InlineStylesMediaQuery[] | undefined\n): string {\n const stylesStr = styles ? cssObjectToString(styles) : '';\n const mediaStr = Array.isArray(media)\n ? media.map((m) => `${m.query}:${cssObjectToString(m.styles)}`).join('|')\n : '';\n return `__mdi__-${djb2Hash(`${stylesStr}|${mediaStr}`)}`;\n}\n"],"mappings":";;;AAGA,SAAS,SAAS,KAAqB;CACrC,IAAI,OAAO;AACX,MAAK,IAAI,IAAI,GAAG,IAAI,IAAI,QAAQ,IAC9B,SAAS,QAAQ,KAAK,OAAO,IAAI,WAAW,EAAE,GAAI;AAEpD,SAAQ,SAAS,GAAG,SAAS,GAAG;;AAGlC,SAAgB,eACd,QACA,OACQ;AAKR,QAAO,WAAW,SAAS,GAJT,SAASA,6BAAAA,kBAAkB,OAAO,GAAG,GAIf,GAHvB,MAAM,QAAQ,MAAM,GACjC,MAAM,KAAK,MAAM,GAAG,EAAE,MAAM,GAAGA,6BAAAA,kBAAkB,EAAE,OAAO,GAAG,CAAC,KAAK,IAAI,GACvE,KACkD"}
|
|
@@ -32,11 +32,15 @@ function useMantineStylesTransform() {
|
|
|
32
32
|
function useMantineEnv() {
|
|
33
33
|
return useMantineContext().env || "default";
|
|
34
34
|
}
|
|
35
|
+
function useMantineDeduplicateInlineStyles() {
|
|
36
|
+
return useMantineContext().deduplicateInlineStyles;
|
|
37
|
+
}
|
|
35
38
|
//#endregion
|
|
36
39
|
exports.MantineContext = MantineContext;
|
|
37
40
|
exports.useMantineClassNamesPrefix = useMantineClassNamesPrefix;
|
|
38
41
|
exports.useMantineContext = useMantineContext;
|
|
39
42
|
exports.useMantineCssVariablesResolver = useMantineCssVariablesResolver;
|
|
43
|
+
exports.useMantineDeduplicateInlineStyles = useMantineDeduplicateInlineStyles;
|
|
40
44
|
exports.useMantineEnv = useMantineEnv;
|
|
41
45
|
exports.useMantineIsHeadless = useMantineIsHeadless;
|
|
42
46
|
exports.useMantineStyleNonce = useMantineStyleNonce;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mantine.context.cjs","names":[],"sources":["../../../src/core/MantineProvider/Mantine.context.ts"],"sourcesContent":["import { createContext, use } from 'react';\nimport { ConvertCSSVariablesInput } from './convert-css-variables';\nimport type { MantineColorScheme, MantineTheme } from './theme.types';\n\nexport interface MantineStylesTransform {\n sx?: () => (sx: any) => string;\n styles?: () => (styles: any, payload: any) => Record<string, string>;\n}\n\ninterface MantineContextValue {\n colorScheme: MantineColorScheme;\n setColorScheme: (colorScheme: MantineColorScheme) => void;\n clearColorScheme: () => void;\n getRootElement: () => HTMLElement | undefined;\n classNamesPrefix: string;\n getStyleNonce?: () => string | undefined;\n cssVariablesResolver?: (theme: MantineTheme) => ConvertCSSVariablesInput;\n cssVariablesSelector: string;\n withStaticClasses: boolean;\n headless?: boolean;\n stylesTransform?: MantineStylesTransform;\n env?: 'default' | 'test';\n}\n\nexport const MantineContext = createContext<MantineContextValue | null>(null);\n\nexport function useMantineContext() {\n const ctx = use(MantineContext);\n\n if (!ctx) {\n throw new Error('[@mantine/core] MantineProvider was not found in tree');\n }\n\n return ctx;\n}\n\nexport function useMantineCssVariablesResolver() {\n return useMantineContext().cssVariablesResolver;\n}\n\nexport function useMantineClassNamesPrefix() {\n return useMantineContext().classNamesPrefix;\n}\n\nexport function useMantineStyleNonce() {\n return useMantineContext().getStyleNonce;\n}\n\nexport function useMantineWithStaticClasses() {\n return useMantineContext().withStaticClasses;\n}\n\nexport function useMantineIsHeadless() {\n return useMantineContext().headless;\n}\n\nexport function useMantineSxTransform() {\n return useMantineContext().stylesTransform?.sx;\n}\n\nexport function useMantineStylesTransform() {\n return useMantineContext().stylesTransform?.styles;\n}\n\nexport function useMantineEnv() {\n return useMantineContext().env || 'default';\n}\n"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"Mantine.context.cjs","names":[],"sources":["../../../src/core/MantineProvider/Mantine.context.ts"],"sourcesContent":["import { createContext, use } from 'react';\nimport { ConvertCSSVariablesInput } from './convert-css-variables';\nimport type { MantineColorScheme, MantineTheme } from './theme.types';\n\nexport interface MantineStylesTransform {\n sx?: () => (sx: any) => string;\n styles?: () => (styles: any, payload: any) => Record<string, string>;\n}\n\ninterface MantineContextValue {\n colorScheme: MantineColorScheme;\n setColorScheme: (colorScheme: MantineColorScheme) => void;\n clearColorScheme: () => void;\n getRootElement: () => HTMLElement | undefined;\n classNamesPrefix: string;\n getStyleNonce?: () => string | undefined;\n cssVariablesResolver?: (theme: MantineTheme) => ConvertCSSVariablesInput;\n cssVariablesSelector: string;\n withStaticClasses: boolean;\n headless?: boolean;\n stylesTransform?: MantineStylesTransform;\n env?: 'default' | 'test';\n deduplicateInlineStyles?: boolean;\n}\n\nexport const MantineContext = createContext<MantineContextValue | null>(null);\n\nexport function useMantineContext() {\n const ctx = use(MantineContext);\n\n if (!ctx) {\n throw new Error('[@mantine/core] MantineProvider was not found in tree');\n }\n\n return ctx;\n}\n\nexport function useMantineCssVariablesResolver() {\n return useMantineContext().cssVariablesResolver;\n}\n\nexport function useMantineClassNamesPrefix() {\n return useMantineContext().classNamesPrefix;\n}\n\nexport function useMantineStyleNonce() {\n return useMantineContext().getStyleNonce;\n}\n\nexport function useMantineWithStaticClasses() {\n return useMantineContext().withStaticClasses;\n}\n\nexport function useMantineIsHeadless() {\n return useMantineContext().headless;\n}\n\nexport function useMantineSxTransform() {\n return useMantineContext().stylesTransform?.sx;\n}\n\nexport function useMantineStylesTransform() {\n return useMantineContext().stylesTransform?.styles;\n}\n\nexport function useMantineEnv() {\n return useMantineContext().env || 'default';\n}\n\nexport function useMantineDeduplicateInlineStyles() {\n return useMantineContext().deduplicateInlineStyles;\n}\n"],"mappings":";;;;AAyBA,MAAa,kBAAA,GAAA,MAAA,eAA2D,KAAK;AAE7E,SAAgB,oBAAoB;CAClC,MAAM,OAAA,GAAA,MAAA,KAAU,eAAe;AAE/B,KAAI,CAAC,IACH,OAAM,IAAI,MAAM,wDAAwD;AAG1E,QAAO;;AAGT,SAAgB,iCAAiC;AAC/C,QAAO,mBAAmB,CAAC;;AAG7B,SAAgB,6BAA6B;AAC3C,QAAO,mBAAmB,CAAC;;AAG7B,SAAgB,uBAAuB;AACrC,QAAO,mBAAmB,CAAC;;AAG7B,SAAgB,8BAA8B;AAC5C,QAAO,mBAAmB,CAAC;;AAG7B,SAAgB,uBAAuB;AACrC,QAAO,mBAAmB,CAAC;;AAG7B,SAAgB,wBAAwB;AACtC,QAAO,mBAAmB,CAAC,iBAAiB;;AAG9C,SAAgB,4BAA4B;AAC1C,QAAO,mBAAmB,CAAC,iBAAiB;;AAG9C,SAAgB,gBAAgB;AAC9B,QAAO,mBAAmB,CAAC,OAAO;;AAGpC,SAAgB,oCAAoC;AAClD,QAAO,mBAAmB,CAAC"}
|
|
@@ -12,7 +12,7 @@ const require_MantineCssVariables = require("./MantineCssVariables/MantineCssVar
|
|
|
12
12
|
const require_use_respect_reduce_motion = require("./use-respect-reduce-motion/use-respect-reduce-motion.cjs");
|
|
13
13
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
14
14
|
//#region packages/@mantine/core/src/core/MantineProvider/MantineProvider.tsx
|
|
15
|
-
function MantineProvider({ theme, children, getStyleNonce, withStaticClasses = true, withGlobalClasses = true, deduplicateCssVariables = true, withCssVariables = true, cssVariablesSelector, classNamesPrefix = "mantine", colorSchemeManager = require_local_storage_manager.localStorageColorSchemeManager(), defaultColorScheme = "light", getRootElement = () => document.documentElement, cssVariablesResolver, forceColorScheme, stylesTransform, env }) {
|
|
15
|
+
function MantineProvider({ theme, children, getStyleNonce, withStaticClasses = true, withGlobalClasses = true, deduplicateCssVariables = true, withCssVariables = true, cssVariablesSelector, classNamesPrefix = "mantine", colorSchemeManager = require_local_storage_manager.localStorageColorSchemeManager(), defaultColorScheme = "light", getRootElement = () => document.documentElement, cssVariablesResolver, forceColorScheme, stylesTransform, env, deduplicateInlineStyles = false }) {
|
|
16
16
|
const { colorScheme, setColorScheme, clearColorScheme } = require_use_provider_color_scheme.useProviderColorScheme({
|
|
17
17
|
defaultColorScheme,
|
|
18
18
|
forceColorScheme,
|
|
@@ -35,7 +35,8 @@ function MantineProvider({ theme, children, getStyleNonce, withStaticClasses = t
|
|
|
35
35
|
cssVariablesSelector: cssVariablesSelector ?? ":root",
|
|
36
36
|
withStaticClasses,
|
|
37
37
|
stylesTransform,
|
|
38
|
-
env
|
|
38
|
+
env,
|
|
39
|
+
deduplicateInlineStyles
|
|
39
40
|
},
|
|
40
41
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_MantineThemeProvider.MantineThemeProvider, {
|
|
41
42
|
theme,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MantineProvider.cjs","names":["localStorageColorSchemeManager","useProviderColorScheme","MantineContext","MantineThemeProvider","MantineCssVariables","MantineClasses"],"sources":["../../../src/core/MantineProvider/MantineProvider.tsx"],"sourcesContent":["import './baseline.css';\nimport './global.css';\nimport './default-css-variables.css';\n\nimport { localStorageColorSchemeManager, MantineColorSchemeManager } from './color-scheme-managers';\nimport { MantineContext, MantineStylesTransform } from './Mantine.context';\nimport { MantineClasses } from './MantineClasses';\nimport { CSSVariablesResolver, MantineCssVariables } from './MantineCssVariables';\nimport { MantineThemeProvider } from './MantineThemeProvider';\nimport type { MantineColorScheme, MantineThemeOverride } from './theme.types';\nimport { useProviderColorScheme } from './use-mantine-color-scheme';\nimport { useRespectReduceMotion } from './use-respect-reduce-motion';\n\nexport interface MantineProviderProps {\n /** Theme override object */\n theme?: MantineThemeOverride;\n\n /** Used to retrieve/set color scheme value in external storage, by default uses `window.localStorage` */\n colorSchemeManager?: MantineColorSchemeManager;\n\n /** Default color scheme value used when `colorSchemeManager` cannot retrieve value from external storage, `light` by default */\n defaultColorScheme?: MantineColorScheme;\n\n /** Forces color scheme value, if set, MantineProvider ignores `colorSchemeManager` and `defaultColorScheme` */\n forceColorScheme?: 'light' | 'dark';\n\n /** CSS selector to which CSS variables should be added, by default variables are applied to `:root` and `:host` */\n cssVariablesSelector?: string;\n\n /** Determines whether theme CSS variables should be added to given `cssVariablesSelector` @default true */\n withCssVariables?: boolean;\n\n /** Determines whether CSS variables should be deduplicated: if CSS variable has the same value as in default theme, it is not added in the runtime. @default true. */\n deduplicateCssVariables?: boolean;\n\n /** Function to resolve root element to set `data-mantine-color-scheme` attribute, must return undefined on server, `() => document.documentElement` by default */\n getRootElement?: () => HTMLElement | undefined;\n\n /** A prefix for components static classes (for example {selector}-Text-root), `mantine` by default */\n classNamesPrefix?: string;\n\n /** Function to generate nonce attribute added to all generated `style` tags */\n getStyleNonce?: () => string;\n\n /** Function to generate CSS variables based on theme object */\n cssVariablesResolver?: CSSVariablesResolver;\n\n /** Determines whether components should have static classes, for example, `mantine-Button-root`. @default true */\n withStaticClasses?: boolean;\n\n /** Determines whether global classes should be added with `<style />` tag. Global classes are required for `hiddenFrom`/`visibleFrom` and `lightHidden`/`darkHidden` props to work. @default true. */\n withGlobalClasses?: boolean;\n\n /** An object to transform `styles` and `sx` props into css classes, can be used with CSS-in-JS libraries */\n stylesTransform?: MantineStylesTransform;\n\n /** Your application */\n children?: React.ReactNode;\n\n /** Environment at which the provider is used, `'test'` environment disables all transitions and portals */\n env?: 'default' | 'test';\n}\n\nexport function MantineProvider({\n theme,\n children,\n getStyleNonce,\n withStaticClasses = true,\n withGlobalClasses = true,\n deduplicateCssVariables = true,\n withCssVariables = true,\n cssVariablesSelector,\n classNamesPrefix = 'mantine',\n colorSchemeManager = localStorageColorSchemeManager(),\n defaultColorScheme = 'light',\n getRootElement = () => document.documentElement,\n cssVariablesResolver,\n forceColorScheme,\n stylesTransform,\n env,\n}: MantineProviderProps) {\n const { colorScheme, setColorScheme, clearColorScheme } = useProviderColorScheme({\n defaultColorScheme,\n forceColorScheme,\n manager: colorSchemeManager,\n getRootElement,\n });\n\n useRespectReduceMotion({\n respectReducedMotion: theme?.respectReducedMotion || false,\n getRootElement,\n });\n\n return (\n <MantineContext\n value={{\n colorScheme,\n setColorScheme,\n clearColorScheme,\n getRootElement,\n classNamesPrefix,\n getStyleNonce,\n cssVariablesResolver,\n cssVariablesSelector: cssVariablesSelector ?? ':root',\n withStaticClasses,\n stylesTransform,\n env,\n }}\n >\n <MantineThemeProvider theme={theme}>\n {withCssVariables && (\n <MantineCssVariables\n cssVariablesSelector={cssVariablesSelector}\n deduplicateCssVariables={deduplicateCssVariables}\n />\n )}\n {withGlobalClasses && <MantineClasses />}\n {children}\n </MantineThemeProvider>\n </MantineContext>\n );\n}\n\nMantineProvider.displayName = '@mantine/core/MantineProvider';\n\nexport interface HeadlessMantineProviderProps {\n /** Theme override object */\n theme?: MantineThemeOverride;\n\n /** Your application */\n children?: React.ReactNode;\n\n /** Environment at which the provider is used, `'test'` environment disables all transitions and portals */\n env?: 'default' | 'test';\n}\n\nexport function HeadlessMantineProvider({ children, theme, env }: HeadlessMantineProviderProps) {\n return (\n <MantineContext\n value={{\n colorScheme: 'auto',\n setColorScheme: () => {},\n clearColorScheme: () => {},\n getRootElement: () => document.documentElement,\n classNamesPrefix: 'mantine',\n cssVariablesSelector: ':root',\n withStaticClasses: false,\n headless: true,\n env,\n }}\n >\n <MantineThemeProvider theme={theme}>{children}</MantineThemeProvider>\n </MantineContext>\n );\n}\n\nHeadlessMantineProvider.displayName = '@mantine/core/HeadlessMantineProvider';\n"],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"MantineProvider.cjs","names":["localStorageColorSchemeManager","useProviderColorScheme","MantineContext","MantineThemeProvider","MantineCssVariables","MantineClasses"],"sources":["../../../src/core/MantineProvider/MantineProvider.tsx"],"sourcesContent":["import './baseline.css';\nimport './global.css';\nimport './default-css-variables.css';\n\nimport { localStorageColorSchemeManager, MantineColorSchemeManager } from './color-scheme-managers';\nimport { MantineContext, MantineStylesTransform } from './Mantine.context';\nimport { MantineClasses } from './MantineClasses';\nimport { CSSVariablesResolver, MantineCssVariables } from './MantineCssVariables';\nimport { MantineThemeProvider } from './MantineThemeProvider';\nimport type { MantineColorScheme, MantineThemeOverride } from './theme.types';\nimport { useProviderColorScheme } from './use-mantine-color-scheme';\nimport { useRespectReduceMotion } from './use-respect-reduce-motion';\n\nexport interface MantineProviderProps {\n /** Theme override object */\n theme?: MantineThemeOverride;\n\n /** Used to retrieve/set color scheme value in external storage, by default uses `window.localStorage` */\n colorSchemeManager?: MantineColorSchemeManager;\n\n /** Default color scheme value used when `colorSchemeManager` cannot retrieve value from external storage, `light` by default */\n defaultColorScheme?: MantineColorScheme;\n\n /** Forces color scheme value, if set, MantineProvider ignores `colorSchemeManager` and `defaultColorScheme` */\n forceColorScheme?: 'light' | 'dark';\n\n /** CSS selector to which CSS variables should be added, by default variables are applied to `:root` and `:host` */\n cssVariablesSelector?: string;\n\n /** Determines whether theme CSS variables should be added to given `cssVariablesSelector` @default true */\n withCssVariables?: boolean;\n\n /** Determines whether CSS variables should be deduplicated: if CSS variable has the same value as in default theme, it is not added in the runtime. @default true. */\n deduplicateCssVariables?: boolean;\n\n /** Function to resolve root element to set `data-mantine-color-scheme` attribute, must return undefined on server, `() => document.documentElement` by default */\n getRootElement?: () => HTMLElement | undefined;\n\n /** A prefix for components static classes (for example {selector}-Text-root), `mantine` by default */\n classNamesPrefix?: string;\n\n /** Function to generate nonce attribute added to all generated `style` tags */\n getStyleNonce?: () => string;\n\n /** Function to generate CSS variables based on theme object */\n cssVariablesResolver?: CSSVariablesResolver;\n\n /** Determines whether components should have static classes, for example, `mantine-Button-root`. @default true */\n withStaticClasses?: boolean;\n\n /** Determines whether global classes should be added with `<style />` tag. Global classes are required for `hiddenFrom`/`visibleFrom` and `lightHidden`/`darkHidden` props to work. @default true. */\n withGlobalClasses?: boolean;\n\n /** An object to transform `styles` and `sx` props into css classes, can be used with CSS-in-JS libraries */\n stylesTransform?: MantineStylesTransform;\n\n /** Determines whether inline styles with identical content should be deduplicated using React 19 style hoisting. When enabled, components with the same responsive style props share a single `<style />` tag instead of each generating their own. @default false */\n deduplicateInlineStyles?: boolean;\n\n /** Your application */\n children?: React.ReactNode;\n\n /** Environment at which the provider is used, `'test'` environment disables all transitions and portals */\n env?: 'default' | 'test';\n}\n\nexport function MantineProvider({\n theme,\n children,\n getStyleNonce,\n withStaticClasses = true,\n withGlobalClasses = true,\n deduplicateCssVariables = true,\n withCssVariables = true,\n cssVariablesSelector,\n classNamesPrefix = 'mantine',\n colorSchemeManager = localStorageColorSchemeManager(),\n defaultColorScheme = 'light',\n getRootElement = () => document.documentElement,\n cssVariablesResolver,\n forceColorScheme,\n stylesTransform,\n env,\n deduplicateInlineStyles = false,\n}: MantineProviderProps) {\n const { colorScheme, setColorScheme, clearColorScheme } = useProviderColorScheme({\n defaultColorScheme,\n forceColorScheme,\n manager: colorSchemeManager,\n getRootElement,\n });\n\n useRespectReduceMotion({\n respectReducedMotion: theme?.respectReducedMotion || false,\n getRootElement,\n });\n\n return (\n <MantineContext\n value={{\n colorScheme,\n setColorScheme,\n clearColorScheme,\n getRootElement,\n classNamesPrefix,\n getStyleNonce,\n cssVariablesResolver,\n cssVariablesSelector: cssVariablesSelector ?? ':root',\n withStaticClasses,\n stylesTransform,\n env,\n deduplicateInlineStyles,\n }}\n >\n <MantineThemeProvider theme={theme}>\n {withCssVariables && (\n <MantineCssVariables\n cssVariablesSelector={cssVariablesSelector}\n deduplicateCssVariables={deduplicateCssVariables}\n />\n )}\n {withGlobalClasses && <MantineClasses />}\n {children}\n </MantineThemeProvider>\n </MantineContext>\n );\n}\n\nMantineProvider.displayName = '@mantine/core/MantineProvider';\n\nexport interface HeadlessMantineProviderProps {\n /** Theme override object */\n theme?: MantineThemeOverride;\n\n /** Your application */\n children?: React.ReactNode;\n\n /** Environment at which the provider is used, `'test'` environment disables all transitions and portals */\n env?: 'default' | 'test';\n}\n\nexport function HeadlessMantineProvider({ children, theme, env }: HeadlessMantineProviderProps) {\n return (\n <MantineContext\n value={{\n colorScheme: 'auto',\n setColorScheme: () => {},\n clearColorScheme: () => {},\n getRootElement: () => document.documentElement,\n classNamesPrefix: 'mantine',\n cssVariablesSelector: ':root',\n withStaticClasses: false,\n headless: true,\n env,\n }}\n >\n <MantineThemeProvider theme={theme}>{children}</MantineThemeProvider>\n </MantineContext>\n );\n}\n\nHeadlessMantineProvider.displayName = '@mantine/core/HeadlessMantineProvider';\n"],"mappings":";;;;;;;;;;;;;;AAkEA,SAAgB,gBAAgB,EAC9B,OACA,UACA,eACA,oBAAoB,MACpB,oBAAoB,MACpB,0BAA0B,MAC1B,mBAAmB,MACnB,sBACA,mBAAmB,WACnB,qBAAqBA,8BAAAA,gCAAgC,EACrD,qBAAqB,SACrB,uBAAuB,SAAS,iBAChC,sBACA,kBACA,iBACA,KACA,0BAA0B,SACH;CACvB,MAAM,EAAE,aAAa,gBAAgB,qBAAqBC,kCAAAA,uBAAuB;EAC/E;EACA;EACA,SAAS;EACT;EACD,CAAC;AAEF,mCAAA,uBAAuB;EACrB,sBAAsB,OAAO,wBAAwB;EACrD;EACD,CAAC;AAEF,QACE,iBAAA,GAAA,kBAAA,KAACC,wBAAAA,gBAAD;EACE,OAAO;GACL;GACA;GACA;GACA;GACA;GACA;GACA;GACA,sBAAsB,wBAAwB;GAC9C;GACA;GACA;GACA;GACD;YAED,iBAAA,GAAA,kBAAA,MAACC,6BAAAA,sBAAD;GAA6B;aAA7B;IACG,oBACC,iBAAA,GAAA,kBAAA,KAACC,4BAAAA,qBAAD;KACwB;KACG;KACzB,CAAA;IAEH,qBAAqB,iBAAA,GAAA,kBAAA,KAACC,uBAAAA,gBAAD,EAAkB,CAAA;IACvC;IACoB;;EACR,CAAA;;AAIrB,gBAAgB,cAAc;AAa9B,SAAgB,wBAAwB,EAAE,UAAU,OAAO,OAAqC;AAC9F,QACE,iBAAA,GAAA,kBAAA,KAACH,wBAAAA,gBAAD;EACE,OAAO;GACL,aAAa;GACb,sBAAsB;GACtB,wBAAwB;GACxB,sBAAsB,SAAS;GAC/B,kBAAkB;GAClB,sBAAsB;GACtB,mBAAmB;GACnB,UAAU;GACV;GACD;YAED,iBAAA,GAAA,kBAAA,KAACC,6BAAAA,sBAAD;GAA6B;GAAQ;GAAgC,CAAA;EACtD,CAAA;;AAIrB,wBAAwB,cAAc"}
|
package/cjs/index.cjs
CHANGED
|
@@ -72,6 +72,7 @@ const require_get_global_class_names = require("./core/styles-api/use-styles/get
|
|
|
72
72
|
const require_use_styles = require("./core/styles-api/use-styles/use-styles.cjs");
|
|
73
73
|
const require_styles_to_string = require("./core/InlineStyles/styles-to-string/styles-to-string.cjs");
|
|
74
74
|
const require_InlineStyles = require("./core/InlineStyles/InlineStyles.cjs");
|
|
75
|
+
const require_hash_styles = require("./core/InlineStyles/hash-styles.cjs");
|
|
75
76
|
const require_extract_style_props = require("./core/Box/style-props/extract-style-props/extract-style-props.cjs");
|
|
76
77
|
const require_style_props_data = require("./core/Box/style-props/style-props-data.cjs");
|
|
77
78
|
const require_parse_style_props = require("./core/Box/style-props/parse-style-props/parse-style-props.cjs");
|
|
@@ -243,6 +244,7 @@ const require_ListItem = require("./components/List/ListItem/ListItem.cjs");
|
|
|
243
244
|
const require_List = require("./components/List/List.cjs");
|
|
244
245
|
const require_LoadingOverlay = require("./components/LoadingOverlay/LoadingOverlay.cjs");
|
|
245
246
|
const require_Marquee = require("./components/Marquee/Marquee.cjs");
|
|
247
|
+
const require_MaskInput = require("./components/MaskInput/MaskInput.cjs");
|
|
246
248
|
const require_Menu_context = require("./components/Menu/Menu.context.cjs");
|
|
247
249
|
const require_MenuDivider = require("./components/Menu/MenuDivider/MenuDivider.cjs");
|
|
248
250
|
const require_MenuDropdown = require("./components/Menu/MenuDropdown/MenuDropdown.cjs");
|
|
@@ -336,6 +338,11 @@ const require_Timeline = require("./components/Timeline/Timeline.cjs");
|
|
|
336
338
|
const require_Title = require("./components/Title/Title.cjs");
|
|
337
339
|
const require_use_tree = require("./components/Tree/use-tree.cjs");
|
|
338
340
|
const require_Tree = require("./components/Tree/Tree.cjs");
|
|
341
|
+
const require_merge_async_children = require("./components/Tree/merge-async-children/merge-async-children.cjs");
|
|
342
|
+
const require_move_tree_node = require("./components/Tree/move-tree-node/move-tree-node.cjs");
|
|
343
|
+
const require_filter_tree_data = require("./components/Tree/filter-tree-data/filter-tree-data.cjs");
|
|
344
|
+
const require_flatten_tree_data = require("./components/Tree/flatten-tree-data/flatten-tree-data.cjs");
|
|
345
|
+
const require_FlatTreeNode = require("./components/Tree/FlatTreeNode.cjs");
|
|
339
346
|
const require_Typography = require("./components/Typography/Typography.cjs");
|
|
340
347
|
let react_remove_scroll = require("react-remove-scroll");
|
|
341
348
|
exports.Accordion = require_Accordion.Accordion;
|
|
@@ -430,6 +437,7 @@ exports.FOCUS_CLASS_NAMES = require_get_global_class_names.FOCUS_CLASS_NAMES;
|
|
|
430
437
|
exports.Fieldset = require_Fieldset.Fieldset;
|
|
431
438
|
exports.FileButton = require_FileButton.FileButton;
|
|
432
439
|
exports.FileInput = require_FileInput.FileInput;
|
|
440
|
+
exports.FlatTreeNode = require_FlatTreeNode.FlatTreeNode;
|
|
433
441
|
exports.Flex = require_Flex.Flex;
|
|
434
442
|
exports.FloatingArrow = require_FloatingArrow.FloatingArrow;
|
|
435
443
|
exports.FloatingIndicator = require_FloatingIndicator.FloatingIndicator;
|
|
@@ -473,6 +481,7 @@ exports.MantineThemeContext = require_MantineThemeProvider.MantineThemeContext;
|
|
|
473
481
|
exports.MantineThemeProvider = require_MantineThemeProvider.MantineThemeProvider;
|
|
474
482
|
exports.Mark = require_Mark.Mark;
|
|
475
483
|
exports.Marquee = require_Marquee.Marquee;
|
|
484
|
+
exports.MaskInput = require_MaskInput.MaskInput;
|
|
476
485
|
exports.Menu = require_Menu.Menu;
|
|
477
486
|
exports.MenuDivider = require_MenuDivider.MenuDivider;
|
|
478
487
|
exports.MenuDropdown = require_MenuDropdown.MenuDropdown;
|
|
@@ -620,15 +629,18 @@ exports.deepMerge = require_deep_merge.deepMerge;
|
|
|
620
629
|
exports.defaultCssVariablesResolver = require_default_css_variables_resolver.defaultCssVariablesResolver;
|
|
621
630
|
exports.defaultLoaders = require_Loader.defaultLoaders;
|
|
622
631
|
exports.defaultOptionsFilter = require_default_options_filter.defaultOptionsFilter;
|
|
632
|
+
exports.defaultTreeNodeFilter = require_filter_tree_data.defaultTreeNodeFilter;
|
|
623
633
|
exports.defaultVariantColorsResolver = require_default_variant_colors_resolver.defaultVariantColorsResolver;
|
|
624
634
|
exports.em = require_rem.em;
|
|
625
635
|
exports.extractStyleProps = require_extract_style_props.extractStyleProps;
|
|
626
636
|
exports.factory = require_factory.factory;
|
|
627
637
|
exports.filterProps = require_filter_props.filterProps;
|
|
638
|
+
exports.filterTreeData = require_filter_tree_data.filterTreeData;
|
|
628
639
|
exports.findClosestNumber = require_find_closest_number.findClosestNumber;
|
|
629
640
|
exports.findElementAncestor = require_find_element_ancestor.findElementAncestor;
|
|
630
641
|
exports.findElementBySelector = require_find_element_in_shadow_dom.findElementBySelector;
|
|
631
642
|
exports.findElementsBySelector = require_find_element_in_shadow_dom.findElementsBySelector;
|
|
643
|
+
exports.flattenTreeData = require_flatten_tree_data.flattenTreeData;
|
|
632
644
|
exports.genericFactory = require_factory.genericFactory;
|
|
633
645
|
exports.getAutoContrastValue = require_get_auto_contrast_value.getAutoContrastValue;
|
|
634
646
|
exports.getBaseValue = require_get_base_value.getBaseValue;
|
|
@@ -659,6 +671,7 @@ exports.getStyleObject = require_get_style_object.getStyleObject;
|
|
|
659
671
|
exports.getThemeColor = require_get_theme_color.getThemeColor;
|
|
660
672
|
exports.getTransitionProps = require_get_transition_props.getTransitionProps;
|
|
661
673
|
exports.getTreeExpandedState = require_use_tree.getTreeExpandedState;
|
|
674
|
+
exports.hashStyleProps = require_hash_styles.hashStyleProps;
|
|
662
675
|
exports.isColorValid = require_parsers.isColorValid;
|
|
663
676
|
exports.isElement = require_is_element.isElement;
|
|
664
677
|
exports.isLightColor = require_luminance.isLightColor;
|
|
@@ -673,8 +686,10 @@ exports.localStorageColorSchemeManager = require_local_storage_manager.localStor
|
|
|
673
686
|
exports.luminance = require_luminance.luminance;
|
|
674
687
|
exports.mantineHtmlProps = require_mantine_html_props.mantineHtmlProps;
|
|
675
688
|
exports.memoize = require_memoize.memoize;
|
|
689
|
+
exports.mergeAsyncChildren = require_merge_async_children.mergeAsyncChildren;
|
|
676
690
|
exports.mergeMantineTheme = require_merge_mantine_theme.mergeMantineTheme;
|
|
677
691
|
exports.mergeThemeOverrides = require_merge_theme_overrides.mergeThemeOverrides;
|
|
692
|
+
exports.moveTreeNode = require_move_tree_node.moveTreeNode;
|
|
678
693
|
exports.noop = require_noop.noop;
|
|
679
694
|
exports.parseColor = require_parsers.parseColor;
|
|
680
695
|
exports.parseStyleProps = require_parse_style_props.parseStyleProps;
|
|
@@ -708,6 +723,7 @@ exports.useMantineClassNamesPrefix = require_Mantine_context.useMantineClassName
|
|
|
708
723
|
exports.useMantineColorScheme = require_use_mantine_color_scheme.useMantineColorScheme;
|
|
709
724
|
exports.useMantineContext = require_Mantine_context.useMantineContext;
|
|
710
725
|
exports.useMantineCssVariablesResolver = require_Mantine_context.useMantineCssVariablesResolver;
|
|
726
|
+
exports.useMantineDeduplicateInlineStyles = require_Mantine_context.useMantineDeduplicateInlineStyles;
|
|
711
727
|
exports.useMantineEnv = require_Mantine_context.useMantineEnv;
|
|
712
728
|
exports.useMantineIsHeadless = require_Mantine_context.useMantineIsHeadless;
|
|
713
729
|
exports.useMantineStyleNonce = require_Mantine_context.useMantineStyleNonce;
|
|
@@ -19,13 +19,12 @@ const varsResolver = createVarsResolver((theme, { color, iconSize, radius }) =>
|
|
|
19
19
|
theme,
|
|
20
20
|
colorScheme: "dark"
|
|
21
21
|
});
|
|
22
|
-
const lightParsed = parseThemeColor({
|
|
23
|
-
color: color || theme.primaryColor,
|
|
24
|
-
theme,
|
|
25
|
-
colorScheme: "light"
|
|
26
|
-
});
|
|
27
22
|
return { root: {
|
|
28
|
-
"--bq-bg-light": rgba(
|
|
23
|
+
"--bq-bg-light": rgba(parseThemeColor({
|
|
24
|
+
color: color || theme.primaryColor,
|
|
25
|
+
theme,
|
|
26
|
+
colorScheme: "light"
|
|
27
|
+
}).value, .07),
|
|
29
28
|
"--bq-bg-dark": rgba(darkParsed.value, .06),
|
|
30
29
|
"--bq-bd": getThemeColor(color, theme),
|
|
31
30
|
"--bq-icon-size": rem(iconSize),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Blockquote.mjs","names":["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,eAAe,oBAAuC,OAAO,EAAE,OAAO,UAAU,aAAa;CACjG,MAAM,aAAa,gBAAgB;EACjC,OAAO,SAAS,MAAM;EACtB;EACA,aAAa;EACd,CAAC;
|
|
1
|
+
{"version":3,"file":"Blockquote.mjs","names":["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,eAAe,oBAAuC,OAAO,EAAE,OAAO,UAAU,aAAa;CACjG,MAAM,aAAa,gBAAgB;EACjC,OAAO,SAAS,MAAM;EACtB;EACA,aAAa;EACd,CAAC;AAQF,QAAO,EACL,MAAM;EACJ,iBAAiB,KARD,gBAAgB;GAClC,OAAO,SAAS,MAAM;GACtB;GACA,aAAa;GACd,CAAC,CAIoC,OAAO,IAAK;EAC9C,gBAAgB,KAAK,WAAW,OAAO,IAAK;EAC5C,WAAW,cAAc,OAAO,MAAM;EACtC,kBAAkB,IAAI,SAAS;EAC/B,eAAe,UAAU,OAAO;EACjC,EACF;EACD;AAEF,MAAa,aAAa,SAA4B,WAAW;CAC/D,MAAM,QAAQ,SAAS,cAAc,cAAc,OAAO;CAC1D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,UACA,MACA,UACA,MACA,YACA,GAAG,WACD;CAEJ,MAAM,YAAY,UAA6B;EAC7C,MAAM;EACN,SAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,QACE,qBAAC,KAAD;EAAK,WAAU;EAAa,GAAI,UAAU,OAAO;EAAE,GAAI;YAAvD;GACG,QAAQ,oBAAC,QAAD;IAAM,GAAI,UAAU,OAAO;cAAG;IAAY,CAAA;GAClD;GACA,QAAQ,oBAAC,QAAD;IAAM,GAAI,UAAU,OAAO;cAAG;IAAY,CAAA;GAC/C;;EAER;AAEF,WAAW,UAAUA;AACrB,WAAW,eAAe;AAC1B,WAAW,cAAc"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { filterProps } from "../../core/utils/filter-props/filter-props.mjs";
|
|
3
|
+
import { useMantineDeduplicateInlineStyles } from "../../core/MantineProvider/Mantine.context.mjs";
|
|
3
4
|
import { useMantineTheme } from "../../core/MantineProvider/MantineThemeProvider/MantineThemeProvider.mjs";
|
|
4
5
|
import { useProps } from "../../core/MantineProvider/use-props/use-props.mjs";
|
|
5
6
|
import { useStyles } from "../../core/styles-api/use-styles/use-styles.mjs";
|
|
6
7
|
import { InlineStyles } from "../../core/InlineStyles/InlineStyles.mjs";
|
|
8
|
+
import { hashStyleProps } from "../../core/InlineStyles/hash-styles.mjs";
|
|
7
9
|
import { parseStyleProps } from "../../core/Box/style-props/parse-style-props/parse-style-props.mjs";
|
|
8
10
|
import { useRandomClassName } from "../../core/Box/use-random-classname/use-random-classname.mjs";
|
|
9
11
|
import { polymorphicFactory } from "../../core/factory/polymorphic-factory.mjs";
|
|
@@ -28,7 +30,7 @@ const Flex = polymorphicFactory((_props) => {
|
|
|
28
30
|
vars
|
|
29
31
|
});
|
|
30
32
|
const theme = useMantineTheme();
|
|
31
|
-
const
|
|
33
|
+
const randomClassName = useRandomClassName();
|
|
32
34
|
const parsedStyleProps = parseStyleProps({
|
|
33
35
|
styleProps: {
|
|
34
36
|
gap,
|
|
@@ -42,10 +44,13 @@ const Flex = polymorphicFactory((_props) => {
|
|
|
42
44
|
theme,
|
|
43
45
|
data: FLEX_STYLE_PROPS_DATA
|
|
44
46
|
});
|
|
47
|
+
const deduplicateInlineStyles = useMantineDeduplicateInlineStyles();
|
|
48
|
+
const responsiveClassName = deduplicateInlineStyles && parsedStyleProps.hasResponsiveStyles ? hashStyleProps(parsedStyleProps.styles, parsedStyleProps.media) : randomClassName;
|
|
45
49
|
return /* @__PURE__ */ jsxs(Fragment, { children: [parsedStyleProps.hasResponsiveStyles && /* @__PURE__ */ jsx(InlineStyles, {
|
|
46
50
|
selector: `.${responsiveClassName}`,
|
|
47
51
|
styles: parsedStyleProps.styles,
|
|
48
|
-
media: parsedStyleProps.media
|
|
52
|
+
media: parsedStyleProps.media,
|
|
53
|
+
deduplicate: deduplicateInlineStyles
|
|
49
54
|
}), /* @__PURE__ */ jsx(Box, {
|
|
50
55
|
...getStyles("root", {
|
|
51
56
|
className: responsiveClassName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flex.mjs","names":["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.mjs","names":["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,OAAO,oBAAiC,WAAW;CAC9D,MAAM,QAAQ,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,YAAY,UAAuB;EACvC,MAAM;EACN,SAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,QAAQ,iBAAiB;CAC/B,MAAM,kBAAkB,oBAAoB;CAC5C,MAAM,mBAAmB,gBAAgB;EACvC,YAAY;GAAE;GAAK;GAAQ;GAAW;GAAO;GAAS;GAAM;GAAW;EACvE;EACA,MAAM;EACP,CAAC;CAEF,MAAM,0BAA0B,mCAAmC;CACnE,MAAM,sBACJ,2BAA2B,iBAAiB,sBACxC,eAAe,iBAAiB,QAAQ,iBAAiB,MAAM,GAC/D;AAEN,QACE,qBAAA,UAAA,EAAA,UAAA,CACG,iBAAiB,uBAChB,oBAAC,cAAD;EACE,UAAU,IAAI;EACd,QAAQ,iBAAiB;EACzB,OAAO,iBAAiB;EACxB,aAAa;EACb,CAAA,EAEJ,oBAAC,KAAD;EACE,GAAI,UAAU,QAAQ;GACpB,WAAW;GACX,OAAO,YAAY,iBAAiB,aAAa;GAClD,CAAC;EACF,GAAI;EACJ,CAAA,CACD,EAAA,CAAA;EAEL;AAEF,KAAK,UAAUA;AACf,KAAK,cAAc"}
|
|
@@ -11,8 +11,7 @@ import { useMergedRef, useReducedMotion } from "@mantine/hooks";
|
|
|
11
11
|
import { jsx } from "react/jsx-runtime";
|
|
12
12
|
//#region packages/@mantine/core/src/components/FloatingIndicator/FloatingIndicator.tsx
|
|
13
13
|
const varsResolver = createVarsResolver((theme, { transitionDuration }, { shouldReduceMotion }) => {
|
|
14
|
-
|
|
15
|
-
return { root: { "--transition-duration": duration } };
|
|
14
|
+
return { root: { "--transition-duration": (theme.respectReducedMotion ? shouldReduceMotion : false) ? "0ms" : typeof transitionDuration === "number" ? `${transitionDuration}ms` : transitionDuration || "150ms" } };
|
|
16
15
|
});
|
|
17
16
|
const FloatingIndicator = factory((_props) => {
|
|
18
17
|
const props = useProps("FloatingIndicator", null, _props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingIndicator.mjs","names":["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,eAAe,oBAClB,OAAO,EAAE,sBAAsB,EAAE,yBAAyB;
|
|
1
|
+
{"version":3,"file":"FloatingIndicator.mjs","names":["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,eAAe,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,oBAAoB,SAAmC,WAAW;CAC7E,MAAM,QAAQ,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,YAAY,UAAoC;EACpD,MAAM;EACN,SAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW,EAAE,oBAdY,kBAAkB,EAcV;EAClC,CAAC;CAEF,MAAM,WAAW,OAAuB,KAAK;CAC7C,MAAM,EAAE,aAAa,WAAW,qBAAqB;EACnD;EACA;EACA,KAAK;EACL;EACA;EACA;EACD,CAAC;CAEF,MAAM,YAAY,aAAa,KAAK,SAAS;AAE7C,KAAI,CAAC,UAAU,CAAC,OACd,QAAO;AAGT,QACE,oBAAC,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,UAAUA;AAC5B,kBAAkB,eAAe"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useProps } from "../../core/MantineProvider/use-props/use-props.mjs";
|
|
3
|
+
import { factory } from "../../core/factory/factory.mjs";
|
|
4
|
+
import { InputBase } from "../InputBase/InputBase.mjs";
|
|
5
|
+
import { useMaskInputProps } from "./use-mask-input-props.mjs";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
//#region packages/@mantine/core/src/components/MaskInput/MaskInput.tsx
|
|
8
|
+
const defaultProps = {};
|
|
9
|
+
const MaskInput = factory((props) => {
|
|
10
|
+
const { maskRef, elementProps } = useMaskInputProps(useProps("MaskInput", defaultProps, props));
|
|
11
|
+
return /* @__PURE__ */ jsx(InputBase, {
|
|
12
|
+
component: "input",
|
|
13
|
+
ref: maskRef,
|
|
14
|
+
...elementProps,
|
|
15
|
+
__staticSelector: "MaskInput"
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
MaskInput.classes = InputBase.classes;
|
|
19
|
+
MaskInput.displayName = "@mantine/core/MaskInput";
|
|
20
|
+
//#endregion
|
|
21
|
+
export { MaskInput };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=MaskInput.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaskInput.mjs","names":[],"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,YAAY,SAA2B,UAAU;CAE5D,MAAM,EAAE,SAAS,iBAAiB,kBADnB,SAAS,aAAa,cAAc,MAAM,CACE;AAE3D,QACE,oBAAC,WAAD;EACE,WAAU;EACV,KAAK;EACL,GAAK;EACL,kBAAiB;EACjB,CAAA;EAEJ;AAEF,UAAU,UAAU,UAAU;AAC9B,UAAU,cAAc"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMask, useMergedRef } from "@mantine/hooks";
|
|
3
|
+
//#region packages/@mantine/core/src/components/MaskInput/use-mask-input-props.ts
|
|
4
|
+
function useMaskInputProps(props) {
|
|
5
|
+
const { mask, tokens, modify, separate, slotChar, alwaysShowMask, showMaskOnFocus, transform, autoClear, onChangeRaw, onComplete, beforeMaskedStateChange, ref, ...elementProps } = props;
|
|
6
|
+
const { ref: maskCallbackRef } = useMask({
|
|
7
|
+
mask,
|
|
8
|
+
tokens,
|
|
9
|
+
modify,
|
|
10
|
+
separate,
|
|
11
|
+
slotChar,
|
|
12
|
+
alwaysShowMask,
|
|
13
|
+
showMaskOnFocus,
|
|
14
|
+
transform,
|
|
15
|
+
autoClear,
|
|
16
|
+
onChangeRaw,
|
|
17
|
+
onComplete,
|
|
18
|
+
beforeMaskedStateChange
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
maskRef: useMergedRef(ref, maskCallbackRef),
|
|
22
|
+
elementProps
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { useMaskInputProps };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=use-mask-input-props.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-mask-input-props.mjs","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,oBAAoB,QAAQ;EACvC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAIF,QAAO;EAAE,SAFO,aAAa,KAAK,gBAAgB;EAEhC;EAAc"}
|
|
@@ -115,9 +115,8 @@ const Rating = factory((_props) => {
|
|
|
115
115
|
const items = Array(_count).fill(0).map((_, index) => {
|
|
116
116
|
const integerValue = index + 1;
|
|
117
117
|
const fractionItems = Array.from(new Array(index === 0 ? _fractions + 1 : _fractions));
|
|
118
|
-
const isGroupActive = !readOnly && Math.ceil(hovered) === integerValue;
|
|
119
118
|
return /* @__PURE__ */ jsx("div", {
|
|
120
|
-
"data-active":
|
|
119
|
+
"data-active": !readOnly && Math.ceil(hovered) === integerValue || void 0,
|
|
121
120
|
...getStyles("symbolGroup"),
|
|
122
121
|
children: fractionItems.map((__, fractionIndex) => {
|
|
123
122
|
const fractionValue = decimalUnit * (index === 0 ? fractionIndex : fractionIndex + 1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rating.mjs","names":["useId","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":"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"}
|
|
1
|
+
{"version":3,"file":"Rating.mjs","names":["useId","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,eAAe,oBAAmC,OAAO,EAAE,MAAM,aAAa,EAClF,MAAM;CACJ,iBAAiB,QAAQ,MAAM,cAAc;CAC7C,kBAAkB,cAAc,OAAO,MAAM;CAC9C,EACF,EAAE;AAEH,MAAa,SAAS,SAAwB,WAAW;CACvD,MAAM,QAAQ,SAAS,UAAU,cAAc,OAAO;CACtD,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,MACA,IACA,OACA,cACA,UACA,WACA,OACA,cACA,UACA,YACA,aACA,SACA,cACA,cACA,YACA,MACA,SACA,gBACA,OACA,aACA,YACA,uBACA,YACA,KACA,GAAG,WACD;CAEJ,MAAM,YAAY,UAAyB;EACzC,MAAM;EACN,SAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,EAAE,QAAQ,cAAc;CAE9B,MAAM,QAAQA,QAAM,KAAK;CACzB,MAAM,MAAMA,QAAM,GAAG;CACrB,MAAM,UAAU,OAAuB,KAAK;CAE5C,MAAM,CAAC,QAAQ,YAAY,gBAAgB;EACzC;EACA;EACA,YAAY;EACZ;EACD,CAAC;CAEF,MAAM,CAAC,SAAS,cAAc,SAAS,GAAG;CAC1C,MAAM,CAAC,WAAW,cAAc,SAAS,KAAK;CAE9C,MAAM,aAAa,KAAK,MAAM,UAAU;CACxC,MAAM,SAAS,KAAK,MAAM,MAAM;CAEhC,MAAM,cAAc,IAAI;CACxB,MAAM,qBAAqB,aAAa,QAAQ,YAAY;CAC5D,MAAM,aAAa,YAAY,KAAK,UAAU;CAE9C,MAAM,4BAA4B,MAAc;AAC9C,MAAI,CAAC,QAAQ,QACX,QAAO;EAGT,MAAM,EAAE,MAAM,OAAO,UAAU,QAAQ,QAAQ,uBAAuB;EACtE,MAAM,cAAc,QAAQ;AAK5B,SAAO,MAAM,cAHS,QAAQ,QAAQ,QAAQ,IAAI,IAAI,QACnB,cAEI,cAAc,GAAG,YAAY,EAAE,aAAa,OAAO;;CAG5F,MAAM,oBAAoB,UAA4C;AACpE,iBAAe,MAAM;AACrB,GAAC,YAAY,WAAW,MAAM;;CAGhC,MAAM,mBAAmB,UAA4C;AACnE,gBAAc,MAAM;AAEpB,MAAI,SACF;EAGF,MAAM,UAAU,yBAAyB,MAAM,QAAQ;AAEvD,aAAW,QAAQ;AACnB,cAAY,WAAW,UAAU,QAAQ;;CAG3C,MAAM,oBAAoB,UAA4C;AACpE,iBAAe,MAAM;AAErB,MAAI,SACF;AAGF,aAAW,GAAG;AACd,aAAW,KAAK;AAChB,cAAY,MAAM,UAAU,GAAG;;CAGjC,MAAM,oBAAoB,UAA4C;EACpE,MAAM,EAAE,YAAY;AACpB,MAAI,QAAQ,WAAW,EACrB;AAGF,MAAI,CAAC,UAAU;GACb,MAAM,QAAQ,QAAQ;AACtB,YAAS,yBAAyB,MAAM,QAAQ,CAAC;;AAGnD,iBAAe,MAAM;;CAGvB,MAAM,kBAAkB,UAA4C;AAClE,QAAM,gBAAgB;AAEtB,eAAa,MAAM;;CAGrB,MAAM,uBAAuB,aAAa,WAAW,GAAG;CAExD,MAAM,qBAAqB,UAAwD;AACjF,MAAI,CAAC,SACH,KAAI,OAAO,UAAU,SACnB,YAAW,MAAM;MAEjB,YAAW,WAAW,MAAM,OAAO,MAAM,CAAC;;CAKhD,MAAM,gBAAgB,UAAwD;AAC5E,MAAI,CAAC,UAAU;GACb,MAAM,WAAW,OAAO,UAAU,WAAW,QAAQ,WAAW,MAAM,OAAO,MAAM;AAGnF,OAAI,cAAc,aAAa,mBAC7B,UAAS,EAAE;OAEX,UAAS,SAAS;;;CAKxB,MAAM,QAAQ,MAAM,OAAO,CACxB,KAAK,EAAE,CACP,KAAK,GAAG,UAAU;EACjB,MAAM,eAAe,QAAQ;EAC7B,MAAM,gBAAgB,MAAM,KAAK,IAAI,MAAM,UAAU,IAAI,aAAa,IAAI,WAAW,CAAC;AAGtF,SACE,oBAAC,OAAD;GAEE,eALkB,CAAC,YAAY,KAAK,KAAK,QAAQ,KAAK,gBAKxB,KAAA;GAC9B,GAAI,UAAU,cAAc;aAE3B,cAAc,KAAK,IAAI,kBAAkB;IACxC,MAAM,gBAAgB,eAAe,UAAU,IAAI,gBAAgB,gBAAgB;IACnF,MAAM,cAAc,aAAa,eAAe,IAAI,eAAe,YAAY;AAE/E,WACE,oBAAC,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,oBAAC,gBAAD;EAAgB,OAAO,EAAE,WAAW;YAClC,oBAAC,KAAD;GACE,KAAK,aAAa,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;AACjB,OAAO,eAAe;AACtB,OAAO,cAAc"}
|
|
@@ -64,6 +64,8 @@ const SemiCircleProgress = factory((_props) => {
|
|
|
64
64
|
"data-orientation": orientation,
|
|
65
65
|
children: label
|
|
66
66
|
}), /* @__PURE__ */ jsxs("svg", {
|
|
67
|
+
width: size,
|
|
68
|
+
height: size / 2,
|
|
67
69
|
viewBox: `0 0 ${size} ${size / 2}`,
|
|
68
70
|
...getStyles("svg"),
|
|
69
71
|
children: [/* @__PURE__ */ jsx("circle", {
|