@conveyorhq/arrow-ds 1.151.0 → 1.152.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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@conveyorhq/arrow-ds",
3
3
  "author": "Conveyor",
4
4
  "license": "MIT",
5
- "version": "1.151.0",
5
+ "version": "1.152.0",
6
6
  "description": "Arrow Design System",
7
7
  "repository": "https://github.com/conveyor/arrow-ds",
8
8
  "publishConfig": {
@@ -0,0 +1,21 @@
1
+ import React, { ReactNode, CSSProperties, RefAttributes } from "react";
2
+ export type MarqueeProps = {
3
+ style?: CSSProperties;
4
+ className?: string;
5
+ autoFill?: boolean;
6
+ play?: boolean;
7
+ pauseOnHover?: boolean;
8
+ pauseOnClick?: boolean;
9
+ direction?: "left" | "right" | "up" | "down";
10
+ speed?: number;
11
+ delay?: number;
12
+ loop?: number;
13
+ gradient?: boolean;
14
+ gradientColor?: string;
15
+ gradientWidth?: number | string;
16
+ onFinish?: () => void;
17
+ onCycleComplete?: () => void;
18
+ onMount?: () => void;
19
+ children?: ReactNode;
20
+ } & RefAttributes<HTMLDivElement>;
21
+ export declare const Marquee: React.ForwardRefExoticComponent<Omit<MarqueeProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.Marquee = void 0;
30
+ const react_1 = __importStar(require("react"));
31
+ const classnames_1 = __importDefault(require("classnames"));
32
+ const utilities_1 = require("../../utilities");
33
+ const Box_1 = require("../Box");
34
+ const cn = (0, utilities_1.bemHOF)("Marquee");
35
+ const MarqueeChild = ({ children, style, }) => {
36
+ return (react_1.default.createElement(Box_1.Box, { className: cn({ e: "child" }), style: style }, children));
37
+ };
38
+ const MarqueeContent = ({ children, ...props }) => {
39
+ return (react_1.default.createElement(Box_1.Box, { className: cn({ e: "content" }), ...props }, children));
40
+ };
41
+ const MarqueeGradient = ({ style }) => {
42
+ return react_1.default.createElement(Box_1.Box, { className: cn({ e: "overlay" }), style: style });
43
+ };
44
+ exports.Marquee = (0, react_1.forwardRef)(function Marquee({ style = {}, className = "", autoFill = false, play = true, pauseOnHover = false, pauseOnClick = false, direction = "left", speed = 50, delay = 0, loop = 0, gradient = false, gradientColor = "white", gradientWidth = 200, onFinish, onCycleComplete, onMount, children, }, ref) {
45
+ const [containerWidth, setContainerWidth] = (0, react_1.useState)(0);
46
+ const [marqueeWidth, setMarqueeWidth] = (0, react_1.useState)(0);
47
+ const [multiplier, setMultiplier] = (0, react_1.useState)(1);
48
+ const [isMounted, setIsMounted] = (0, react_1.useState)(false);
49
+ const rootRef = (0, react_1.useRef)(null);
50
+ const containerRef = ref || rootRef;
51
+ const childrenRef = (0, react_1.useRef)(null);
52
+ const calculateWidth = (0, react_1.useCallback)(() => {
53
+ if (childrenRef.current && containerRef.current) {
54
+ const containerRect = containerRef.current.getBoundingClientRect();
55
+ const marqueeRect = childrenRef.current.getBoundingClientRect();
56
+ let containerRectWidth = containerRect.width;
57
+ let marqueeRectWidth = marqueeRect.width;
58
+ if (direction === "up" || direction === "down") {
59
+ containerRectWidth = containerRect.height;
60
+ marqueeRectWidth = marqueeRect.height;
61
+ }
62
+ if (autoFill && containerRectWidth && marqueeRectWidth) {
63
+ setMultiplier(marqueeRectWidth < containerRectWidth
64
+ ? Math.ceil(containerRectWidth / marqueeRectWidth)
65
+ : 1);
66
+ }
67
+ else {
68
+ setMultiplier(1);
69
+ }
70
+ setContainerWidth(containerRectWidth);
71
+ setMarqueeWidth(marqueeRectWidth);
72
+ }
73
+ }, [autoFill, containerRef, direction]);
74
+ (0, react_1.useEffect)(() => {
75
+ if (!isMounted)
76
+ return;
77
+ calculateWidth();
78
+ if (childrenRef.current && containerRef.current) {
79
+ const resizeObserver = new ResizeObserver(() => calculateWidth());
80
+ resizeObserver.observe(containerRef.current);
81
+ resizeObserver.observe(childrenRef.current);
82
+ return () => {
83
+ if (!resizeObserver)
84
+ return;
85
+ resizeObserver.disconnect();
86
+ };
87
+ }
88
+ }, [calculateWidth, containerRef, isMounted]);
89
+ (0, react_1.useEffect)(() => {
90
+ calculateWidth();
91
+ }, [calculateWidth, children]);
92
+ (0, react_1.useEffect)(() => {
93
+ setIsMounted(true);
94
+ }, []);
95
+ (0, react_1.useEffect)(() => {
96
+ if (typeof onMount === "function") {
97
+ onMount();
98
+ }
99
+ }, [onMount]);
100
+ const duration = (0, react_1.useMemo)(() => {
101
+ if (autoFill) {
102
+ return (marqueeWidth * multiplier) / speed;
103
+ }
104
+ return marqueeWidth < containerWidth
105
+ ? containerWidth / speed
106
+ : marqueeWidth / speed;
107
+ }, [autoFill, containerWidth, marqueeWidth, multiplier, speed]);
108
+ const rootStyle = (0, react_1.useMemo)(() => ({
109
+ ...style,
110
+ ["--ads-marquee-pause-on-hover"]: !play || pauseOnHover ? "paused" : "running",
111
+ ["--ads-marquee-pause-on-click"]: !play || (pauseOnHover && !pauseOnClick) || pauseOnClick
112
+ ? "paused"
113
+ : "running",
114
+ ["--ads-marquee-width"]: direction === "up" || direction === "down" ? `100vh` : "100%",
115
+ ["--ads-marquee-transform"]: direction === "up"
116
+ ? "rotate(-90deg)"
117
+ : direction === "down"
118
+ ? "rotate(90deg)"
119
+ : "none",
120
+ }), [style, play, pauseOnHover, pauseOnClick, direction]);
121
+ const gradientStyle = (0, react_1.useMemo)(() => ({
122
+ ["--ads-marquee-gradient-color"]: gradientColor,
123
+ ["--ads-marquee-gradient-width"]: typeof gradientWidth === "number"
124
+ ? `${gradientWidth}px`
125
+ : gradientWidth,
126
+ }), [gradientColor, gradientWidth]);
127
+ const contentStyle = (0, react_1.useMemo)(() => ({
128
+ ["--ads-marquee-play"]: play ? "running" : "paused",
129
+ ["--ads-marquee-direction"]: direction === "left" ? "normal" : "reverse",
130
+ ["--ads-marquee-duration"]: `${duration}s`,
131
+ ["--ads-marquee-delay"]: `${delay}s`,
132
+ ["--ads-marquee-iteration-count"]: loop !== 0 ? `${loop}` : "infinite",
133
+ ["--ads-marquee-min-width"]: autoFill ? `auto` : "100%",
134
+ }), [play, direction, duration, delay, loop, autoFill]);
135
+ const childStyle = (0, react_1.useMemo)(() => ({
136
+ ["--ads-marquee-transform"]: direction === "up"
137
+ ? "rotate(90deg)"
138
+ : direction === "down"
139
+ ? "rotate(-90deg)"
140
+ : "none",
141
+ }), [direction]);
142
+ const multiplyChildren = (0, react_1.useCallback)((childrenMultiplier) => {
143
+ return [
144
+ ...Array(Number.isFinite(childrenMultiplier) && childrenMultiplier >= 0
145
+ ? childrenMultiplier
146
+ : 0),
147
+ ].map((_, i) => (react_1.default.createElement(react_1.Fragment, { key: i }, react_1.Children.map(children, (child) => {
148
+ return react_1.default.createElement(MarqueeChild, { style: childStyle }, child);
149
+ }))));
150
+ }, [childStyle, children]);
151
+ return !isMounted ? null : (react_1.default.createElement(Box_1.Box, { ref: containerRef, className: (0, classnames_1.default)(cn(), className), style: rootStyle },
152
+ gradient && react_1.default.createElement(MarqueeGradient, { style: gradientStyle }),
153
+ react_1.default.createElement(MarqueeContent, { onAnimationIteration: onCycleComplete, onAnimationEnd: onFinish, style: contentStyle },
154
+ react_1.default.createElement(Box_1.Box, { ref: childrenRef, className: cn({ e: "children" }) }, react_1.Children.map(children, (child) => {
155
+ return react_1.default.createElement(MarqueeChild, { style: childStyle }, child);
156
+ })),
157
+ multiplyChildren(multiplier - 1)),
158
+ react_1.default.createElement(MarqueeContent, { style: contentStyle }, multiplyChildren(multiplier))));
159
+ });
@@ -0,0 +1 @@
1
+ export * from "./Marquee";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Marquee"), exports);
@@ -4757,6 +4757,98 @@ override built-in Image component classes */
4757
4757
  border-color: rgb(222 231 238 / var(--tw-border-opacity));
4758
4758
  }
