@yamada-ui/react 2.3.0-dev-20261027031124 → 2.3.0-dev-20261027072316
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/dist/cjs/components/marquee/marquee.cjs +3 -3
- package/dist/cjs/components/marquee/marquee.cjs.map +1 -1
- package/dist/cjs/components/marquee/marquee.style.cjs +36 -36
- package/dist/cjs/components/marquee/marquee.style.cjs.map +1 -1
- package/dist/cjs/components/marquee/use-marquee.cjs +6 -6
- package/dist/cjs/components/marquee/use-marquee.cjs.map +1 -1
- package/dist/esm/components/marquee/marquee.js +3 -3
- package/dist/esm/components/marquee/marquee.js.map +1 -1
- package/dist/esm/components/marquee/marquee.style.js +36 -36
- package/dist/esm/components/marquee/marquee.style.js.map +1 -1
- package/dist/esm/components/marquee/use-marquee.js +6 -6
- package/dist/esm/components/marquee/use-marquee.js.map +1 -1
- package/dist/types/components/chart/polar-chart.style.d.ts +1 -1
- package/package.json +2 -2
|
@@ -43,9 +43,9 @@ const MarqueeRoot = withProvider(({ children, contentProps, ...rest }) => {
|
|
|
43
43
|
});
|
|
44
44
|
}, "root")(void 0, ({ edgeColor, edgeSize, gap, ...rest }) => ({
|
|
45
45
|
...rest,
|
|
46
|
-
"--
|
|
47
|
-
"--
|
|
48
|
-
"--
|
|
46
|
+
"--edge-color": require_var.varAttr(edgeColor, "colors"),
|
|
47
|
+
"--edge-size": require_var.varAttr(edgeSize, "sizes"),
|
|
48
|
+
"--gap": require_var.varAttr(gap, "spaces")
|
|
49
49
|
}));
|
|
50
50
|
const MarqueeContent = withContext(({ children, ...rest }) => {
|
|
51
51
|
const { copies, getContentProps, getGroupProps } = require_use_marquee.useMarqueeContext();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marquee.cjs","names":["createSlotComponent","marqueeStyle","useValidChildren","useFindChild","usePickChildren","useOmitChildren","useMarquee","useMemo","MarqueeContext","styled","varAttr","useMarqueeContext"],"sources":["../../../../src/components/marquee/marquee.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n CSSProps,\n HTMLStyledProps,\n SimpleDirection,\n ThemeProps,\n} from \"../../core\"\nimport type { Merge } from \"../../utils\"\nimport type { MarqueeStyle } from \"./marquee.style\"\nimport type { UseMarqueeProps } from \"./use-marquee\"\nimport { useMemo } from \"react\"\nimport { createSlotComponent, styled, varAttr } from \"../../core\"\nimport {\n useFindChild,\n useOmitChildren,\n usePickChildren,\n useValidChildren,\n} from \"../../utils\"\nimport { marqueeStyle } from \"./marquee.style\"\nimport { MarqueeContext, useMarquee, useMarqueeContext } from \"./use-marquee\"\n\nexport interface MarqueeRootProps\n extends Merge<HTMLStyledProps, UseMarqueeProps>, ThemeProps<MarqueeStyle> {\n /**\n * The color of the edge gradient.\n *\n * @default 'bg'\n */\n edgeColor?: CSSProps[\"color\"]\n /**\n * The size of the edge gradient.\n *\n * @default '20%'\n */\n edgeSize?: CSSProps[\"width\"]\n /**\n * Props for content component.\n */\n contentProps?: MarqueeContentProps\n}\n\nconst {\n PropsContext: MarqueePropsContext,\n usePropsContext: useMarqueePropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<MarqueeRootProps, MarqueeStyle>(\"marquee\", marqueeStyle)\n\nexport { MarqueePropsContext, useMarqueePropsContext }\n\n/**\n * `Marquee` continuously scrolls content horizontally or vertically.\n *\n * @see https://yamada-ui.com/docs/components/marquee\n */\nexport const MarqueeRoot = withProvider<\"div\", MarqueeRootProps>(\n ({ children, contentProps, ...rest }) => {\n const validChildren = useValidChildren(children)\n const customContent = useFindChild(validChildren, MarqueeContent)\n const items = usePickChildren(validChildren, MarqueeItem)\n const otherChildren = useOmitChildren(validChildren, MarqueeItem)\n const {\n copies,\n getContentProps,\n getEdgeProps,\n getGroupProps,\n getRootProps,\n } = useMarquee(rest)\n const context = useMemo(\n () => ({ copies, getContentProps, getEdgeProps, getGroupProps }),\n [copies, getContentProps, getEdgeProps, getGroupProps],\n )\n\n return (\n <MarqueeContext value={context}>\n <styled.div {...getRootProps()}>\n {customContent ? (\n children\n ) : (\n <>\n <MarqueeContent {...contentProps}>{items}</MarqueeContent>\n {otherChildren}\n </>\n )}\n </styled.div>\n </MarqueeContext>\n )\n },\n \"root\",\n)(undefined, ({ edgeColor, edgeSize, gap, ...rest }) => ({\n ...rest,\n \"--
|
|
1
|
+
{"version":3,"file":"marquee.cjs","names":["createSlotComponent","marqueeStyle","useValidChildren","useFindChild","usePickChildren","useOmitChildren","useMarquee","useMemo","MarqueeContext","styled","varAttr","useMarqueeContext"],"sources":["../../../../src/components/marquee/marquee.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n CSSProps,\n HTMLStyledProps,\n SimpleDirection,\n ThemeProps,\n} from \"../../core\"\nimport type { Merge } from \"../../utils\"\nimport type { MarqueeStyle } from \"./marquee.style\"\nimport type { UseMarqueeProps } from \"./use-marquee\"\nimport { useMemo } from \"react\"\nimport { createSlotComponent, styled, varAttr } from \"../../core\"\nimport {\n useFindChild,\n useOmitChildren,\n usePickChildren,\n useValidChildren,\n} from \"../../utils\"\nimport { marqueeStyle } from \"./marquee.style\"\nimport { MarqueeContext, useMarquee, useMarqueeContext } from \"./use-marquee\"\n\nexport interface MarqueeRootProps\n extends Merge<HTMLStyledProps, UseMarqueeProps>, ThemeProps<MarqueeStyle> {\n /**\n * The color of the edge gradient.\n *\n * @default 'bg'\n */\n edgeColor?: CSSProps[\"color\"]\n /**\n * The size of the edge gradient.\n *\n * @default '20%'\n */\n edgeSize?: CSSProps[\"width\"]\n /**\n * Props for content component.\n */\n contentProps?: MarqueeContentProps\n}\n\nconst {\n PropsContext: MarqueePropsContext,\n usePropsContext: useMarqueePropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<MarqueeRootProps, MarqueeStyle>(\"marquee\", marqueeStyle)\n\nexport { MarqueePropsContext, useMarqueePropsContext }\n\n/**\n * `Marquee` continuously scrolls content horizontally or vertically.\n *\n * @see https://yamada-ui.com/docs/components/marquee\n */\nexport const MarqueeRoot = withProvider<\"div\", MarqueeRootProps>(\n ({ children, contentProps, ...rest }) => {\n const validChildren = useValidChildren(children)\n const customContent = useFindChild(validChildren, MarqueeContent)\n const items = usePickChildren(validChildren, MarqueeItem)\n const otherChildren = useOmitChildren(validChildren, MarqueeItem)\n const {\n copies,\n getContentProps,\n getEdgeProps,\n getGroupProps,\n getRootProps,\n } = useMarquee(rest)\n const context = useMemo(\n () => ({ copies, getContentProps, getEdgeProps, getGroupProps }),\n [copies, getContentProps, getEdgeProps, getGroupProps],\n )\n\n return (\n <MarqueeContext value={context}>\n <styled.div {...getRootProps()}>\n {customContent ? (\n children\n ) : (\n <>\n <MarqueeContent {...contentProps}>{items}</MarqueeContent>\n {otherChildren}\n </>\n )}\n </styled.div>\n </MarqueeContext>\n )\n },\n \"root\",\n)(undefined, ({ edgeColor, edgeSize, gap, ...rest }) => ({\n ...rest,\n \"--edge-color\": varAttr(edgeColor, \"colors\"),\n \"--edge-size\": varAttr(edgeSize, \"sizes\"),\n \"--gap\": varAttr(gap, \"spaces\"),\n}))\n\nexport interface MarqueeContentProps extends HTMLStyledProps {}\n\nexport const MarqueeContent = withContext<\"div\", MarqueeContentProps>(\n ({ children, ...rest }) => {\n const { copies, getContentProps, getGroupProps } = useMarqueeContext()\n\n return (\n <styled.div {...getContentProps(rest)}>\n {Array.from({ length: copies + 1 }, (_, index) => (\n <MarqueeGroup key={index} {...getGroupProps({ index })}>\n {children}\n </MarqueeGroup>\n ))}\n </styled.div>\n )\n },\n \"content\",\n)()\n\nconst MarqueeGroup = withContext(\"div\", \"group\")()\n\nexport interface MarqueeItemProps extends HTMLStyledProps {}\n\nexport const MarqueeItem = withContext<\"div\", MarqueeItemProps>(\"div\", \"item\")()\n\nexport interface MarqueeEdgeProps extends Omit<HTMLStyledProps, \"direction\"> {\n /**\n * The edge to fade, relative to the marquee orientation.\n *\n * @default 'start'\n */\n direction?: SimpleDirection\n}\n\nexport const MarqueeEdge = withContext<\"div\", MarqueeEdgeProps>(\"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E;AAIF,MAAa,iBAAiB,aAC3B,EAAE,UAAU,GAAG,WAAW;CACzB,MAAM,EAAE,QAAQ,iBAAiB,kBAAkBC,oBAAAA,kBAAkB;CAErE,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACF,gBAAAA,OAAO,KAAR;EAAY,GAAI,gBAAgB,IAAI;EACjC,UAAA,MAAM,KAAK,EAAE,QAAQ,SAAS,EAAE,IAAI,GAAG,UACtC,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAD;GAA0B,GAAI,cAAc,EAAE,MAAM,CAAC;GAClD;EACW,GAFK,KAEL,CACf;CACS,CAAA;AAEhB,GACA,SACF,CAAC,CAAC;AAEF,MAAM,eAAe,YAAY,OAAO,OAAO,CAAC,CAAC;AAIjD,MAAa,cAAc,YAAqC,OAAO,MAAM,CAAC,CAAC;AAW/E,MAAa,cAAc,YAAqC,OAAO,MAAM,CAAC,CAC5E,KAAA,IACC,UAAU;CACT,MAAM,EAAE,iBAAiBE,oBAAAA,kBAAkB;CAE3C,OAAO,aAAa,KAAK;AAC3B,CACF"}
|
|
@@ -3,19 +3,19 @@ const marqueeStyle = require("../../core/system/config.cjs").defineComponentSlot
|
|
|
3
3
|
content: {
|
|
4
4
|
"&:not([data-ready])": { animationName: "none" },
|
|
5
5
|
alignItems: "center",
|
|
6
|
-
animationDelay: "{
|
|
7
|
-
animationDirection: "{
|
|
8
|
-
animationDuration: "{
|
|
6
|
+
animationDelay: "{delay}",
|
|
7
|
+
animationDirection: "{direction}",
|
|
8
|
+
animationDuration: "{duration}",
|
|
9
9
|
animationFillMode: "both",
|
|
10
|
-
animationIterationCount: "{
|
|
11
|
-
animationPlayState: "{
|
|
10
|
+
animationIterationCount: "{loop-count}",
|
|
11
|
+
animationPlayState: "{play-state}",
|
|
12
12
|
animationTimingFunction: "linear",
|
|
13
13
|
display: "flex",
|
|
14
14
|
flex: "0 0 auto",
|
|
15
15
|
minW: "0",
|
|
16
16
|
position: "relative",
|
|
17
17
|
_horizontal: { w: "max-content" },
|
|
18
|
-
_keyframes: { to: { transform: "translate({
|
|
18
|
+
_keyframes: { to: { transform: "translate({translate-x}, {translate-y})" } },
|
|
19
19
|
_mediaReduceMotion: { animationName: "none" },
|
|
20
20
|
_vertical: {
|
|
21
21
|
flexDirection: "column",
|
|
@@ -29,89 +29,89 @@ const marqueeStyle = require("../../core/system/config.cjs").defineComponentSlot
|
|
|
29
29
|
_horizontal: {
|
|
30
30
|
bottom: "0",
|
|
31
31
|
top: "0",
|
|
32
|
-
w: "{
|
|
32
|
+
w: "{edge-size}",
|
|
33
33
|
_end: {
|
|
34
|
-
bgGradient: "linear(to-l, {
|
|
34
|
+
bgGradient: "linear(to-l, {edge-color}, transparent)",
|
|
35
35
|
insetInlineEnd: "0",
|
|
36
|
-
_rtl: { bgGradient: "linear(to-r, {
|
|
36
|
+
_rtl: { bgGradient: "linear(to-r, {edge-color}, transparent)" }
|
|
37
37
|
},
|
|
38
38
|
_start: {
|
|
39
|
-
bgGradient: "linear(to-r, {
|
|
39
|
+
bgGradient: "linear(to-r, {edge-color}, transparent)",
|
|
40
40
|
insetInlineStart: "0",
|
|
41
|
-
_rtl: { bgGradient: "linear(to-l, {
|
|
41
|
+
_rtl: { bgGradient: "linear(to-l, {edge-color}, transparent)" }
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
_vertical: {
|
|
45
|
-
h: "{
|
|
45
|
+
h: "{edge-size}",
|
|
46
46
|
insetInline: "0",
|
|
47
47
|
_end: {
|
|
48
|
-
bgGradient: "linear(to-t, {
|
|
48
|
+
bgGradient: "linear(to-t, {edge-color}, transparent)",
|
|
49
49
|
bottom: "0"
|
|
50
50
|
},
|
|
51
51
|
_start: {
|
|
52
|
-
bgGradient: "linear(to-b, {
|
|
52
|
+
bgGradient: "linear(to-b, {edge-color}, transparent)",
|
|
53
53
|
top: "0"
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
group: {
|
|
58
58
|
"&[data-clone]": {
|
|
59
|
-
display: "{
|
|
59
|
+
display: "{clone-display, flex}",
|
|
60
60
|
position: "absolute",
|
|
61
61
|
_horizontal: {
|
|
62
|
-
transform: "translateX(calc({
|
|
62
|
+
transform: "translateX(calc({copy-offset-x} * {index}))",
|
|
63
63
|
w: "max-content"
|
|
64
64
|
},
|
|
65
65
|
_vertical: {
|
|
66
|
-
transform: "translateY(calc({
|
|
66
|
+
transform: "translateY(calc({distance} * {index}))",
|
|
67
67
|
w: "full"
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
alignItems: "center",
|
|
71
71
|
display: "flex",
|
|
72
72
|
flex: "0 0 auto",
|
|
73
|
-
gap: "{
|
|
74
|
-
_horizontal: { pe: "{
|
|
73
|
+
gap: "{gap}",
|
|
74
|
+
_horizontal: { pe: "{gap}" },
|
|
75
75
|
_mediaReduceMotion: { "&[data-clone]": { display: "none" } },
|
|
76
76
|
_vertical: {
|
|
77
77
|
flexDirection: "column",
|
|
78
|
-
pb: "{
|
|
78
|
+
pb: "{gap}"
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
81
|
item: { flexShrink: 0 },
|
|
82
82
|
root: {
|
|
83
83
|
"&[data-pause-on-focus]": { _nativeFocusWithin: {
|
|
84
84
|
"& > [data-marquee-content]": { transform: "none !important" },
|
|
85
|
-
"--
|
|
86
|
-
"--
|
|
85
|
+
"--clone-display": "none",
|
|
86
|
+
"--play-state": "paused",
|
|
87
87
|
overflow: "auto"
|
|
88
88
|
} },
|
|
89
|
-
"&[data-pause-on-hover]": { _hover: { "--
|
|
90
|
-
"--
|
|
91
|
-
"--
|
|
92
|
-
"--
|
|
93
|
-
"--
|
|
94
|
-
"--
|
|
95
|
-
"--
|
|
96
|
-
"--
|
|
89
|
+
"&[data-pause-on-hover]": { _hover: { "--play-state": "paused" } },
|
|
90
|
+
"--copy-offset-x": "{distance}",
|
|
91
|
+
"--edge-color": "colors.bg",
|
|
92
|
+
"--edge-size": "20%",
|
|
93
|
+
"--gap": "spaces.4",
|
|
94
|
+
"--play-state": "running",
|
|
95
|
+
"--translate-x": "calc({distance} * -1)",
|
|
96
|
+
"--translate-y": "0px",
|
|
97
97
|
overflow: "hidden",
|
|
98
98
|
position: "relative",
|
|
99
99
|
rounded: "l2",
|
|
100
100
|
w: "full",
|
|
101
101
|
_complete: {
|
|
102
102
|
"& > [data-marquee-content]": { transform: "none !important" },
|
|
103
|
-
"--
|
|
103
|
+
"--clone-display": "none",
|
|
104
104
|
overflow: "auto"
|
|
105
105
|
},
|
|
106
106
|
_horizontal: { "&[dir=rtl]": {
|
|
107
|
-
"--
|
|
108
|
-
"--
|
|
107
|
+
"--copy-offset-x": "calc({distance} * -1)",
|
|
108
|
+
"--translate-x": "{distance}"
|
|
109
109
|
} },
|
|
110
110
|
_mediaReduceMotion: { overflow: "auto" },
|
|
111
|
-
_paused: { "--
|
|
111
|
+
_paused: { "--play-state": "paused" },
|
|
112
112
|
_vertical: {
|
|
113
|
-
"--
|
|
114
|
-
"--
|
|
113
|
+
"--translate-x": "0px",
|
|
114
|
+
"--translate-y": "calc({distance} * -1)"
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
} });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marquee.style.cjs","names":["defineComponentSlotStyle"],"sources":["../../../../src/components/marquee/marquee.style.ts"],"sourcesContent":["import { defineComponentSlotStyle } from \"../../core\"\n\nexport const marqueeStyle = defineComponentSlotStyle({\n base: {\n content: {\n \"&:not([data-ready])\": { animationName: \"none\" },\n alignItems: \"center\",\n animationDelay: \"{
|
|
1
|
+
{"version":3,"file":"marquee.style.cjs","names":["defineComponentSlotStyle"],"sources":["../../../../src/components/marquee/marquee.style.ts"],"sourcesContent":["import { defineComponentSlotStyle } from \"../../core\"\n\nexport const marqueeStyle = defineComponentSlotStyle({\n base: {\n content: {\n \"&:not([data-ready])\": { animationName: \"none\" },\n alignItems: \"center\",\n animationDelay: \"{delay}\",\n animationDirection: \"{direction}\",\n animationDuration: \"{duration}\",\n animationFillMode: \"both\",\n animationIterationCount: \"{loop-count}\",\n animationPlayState: \"{play-state}\",\n animationTimingFunction: \"linear\",\n display: \"flex\",\n flex: \"0 0 auto\",\n minW: \"0\",\n position: \"relative\",\n _horizontal: { w: \"max-content\" },\n _keyframes: {\n to: {\n transform: \"translate({translate-x}, {translate-y})\",\n },\n },\n _mediaReduceMotion: { animationName: \"none\" },\n _vertical: { flexDirection: \"column\", h: \"max-content\" },\n },\n edge: {\n pointerEvents: \"none\",\n position: \"absolute\",\n zIndex: \"1\",\n _horizontal: {\n bottom: \"0\",\n top: \"0\",\n w: \"{edge-size}\",\n _end: {\n bgGradient: \"linear(to-l, {edge-color}, transparent)\",\n insetInlineEnd: \"0\",\n _rtl: {\n bgGradient: \"linear(to-r, {edge-color}, transparent)\",\n },\n },\n _start: {\n bgGradient: \"linear(to-r, {edge-color}, transparent)\",\n insetInlineStart: \"0\",\n _rtl: {\n bgGradient: \"linear(to-l, {edge-color}, transparent)\",\n },\n },\n },\n _vertical: {\n h: \"{edge-size}\",\n insetInline: \"0\",\n _end: {\n bgGradient: \"linear(to-t, {edge-color}, transparent)\",\n bottom: \"0\",\n },\n _start: {\n bgGradient: \"linear(to-b, {edge-color}, transparent)\",\n top: \"0\",\n },\n },\n },\n group: {\n \"&[data-clone]\": {\n display: \"{clone-display, flex}\",\n position: \"absolute\",\n _horizontal: {\n transform: \"translateX(calc({copy-offset-x} * {index}))\",\n w: \"max-content\",\n },\n _vertical: {\n transform: \"translateY(calc({distance} * {index}))\",\n w: \"full\",\n },\n },\n alignItems: \"center\",\n display: \"flex\",\n flex: \"0 0 auto\",\n gap: \"{gap}\",\n _horizontal: { pe: \"{gap}\" },\n _mediaReduceMotion: { \"&[data-clone]\": { display: \"none\" } },\n _vertical: { flexDirection: \"column\", pb: \"{gap}\" },\n },\n item: { flexShrink: 0 },\n root: {\n \"&[data-pause-on-focus]\": {\n _nativeFocusWithin: {\n \"& > [data-marquee-content]\": { transform: \"none !important\" },\n \"--clone-display\": \"none\",\n \"--play-state\": \"paused\",\n overflow: \"auto\",\n },\n },\n \"&[data-pause-on-hover]\": {\n _hover: { \"--play-state\": \"paused\" },\n },\n \"--copy-offset-x\": \"{distance}\",\n \"--edge-color\": \"colors.bg\",\n \"--edge-size\": \"20%\",\n \"--gap\": \"spaces.4\",\n \"--play-state\": \"running\",\n \"--translate-x\": \"calc({distance} * -1)\",\n \"--translate-y\": \"0px\",\n overflow: \"hidden\",\n position: \"relative\",\n rounded: \"l2\",\n w: \"full\",\n _complete: {\n \"& > [data-marquee-content]\": { transform: \"none !important\" },\n \"--clone-display\": \"none\",\n overflow: \"auto\",\n },\n _horizontal: {\n \"&[dir=rtl]\": {\n \"--copy-offset-x\": \"calc({distance} * -1)\",\n \"--translate-x\": \"{distance}\",\n },\n },\n _mediaReduceMotion: { overflow: \"auto\" },\n _paused: { \"--play-state\": \"paused\" },\n _vertical: {\n \"--translate-x\": \"0px\",\n \"--translate-y\": \"calc({distance} * -1)\",\n },\n },\n },\n})\n\nexport type MarqueeStyle = typeof marqueeStyle\n"],"mappings":";AAEA,MAAa,qDAAeA,CAAAA,CAAAA,yBAAyB,EACnD,MAAM;CACJ,SAAS;EACP,uBAAuB,EAAE,eAAe,OAAO;EAC/C,YAAY;EACZ,gBAAgB;EAChB,oBAAoB;EACpB,mBAAmB;EACnB,mBAAmB;EACnB,yBAAyB;EACzB,oBAAoB;EACpB,yBAAyB;EACzB,SAAS;EACT,MAAM;EACN,MAAM;EACN,UAAU;EACV,aAAa,EAAE,GAAG,cAAc;EAChC,YAAY,EACV,IAAI,EACF,WAAW,0CACb,EACF;EACA,oBAAoB,EAAE,eAAe,OAAO;EAC5C,WAAW;GAAE,eAAe;GAAU,GAAG;EAAc;CACzD;CACA,MAAM;EACJ,eAAe;EACf,UAAU;EACV,QAAQ;EACR,aAAa;GACX,QAAQ;GACR,KAAK;GACL,GAAG;GACH,MAAM;IACJ,YAAY;IACZ,gBAAgB;IAChB,MAAM,EACJ,YAAY,0CACd;GACF;GACA,QAAQ;IACN,YAAY;IACZ,kBAAkB;IAClB,MAAM,EACJ,YAAY,0CACd;GACF;EACF;EACA,WAAW;GACT,GAAG;GACH,aAAa;GACb,MAAM;IACJ,YAAY;IACZ,QAAQ;GACV;GACA,QAAQ;IACN,YAAY;IACZ,KAAK;GACP;EACF;CACF;CACA,OAAO;EACL,iBAAiB;GACf,SAAS;GACT,UAAU;GACV,aAAa;IACX,WAAW;IACX,GAAG;GACL;GACA,WAAW;IACT,WAAW;IACX,GAAG;GACL;EACF;EACA,YAAY;EACZ,SAAS;EACT,MAAM;EACN,KAAK;EACL,aAAa,EAAE,IAAI,QAAQ;EAC3B,oBAAoB,EAAE,iBAAiB,EAAE,SAAS,OAAO,EAAE;EAC3D,WAAW;GAAE,eAAe;GAAU,IAAI;EAAQ;CACpD;CACA,MAAM,EAAE,YAAY,EAAE;CACtB,MAAM;EACJ,0BAA0B,EACxB,oBAAoB;GAClB,8BAA8B,EAAE,WAAW,kBAAkB;GAC7D,mBAAmB;GACnB,gBAAgB;GAChB,UAAU;EACZ,EACF;EACA,0BAA0B,EACxB,QAAQ,EAAE,gBAAgB,SAAS,EACrC;EACA,mBAAmB;EACnB,gBAAgB;EAChB,eAAe;EACf,SAAS;EACT,gBAAgB;EAChB,iBAAiB;EACjB,iBAAiB;EACjB,UAAU;EACV,UAAU;EACV,SAAS;EACT,GAAG;EACH,WAAW;GACT,8BAA8B,EAAE,WAAW,kBAAkB;GAC7D,mBAAmB;GACnB,UAAU;EACZ;EACA,aAAa,EACX,cAAc;GACZ,mBAAmB;GACnB,iBAAiB;EACnB,EACF;EACA,oBAAoB,EAAE,UAAU,OAAO;EACvC,SAAS,EAAE,gBAAgB,SAAS;EACpC,WAAW;GACT,iBAAiB;GACjB,iBAAiB;EACnB;CACF;AACF,EACF,CAAC"}
|
|
@@ -80,11 +80,11 @@ function useMarquee({ controlRef, defaultPaused = false, delay = 0, dir: dirProp
|
|
|
80
80
|
}, [vertical]);
|
|
81
81
|
const getRootProps = (0, react.useCallback)((props = {}) => require_props.mergeProps({
|
|
82
82
|
style: {
|
|
83
|
-
"--
|
|
84
|
-
"--
|
|
85
|
-
"--
|
|
86
|
-
"--
|
|
87
|
-
"--
|
|
83
|
+
"--delay": `${Number.isFinite(delay) ? delay : 0}s`,
|
|
84
|
+
"--direction": animationDirection,
|
|
85
|
+
"--distance": `${size.content}px`,
|
|
86
|
+
"--duration": `${ready ? duration : 0}s`,
|
|
87
|
+
"--loop-count": iterations || "infinite"
|
|
88
88
|
},
|
|
89
89
|
"aria-keyshortcuts": "Space",
|
|
90
90
|
"aria-live": "off",
|
|
@@ -164,7 +164,7 @@ function useMarquee({ controlRef, defaultPaused = false, delay = 0, dir: dirProp
|
|
|
164
164
|
dir,
|
|
165
165
|
inert: true
|
|
166
166
|
})(), [dir, orientation]),
|
|
167
|
-
getGroupProps: (0, react.useCallback)(({ id, ref, index = 0, ...props } = {}) => require_props.mergeProps({ style: { "--
|
|
167
|
+
getGroupProps: (0, react.useCallback)(({ id, ref, index = 0, ...props } = {}) => require_props.mergeProps({ style: { "--index": index } }, props, {
|
|
168
168
|
id: index ? void 0 : id,
|
|
169
169
|
ref: index ? void 0 : require_ref.mergeRefs(ref, contentRef),
|
|
170
170
|
"aria-hidden": index ? true : void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-marquee.cjs","names":["createContext","useI18n","useRef","useState","useControllableState","useCallbackRef","useCallback","useMemo","mergeProps","mergeRefs"],"sources":["../../../../src/components/marquee/use-marquee.ts"],"sourcesContent":["\"use client\"\n\nimport type {\n AnimationEvent,\n FocusEvent,\n KeyboardEvent,\n RefObject,\n} from \"react\"\nimport type {\n HTMLProps,\n Orientation,\n PropGetter,\n SimpleDirection,\n} from \"../../core\"\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n assignRef,\n createContext,\n dataAttr,\n mergeRefs,\n useCallbackRef,\n} from \"../../utils\"\n\nexport interface MarqueeControl {\n /**\n * Whether the marquee is paused.\n */\n paused: boolean\n /**\n * Pauses the marquee.\n */\n pause: () => void\n /**\n * Restarts the animation, including its delay and loop count.\n */\n restart: () => void\n /**\n * Resumes the marquee.\n */\n resume: () => void\n /**\n * Toggles the pause state.\n */\n togglePause: () => void\n}\n\nexport interface UseMarqueeProps extends HTMLProps {\n /**\n * Ref of the marquee controls.\n */\n controlRef?: RefObject<MarqueeControl | null>\n /**\n * Whether the marquee is initially paused.\n *\n * @default false\n */\n defaultPaused?: boolean\n /**\n * The delay before the animation starts, in seconds.\n *\n * @default 0\n */\n delay?: number\n /**\n * The direction the content scrolls towards.\n *\n * @default 'start'\n */\n direction?: SimpleDirection\n /**\n * The duration of one loop in seconds. Overrides `speed`.\n */\n duration?: number\n /**\n * The number of animation loops. Set to `0` for infinite loops.\n *\n * @default 0\n */\n loopCount?: number\n /**\n * The orientation of the marquee.\n *\n * @default 'horizontal'\n */\n orientation?: Orientation\n /**\n * If `true`, the animation is paused.\n *\n * @default false\n */\n paused?: boolean\n /**\n * If `true`, the animation pauses while an item is focused.\n *\n * @default false\n */\n pauseOnFocus?: boolean\n /**\n * If `true`, the animation pauses on hover.\n *\n * @default false\n */\n pauseOnHover?: boolean\n /**\n * If `true`, the scrolling direction is reversed.\n *\n * @default false\n */\n reverse?: boolean\n /**\n * The scrolling speed in pixels per second.\n *\n * @default 50\n */\n speed?: number\n /**\n * The callback invoked when all finite loops finish.\n */\n onComplete?: () => void\n /**\n * The callback invoked after each animation iteration, except the final one.\n */\n onLoopComplete?: () => void\n /**\n * The callback invoked when the persistent pause state changes.\n */\n onPauseChange?: (paused: boolean) => void\n}\n\ninterface MarqueeContext extends Pick<\n UseMarqueeReturn,\n \"copies\" | \"getContentProps\" | \"getEdgeProps\" | \"getGroupProps\"\n> {}\n\nconst [MarqueeContext, useMarqueeContext] = createContext<MarqueeContext>({\n name: \"MarqueeContext\",\n})\n\nexport { MarqueeContext, useMarqueeContext }\n\nexport function useMarquee({\n controlRef,\n defaultPaused = false,\n delay = 0,\n dir: dirProp,\n direction = \"start\",\n duration: durationProp,\n loopCount = 0,\n orientation = \"horizontal\",\n paused: pausedProp,\n pauseOnFocus = false,\n pauseOnHover = false,\n reverse = false,\n speed = 50,\n onComplete: onCompleteProp,\n onLoopComplete: onLoopCompleteProp,\n onPauseChange,\n ...rest\n}: UseMarqueeProps = {}) {\n const { dir: defaultDir } = useI18n()\n const dir = dirProp ?? defaultDir\n const vertical = orientation === \"vertical\"\n const rootRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const trackRef = useRef<HTMLDivElement>(null)\n const [hovered, setHovered] = useState(false)\n const [focused, setFocused] = useState(false)\n const [completed, setCompleted] = useState(false)\n const [paused, setPaused] = useControllableState({\n defaultValue: defaultPaused,\n value: pausedProp,\n onChange: onPauseChange,\n })\n const onComplete = useCallbackRef(onCompleteProp)\n const onLoopComplete = useCallbackRef(onLoopCompleteProp)\n const [size, setSize] = useState({ content: 0, root: 0 })\n const duration = durationProp ?? (speed > 0 ? size.content / speed : 0)\n const ready = size.content > 0 && Number.isFinite(duration) && duration > 0\n const copies = Math.max(\n 1,\n size.content > 0 ? Math.ceil(size.root / size.content) : 1,\n )\n const iterations = Number.isFinite(loopCount) && loopCount > 0 ? loopCount : 0\n const animationDirection =\n (direction === \"end\") !== reverse ? \"reverse\" : \"normal\"\n const interactionPaused =\n (pauseOnHover && hovered) || (pauseOnFocus && focused)\n const animationPaused = paused || interactionPaused || completed || !ready\n\n const pause = useCallback(() => setPaused(true), [setPaused])\n const resume = useCallback(() => setPaused(false), [setPaused])\n const togglePause = useCallback(() => setPaused((prev) => !prev), [setPaused])\n const restart = useCallback(() => {\n trackRef.current?.getAnimations().forEach((animation) => {\n animation.currentTime = 0\n })\n setCompleted(false)\n }, [])\n const control = useMemo<MarqueeControl>(\n () => ({ pause, paused: animationPaused, restart, resume, togglePause }),\n [animationPaused, pause, restart, resume, togglePause],\n )\n\n assignRef(controlRef, control)\n\n useEffect(() => {\n const root = rootRef.current\n const content = contentRef.current\n\n if (!root || !content) return\n\n const observer = new ResizeObserver((entries) => {\n entries.forEach(({ target, borderBoxSize }) => {\n const box = borderBoxSize[0]\n\n if (!box) return\n\n const key = target === root ? \"root\" : \"content\"\n const value = vertical ? box.blockSize : box.inlineSize\n\n setSize((prev) =>\n prev[key] === value ? prev : { ...prev, [key]: value },\n )\n })\n })\n\n observer.observe(root, { box: \"border-box\" })\n observer.observe(content, { box: \"border-box\" })\n\n return () => observer.disconnect()\n }, [vertical])\n\n const getRootProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps(\n {\n style: {\n \"--marquee-delay\": `${Number.isFinite(delay) ? delay : 0}s`,\n \"--marquee-direction\": animationDirection,\n \"--marquee-distance\": `${size.content}px`,\n \"--marquee-duration\": `${ready ? duration : 0}s`,\n \"--marquee-loop-count\": iterations || \"infinite\",\n },\n \"aria-keyshortcuts\": \"Space\",\n \"aria-live\": \"off\",\n \"aria-roledescription\": \"marquee\",\n role: \"region\",\n tabIndex: 0,\n },\n rest,\n props,\n {\n ref: rootRef,\n \"data-complete\": dataAttr(completed),\n \"data-end\": dataAttr(direction === \"end\"),\n \"data-orientation\": orientation,\n \"data-pause-on-focus\": dataAttr(pauseOnFocus),\n \"data-pause-on-hover\": dataAttr(pauseOnHover),\n \"data-paused\": dataAttr(animationPaused),\n \"data-start\": dataAttr(direction === \"start\"),\n dir,\n onBlurCapture: (ev: FocusEvent<HTMLDivElement>) => {\n if (ev.currentTarget.contains(ev.relatedTarget)) return\n\n setFocused(false)\n\n if (!pauseOnFocus) return\n\n ev.currentTarget.scrollLeft = 0\n ev.currentTarget.scrollTop = 0\n },\n onFocusCapture: () => setFocused(true),\n onKeyDown: (ev: KeyboardEvent<HTMLDivElement>) => {\n if (\n ev.target !== ev.currentTarget ||\n ev.key !== \" \" ||\n ev.altKey ||\n ev.ctrlKey ||\n ev.metaKey ||\n ev.repeat\n )\n return\n\n ev.preventDefault()\n togglePause()\n },\n onMouseEnter: () => setHovered(true),\n onMouseLeave: () => setHovered(false),\n },\n )(),\n [\n rest,\n direction,\n orientation,\n pauseOnFocus,\n pauseOnHover,\n animationPaused,\n completed,\n ready,\n dir,\n duration,\n animationDirection,\n delay,\n iterations,\n size.content,\n togglePause,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps(props, {\n ref: trackRef,\n \"data-marquee-content\": \"\",\n \"data-orientation\": orientation,\n \"data-ready\": dataAttr(ready),\n onAnimationEnd: (ev: AnimationEvent<HTMLDivElement>) => {\n if (ev.target !== ev.currentTarget || !iterations) return\n\n setCompleted(true)\n onComplete()\n },\n onAnimationIteration: (ev: AnimationEvent<HTMLDivElement>) => {\n if (ev.target === ev.currentTarget) onLoopComplete()\n },\n })(),\n [orientation, ready, iterations, onComplete, onLoopComplete],\n )\n\n const getEdgeProps: PropGetter<\"div\", { direction?: SimpleDirection }> =\n useCallback(\n ({ direction = \"start\", ...props } = {}) =>\n mergeProps(props, {\n \"aria-hidden\": true,\n \"data-end\": dataAttr(direction === \"end\"),\n \"data-orientation\": orientation,\n \"data-start\": dataAttr(direction === \"start\"),\n dir,\n inert: true,\n })(),\n [dir, orientation],\n )\n\n const getGroupProps: PropGetter<\"div\", { index?: number }> = useCallback(\n ({ id, ref, index = 0, ...props } = {}) =>\n mergeProps({ style: { \"--marquee-index\": index } }, props, {\n id: index ? undefined : id,\n ref: index ? undefined : mergeRefs(ref, contentRef),\n \"aria-hidden\": index ? true : undefined,\n \"data-clone\": dataAttr(!!index),\n \"data-orientation\": orientation,\n inert: index ? true : undefined,\n })(),\n [orientation],\n )\n\n return {\n control,\n copies,\n getContentProps,\n getEdgeProps,\n getGroupProps,\n getRootProps,\n }\n}\n\nexport type UseMarqueeReturn = ReturnType<typeof useMarquee>\n"],"m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AS,CAAC,CAAC,KAAK;GAC9B,oBAAoB;GACpB,OAAO,QAAQ,OAAO,KAAA;EACxB,CAAC,CAAC,CAAC,GACL,CAAC,WAAW,CAQA;EACZ;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"use-marquee.cjs","names":["createContext","useI18n","useRef","useState","useControllableState","useCallbackRef","useCallback","useMemo","mergeProps","mergeRefs"],"sources":["../../../../src/components/marquee/use-marquee.ts"],"sourcesContent":["\"use client\"\n\nimport type {\n AnimationEvent,\n FocusEvent,\n KeyboardEvent,\n RefObject,\n} from \"react\"\nimport type {\n HTMLProps,\n Orientation,\n PropGetter,\n SimpleDirection,\n} from \"../../core\"\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n assignRef,\n createContext,\n dataAttr,\n mergeRefs,\n useCallbackRef,\n} from \"../../utils\"\n\nexport interface MarqueeControl {\n /**\n * Whether the marquee is paused.\n */\n paused: boolean\n /**\n * Pauses the marquee.\n */\n pause: () => void\n /**\n * Restarts the animation, including its delay and loop count.\n */\n restart: () => void\n /**\n * Resumes the marquee.\n */\n resume: () => void\n /**\n * Toggles the pause state.\n */\n togglePause: () => void\n}\n\nexport interface UseMarqueeProps extends HTMLProps {\n /**\n * Ref of the marquee controls.\n */\n controlRef?: RefObject<MarqueeControl | null>\n /**\n * Whether the marquee is initially paused.\n *\n * @default false\n */\n defaultPaused?: boolean\n /**\n * The delay before the animation starts, in seconds.\n *\n * @default 0\n */\n delay?: number\n /**\n * The direction the content scrolls towards.\n *\n * @default 'start'\n */\n direction?: SimpleDirection\n /**\n * The duration of one loop in seconds. Overrides `speed`.\n */\n duration?: number\n /**\n * The number of animation loops. Set to `0` for infinite loops.\n *\n * @default 0\n */\n loopCount?: number\n /**\n * The orientation of the marquee.\n *\n * @default 'horizontal'\n */\n orientation?: Orientation\n /**\n * If `true`, the animation is paused.\n *\n * @default false\n */\n paused?: boolean\n /**\n * If `true`, the animation pauses while an item is focused.\n *\n * @default false\n */\n pauseOnFocus?: boolean\n /**\n * If `true`, the animation pauses on hover.\n *\n * @default false\n */\n pauseOnHover?: boolean\n /**\n * If `true`, the scrolling direction is reversed.\n *\n * @default false\n */\n reverse?: boolean\n /**\n * The scrolling speed in pixels per second.\n *\n * @default 50\n */\n speed?: number\n /**\n * The callback invoked when all finite loops finish.\n */\n onComplete?: () => void\n /**\n * The callback invoked after each animation iteration, except the final one.\n */\n onLoopComplete?: () => void\n /**\n * The callback invoked when the persistent pause state changes.\n */\n onPauseChange?: (paused: boolean) => void\n}\n\ninterface MarqueeContext extends Pick<\n UseMarqueeReturn,\n \"copies\" | \"getContentProps\" | \"getEdgeProps\" | \"getGroupProps\"\n> {}\n\nconst [MarqueeContext, useMarqueeContext] = createContext<MarqueeContext>({\n name: \"MarqueeContext\",\n})\n\nexport { MarqueeContext, useMarqueeContext }\n\nexport function useMarquee({\n controlRef,\n defaultPaused = false,\n delay = 0,\n dir: dirProp,\n direction = \"start\",\n duration: durationProp,\n loopCount = 0,\n orientation = \"horizontal\",\n paused: pausedProp,\n pauseOnFocus = false,\n pauseOnHover = false,\n reverse = false,\n speed = 50,\n onComplete: onCompleteProp,\n onLoopComplete: onLoopCompleteProp,\n onPauseChange,\n ...rest\n}: UseMarqueeProps = {}) {\n const { dir: defaultDir } = useI18n()\n const dir = dirProp ?? defaultDir\n const vertical = orientation === \"vertical\"\n const rootRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const trackRef = useRef<HTMLDivElement>(null)\n const [hovered, setHovered] = useState(false)\n const [focused, setFocused] = useState(false)\n const [completed, setCompleted] = useState(false)\n const [paused, setPaused] = useControllableState({\n defaultValue: defaultPaused,\n value: pausedProp,\n onChange: onPauseChange,\n })\n const onComplete = useCallbackRef(onCompleteProp)\n const onLoopComplete = useCallbackRef(onLoopCompleteProp)\n const [size, setSize] = useState({ content: 0, root: 0 })\n const duration = durationProp ?? (speed > 0 ? size.content / speed : 0)\n const ready = size.content > 0 && Number.isFinite(duration) && duration > 0\n const copies = Math.max(\n 1,\n size.content > 0 ? Math.ceil(size.root / size.content) : 1,\n )\n const iterations = Number.isFinite(loopCount) && loopCount > 0 ? loopCount : 0\n const animationDirection =\n (direction === \"end\") !== reverse ? \"reverse\" : \"normal\"\n const interactionPaused =\n (pauseOnHover && hovered) || (pauseOnFocus && focused)\n const animationPaused = paused || interactionPaused || completed || !ready\n\n const pause = useCallback(() => setPaused(true), [setPaused])\n const resume = useCallback(() => setPaused(false), [setPaused])\n const togglePause = useCallback(() => setPaused((prev) => !prev), [setPaused])\n const restart = useCallback(() => {\n trackRef.current?.getAnimations().forEach((animation) => {\n animation.currentTime = 0\n })\n setCompleted(false)\n }, [])\n const control = useMemo<MarqueeControl>(\n () => ({ pause, paused: animationPaused, restart, resume, togglePause }),\n [animationPaused, pause, restart, resume, togglePause],\n )\n\n assignRef(controlRef, control)\n\n useEffect(() => {\n const root = rootRef.current\n const content = contentRef.current\n\n if (!root || !content) return\n\n const observer = new ResizeObserver((entries) => {\n entries.forEach(({ target, borderBoxSize }) => {\n const box = borderBoxSize[0]\n\n if (!box) return\n\n const key = target === root ? \"root\" : \"content\"\n const value = vertical ? box.blockSize : box.inlineSize\n\n setSize((prev) =>\n prev[key] === value ? prev : { ...prev, [key]: value },\n )\n })\n })\n\n observer.observe(root, { box: \"border-box\" })\n observer.observe(content, { box: \"border-box\" })\n\n return () => observer.disconnect()\n }, [vertical])\n\n const getRootProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps(\n {\n style: {\n \"--delay\": `${Number.isFinite(delay) ? delay : 0}s`,\n \"--direction\": animationDirection,\n \"--distance\": `${size.content}px`,\n \"--duration\": `${ready ? duration : 0}s`,\n \"--loop-count\": iterations || \"infinite\",\n },\n \"aria-keyshortcuts\": \"Space\",\n \"aria-live\": \"off\",\n \"aria-roledescription\": \"marquee\",\n role: \"region\",\n tabIndex: 0,\n },\n rest,\n props,\n {\n ref: rootRef,\n \"data-complete\": dataAttr(completed),\n \"data-end\": dataAttr(direction === \"end\"),\n \"data-orientation\": orientation,\n \"data-pause-on-focus\": dataAttr(pauseOnFocus),\n \"data-pause-on-hover\": dataAttr(pauseOnHover),\n \"data-paused\": dataAttr(animationPaused),\n \"data-start\": dataAttr(direction === \"start\"),\n dir,\n onBlurCapture: (ev: FocusEvent<HTMLDivElement>) => {\n if (ev.currentTarget.contains(ev.relatedTarget)) return\n\n setFocused(false)\n\n if (!pauseOnFocus) return\n\n ev.currentTarget.scrollLeft = 0\n ev.currentTarget.scrollTop = 0\n },\n onFocusCapture: () => setFocused(true),\n onKeyDown: (ev: KeyboardEvent<HTMLDivElement>) => {\n if (\n ev.target !== ev.currentTarget ||\n ev.key !== \" \" ||\n ev.altKey ||\n ev.ctrlKey ||\n ev.metaKey ||\n ev.repeat\n )\n return\n\n ev.preventDefault()\n togglePause()\n },\n onMouseEnter: () => setHovered(true),\n onMouseLeave: () => setHovered(false),\n },\n )(),\n [\n rest,\n direction,\n orientation,\n pauseOnFocus,\n pauseOnHover,\n animationPaused,\n completed,\n ready,\n dir,\n duration,\n animationDirection,\n delay,\n iterations,\n size.content,\n togglePause,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps(props, {\n ref: trackRef,\n \"data-marquee-content\": \"\",\n \"data-orientation\": orientation,\n \"data-ready\": dataAttr(ready),\n onAnimationEnd: (ev: AnimationEvent<HTMLDivElement>) => {\n if (ev.target !== ev.currentTarget || !iterations) return\n\n setCompleted(true)\n onComplete()\n },\n onAnimationIteration: (ev: AnimationEvent<HTMLDivElement>) => {\n if (ev.target === ev.currentTarget) onLoopComplete()\n },\n })(),\n [orientation, ready, iterations, onComplete, onLoopComplete],\n )\n\n const getEdgeProps: PropGetter<\"div\", { direction?: SimpleDirection }> =\n useCallback(\n ({ direction = \"start\", ...props } = {}) =>\n mergeProps(props, {\n \"aria-hidden\": true,\n \"data-end\": dataAttr(direction === \"end\"),\n \"data-orientation\": orientation,\n \"data-start\": dataAttr(direction === \"start\"),\n dir,\n inert: true,\n })(),\n [dir, orientation],\n )\n\n const getGroupProps: PropGetter<\"div\", { index?: number }> = useCallback(\n ({ id, ref, index = 0, ...props } = {}) =>\n mergeProps({ style: { \"--index\": index } }, props, {\n id: index ? undefined : id,\n ref: index ? undefined : mergeRefs(ref, contentRef),\n \"aria-hidden\": index ? true : undefined,\n \"data-clone\": dataAttr(!!index),\n \"data-orientation\": orientation,\n inert: index ? true : undefined,\n })(),\n [orientation],\n )\n\n return {\n control,\n copies,\n getContentProps,\n getEdgeProps,\n getGroupProps,\n getRootProps,\n }\n}\n\nexport type UseMarqueeReturn = ReturnType<typeof useMarquee>\n"],"mappings":";;;;;;;;;AAyIA,MAAM,CAAC,gBAAgB,qBAAqBA,gBAAAA,cAA8B,EACxE,MAAM,iBACR,CAAC;AAID,SAAgB,WAAW,EACzB,YACA,gBAAgB,OAChB,QAAQ,GACR,KAAK,SACL,YAAY,SACZ,UAAU,cACV,YAAY,GACZ,cAAc,cACd,QAAQ,YACR,eAAe,OACf,eAAe,OACf,UAAU,OACV,QAAQ,IACR,YAAY,gBACZ,gBAAgB,oBAChB,eACA,GAAG,SACgB,CAAC,GAAG;CACvB,MAAM,EAAE,KAAK,eAAeC,sBAAAA,QAAQ;CACpC,MAAM,MAAM,WAAW;CACvB,MAAM,WAAW,gBAAgB;CACjC,MAAM,WAAA,GAAUC,MAAAA,OAAAA,CAAuB,IAAI;CAC3C,MAAM,cAAA,GAAaA,MAAAA,OAAAA,CAAuB,IAAI;CAC9C,MAAM,YAAA,GAAWA,MAAAA,OAAAA,CAAuB,IAAI;CAC5C,MAAM,CAAC,SAAS,eAAA,GAAcC,MAAAA,SAAAA,CAAS,KAAK;CAC5C,MAAM,CAAC,SAAS,eAAA,GAAcA,MAAAA,SAAAA,CAAS,KAAK;CAC5C,MAAM,CAAC,WAAW,iBAA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,CAAS,cAAc,KAAK;GACxC,oBAAoB;GACpB,eAAA,GAAA,oBAAA,cAAc,SAAA,CAAS,cAAc,OAAO;GAC5C;GACA,OAAO;EACT,CAAC,CAAC,CAAC,GACL,CAAC,KAAK,WAAW,CAoBR;EACX,gBAAA,GAlB2DF,MAAAA,YAAAA,EAC1D,EAAE,IAAI,KAAK,QAAQ,GAAG,GAAG,UAAU,CAAC,MACnCE,cAAAA,WAAW,EAAE,OAAO,EAAE,WAAW,MAAM,EAAE,GAAG,OAAO;GACjD,IAAI,QAAQ,KAAA,IAAY;GACxB,KAAK,QAAQ,KAAA,IAAYC,YAAAA,UAAU,KAAK,UAAU;GAClD,eAAe,QAAQ,OAAO,KAAA;GAC9B,eAAA,GAAA,oBAAA,cAAc,SAAA,CAAS,CAAC,CAAC,KAAK;GAC9B,oBAAoB;GACpB,OAAO,QAAQ,OAAO,KAAA;EACxB,CAAC,CAAC,CAAC,GACL,CAAC,WAAW,CAQA;EACZ;CACF;AACF"}
|
|
@@ -43,9 +43,9 @@ const MarqueeRoot = withProvider(({ children, contentProps, ...rest }) => {
|
|
|
43
43
|
});
|
|
44
44
|
}, "root")(void 0, ({ edgeColor, edgeSize, gap, ...rest }) => ({
|
|
45
45
|
...rest,
|
|
46
|
-
"--
|
|
47
|
-
"--
|
|
48
|
-
"--
|
|
46
|
+
"--edge-color": varAttr(edgeColor, "colors"),
|
|
47
|
+
"--edge-size": varAttr(edgeSize, "sizes"),
|
|
48
|
+
"--gap": varAttr(gap, "spaces")
|
|
49
49
|
}));
|
|
50
50
|
const MarqueeContent = withContext(({ children, ...rest }) => {
|
|
51
51
|
const { copies, getContentProps, getGroupProps } = useMarqueeContext();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marquee.js","names":[],"sources":["../../../../src/components/marquee/marquee.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n CSSProps,\n HTMLStyledProps,\n SimpleDirection,\n ThemeProps,\n} from \"../../core\"\nimport type { Merge } from \"../../utils\"\nimport type { MarqueeStyle } from \"./marquee.style\"\nimport type { UseMarqueeProps } from \"./use-marquee\"\nimport { useMemo } from \"react\"\nimport { createSlotComponent, styled, varAttr } from \"../../core\"\nimport {\n useFindChild,\n useOmitChildren,\n usePickChildren,\n useValidChildren,\n} from \"../../utils\"\nimport { marqueeStyle } from \"./marquee.style\"\nimport { MarqueeContext, useMarquee, useMarqueeContext } from \"./use-marquee\"\n\nexport interface MarqueeRootProps\n extends Merge<HTMLStyledProps, UseMarqueeProps>, ThemeProps<MarqueeStyle> {\n /**\n * The color of the edge gradient.\n *\n * @default 'bg'\n */\n edgeColor?: CSSProps[\"color\"]\n /**\n * The size of the edge gradient.\n *\n * @default '20%'\n */\n edgeSize?: CSSProps[\"width\"]\n /**\n * Props for content component.\n */\n contentProps?: MarqueeContentProps\n}\n\nconst {\n PropsContext: MarqueePropsContext,\n usePropsContext: useMarqueePropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<MarqueeRootProps, MarqueeStyle>(\"marquee\", marqueeStyle)\n\nexport { MarqueePropsContext, useMarqueePropsContext }\n\n/**\n * `Marquee` continuously scrolls content horizontally or vertically.\n *\n * @see https://yamada-ui.com/docs/components/marquee\n */\nexport const MarqueeRoot = withProvider<\"div\", MarqueeRootProps>(\n ({ children, contentProps, ...rest }) => {\n const validChildren = useValidChildren(children)\n const customContent = useFindChild(validChildren, MarqueeContent)\n const items = usePickChildren(validChildren, MarqueeItem)\n const otherChildren = useOmitChildren(validChildren, MarqueeItem)\n const {\n copies,\n getContentProps,\n getEdgeProps,\n getGroupProps,\n getRootProps,\n } = useMarquee(rest)\n const context = useMemo(\n () => ({ copies, getContentProps, getEdgeProps, getGroupProps }),\n [copies, getContentProps, getEdgeProps, getGroupProps],\n )\n\n return (\n <MarqueeContext value={context}>\n <styled.div {...getRootProps()}>\n {customContent ? (\n children\n ) : (\n <>\n <MarqueeContent {...contentProps}>{items}</MarqueeContent>\n {otherChildren}\n </>\n )}\n </styled.div>\n </MarqueeContext>\n )\n },\n \"root\",\n)(undefined, ({ edgeColor, edgeSize, gap, ...rest }) => ({\n ...rest,\n \"--
|
|
1
|
+
{"version":3,"file":"marquee.js","names":[],"sources":["../../../../src/components/marquee/marquee.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n CSSProps,\n HTMLStyledProps,\n SimpleDirection,\n ThemeProps,\n} from \"../../core\"\nimport type { Merge } from \"../../utils\"\nimport type { MarqueeStyle } from \"./marquee.style\"\nimport type { UseMarqueeProps } from \"./use-marquee\"\nimport { useMemo } from \"react\"\nimport { createSlotComponent, styled, varAttr } from \"../../core\"\nimport {\n useFindChild,\n useOmitChildren,\n usePickChildren,\n useValidChildren,\n} from \"../../utils\"\nimport { marqueeStyle } from \"./marquee.style\"\nimport { MarqueeContext, useMarquee, useMarqueeContext } from \"./use-marquee\"\n\nexport interface MarqueeRootProps\n extends Merge<HTMLStyledProps, UseMarqueeProps>, ThemeProps<MarqueeStyle> {\n /**\n * The color of the edge gradient.\n *\n * @default 'bg'\n */\n edgeColor?: CSSProps[\"color\"]\n /**\n * The size of the edge gradient.\n *\n * @default '20%'\n */\n edgeSize?: CSSProps[\"width\"]\n /**\n * Props for content component.\n */\n contentProps?: MarqueeContentProps\n}\n\nconst {\n PropsContext: MarqueePropsContext,\n usePropsContext: useMarqueePropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<MarqueeRootProps, MarqueeStyle>(\"marquee\", marqueeStyle)\n\nexport { MarqueePropsContext, useMarqueePropsContext }\n\n/**\n * `Marquee` continuously scrolls content horizontally or vertically.\n *\n * @see https://yamada-ui.com/docs/components/marquee\n */\nexport const MarqueeRoot = withProvider<\"div\", MarqueeRootProps>(\n ({ children, contentProps, ...rest }) => {\n const validChildren = useValidChildren(children)\n const customContent = useFindChild(validChildren, MarqueeContent)\n const items = usePickChildren(validChildren, MarqueeItem)\n const otherChildren = useOmitChildren(validChildren, MarqueeItem)\n const {\n copies,\n getContentProps,\n getEdgeProps,\n getGroupProps,\n getRootProps,\n } = useMarquee(rest)\n const context = useMemo(\n () => ({ copies, getContentProps, getEdgeProps, getGroupProps }),\n [copies, getContentProps, getEdgeProps, getGroupProps],\n )\n\n return (\n <MarqueeContext value={context}>\n <styled.div {...getRootProps()}>\n {customContent ? (\n children\n ) : (\n <>\n <MarqueeContent {...contentProps}>{items}</MarqueeContent>\n {otherChildren}\n </>\n )}\n </styled.div>\n </MarqueeContext>\n )\n },\n \"root\",\n)(undefined, ({ edgeColor, edgeSize, gap, ...rest }) => ({\n ...rest,\n \"--edge-color\": varAttr(edgeColor, \"colors\"),\n \"--edge-size\": varAttr(edgeSize, \"sizes\"),\n \"--gap\": varAttr(gap, \"spaces\"),\n}))\n\nexport interface MarqueeContentProps extends HTMLStyledProps {}\n\nexport const MarqueeContent = withContext<\"div\", MarqueeContentProps>(\n ({ children, ...rest }) => {\n const { copies, getContentProps, getGroupProps } = useMarqueeContext()\n\n return (\n <styled.div {...getContentProps(rest)}>\n {Array.from({ length: copies + 1 }, (_, index) => (\n <MarqueeGroup key={index} {...getGroupProps({ index })}>\n {children}\n </MarqueeGroup>\n ))}\n </styled.div>\n )\n },\n \"content\",\n)()\n\nconst MarqueeGroup = withContext(\"div\", \"group\")()\n\nexport interface MarqueeItemProps extends HTMLStyledProps {}\n\nexport const MarqueeItem = withContext<\"div\", MarqueeItemProps>(\"div\", \"item\")()\n\nexport interface MarqueeEdgeProps extends Omit<HTMLStyledProps, \"direction\"> {\n /**\n * The edge to fade, relative to the marquee orientation.\n *\n * @default 'start'\n */\n direction?: SimpleDirection\n}\n\nexport const MarqueeEdge = withContext<\"div\", MarqueeEdgeProps>(\"div\", \"edge\")(\n undefined,\n (props) => {\n const { getEdgeProps } = useMarqueeContext()\n\n return getEdgeProps(props)\n },\n)\n"],"mappings":";;;;;;;;;;AA0CA,MAAM,EACJ,cAAc,qBACd,iBAAiB,wBACjB,aACA,iBACE,oBAAoD,WAAW,YAAY;;;;;;AAS/E,MAAa,cAAc,cACxB,EAAE,U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a,cAAc,YAAqC,OAAO,MAAM,CAAC,CAC5E,KAAA,IACC,UAAU;CACT,MAAM,EAAE,iBAAiB,kBAAkB;CAE3C,OAAO,aAAa,KAAK;AAC3B,CACF"}
|
|
@@ -4,19 +4,19 @@ const marqueeStyle = defineComponentSlotStyle({ base: {
|
|
|
4
4
|
content: {
|
|
5
5
|
"&:not([data-ready])": { animationName: "none" },
|
|
6
6
|
alignItems: "center",
|
|
7
|
-
animationDelay: "{
|
|
8
|
-
animationDirection: "{
|
|
9
|
-
animationDuration: "{
|
|
7
|
+
animationDelay: "{delay}",
|
|
8
|
+
animationDirection: "{direction}",
|
|
9
|
+
animationDuration: "{duration}",
|
|
10
10
|
animationFillMode: "both",
|
|
11
|
-
animationIterationCount: "{
|
|
12
|
-
animationPlayState: "{
|
|
11
|
+
animationIterationCount: "{loop-count}",
|
|
12
|
+
animationPlayState: "{play-state}",
|
|
13
13
|
animationTimingFunction: "linear",
|
|
14
14
|
display: "flex",
|
|
15
15
|
flex: "0 0 auto",
|
|
16
16
|
minW: "0",
|
|
17
17
|
position: "relative",
|
|
18
18
|
_horizontal: { w: "max-content" },
|
|
19
|
-
_keyframes: { to: { transform: "translate({
|
|
19
|
+
_keyframes: { to: { transform: "translate({translate-x}, {translate-y})" } },
|
|
20
20
|
_mediaReduceMotion: { animationName: "none" },
|
|
21
21
|
_vertical: {
|
|
22
22
|
flexDirection: "column",
|
|
@@ -30,89 +30,89 @@ const marqueeStyle = defineComponentSlotStyle({ base: {
|
|
|
30
30
|
_horizontal: {
|
|
31
31
|
bottom: "0",
|
|
32
32
|
top: "0",
|
|
33
|
-
w: "{
|
|
33
|
+
w: "{edge-size}",
|
|
34
34
|
_end: {
|
|
35
|
-
bgGradient: "linear(to-l, {
|
|
35
|
+
bgGradient: "linear(to-l, {edge-color}, transparent)",
|
|
36
36
|
insetInlineEnd: "0",
|
|
37
|
-
_rtl: { bgGradient: "linear(to-r, {
|
|
37
|
+
_rtl: { bgGradient: "linear(to-r, {edge-color}, transparent)" }
|
|
38
38
|
},
|
|
39
39
|
_start: {
|
|
40
|
-
bgGradient: "linear(to-r, {
|
|
40
|
+
bgGradient: "linear(to-r, {edge-color}, transparent)",
|
|
41
41
|
insetInlineStart: "0",
|
|
42
|
-
_rtl: { bgGradient: "linear(to-l, {
|
|
42
|
+
_rtl: { bgGradient: "linear(to-l, {edge-color}, transparent)" }
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
_vertical: {
|
|
46
|
-
h: "{
|
|
46
|
+
h: "{edge-size}",
|
|
47
47
|
insetInline: "0",
|
|
48
48
|
_end: {
|
|
49
|
-
bgGradient: "linear(to-t, {
|
|
49
|
+
bgGradient: "linear(to-t, {edge-color}, transparent)",
|
|
50
50
|
bottom: "0"
|
|
51
51
|
},
|
|
52
52
|
_start: {
|
|
53
|
-
bgGradient: "linear(to-b, {
|
|
53
|
+
bgGradient: "linear(to-b, {edge-color}, transparent)",
|
|
54
54
|
top: "0"
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
group: {
|
|
59
59
|
"&[data-clone]": {
|
|
60
|
-
display: "{
|
|
60
|
+
display: "{clone-display, flex}",
|
|
61
61
|
position: "absolute",
|
|
62
62
|
_horizontal: {
|
|
63
|
-
transform: "translateX(calc({
|
|
63
|
+
transform: "translateX(calc({copy-offset-x} * {index}))",
|
|
64
64
|
w: "max-content"
|
|
65
65
|
},
|
|
66
66
|
_vertical: {
|
|
67
|
-
transform: "translateY(calc({
|
|
67
|
+
transform: "translateY(calc({distance} * {index}))",
|
|
68
68
|
w: "full"
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
alignItems: "center",
|
|
72
72
|
display: "flex",
|
|
73
73
|
flex: "0 0 auto",
|
|
74
|
-
gap: "{
|
|
75
|
-
_horizontal: { pe: "{
|
|
74
|
+
gap: "{gap}",
|
|
75
|
+
_horizontal: { pe: "{gap}" },
|
|
76
76
|
_mediaReduceMotion: { "&[data-clone]": { display: "none" } },
|
|
77
77
|
_vertical: {
|
|
78
78
|
flexDirection: "column",
|
|
79
|
-
pb: "{
|
|
79
|
+
pb: "{gap}"
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
item: { flexShrink: 0 },
|
|
83
83
|
root: {
|
|
84
84
|
"&[data-pause-on-focus]": { _nativeFocusWithin: {
|
|
85
85
|
"& > [data-marquee-content]": { transform: "none !important" },
|
|
86
|
-
"--
|
|
87
|
-
"--
|
|
86
|
+
"--clone-display": "none",
|
|
87
|
+
"--play-state": "paused",
|
|
88
88
|
overflow: "auto"
|
|
89
89
|
} },
|
|
90
|
-
"&[data-pause-on-hover]": { _hover: { "--
|
|
91
|
-
"--
|
|
92
|
-
"--
|
|
93
|
-
"--
|
|
94
|
-
"--
|
|
95
|
-
"--
|
|
96
|
-
"--
|
|
97
|
-
"--
|
|
90
|
+
"&[data-pause-on-hover]": { _hover: { "--play-state": "paused" } },
|
|
91
|
+
"--copy-offset-x": "{distance}",
|
|
92
|
+
"--edge-color": "colors.bg",
|
|
93
|
+
"--edge-size": "20%",
|
|
94
|
+
"--gap": "spaces.4",
|
|
95
|
+
"--play-state": "running",
|
|
96
|
+
"--translate-x": "calc({distance} * -1)",
|
|
97
|
+
"--translate-y": "0px",
|
|
98
98
|
overflow: "hidden",
|
|
99
99
|
position: "relative",
|
|
100
100
|
rounded: "l2",
|
|
101
101
|
w: "full",
|
|
102
102
|
_complete: {
|
|
103
103
|
"& > [data-marquee-content]": { transform: "none !important" },
|
|
104
|
-
"--
|
|
104
|
+
"--clone-display": "none",
|
|
105
105
|
overflow: "auto"
|
|
106
106
|
},
|
|
107
107
|
_horizontal: { "&[dir=rtl]": {
|
|
108
|
-
"--
|
|
109
|
-
"--
|
|
108
|
+
"--copy-offset-x": "calc({distance} * -1)",
|
|
109
|
+
"--translate-x": "{distance}"
|
|
110
110
|
} },
|
|
111
111
|
_mediaReduceMotion: { overflow: "auto" },
|
|
112
|
-
_paused: { "--
|
|
112
|
+
_paused: { "--play-state": "paused" },
|
|
113
113
|
_vertical: {
|
|
114
|
-
"--
|
|
115
|
-
"--
|
|
114
|
+
"--translate-x": "0px",
|
|
115
|
+
"--translate-y": "calc({distance} * -1)"
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
} });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marquee.style.js","names":[],"sources":["../../../../src/components/marquee/marquee.style.ts"],"sourcesContent":["import { defineComponentSlotStyle } from \"../../core\"\n\nexport const marqueeStyle = defineComponentSlotStyle({\n base: {\n content: {\n \"&:not([data-ready])\": { animationName: \"none\" },\n alignItems: \"center\",\n animationDelay: \"{
|
|
1
|
+
{"version":3,"file":"marquee.style.js","names":[],"sources":["../../../../src/components/marquee/marquee.style.ts"],"sourcesContent":["import { defineComponentSlotStyle } from \"../../core\"\n\nexport const marqueeStyle = defineComponentSlotStyle({\n base: {\n content: {\n \"&:not([data-ready])\": { animationName: \"none\" },\n alignItems: \"center\",\n animationDelay: \"{delay}\",\n animationDirection: \"{direction}\",\n animationDuration: \"{duration}\",\n animationFillMode: \"both\",\n animationIterationCount: \"{loop-count}\",\n animationPlayState: \"{play-state}\",\n animationTimingFunction: \"linear\",\n display: \"flex\",\n flex: \"0 0 auto\",\n minW: \"0\",\n position: \"relative\",\n _horizontal: { w: \"max-content\" },\n _keyframes: {\n to: {\n transform: \"translate({translate-x}, {translate-y})\",\n },\n },\n _mediaReduceMotion: { animationName: \"none\" },\n _vertical: { flexDirection: \"column\", h: \"max-content\" },\n },\n edge: {\n pointerEvents: \"none\",\n position: \"absolute\",\n zIndex: \"1\",\n _horizontal: {\n bottom: \"0\",\n top: \"0\",\n w: \"{edge-size}\",\n _end: {\n bgGradient: \"linear(to-l, {edge-color}, transparent)\",\n insetInlineEnd: \"0\",\n _rtl: {\n bgGradient: \"linear(to-r, {edge-color}, transparent)\",\n },\n },\n _start: {\n bgGradient: \"linear(to-r, {edge-color}, transparent)\",\n insetInlineStart: \"0\",\n _rtl: {\n bgGradient: \"linear(to-l, {edge-color}, transparent)\",\n },\n },\n },\n _vertical: {\n h: \"{edge-size}\",\n insetInline: \"0\",\n _end: {\n bgGradient: \"linear(to-t, {edge-color}, transparent)\",\n bottom: \"0\",\n },\n _start: {\n bgGradient: \"linear(to-b, {edge-color}, transparent)\",\n top: \"0\",\n },\n },\n },\n group: {\n \"&[data-clone]\": {\n display: \"{clone-display, flex}\",\n position: \"absolute\",\n _horizontal: {\n transform: \"translateX(calc({copy-offset-x} * {index}))\",\n w: \"max-content\",\n },\n _vertical: {\n transform: \"translateY(calc({distance} * {index}))\",\n w: \"full\",\n },\n },\n alignItems: \"center\",\n display: \"flex\",\n flex: \"0 0 auto\",\n gap: \"{gap}\",\n _horizontal: { pe: \"{gap}\" },\n _mediaReduceMotion: { \"&[data-clone]\": { display: \"none\" } },\n _vertical: { flexDirection: \"column\", pb: \"{gap}\" },\n },\n item: { flexShrink: 0 },\n root: {\n \"&[data-pause-on-focus]\": {\n _nativeFocusWithin: {\n \"& > [data-marquee-content]\": { transform: \"none !important\" },\n \"--clone-display\": \"none\",\n \"--play-state\": \"paused\",\n overflow: \"auto\",\n },\n },\n \"&[data-pause-on-hover]\": {\n _hover: { \"--play-state\": \"paused\" },\n },\n \"--copy-offset-x\": \"{distance}\",\n \"--edge-color\": \"colors.bg\",\n \"--edge-size\": \"20%\",\n \"--gap\": \"spaces.4\",\n \"--play-state\": \"running\",\n \"--translate-x\": \"calc({distance} * -1)\",\n \"--translate-y\": \"0px\",\n overflow: \"hidden\",\n position: \"relative\",\n rounded: \"l2\",\n w: \"full\",\n _complete: {\n \"& > [data-marquee-content]\": { transform: \"none !important\" },\n \"--clone-display\": \"none\",\n overflow: \"auto\",\n },\n _horizontal: {\n \"&[dir=rtl]\": {\n \"--copy-offset-x\": \"calc({distance} * -1)\",\n \"--translate-x\": \"{distance}\",\n },\n },\n _mediaReduceMotion: { overflow: \"auto\" },\n _paused: { \"--play-state\": \"paused\" },\n _vertical: {\n \"--translate-x\": \"0px\",\n \"--translate-y\": \"calc({distance} * -1)\",\n },\n },\n },\n})\n\nexport type MarqueeStyle = typeof marqueeStyle\n"],"mappings":";;AAEA,MAAa,eAAe,yBAAyB,EACnD,MAAM;CACJ,SAAS;EACP,uBAAuB,EAAE,eAAe,OAAO;EAC/C,YAAY;EACZ,gBAAgB;EAChB,oBAAoB;EACpB,mBAAmB;EACnB,mBAAmB;EACnB,yBAAyB;EACzB,oBAAoB;EACpB,yBAAyB;EACzB,SAAS;EACT,MAAM;EACN,MAAM;EACN,UAAU;EACV,aAAa,EAAE,GAAG,cAAc;EAChC,YAAY,EACV,IAAI,EACF,WAAW,0CACb,EACF;EACA,oBAAoB,EAAE,eAAe,OAAO;EAC5C,WAAW;GAAE,eAAe;GAAU,GAAG;EAAc;CACzD;CACA,MAAM;EACJ,eAAe;EACf,UAAU;EACV,QAAQ;EACR,aAAa;GACX,QAAQ;GACR,KAAK;GACL,GAAG;GACH,MAAM;IACJ,YAAY;IACZ,gBAAgB;IAChB,MAAM,EACJ,YAAY,0CACd;GACF;GACA,QAAQ;IACN,YAAY;IACZ,kBAAkB;IAClB,MAAM,EACJ,YAAY,0CACd;GACF;EACF;EACA,WAAW;GACT,GAAG;GACH,aAAa;GACb,MAAM;IACJ,YAAY;IACZ,QAAQ;GACV;GACA,QAAQ;IACN,YAAY;IACZ,KAAK;GACP;EACF;CACF;CACA,OAAO;EACL,iBAAiB;GACf,SAAS;GACT,UAAU;GACV,aAAa;IACX,WAAW;IACX,GAAG;GACL;GACA,WAAW;IACT,WAAW;IACX,GAAG;GACL;EACF;EACA,YAAY;EACZ,SAAS;EACT,MAAM;EACN,KAAK;EACL,aAAa,EAAE,IAAI,QAAQ;EAC3B,oBAAoB,EAAE,iBAAiB,EAAE,SAAS,OAAO,EAAE;EAC3D,WAAW;GAAE,eAAe;GAAU,IAAI;EAAQ;CACpD;CACA,MAAM,EAAE,YAAY,EAAE;CACtB,MAAM;EACJ,0BAA0B,EACxB,oBAAoB;GAClB,8BAA8B,EAAE,WAAW,kBAAkB;GAC7D,mBAAmB;GACnB,gBAAgB;GAChB,UAAU;EACZ,EACF;EACA,0BAA0B,EACxB,QAAQ,EAAE,gBAAgB,SAAS,EACrC;EACA,mBAAmB;EACnB,gBAAgB;EAChB,eAAe;EACf,SAAS;EACT,gBAAgB;EAChB,iBAAiB;EACjB,iBAAiB;EACjB,UAAU;EACV,UAAU;EACV,SAAS;EACT,GAAG;EACH,WAAW;GACT,8BAA8B,EAAE,WAAW,kBAAkB;GAC7D,mBAAmB;GACnB,UAAU;EACZ;EACA,aAAa,EACX,cAAc;GACZ,mBAAmB;GACnB,iBAAiB;EACnB,EACF;EACA,oBAAoB,EAAE,UAAU,OAAO;EACvC,SAAS,EAAE,gBAAgB,SAAS;EACpC,WAAW;GACT,iBAAiB;GACjB,iBAAiB;EACnB;CACF;AACF,EACF,CAAC"}
|
|
@@ -80,11 +80,11 @@ function useMarquee({ controlRef, defaultPaused = false, delay = 0, dir: dirProp
|
|
|
80
80
|
}, [vertical]);
|
|
81
81
|
const getRootProps = useCallback((props = {}) => mergeProps({
|
|
82
82
|
style: {
|
|
83
|
-
"--
|
|
84
|
-
"--
|
|
85
|
-
"--
|
|
86
|
-
"--
|
|
87
|
-
"--
|
|
83
|
+
"--delay": `${Number.isFinite(delay) ? delay : 0}s`,
|
|
84
|
+
"--direction": animationDirection,
|
|
85
|
+
"--distance": `${size.content}px`,
|
|
86
|
+
"--duration": `${ready ? duration : 0}s`,
|
|
87
|
+
"--loop-count": iterations || "infinite"
|
|
88
88
|
},
|
|
89
89
|
"aria-keyshortcuts": "Space",
|
|
90
90
|
"aria-live": "off",
|
|
@@ -164,7 +164,7 @@ function useMarquee({ controlRef, defaultPaused = false, delay = 0, dir: dirProp
|
|
|
164
164
|
dir,
|
|
165
165
|
inert: true
|
|
166
166
|
})(), [dir, orientation]),
|
|
167
|
-
getGroupProps: useCallback(({ id, ref, index = 0, ...props } = {}) => mergeProps({ style: { "--
|
|
167
|
+
getGroupProps: useCallback(({ id, ref, index = 0, ...props } = {}) => mergeProps({ style: { "--index": index } }, props, {
|
|
168
168
|
id: index ? void 0 : id,
|
|
169
169
|
ref: index ? void 0 : mergeRefs(ref, contentRef),
|
|
170
170
|
"aria-hidden": index ? true : void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-marquee.js","names":["createContext","dataAttr"],"sources":["../../../../src/components/marquee/use-marquee.ts"],"sourcesContent":["\"use client\"\n\nimport type {\n AnimationEvent,\n FocusEvent,\n KeyboardEvent,\n RefObject,\n} from \"react\"\nimport type {\n HTMLProps,\n Orientation,\n PropGetter,\n SimpleDirection,\n} from \"../../core\"\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n assignRef,\n createContext,\n dataAttr,\n mergeRefs,\n useCallbackRef,\n} from \"../../utils\"\n\nexport interface MarqueeControl {\n /**\n * Whether the marquee is paused.\n */\n paused: boolean\n /**\n * Pauses the marquee.\n */\n pause: () => void\n /**\n * Restarts the animation, including its delay and loop count.\n */\n restart: () => void\n /**\n * Resumes the marquee.\n */\n resume: () => void\n /**\n * Toggles the pause state.\n */\n togglePause: () => void\n}\n\nexport interface UseMarqueeProps extends HTMLProps {\n /**\n * Ref of the marquee controls.\n */\n controlRef?: RefObject<MarqueeControl | null>\n /**\n * Whether the marquee is initially paused.\n *\n * @default false\n */\n defaultPaused?: boolean\n /**\n * The delay before the animation starts, in seconds.\n *\n * @default 0\n */\n delay?: number\n /**\n * The direction the content scrolls towards.\n *\n * @default 'start'\n */\n direction?: SimpleDirection\n /**\n * The duration of one loop in seconds. Overrides `speed`.\n */\n duration?: number\n /**\n * The number of animation loops. Set to `0` for infinite loops.\n *\n * @default 0\n */\n loopCount?: number\n /**\n * The orientation of the marquee.\n *\n * @default 'horizontal'\n */\n orientation?: Orientation\n /**\n * If `true`, the animation is paused.\n *\n * @default false\n */\n paused?: boolean\n /**\n * If `true`, the animation pauses while an item is focused.\n *\n * @default false\n */\n pauseOnFocus?: boolean\n /**\n * If `true`, the animation pauses on hover.\n *\n * @default false\n */\n pauseOnHover?: boolean\n /**\n * If `true`, the scrolling direction is reversed.\n *\n * @default false\n */\n reverse?: boolean\n /**\n * The scrolling speed in pixels per second.\n *\n * @default 50\n */\n speed?: number\n /**\n * The callback invoked when all finite loops finish.\n */\n onComplete?: () => void\n /**\n * The callback invoked after each animation iteration, except the final one.\n */\n onLoopComplete?: () => void\n /**\n * The callback invoked when the persistent pause state changes.\n */\n onPauseChange?: (paused: boolean) => void\n}\n\ninterface MarqueeContext extends Pick<\n UseMarqueeReturn,\n \"copies\" | \"getContentProps\" | \"getEdgeProps\" | \"getGroupProps\"\n> {}\n\nconst [MarqueeContext, useMarqueeContext] = createContext<MarqueeContext>({\n name: \"MarqueeContext\",\n})\n\nexport { MarqueeContext, useMarqueeContext }\n\nexport function useMarquee({\n controlRef,\n defaultPaused = false,\n delay = 0,\n dir: dirProp,\n direction = \"start\",\n duration: durationProp,\n loopCount = 0,\n orientation = \"horizontal\",\n paused: pausedProp,\n pauseOnFocus = false,\n pauseOnHover = false,\n reverse = false,\n speed = 50,\n onComplete: onCompleteProp,\n onLoopComplete: onLoopCompleteProp,\n onPauseChange,\n ...rest\n}: UseMarqueeProps = {}) {\n const { dir: defaultDir } = useI18n()\n const dir = dirProp ?? defaultDir\n const vertical = orientation === \"vertical\"\n const rootRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const trackRef = useRef<HTMLDivElement>(null)\n const [hovered, setHovered] = useState(false)\n const [focused, setFocused] = useState(false)\n const [completed, setCompleted] = useState(false)\n const [paused, setPaused] = useControllableState({\n defaultValue: defaultPaused,\n value: pausedProp,\n onChange: onPauseChange,\n })\n const onComplete = useCallbackRef(onCompleteProp)\n const onLoopComplete = useCallbackRef(onLoopCompleteProp)\n const [size, setSize] = useState({ content: 0, root: 0 })\n const duration = durationProp ?? (speed > 0 ? size.content / speed : 0)\n const ready = size.content > 0 && Number.isFinite(duration) && duration > 0\n const copies = Math.max(\n 1,\n size.content > 0 ? Math.ceil(size.root / size.content) : 1,\n )\n const iterations = Number.isFinite(loopCount) && loopCount > 0 ? loopCount : 0\n const animationDirection =\n (direction === \"end\") !== reverse ? \"reverse\" : \"normal\"\n const interactionPaused =\n (pauseOnHover && hovered) || (pauseOnFocus && focused)\n const animationPaused = paused || interactionPaused || completed || !ready\n\n const pause = useCallback(() => setPaused(true), [setPaused])\n const resume = useCallback(() => setPaused(false), [setPaused])\n const togglePause = useCallback(() => setPaused((prev) => !prev), [setPaused])\n const restart = useCallback(() => {\n trackRef.current?.getAnimations().forEach((animation) => {\n animation.currentTime = 0\n })\n setCompleted(false)\n }, [])\n const control = useMemo<MarqueeControl>(\n () => ({ pause, paused: animationPaused, restart, resume, togglePause }),\n [animationPaused, pause, restart, resume, togglePause],\n )\n\n assignRef(controlRef, control)\n\n useEffect(() => {\n const root = rootRef.current\n const content = contentRef.current\n\n if (!root || !content) return\n\n const observer = new ResizeObserver((entries) => {\n entries.forEach(({ target, borderBoxSize }) => {\n const box = borderBoxSize[0]\n\n if (!box) return\n\n const key = target === root ? \"root\" : \"content\"\n const value = vertical ? box.blockSize : box.inlineSize\n\n setSize((prev) =>\n prev[key] === value ? prev : { ...prev, [key]: value },\n )\n })\n })\n\n observer.observe(root, { box: \"border-box\" })\n observer.observe(content, { box: \"border-box\" })\n\n return () => observer.disconnect()\n }, [vertical])\n\n const getRootProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps(\n {\n style: {\n \"--marquee-delay\": `${Number.isFinite(delay) ? delay : 0}s`,\n \"--marquee-direction\": animationDirection,\n \"--marquee-distance\": `${size.content}px`,\n \"--marquee-duration\": `${ready ? duration : 0}s`,\n \"--marquee-loop-count\": iterations || \"infinite\",\n },\n \"aria-keyshortcuts\": \"Space\",\n \"aria-live\": \"off\",\n \"aria-roledescription\": \"marquee\",\n role: \"region\",\n tabIndex: 0,\n },\n rest,\n props,\n {\n ref: rootRef,\n \"data-complete\": dataAttr(completed),\n \"data-end\": dataAttr(direction === \"end\"),\n \"data-orientation\": orientation,\n \"data-pause-on-focus\": dataAttr(pauseOnFocus),\n \"data-pause-on-hover\": dataAttr(pauseOnHover),\n \"data-paused\": dataAttr(animationPaused),\n \"data-start\": dataAttr(direction === \"start\"),\n dir,\n onBlurCapture: (ev: FocusEvent<HTMLDivElement>) => {\n if (ev.currentTarget.contains(ev.relatedTarget)) return\n\n setFocused(false)\n\n if (!pauseOnFocus) return\n\n ev.currentTarget.scrollLeft = 0\n ev.currentTarget.scrollTop = 0\n },\n onFocusCapture: () => setFocused(true),\n onKeyDown: (ev: KeyboardEvent<HTMLDivElement>) => {\n if (\n ev.target !== ev.currentTarget ||\n ev.key !== \" \" ||\n ev.altKey ||\n ev.ctrlKey ||\n ev.metaKey ||\n ev.repeat\n )\n return\n\n ev.preventDefault()\n togglePause()\n },\n onMouseEnter: () => setHovered(true),\n onMouseLeave: () => setHovered(false),\n },\n )(),\n [\n rest,\n direction,\n orientation,\n pauseOnFocus,\n pauseOnHover,\n animationPaused,\n completed,\n ready,\n dir,\n duration,\n animationDirection,\n delay,\n iterations,\n size.content,\n togglePause,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps(props, {\n ref: trackRef,\n \"data-marquee-content\": \"\",\n \"data-orientation\": orientation,\n \"data-ready\": dataAttr(ready),\n onAnimationEnd: (ev: AnimationEvent<HTMLDivElement>) => {\n if (ev.target !== ev.currentTarget || !iterations) return\n\n setCompleted(true)\n onComplete()\n },\n onAnimationIteration: (ev: AnimationEvent<HTMLDivElement>) => {\n if (ev.target === ev.currentTarget) onLoopComplete()\n },\n })(),\n [orientation, ready, iterations, onComplete, onLoopComplete],\n )\n\n const getEdgeProps: PropGetter<\"div\", { direction?: SimpleDirection }> =\n useCallback(\n ({ direction = \"start\", ...props } = {}) =>\n mergeProps(props, {\n \"aria-hidden\": true,\n \"data-end\": dataAttr(direction === \"end\"),\n \"data-orientation\": orientation,\n \"data-start\": dataAttr(direction === \"start\"),\n dir,\n inert: true,\n })(),\n [dir, orientation],\n )\n\n const getGroupProps: PropGetter<\"div\", { index?: number }> = useCallback(\n ({ id, ref, index = 0, ...props } = {}) =>\n mergeProps({ style: { \"--marquee-index\": index } }, props, {\n id: index ? undefined : id,\n ref: index ? undefined : mergeRefs(ref, contentRef),\n \"aria-hidden\": index ? true : undefined,\n \"data-clone\": dataAttr(!!index),\n \"data-orientation\": orientation,\n inert: index ? true : undefined,\n })(),\n [orientation],\n )\n\n return {\n control,\n copies,\n getContentProps,\n getEdgeProps,\n getGroupProps,\n getRootProps,\n }\n}\n\nexport type UseMarqueeReturn = ReturnType<typeof useMarquee>\n"],"mappings":";;;;;;;;;AAyIA,MAAM,CAAC,gBAAgB,qBAAqBA,gBAA8B,EACxE,MAAM,iBACR,CAAC;AAID,SAAgB,WAAW,EACzB,YACA,gBAAgB,OAChB,QAAQ,GACR,KAAK,SACL,YAAY,SACZ,UAAU,cACV,YAAY,GACZ,cAAc,cACd,QAAQ,YACR,eAAe,OACf,eAAe,OACf,UAAU,OACV,QAAQ,IACR,YAAY,gBACZ,gBAAgB,oBAChB,eACA,GAAG,SACgB,CAAC,GAAG;CACvB,MAAM,EAAE,KAAK,eAAe,QAAQ;CACpC,MAAM,MAAM,WAAW;CACvB,MAAM,WAAW,gBAAgB;CACjC,MAAM,UAAU,OAAuB,IAAI;CAC3C,MAAM,aAAa,OAAuB,IAAI;CAC9C,MAAM,WAAW,OAAuB,IAAI;CAC5C,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,CAAC,QAAQ,aAAa,qBAAqB;EAC/C,cAAc;EACd,OAAO;EACP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O,KAAA;GAC9B,eAAA,GAAcA,cAAAA,SAAAA,CAAS,CAAC,CAAC,KAAK;GAC9B,oBAAoB;GACpB,OAAO,QAAQ,OAAO,KAAA;EACxB,CAAC,CAAC,CAAC,GACL,CAAC,WAAW,CAQA;EACZ;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"use-marquee.js","names":["createContext","dataAttr"],"sources":["../../../../src/components/marquee/use-marquee.ts"],"sourcesContent":["\"use client\"\n\nimport type {\n AnimationEvent,\n FocusEvent,\n KeyboardEvent,\n RefObject,\n} from \"react\"\nimport type {\n HTMLProps,\n Orientation,\n PropGetter,\n SimpleDirection,\n} from \"../../core\"\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n assignRef,\n createContext,\n dataAttr,\n mergeRefs,\n useCallbackRef,\n} from \"../../utils\"\n\nexport interface MarqueeControl {\n /**\n * Whether the marquee is paused.\n */\n paused: boolean\n /**\n * Pauses the marquee.\n */\n pause: () => void\n /**\n * Restarts the animation, including its delay and loop count.\n */\n restart: () => void\n /**\n * Resumes the marquee.\n */\n resume: () => void\n /**\n * Toggles the pause state.\n */\n togglePause: () => void\n}\n\nexport interface UseMarqueeProps extends HTMLProps {\n /**\n * Ref of the marquee controls.\n */\n controlRef?: RefObject<MarqueeControl | null>\n /**\n * Whether the marquee is initially paused.\n *\n * @default false\n */\n defaultPaused?: boolean\n /**\n * The delay before the animation starts, in seconds.\n *\n * @default 0\n */\n delay?: number\n /**\n * The direction the content scrolls towards.\n *\n * @default 'start'\n */\n direction?: SimpleDirection\n /**\n * The duration of one loop in seconds. Overrides `speed`.\n */\n duration?: number\n /**\n * The number of animation loops. Set to `0` for infinite loops.\n *\n * @default 0\n */\n loopCount?: number\n /**\n * The orientation of the marquee.\n *\n * @default 'horizontal'\n */\n orientation?: Orientation\n /**\n * If `true`, the animation is paused.\n *\n * @default false\n */\n paused?: boolean\n /**\n * If `true`, the animation pauses while an item is focused.\n *\n * @default false\n */\n pauseOnFocus?: boolean\n /**\n * If `true`, the animation pauses on hover.\n *\n * @default false\n */\n pauseOnHover?: boolean\n /**\n * If `true`, the scrolling direction is reversed.\n *\n * @default false\n */\n reverse?: boolean\n /**\n * The scrolling speed in pixels per second.\n *\n * @default 50\n */\n speed?: number\n /**\n * The callback invoked when all finite loops finish.\n */\n onComplete?: () => void\n /**\n * The callback invoked after each animation iteration, except the final one.\n */\n onLoopComplete?: () => void\n /**\n * The callback invoked when the persistent pause state changes.\n */\n onPauseChange?: (paused: boolean) => void\n}\n\ninterface MarqueeContext extends Pick<\n UseMarqueeReturn,\n \"copies\" | \"getContentProps\" | \"getEdgeProps\" | \"getGroupProps\"\n> {}\n\nconst [MarqueeContext, useMarqueeContext] = createContext<MarqueeContext>({\n name: \"MarqueeContext\",\n})\n\nexport { MarqueeContext, useMarqueeContext }\n\nexport function useMarquee({\n controlRef,\n defaultPaused = false,\n delay = 0,\n dir: dirProp,\n direction = \"start\",\n duration: durationProp,\n loopCount = 0,\n orientation = \"horizontal\",\n paused: pausedProp,\n pauseOnFocus = false,\n pauseOnHover = false,\n reverse = false,\n speed = 50,\n onComplete: onCompleteProp,\n onLoopComplete: onLoopCompleteProp,\n onPauseChange,\n ...rest\n}: UseMarqueeProps = {}) {\n const { dir: defaultDir } = useI18n()\n const dir = dirProp ?? defaultDir\n const vertical = orientation === \"vertical\"\n const rootRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const trackRef = useRef<HTMLDivElement>(null)\n const [hovered, setHovered] = useState(false)\n const [focused, setFocused] = useState(false)\n const [completed, setCompleted] = useState(false)\n const [paused, setPaused] = useControllableState({\n defaultValue: defaultPaused,\n value: pausedProp,\n onChange: onPauseChange,\n })\n const onComplete = useCallbackRef(onCompleteProp)\n const onLoopComplete = useCallbackRef(onLoopCompleteProp)\n const [size, setSize] = useState({ content: 0, root: 0 })\n const duration = durationProp ?? (speed > 0 ? size.content / speed : 0)\n const ready = size.content > 0 && Number.isFinite(duration) && duration > 0\n const copies = Math.max(\n 1,\n size.content > 0 ? Math.ceil(size.root / size.content) : 1,\n )\n const iterations = Number.isFinite(loopCount) && loopCount > 0 ? loopCount : 0\n const animationDirection =\n (direction === \"end\") !== reverse ? \"reverse\" : \"normal\"\n const interactionPaused =\n (pauseOnHover && hovered) || (pauseOnFocus && focused)\n const animationPaused = paused || interactionPaused || completed || !ready\n\n const pause = useCallback(() => setPaused(true), [setPaused])\n const resume = useCallback(() => setPaused(false), [setPaused])\n const togglePause = useCallback(() => setPaused((prev) => !prev), [setPaused])\n const restart = useCallback(() => {\n trackRef.current?.getAnimations().forEach((animation) => {\n animation.currentTime = 0\n })\n setCompleted(false)\n }, [])\n const control = useMemo<MarqueeControl>(\n () => ({ pause, paused: animationPaused, restart, resume, togglePause }),\n [animationPaused, pause, restart, resume, togglePause],\n )\n\n assignRef(controlRef, control)\n\n useEffect(() => {\n const root = rootRef.current\n const content = contentRef.current\n\n if (!root || !content) return\n\n const observer = new ResizeObserver((entries) => {\n entries.forEach(({ target, borderBoxSize }) => {\n const box = borderBoxSize[0]\n\n if (!box) return\n\n const key = target === root ? \"root\" : \"content\"\n const value = vertical ? box.blockSize : box.inlineSize\n\n setSize((prev) =>\n prev[key] === value ? prev : { ...prev, [key]: value },\n )\n })\n })\n\n observer.observe(root, { box: \"border-box\" })\n observer.observe(content, { box: \"border-box\" })\n\n return () => observer.disconnect()\n }, [vertical])\n\n const getRootProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps(\n {\n style: {\n \"--delay\": `${Number.isFinite(delay) ? delay : 0}s`,\n \"--direction\": animationDirection,\n \"--distance\": `${size.content}px`,\n \"--duration\": `${ready ? duration : 0}s`,\n \"--loop-count\": iterations || \"infinite\",\n },\n \"aria-keyshortcuts\": \"Space\",\n \"aria-live\": \"off\",\n \"aria-roledescription\": \"marquee\",\n role: \"region\",\n tabIndex: 0,\n },\n rest,\n props,\n {\n ref: rootRef,\n \"data-complete\": dataAttr(completed),\n \"data-end\": dataAttr(direction === \"end\"),\n \"data-orientation\": orientation,\n \"data-pause-on-focus\": dataAttr(pauseOnFocus),\n \"data-pause-on-hover\": dataAttr(pauseOnHover),\n \"data-paused\": dataAttr(animationPaused),\n \"data-start\": dataAttr(direction === \"start\"),\n dir,\n onBlurCapture: (ev: FocusEvent<HTMLDivElement>) => {\n if (ev.currentTarget.contains(ev.relatedTarget)) return\n\n setFocused(false)\n\n if (!pauseOnFocus) return\n\n ev.currentTarget.scrollLeft = 0\n ev.currentTarget.scrollTop = 0\n },\n onFocusCapture: () => setFocused(true),\n onKeyDown: (ev: KeyboardEvent<HTMLDivElement>) => {\n if (\n ev.target !== ev.currentTarget ||\n ev.key !== \" \" ||\n ev.altKey ||\n ev.ctrlKey ||\n ev.metaKey ||\n ev.repeat\n )\n return\n\n ev.preventDefault()\n togglePause()\n },\n onMouseEnter: () => setHovered(true),\n onMouseLeave: () => setHovered(false),\n },\n )(),\n [\n rest,\n direction,\n orientation,\n pauseOnFocus,\n pauseOnHover,\n animationPaused,\n completed,\n ready,\n dir,\n duration,\n animationDirection,\n delay,\n iterations,\n size.content,\n togglePause,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps(props, {\n ref: trackRef,\n \"data-marquee-content\": \"\",\n \"data-orientation\": orientation,\n \"data-ready\": dataAttr(ready),\n onAnimationEnd: (ev: AnimationEvent<HTMLDivElement>) => {\n if (ev.target !== ev.currentTarget || !iterations) return\n\n setCompleted(true)\n onComplete()\n },\n onAnimationIteration: (ev: AnimationEvent<HTMLDivElement>) => {\n if (ev.target === ev.currentTarget) onLoopComplete()\n },\n })(),\n [orientation, ready, iterations, onComplete, onLoopComplete],\n )\n\n const getEdgeProps: PropGetter<\"div\", { direction?: SimpleDirection }> =\n useCallback(\n ({ direction = \"start\", ...props } = {}) =>\n mergeProps(props, {\n \"aria-hidden\": true,\n \"data-end\": dataAttr(direction === \"end\"),\n \"data-orientation\": orientation,\n \"data-start\": dataAttr(direction === \"start\"),\n dir,\n inert: true,\n })(),\n [dir, orientation],\n )\n\n const getGroupProps: PropGetter<\"div\", { index?: number }> = useCallback(\n ({ id, ref, index = 0, ...props } = {}) =>\n mergeProps({ style: { \"--index\": index } }, props, {\n id: index ? undefined : id,\n ref: index ? undefined : mergeRefs(ref, contentRef),\n \"aria-hidden\": index ? true : undefined,\n \"data-clone\": dataAttr(!!index),\n \"data-orientation\": orientation,\n inert: index ? true : undefined,\n })(),\n [orientation],\n )\n\n return {\n control,\n copies,\n getContentProps,\n getEdgeProps,\n getGroupProps,\n getRootProps,\n }\n}\n\nexport type UseMarqueeReturn = ReturnType<typeof useMarquee>\n"],"mappings":";;;;;;;;;AAyIA,MAAM,CAAC,gBAAgB,qBAAqBA,gBAA8B,EACxE,MAAM,iBACR,CAAC;AAID,SAAgB,WAAW,EACzB,YACA,gBAAgB,OAChB,QAAQ,GACR,KAAK,SACL,YAAY,SACZ,UAAU,cACV,YAAY,GACZ,cAAc,cACd,QAAQ,YACR,eAAe,OACf,eAAe,OACf,UAAU,OACV,QAAQ,IACR,YAAY,gBACZ,gBAAgB,oBAChB,eACA,GAAG,SACgB,CAAC,GAAG;CACvB,MAAM,EAAE,KAAK,eAAe,QAAQ;CACpC,MAAM,MAAM,WAAW;CACvB,MAAM,WAAW,gBAAgB;CACjC,MAAM,UAAU,OAAuB,IAAI;CAC3C,MAAM,aAAa,OAAuB,IAAI;CAC9C,MAAM,WAAW,OAAuB,IAAI;CAC5C,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,CAAC,QAAQ,aAAa,qBAAqB;EAC/C,cAAc;EACd,OAAO;EACP,UAAU;CACZ,CAAC;CACD,MAAM,aAAa,eAAe,cAAc;CA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AK;GAC9B,oBAAoB;GACpB,OAAO,QAAQ,OAAO,KAAA;EACxB,CAAC,CAAC,CAAC,GACL,CAAC,WAAW,CAQA;EACZ;CACF;AACF"}
|
|
@@ -2,7 +2,7 @@ import { ComponentSlotStyle } from "../../core/system/index.type.js";
|
|
|
2
2
|
import { CSSModifierObject, CSSPropObject, CSSSlotObject } from "../../core/css/index.type.js";
|
|
3
3
|
import "../../index.js";
|
|
4
4
|
//#region src/components/chart/polar-chart.style.d.ts
|
|
5
|
-
export declare const polarChartStyle: ComponentSlotStyle<"label" | "grid" | "dot" | "root" | "labelList" | "activeDot" | "
|
|
5
|
+
export declare const polarChartStyle: ComponentSlotStyle<"label" | "grid" | "dot" | "root" | "labelList" | "activeDot" | "radial" | "labelLine" | "angleAxis" | "angleAxisLabel" | "angleAxisLine" | "angleAxisTick" | "angleAxisTickLine" | "pie" | "radar" | "radialBackground" | "radiusAxis" | "radiusAxisLabel" | "radiusAxisLine" | "radiusAxisTick" | "radiusAxisTickLine" | "sector", CSSPropObject<CSSSlotObject<"label" | "grid" | "dot" | "root" | "labelList" | "activeDot" | "radial" | "labelLine" | "angleAxis" | "angleAxisLabel" | "angleAxisLine" | "angleAxisTick" | "angleAxisTickLine" | "pie" | "radar" | "radialBackground" | "radiusAxis" | "radiusAxisLabel" | "radiusAxisLine" | "radiusAxisTick" | "radiusAxisTickLine" | "sector">>, CSSModifierObject<CSSSlotObject<"label" | "grid" | "dot" | "root" | "labelList" | "activeDot" | "radial" | "labelLine" | "angleAxis" | "angleAxisLabel" | "angleAxisLine" | "angleAxisTick" | "angleAxisTickLine" | "pie" | "radar" | "radialBackground" | "radiusAxis" | "radiusAxisLabel" | "radiusAxisLine" | "radiusAxisTick" | "radiusAxisTickLine" | "sector">>, CSSModifierObject<CSSSlotObject<"label" | "grid" | "dot" | "root" | "labelList" | "activeDot" | "radial" | "labelLine" | "angleAxis" | "angleAxisLabel" | "angleAxisLine" | "angleAxisTick" | "angleAxisTickLine" | "pie" | "radar" | "radialBackground" | "radiusAxis" | "radiusAxisLabel" | "radiusAxisLine" | "radiusAxisTick" | "radiusAxisTickLine" | "sector">>>;
|
|
6
6
|
export type PolarChartStyle = typeof polarChartStyle;
|
|
7
7
|
//#endregion
|
|
8
8
|
//# sourceMappingURL=polar-chart.style.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yamada-ui/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.3.0-dev-
|
|
4
|
+
"version": "2.3.0-dev-20261027072316",
|
|
5
5
|
"description": "React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"yamada",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"@emotion/utils": "^1.4.2",
|
|
127
127
|
"@floating-ui/react-dom": "^2.1.9",
|
|
128
128
|
"@tanstack/react-table": "^8.21.3",
|
|
129
|
-
"@yamada-ui/utils": "2.
|
|
129
|
+
"@yamada-ui/utils": "2.2.0-dev-20261027072316",
|
|
130
130
|
"copy-to-clipboard": "3.3.3",
|
|
131
131
|
"csstype": "^3.2.3",
|
|
132
132
|
"dayjs": "^1.11.23",
|