4759
4759
 
4760
+ .ads-Marquee {
4761
+ position: relative;
4762
+ display: flex;
4763
+ flex-direction: row;
4764
+ overflow-x: hidden;
4765
+
4766
+ width: var(--ads-marquee-width);
4767
+ -webkit-transform: var(--ads-marquee-transform);
4768
+ transform: var(--ads-marquee-transform);
4769
+ }
4770
+
4771
+ .ads-Marquee:hover div {
4772
+ -webkit-animation-play-state: var(--ads-marquee-pause-on-hover);
4773
+ animation-play-state: var(--ads-marquee-pause-on-hover);
4774
+ }
4775
+
4776
+ .ads-Marquee:active div {
4777
+ -webkit-animation-play-state: var(--ads-marquee-pause-on-click);
4778
+ animation-play-state: var(--ads-marquee-pause-on-click);
4779
+ }
4780
+
4781
+ .ads-Marquee-overlay {
4782
+ position: absolute;
4783
+ height: 100%;
4784
+ width: 100%;
4785
+ }
4786
+
4787
+ .ads-Marquee-overlay::before,
4788
+ .ads-Marquee-overlay::after {
4789
+ pointer-events: none;
4790
+ position: absolute;
4791
+ height: 100%;
4792
+ touch-action: none;
4793
+
4794
+ background: linear-gradient(
4795
+ to right,
4796
+ var(--ads-marquee-gradient-color),
4797
+ rgb(255, 255, 255, 0)
4798
+ );
4799
+ content: "";
4800
+ width: var(--ads-marquee-gradient-width);
4801
+ z-index: 2;
4802
+ }
4803
+
4804
+ .ads-Marquee-overlay::after {
4805
+ right: 0;
4806
+ top: 0;
4807
+
4808
+ -webkit-transform: rotateZ(180deg);
4809
+
4810
+ transform: rotateZ(180deg);
4811
+ }
4812
+
4813
+ .ads-Marquee-overlay::before {
4814
+ left: 0;
4815
+ top: 0;
4816
+ }
4817
+
4818
+ .ads-Marquee-content {
4819
+ z-index: 1;
4820
+ display: flex;
4821
+ flex-direction: row;
4822
+ align-items: center;
4823
+
4824
+ flex: 0 0 auto;
4825
+ min-width: var(--ads-marquee-min-width);
4826
+ -webkit-animation: marquee-scroll var(--ads-marquee-duration) linear
4827
+ var(--ads-marquee-delay) var(--ads-marquee-iteration-count);
4828
+ animation: marquee-scroll var(--ads-marquee-duration) linear
4829
+ var(--ads-marquee-delay) var(--ads-marquee-iteration-count);
4830
+ -webkit-animation-play-state: var(--ads-marquee-play);
4831
+ animation-play-state: var(--ads-marquee-play);
4832
+ -webkit-animation-delay: var(--ads-marquee-delay);
4833
+ animation-delay: var(--ads-marquee-delay);
4834
+ -webkit-animation-direction: var(--ads-marquee-direction);
4835
+ animation-direction: var(--ads-marquee-direction);
4836
+ }
4837
+
4838
+ .ads-Marquee-children {
4839
+ display: flex;
4840
+ min-width: auto;
4841
+ flex-direction: row;
4842
+ align-items: center;
4843
+
4844
+ flex: 0 0 auto;
4845
+ }
4846
+
4847
+ .ads-Marquee-child {
4848
+ -webkit-transform: var(--ads-marquee-transform);
4849
+ transform: var(--ads-marquee-transform);
4850
+ }
4851
+
4760
4852
  .ads-Menu {
4761
4853
  display: inline-flex;
4762
4854
  }
@@ -9085,6 +9177,28 @@ override built-in Image component classes */
9085
9177
  }
9086
9178
  }
9087
9179
 
9180
+ @-webkit-keyframes marquee-scroll {
9181
+ 0% {
9182
+ -webkit-transform: translateX(0%);
9183
+ transform: translateX(0%);
9184
+ }
9185
+ 100% {
9186
+ -webkit-transform: translateX(-100%);
9187
+ transform: translateX(-100%);
9188
+ }
9189
+ }
9190
+
9191
+ @keyframes marquee-scroll {
9192
+ 0% {
9193
+ -webkit-transform: translateX(0%);
9194
+ transform: translateX(0%);
9195
+ }
9196
+ 100% {
9197
+ -webkit-transform: translateX(-100%);
9198
+ transform: translateX(-100%);
9199
+ }
9200
+ }
9201
+
9088
9202
  .animated {
9089
9203
  -webkit-animation-duration: 500ms;
9090
9204
  animation-duration: 500ms;