@auth0/quantum-product 2.9.7 → 2.10.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/esm/floating-bar/floating-bar-actions.js +34 -0
- package/esm/floating-bar/floating-bar-context.js +13 -0
- package/esm/floating-bar/floating-bar-description.js +24 -0
- package/esm/floating-bar/floating-bar-icon.js +32 -0
- package/esm/floating-bar/floating-bar-scroll.js +68 -0
- package/esm/floating-bar/floating-bar.js +206 -0
- package/esm/floating-bar/index.js +6 -0
- package/esm/index.js +1 -0
- package/esm/panel/panel/panel.js +155 -8
- package/esm/panel/panel-context.js +1 -0
- package/floating-bar/floating-bar-actions.d.ts +12 -0
- package/floating-bar/floating-bar-actions.js +70 -0
- package/floating-bar/floating-bar-context.d.ts +11 -0
- package/floating-bar/floating-bar-context.js +52 -0
- package/floating-bar/floating-bar-description.d.ts +12 -0
- package/floating-bar/floating-bar-description.js +60 -0
- package/floating-bar/floating-bar-icon.d.ts +12 -0
- package/floating-bar/floating-bar-icon.js +68 -0
- package/floating-bar/floating-bar-scroll.d.ts +11 -0
- package/floating-bar/floating-bar-scroll.js +104 -0
- package/floating-bar/floating-bar.d.ts +17 -0
- package/floating-bar/floating-bar.js +242 -0
- package/floating-bar/index.d.ts +12 -0
- package/floating-bar/index.js +17 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/panel/panel/panel.d.ts +21 -3
- package/panel/panel/panel.js +155 -8
- package/panel/panel-context.d.ts +2 -0
- package/panel/panel-context.js +1 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import * as React from 'react';
|
|
13
|
+
import { styled } from '../styled';
|
|
14
|
+
import { useFloatingBarOrientation } from './floating-bar-context';
|
|
15
|
+
export var floatingBarActionsComponentName = 'QuantumFloatingBarActions';
|
|
16
|
+
var Root = styled('div', {
|
|
17
|
+
name: floatingBarActionsComponentName,
|
|
18
|
+
slot: 'Root',
|
|
19
|
+
})(function (_a) {
|
|
20
|
+
var theme = _a.theme, ownerState = _a.ownerState;
|
|
21
|
+
return ({
|
|
22
|
+
display: 'flex',
|
|
23
|
+
gap: theme.spacing(1),
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
justifyContent: ownerState.orientation === 'vertical' ? 'flex-end' : 'flex-start',
|
|
26
|
+
marginLeft: ownerState.orientation === 'horizontal' ? 'auto' : 0,
|
|
27
|
+
width: ownerState.orientation === 'vertical' ? '100%' : 'auto',
|
|
28
|
+
flexShrink: 0,
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
export var FloatingBarActions = React.forwardRef(function FloatingBarActions(props, ref) {
|
|
32
|
+
var orientation = useFloatingBarOrientation();
|
|
33
|
+
return React.createElement(Root, __assign({ ref: ref, ownerState: { orientation: orientation } }, props));
|
|
34
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export var FloatingBarOrientationContext = React.createContext('horizontal');
|
|
3
|
+
export var FloatingBarScrollProgressContext = React.createContext(0);
|
|
4
|
+
export var useFloatingBarOrientation = function () { return React.useContext(FloatingBarOrientationContext); };
|
|
5
|
+
export var useFloatingBarScrollProgress = function () { return React.useContext(FloatingBarScrollProgressContext); };
|
|
6
|
+
export var useFloatingBarContext = function () {
|
|
7
|
+
var orientation = useFloatingBarOrientation();
|
|
8
|
+
var scrollProgress = useFloatingBarScrollProgress();
|
|
9
|
+
return React.useMemo(function () { return ({
|
|
10
|
+
orientation: orientation,
|
|
11
|
+
scrollProgress: scrollProgress,
|
|
12
|
+
}); }, [orientation, scrollProgress]);
|
|
13
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import * as React from 'react';
|
|
13
|
+
import { styled } from '../styled';
|
|
14
|
+
export var floatingBarDescriptionComponentName = 'QuantumFloatingBarDescription';
|
|
15
|
+
var Root = styled('div', {
|
|
16
|
+
name: floatingBarDescriptionComponentName,
|
|
17
|
+
slot: 'Root',
|
|
18
|
+
})(function (_a) {
|
|
19
|
+
var theme = _a.theme;
|
|
20
|
+
return (__assign(__assign({}, theme.typography.body2), { color: theme.tokens.color_fg_default, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', flex: 1, minWidth: 0, padding: theme.spacing(0, 0.5) }));
|
|
21
|
+
});
|
|
22
|
+
export var FloatingBarDescription = React.forwardRef(function FloatingBarDescription(props, ref) {
|
|
23
|
+
return React.createElement(Root, __assign({ ref: ref }, props));
|
|
24
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import * as React from 'react';
|
|
13
|
+
import { styled } from '../styled';
|
|
14
|
+
export var floatingBarIconComponentName = 'QuantumFloatingBarIcon';
|
|
15
|
+
var Root = styled('div', {
|
|
16
|
+
name: floatingBarIconComponentName,
|
|
17
|
+
slot: 'Root',
|
|
18
|
+
})(function (_a) {
|
|
19
|
+
var theme = _a.theme;
|
|
20
|
+
return ({
|
|
21
|
+
display: 'flex',
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
justifyContent: 'center',
|
|
24
|
+
color: theme.palette.text.secondary,
|
|
25
|
+
flexShrink: 0,
|
|
26
|
+
height: 24,
|
|
27
|
+
width: 24,
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
export var FloatingBarIcon = React.forwardRef(function FloatingBarIcon(props, ref) {
|
|
31
|
+
return React.createElement(Root, __assign({ ref: ref }, props));
|
|
32
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import * as React from 'react';
|
|
24
|
+
import { styled } from '../styled';
|
|
25
|
+
import { useFloatingBarScrollProgress } from './floating-bar-context';
|
|
26
|
+
export var floatingBarScrollComponentName = 'QuantumFloatingBarScroll';
|
|
27
|
+
var Root = styled('div', {
|
|
28
|
+
name: floatingBarScrollComponentName,
|
|
29
|
+
slot: 'Root',
|
|
30
|
+
})(function (_a) {
|
|
31
|
+
var ownerState = _a.ownerState;
|
|
32
|
+
return ({
|
|
33
|
+
display: 'flex',
|
|
34
|
+
alignItems: 'center',
|
|
35
|
+
justifyContent: 'center',
|
|
36
|
+
flexShrink: 0,
|
|
37
|
+
width: ownerState.variant === 'compact' ? 16 : 20,
|
|
38
|
+
height: ownerState.variant === 'compact' ? 16 : 20,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
export var FloatingBarScroll = React.forwardRef(function FloatingBarScroll(inProps, ref) {
|
|
42
|
+
var scrollProgress = useFloatingBarScrollProgress();
|
|
43
|
+
var _a = inProps.variant, variant = _a === void 0 ? 'default' : _a, other = __rest(inProps, ["variant"]);
|
|
44
|
+
var ownerState = {
|
|
45
|
+
variant: variant,
|
|
46
|
+
};
|
|
47
|
+
var size = variant === 'compact' ? 16 : 20;
|
|
48
|
+
var strokeWidth = 2;
|
|
49
|
+
var radius = (size - strokeWidth) / 2;
|
|
50
|
+
var circumference = 2 * Math.PI * radius;
|
|
51
|
+
var progressOffset = circumference - (scrollProgress / 100) * circumference;
|
|
52
|
+
var dottedStrokeDasharray = '0 3.75';
|
|
53
|
+
var ringDasharray = variant === 'dots' ? dottedStrokeDasharray : "".concat(circumference);
|
|
54
|
+
var circleProps = {
|
|
55
|
+
cx: size / 2,
|
|
56
|
+
cy: size / 2,
|
|
57
|
+
r: radius,
|
|
58
|
+
fill: 'none',
|
|
59
|
+
stroke: 'currentColor',
|
|
60
|
+
strokeWidth: strokeWidth,
|
|
61
|
+
};
|
|
62
|
+
return (React.createElement(Root, __assign({ ref: ref, ownerState: ownerState }, other),
|
|
63
|
+
React.createElement("svg", { width: size, height: size, style: { transform: 'rotate(-90deg)' } },
|
|
64
|
+
React.createElement("circle", __assign({}, circleProps, { opacity: 0.2, strokeDasharray: ringDasharray, strokeLinecap: "round" })),
|
|
65
|
+
React.createElement("circle", __assign({}, circleProps, { strokeDasharray: circumference, strokeDashoffset: progressOffset, strokeLinecap: "round", style: {
|
|
66
|
+
transition: 'stroke-dashoffset 150ms ease-out',
|
|
67
|
+
} })))));
|
|
68
|
+
});
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
24
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
25
|
+
if (!m) return o;
|
|
26
|
+
var i = m.call(o), r, ar = [], e;
|
|
27
|
+
try {
|
|
28
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
29
|
+
}
|
|
30
|
+
catch (error) { e = { error: error }; }
|
|
31
|
+
finally {
|
|
32
|
+
try {
|
|
33
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
34
|
+
}
|
|
35
|
+
finally { if (e) throw e.error; }
|
|
36
|
+
}
|
|
37
|
+
return ar;
|
|
38
|
+
};
|
|
39
|
+
import * as React from 'react';
|
|
40
|
+
import { useEffect, useRef, useState } from 'react';
|
|
41
|
+
import { rootShouldForwardProp, styled } from '../styled';
|
|
42
|
+
import { FloatingBarOrientationContext, FloatingBarScrollProgressContext } from './floating-bar-context';
|
|
43
|
+
export var floatingBarComponentName = 'QuantumFloatingBar';
|
|
44
|
+
var sizeMap = {
|
|
45
|
+
small: 256,
|
|
46
|
+
medium: 384,
|
|
47
|
+
large: 512,
|
|
48
|
+
};
|
|
49
|
+
var ENTER_TRANSITION_DURATION_MS = 300;
|
|
50
|
+
var EXIT_TRANSITION_DURATION_MS = 150;
|
|
51
|
+
var EASING = 'cubic-bezier(0.19, 1, 0.22, 1)';
|
|
52
|
+
var TRANSFORM_SCALE = 0.95;
|
|
53
|
+
var TRANSFORM_DISTANCE_PX = 20;
|
|
54
|
+
var SCROLL_PROGRESS_STEP = 0.5;
|
|
55
|
+
var quantizeScrollProgress = function (progress) {
|
|
56
|
+
var clampedProgress = Math.min(100, Math.max(0, progress));
|
|
57
|
+
var snapThreshold = SCROLL_PROGRESS_STEP / 2;
|
|
58
|
+
if (clampedProgress <= snapThreshold) {
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
if (clampedProgress >= 100 - snapThreshold) {
|
|
62
|
+
return 100;
|
|
63
|
+
}
|
|
64
|
+
var quantizedProgress = Math.round(clampedProgress / SCROLL_PROGRESS_STEP) * SCROLL_PROGRESS_STEP;
|
|
65
|
+
return Number(quantizedProgress.toFixed(2));
|
|
66
|
+
};
|
|
67
|
+
var resolveSide = function (orientation, side) {
|
|
68
|
+
if (orientation === 'vertical') {
|
|
69
|
+
return side === 'left' || side === 'right' ? side : 'right';
|
|
70
|
+
}
|
|
71
|
+
return side === 'top' || side === 'bottom' ? side : 'bottom';
|
|
72
|
+
};
|
|
73
|
+
var getTransforms = function (orientation, resolvedSide) {
|
|
74
|
+
if (orientation === 'vertical') {
|
|
75
|
+
return {
|
|
76
|
+
restingTransform: 'translateY(-50%) scale(1)',
|
|
77
|
+
exitingTransform: resolvedSide === 'left'
|
|
78
|
+
? "translateY(-50%) translateX(-".concat(TRANSFORM_DISTANCE_PX, "px) scale(").concat(TRANSFORM_SCALE, ")")
|
|
79
|
+
: "translateY(-50%) translateX(".concat(TRANSFORM_DISTANCE_PX, "px) scale(").concat(TRANSFORM_SCALE, ")"),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
restingTransform: 'translateX(-50%) scale(1)',
|
|
84
|
+
exitingTransform: resolvedSide === 'top'
|
|
85
|
+
? "translateX(-50%) translateY(-".concat(TRANSFORM_DISTANCE_PX, "px) scale(").concat(TRANSFORM_SCALE, ")")
|
|
86
|
+
: "translateX(-50%) translateY(".concat(TRANSFORM_DISTANCE_PX, "px) scale(").concat(TRANSFORM_SCALE, ")"),
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
var Root = styled('div', {
|
|
90
|
+
name: floatingBarComponentName,
|
|
91
|
+
slot: 'Root',
|
|
92
|
+
shouldForwardProp: function (prop) { return rootShouldForwardProp(prop) && prop !== 'ownerState'; },
|
|
93
|
+
})(function (_a) {
|
|
94
|
+
var _b;
|
|
95
|
+
var theme = _a.theme, ownerState = _a.ownerState;
|
|
96
|
+
var orientation = ownerState.orientation || 'horizontal';
|
|
97
|
+
var resolvedSide = resolveSide(orientation, ownerState.side);
|
|
98
|
+
var size = ownerState.size || 'medium';
|
|
99
|
+
var _c = getTransforms(orientation, resolvedSide), restingTransform = _c.restingTransform, exitingTransform = _c.exitingTransform;
|
|
100
|
+
var isTransitioning = !!ownerState.exiting || !!ownerState.entering;
|
|
101
|
+
return __assign(__assign({ position: 'fixed' }, (orientation === 'vertical' ? { top: '50%' } : { left: '50%' })), (_b = {}, _b[resolvedSide] = theme.spacing(3), _b.transform = isTransitioning ? exitingTransform : restingTransform, _b.opacity = isTransitioning ? 0 : 1, _b.transition = ownerState.exiting
|
|
102
|
+
? "opacity ".concat(EXIT_TRANSITION_DURATION_MS, "ms ").concat(EASING, ", transform ").concat(EXIT_TRANSITION_DURATION_MS, "ms ").concat(EASING)
|
|
103
|
+
: "opacity ".concat(ENTER_TRANSITION_DURATION_MS, "ms ").concat(EASING, ", transform ").concat(ENTER_TRANSITION_DURATION_MS, "ms ").concat(EASING), _b.zIndex = theme.zIndex.fab, _b.display = 'flex', _b.flexDirection = orientation === 'vertical' ? 'column' : 'row', _b.alignItems = orientation === 'vertical' ? 'stretch' : 'center', _b.gap = orientation === 'vertical' ? theme.spacing(0.75) : theme.spacing(1), _b.padding = theme.spacing(1.125), _b.minWidth = sizeMap[size], _b.maxWidth = "min(".concat(sizeMap[size], "px, calc(100vw - ").concat(theme.spacing(4), "))"), _b.boxSizing = 'border-box', _b.backgroundColor = theme.palette.background.paper, _b.border = "1px solid ".concat(theme.tokens.color_border_default), _b.borderRadius = theme.spacing(1.25), _b.overflow = 'hidden', _b.boxShadow = theme.shadows[16], _b));
|
|
104
|
+
});
|
|
105
|
+
export var FloatingBar = React.forwardRef(function FloatingBar(inProps, ref) {
|
|
106
|
+
var _a = inProps.trackScroll, trackScroll = _a === void 0 ? false : _a, containerRef = inProps.containerRef, _b = inProps.open, open = _b === void 0 ? true : _b, side = inProps.side, _c = inProps.orientation, orientation = _c === void 0 ? 'horizontal' : _c, _d = inProps.size, size = _d === void 0 ? 'medium' : _d, children = inProps.children, onTransitionEnd = inProps.onTransitionEnd, other = __rest(inProps, ["trackScroll", "containerRef", "open", "side", "orientation", "size", "children", "onTransitionEnd"]);
|
|
107
|
+
var _e = __read(useState(0), 2), scrollProgress = _e[0], setScrollProgress = _e[1];
|
|
108
|
+
var _f = __read(useState(open), 2), isMounted = _f[0], setIsMounted = _f[1];
|
|
109
|
+
var _g = __read(useState(false), 2), isExiting = _g[0], setIsExiting = _g[1];
|
|
110
|
+
var _h = __read(useState(open), 2), isEntering = _h[0], setIsEntering = _h[1];
|
|
111
|
+
var scrollFrameIdRef = useRef(null);
|
|
112
|
+
var lastScrollProgressRef = useRef(0);
|
|
113
|
+
var containerElement = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current;
|
|
114
|
+
useEffect(function () {
|
|
115
|
+
if (open) {
|
|
116
|
+
setIsMounted(true);
|
|
117
|
+
setIsExiting(false);
|
|
118
|
+
setIsEntering(true);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (!isMounted) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
setIsEntering(false);
|
|
125
|
+
setIsExiting(true);
|
|
126
|
+
}, [open, isMounted]);
|
|
127
|
+
useEffect(function () {
|
|
128
|
+
if (!(isMounted && isEntering && !isExiting)) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
var frameId = window.requestAnimationFrame(function () {
|
|
132
|
+
setIsEntering(false);
|
|
133
|
+
});
|
|
134
|
+
return function () {
|
|
135
|
+
window.cancelAnimationFrame(frameId);
|
|
136
|
+
};
|
|
137
|
+
}, [isMounted, isEntering, isExiting]);
|
|
138
|
+
useEffect(function () {
|
|
139
|
+
if (!(trackScroll && open))
|
|
140
|
+
return;
|
|
141
|
+
var target = containerElement || window;
|
|
142
|
+
var updateScrollProgress = function () {
|
|
143
|
+
scrollFrameIdRef.current = null;
|
|
144
|
+
var scrollTop;
|
|
145
|
+
var scrollHeight;
|
|
146
|
+
if (target === window) {
|
|
147
|
+
scrollTop = window.scrollY;
|
|
148
|
+
scrollHeight = document.documentElement.scrollHeight - window.innerHeight;
|
|
149
|
+
}
|
|
150
|
+
else if (target instanceof HTMLElement) {
|
|
151
|
+
scrollTop = target.scrollTop;
|
|
152
|
+
scrollHeight = target.scrollHeight - target.clientHeight;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
var progress = scrollHeight > 0 ? (scrollTop / scrollHeight) * 100 : 0;
|
|
158
|
+
var quantizedProgress = quantizeScrollProgress(progress);
|
|
159
|
+
if (quantizedProgress === lastScrollProgressRef.current) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
lastScrollProgressRef.current = quantizedProgress;
|
|
163
|
+
setScrollProgress(quantizedProgress);
|
|
164
|
+
};
|
|
165
|
+
var handleScroll = function () {
|
|
166
|
+
if (scrollFrameIdRef.current !== null) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
scrollFrameIdRef.current = window.requestAnimationFrame(updateScrollProgress);
|
|
170
|
+
};
|
|
171
|
+
target.addEventListener('scroll', handleScroll, { passive: true });
|
|
172
|
+
handleScroll();
|
|
173
|
+
return function () {
|
|
174
|
+
target.removeEventListener('scroll', handleScroll);
|
|
175
|
+
if (scrollFrameIdRef.current !== null) {
|
|
176
|
+
window.cancelAnimationFrame(scrollFrameIdRef.current);
|
|
177
|
+
scrollFrameIdRef.current = null;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}, [trackScroll, open, containerElement]);
|
|
181
|
+
if (!isMounted) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
var handleTransitionEnd = function (event) {
|
|
185
|
+
onTransitionEnd === null || onTransitionEnd === void 0 ? void 0 : onTransitionEnd(event);
|
|
186
|
+
if (!isExiting) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (event.target !== event.currentTarget || event.propertyName !== 'opacity') {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
setIsMounted(false);
|
|
193
|
+
setIsExiting(false);
|
|
194
|
+
setIsEntering(false);
|
|
195
|
+
};
|
|
196
|
+
var ownerState = {
|
|
197
|
+
side: side,
|
|
198
|
+
orientation: orientation,
|
|
199
|
+
size: size,
|
|
200
|
+
exiting: isExiting,
|
|
201
|
+
entering: isEntering,
|
|
202
|
+
};
|
|
203
|
+
return (React.createElement(FloatingBarOrientationContext.Provider, { value: orientation },
|
|
204
|
+
React.createElement(FloatingBarScrollProgressContext.Provider, { value: scrollProgress },
|
|
205
|
+
React.createElement(Root, __assign({ ref: ref, ownerState: ownerState, onTransitionEnd: handleTransitionEnd }, other), children))));
|
|
206
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { FloatingBar } from './floating-bar';
|
|
2
|
+
export { FloatingBarScroll } from './floating-bar-scroll';
|
|
3
|
+
export { FloatingBarIcon } from './floating-bar-icon';
|
|
4
|
+
export { FloatingBarDescription } from './floating-bar-description';
|
|
5
|
+
export { FloatingBarActions } from './floating-bar-actions';
|
|
6
|
+
export { useFloatingBarContext, useFloatingBarOrientation, useFloatingBarScrollProgress } from './floating-bar-context';
|
package/esm/index.js
CHANGED
|
@@ -34,6 +34,7 @@ export * from './dropdown-menu';
|
|
|
34
34
|
export * from './empty-state';
|
|
35
35
|
export * from './expansion-panel';
|
|
36
36
|
export * from './field-set';
|
|
37
|
+
export * from './floating-bar';
|
|
37
38
|
export * from './form';
|
|
38
39
|
export * from './gallery-layout';
|
|
39
40
|
export * from './icon';
|
package/esm/panel/panel/panel.js
CHANGED
|
@@ -20,15 +20,31 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
24
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
25
|
+
if (!m) return o;
|
|
26
|
+
var i = m.call(o), r, ar = [], e;
|
|
27
|
+
try {
|
|
28
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
29
|
+
}
|
|
30
|
+
catch (error) { e = { error: error }; }
|
|
31
|
+
finally {
|
|
32
|
+
try {
|
|
33
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
34
|
+
}
|
|
35
|
+
finally { if (e) throw e.error; }
|
|
36
|
+
}
|
|
37
|
+
return ar;
|
|
38
|
+
};
|
|
23
39
|
import * as React from 'react';
|
|
40
|
+
import { XIcon } from '../../icon';
|
|
41
|
+
import { IconButton } from '../../icon-button';
|
|
24
42
|
import { styled } from '../../styled';
|
|
25
43
|
import { useMergedClasses } from '../../styles/classes';
|
|
26
44
|
import { capitalize, clsx } from '../../utils';
|
|
27
|
-
import { panelClasses, getPanelUtilityClass, panelComponentName } from './panel-classes';
|
|
28
|
-
import { IconButton } from '../../icon-button';
|
|
29
|
-
import { XIcon } from '../../icon';
|
|
30
45
|
import { PanelContext } from '../panel-context';
|
|
31
46
|
import { PanelHeader } from '../panel-header';
|
|
47
|
+
import { getPanelUtilityClass, panelClasses, panelComponentName } from './panel-classes';
|
|
32
48
|
var widthBySize = {
|
|
33
49
|
small: 320,
|
|
34
50
|
medium: 360,
|
|
@@ -40,8 +56,9 @@ var Root = styled('div', {
|
|
|
40
56
|
slot: 'Root',
|
|
41
57
|
})(function (_a) {
|
|
42
58
|
var _b;
|
|
59
|
+
var _c;
|
|
43
60
|
var ownerState = _a.ownerState, theme = _a.theme;
|
|
44
|
-
var width = widthBySize[ownerState.size];
|
|
61
|
+
var width = (_c = ownerState.width) !== null && _c !== void 0 ? _c : widthBySize[ownerState.size];
|
|
45
62
|
var isOpen = ownerState.variant === 'permanent' || ownerState.isOpen;
|
|
46
63
|
var marginProp = ownerState.placement === 'start' ? 'marginRight' : 'marginLeft';
|
|
47
64
|
return __assign({ transition: theme.transitions.create(['margin'], {
|
|
@@ -55,8 +72,9 @@ var Content = styled('div', {
|
|
|
55
72
|
name: panelComponentName,
|
|
56
73
|
slot: 'Content',
|
|
57
74
|
})(function (_a) {
|
|
75
|
+
var _b;
|
|
58
76
|
var ownerState = _a.ownerState, theme = _a.theme;
|
|
59
|
-
var width = widthBySize[ownerState.size];
|
|
77
|
+
var width = (_b = ownerState.width) !== null && _b !== void 0 ? _b : widthBySize[ownerState.size];
|
|
60
78
|
var isOpen = ownerState.variant === 'permanent' || ownerState.isOpen;
|
|
61
79
|
return __assign({ position: ownerState.isFixed ? 'fixed' : 'absolute', zIndex: theme.zIndex.drawer - 1, top: ownerState.offsetTop === 'appbar' ? theme.layout.appTop + theme.layout.appBarHeight : ownerState.offsetTop || 0, bottom: 0, width: width, backgroundColor: ownerState.variant === 'floating' ? theme.tokens.color_bg_layer_elevated : theme.tokens.color_bg_layer, transition: theme.transitions.create(['transform'], {
|
|
62
80
|
duration: isOpen ? theme.transitions.duration.enteringScreen : theme.transitions.duration.leavingScreen,
|
|
@@ -81,11 +99,135 @@ var CloseButton = styled(IconButton, {
|
|
|
81
99
|
slot: 'CloseButton',
|
|
82
100
|
})({
|
|
83
101
|
position: 'absolute',
|
|
84
|
-
top:
|
|
102
|
+
top: 24,
|
|
85
103
|
right: 24,
|
|
86
104
|
});
|
|
105
|
+
var ResizeHandle = styled('div', {
|
|
106
|
+
name: panelComponentName,
|
|
107
|
+
slot: 'ResizeHandle',
|
|
108
|
+
})(function (_a) {
|
|
109
|
+
var ownerState = _a.ownerState, theme = _a.theme;
|
|
110
|
+
return (__assign({ width: '16px', cursor: 'ew-resize', position: 'absolute', top: 0, bottom: 0, zIndex: 1, outline: 'none', transition: theme.transitions.create(['all'], {
|
|
111
|
+
duration: theme.transitions.duration.shortest,
|
|
112
|
+
}) }, (ownerState.placement === 'start'
|
|
113
|
+
? {
|
|
114
|
+
right: -16,
|
|
115
|
+
'&:hover, &:focus, &:focus-visible': {
|
|
116
|
+
boxShadow: "inset 2px 0 0 0 ".concat(theme.tokens.color_border_brand_primary),
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
: {
|
|
120
|
+
left: -16,
|
|
121
|
+
'&:hover, &:focus, &:focus-visible': {
|
|
122
|
+
boxShadow: "inset -2px 0 0 0 ".concat(theme.tokens.color_border_brand_primary),
|
|
123
|
+
},
|
|
124
|
+
})));
|
|
125
|
+
});
|
|
126
|
+
var DragIcon = styled('div', {
|
|
127
|
+
name: panelComponentName,
|
|
128
|
+
slot: 'ResizeIcon',
|
|
129
|
+
})(function (_a) {
|
|
130
|
+
var ownerState = _a.ownerState, theme = _a.theme;
|
|
131
|
+
return (__assign(__assign(__assign({ display: 'flex', width: 18, height: 48, cursor: 'col-resize', position: 'absolute', top: '50%', transform: 'translateY(-50%)', zIndex: 2 }, (ownerState.placement === 'start'
|
|
132
|
+
? {
|
|
133
|
+
right: 10,
|
|
134
|
+
}
|
|
135
|
+
: {
|
|
136
|
+
left: 10,
|
|
137
|
+
})), { '&:after': {
|
|
138
|
+
content: '""',
|
|
139
|
+
display: 'block',
|
|
140
|
+
background: theme.tokens.color_bg_layer_bold,
|
|
141
|
+
width: 4,
|
|
142
|
+
height: 40,
|
|
143
|
+
borderRadius: 4,
|
|
144
|
+
alignItems: 'center',
|
|
145
|
+
} }), (ownerState.placement === 'start'
|
|
146
|
+
? {
|
|
147
|
+
justifyContent: 'flex-start',
|
|
148
|
+
}
|
|
149
|
+
: {
|
|
150
|
+
justifyContent: 'flex-end',
|
|
151
|
+
})));
|
|
152
|
+
});
|
|
87
153
|
export var Panel = React.forwardRef(function (props, ref) {
|
|
88
|
-
var title = props.title, isOpen = props.isOpen, _a = props.placement, placement = _a === void 0 ? 'end' : _a, _b = props.variant, variant = _b === void 0 ? 'permanent' : _b, _c = props.size, size = _c === void 0 ? 'medium' : _c, onClose = props.onClose, closeButtonLabel = props.closeButtonLabel, className = props.className, propClasses = props.classes, isFixed = props.isFixed, propOffsetTop = props.offsetTop, children = props.children, _d = props.closeIconButtonProps, closeIconButtonProps = _d === void 0 ? {} : _d, _e = props.PanelHeaderProps, PanelHeaderProps = _e === void 0 ? {} : _e, rootProps = __rest(props, ["title", "isOpen", "placement", "variant", "size", "onClose", "closeButtonLabel", "className", "classes", "isFixed", "offsetTop", "children", "closeIconButtonProps", "PanelHeaderProps"]);
|
|
154
|
+
var title = props.title, isOpen = props.isOpen, _a = props.placement, placement = _a === void 0 ? 'end' : _a, _b = props.variant, variant = _b === void 0 ? 'permanent' : _b, _c = props.size, size = _c === void 0 ? 'medium' : _c, onClose = props.onClose, closeButtonLabel = props.closeButtonLabel, className = props.className, propClasses = props.classes, isFixed = props.isFixed, propOffsetTop = props.offsetTop, children = props.children, _d = props.closeIconButtonProps, closeIconButtonProps = _d === void 0 ? {} : _d, _e = props.PanelHeaderProps, PanelHeaderProps = _e === void 0 ? {} : _e, _f = props.resizable, resizable = _f === void 0 ? false : _f, _g = props.maxWidth, maxWidth = _g === void 0 ? 960 : _g, _h = props.minWidth, minWidth = _h === void 0 ? 200 : _h, _j = props.showDragHandle, showDragHandle = _j === void 0 ? false : _j, rootProps = __rest(props, ["title", "isOpen", "placement", "variant", "size", "onClose", "closeButtonLabel", "className", "classes", "isFixed", "offsetTop", "children", "closeIconButtonProps", "PanelHeaderProps", "resizable", "maxWidth", "minWidth", "showDragHandle"]);
|
|
155
|
+
var _k = __read(React.useState(widthBySize[size]), 2), panelWidth = _k[0], setPanelWidth = _k[1];
|
|
156
|
+
var _l = __read(React.useState(false), 2), isDragging = _l[0], setIsDragging = _l[1];
|
|
157
|
+
var lastSyncedSizeRef = React.useRef(size);
|
|
158
|
+
var panelRef = React.useRef(null);
|
|
159
|
+
var dragStartRef = React.useRef(null);
|
|
160
|
+
var isDraggingRef = React.useRef(false);
|
|
161
|
+
React.useEffect(function () {
|
|
162
|
+
if (size === lastSyncedSizeRef.current || isDragging) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
setPanelWidth(widthBySize[size]);
|
|
166
|
+
lastSyncedSizeRef.current = size;
|
|
167
|
+
}, [size, isDragging]);
|
|
168
|
+
React.useEffect(function () {
|
|
169
|
+
var handleDocumentMouseMove = function (dragEvent) {
|
|
170
|
+
if (!isDraggingRef.current || !dragStartRef.current) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
var _a = dragStartRef.current, startX = _a.startX, startWidth = _a.startWidth;
|
|
174
|
+
var deltaX = dragEvent.clientX - startX;
|
|
175
|
+
var tentativeWidth = placement === 'start' ? startWidth + deltaX : startWidth - deltaX;
|
|
176
|
+
var nextWidth = Math.min(maxWidth, Math.max(minWidth, tentativeWidth));
|
|
177
|
+
setPanelWidth(nextWidth);
|
|
178
|
+
};
|
|
179
|
+
var handleDocumentMouseUp = function () {
|
|
180
|
+
isDraggingRef.current = false;
|
|
181
|
+
dragStartRef.current = null;
|
|
182
|
+
setIsDragging(false);
|
|
183
|
+
};
|
|
184
|
+
document.addEventListener('mousemove', handleDocumentMouseMove);
|
|
185
|
+
document.addEventListener('mouseup', handleDocumentMouseUp);
|
|
186
|
+
return function () {
|
|
187
|
+
document.removeEventListener('mousemove', handleDocumentMouseMove);
|
|
188
|
+
document.removeEventListener('mouseup', handleDocumentMouseUp);
|
|
189
|
+
};
|
|
190
|
+
}, [placement, maxWidth, minWidth]);
|
|
191
|
+
var handleMouseDown = function (e) {
|
|
192
|
+
if (!resizable)
|
|
193
|
+
return;
|
|
194
|
+
e.preventDefault();
|
|
195
|
+
e.stopPropagation();
|
|
196
|
+
var startX = e.clientX;
|
|
197
|
+
var startWidth = panelRef.current ? panelRef.current.offsetWidth : 0;
|
|
198
|
+
dragStartRef.current = { startX: startX, startWidth: startWidth };
|
|
199
|
+
isDraggingRef.current = true;
|
|
200
|
+
setIsDragging(true);
|
|
201
|
+
};
|
|
202
|
+
var handleClick = function (e) {
|
|
203
|
+
e.preventDefault();
|
|
204
|
+
e.stopPropagation();
|
|
205
|
+
};
|
|
206
|
+
var handleKeyDown = function (e) {
|
|
207
|
+
if (!resizable) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
var step = 16;
|
|
211
|
+
var delta = 0;
|
|
212
|
+
if (placement === 'start') {
|
|
213
|
+
if (e.key === 'ArrowRight')
|
|
214
|
+
delta = step;
|
|
215
|
+
if (e.key === 'ArrowLeft')
|
|
216
|
+
delta = -step;
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
if (e.key === 'ArrowLeft')
|
|
220
|
+
delta = step;
|
|
221
|
+
if (e.key === 'ArrowRight')
|
|
222
|
+
delta = -step;
|
|
223
|
+
}
|
|
224
|
+
if (delta === 0) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
e.preventDefault();
|
|
228
|
+
e.stopPropagation();
|
|
229
|
+
setPanelWidth(function (currentWidth) { return Math.min(maxWidth, Math.max(minWidth, currentWidth + delta)); });
|
|
230
|
+
};
|
|
89
231
|
var classes = useMergedClasses(panelClasses, getPanelUtilityClass, propClasses);
|
|
90
232
|
var offsetTop = propOffsetTop != null ? propOffsetTop : isFixed ? 'appbar' : 0;
|
|
91
233
|
var ownerState = {
|
|
@@ -95,13 +237,18 @@ export var Panel = React.forwardRef(function (props, ref) {
|
|
|
95
237
|
size: size,
|
|
96
238
|
isFixed: isFixed,
|
|
97
239
|
offsetTop: offsetTop,
|
|
240
|
+
width: panelWidth,
|
|
98
241
|
};
|
|
99
242
|
var showCloseButton = variant !== 'permanent' && !!onClose;
|
|
100
243
|
return (React.createElement(Root, __assign({ ref: ref, ownerState: ownerState, className: clsx(classes.root, classes["size".concat(capitalize(size))], classes["variant".concat(capitalize(variant))], classes["placement".concat(capitalize(placement))], isFixed && classes.fixed, isOpen && classes.open, className) }, rootProps),
|
|
101
244
|
React.createElement(PanelContext.Provider, { value: __assign(__assign({}, ownerState), { isCloseButtonVisible: showCloseButton }) },
|
|
102
|
-
React.createElement(Content, { className: classes.content, ownerState: ownerState },
|
|
245
|
+
React.createElement(Content, { ref: panelRef, className: classes.content, ownerState: ownerState },
|
|
103
246
|
showCloseButton && (React.createElement(CloseButton, __assign({ label: closeButtonLabel || 'close', className: classes.closeButton, onClick: function (e) { return onClose(e, 'closeButtonClick'); }, variant: "outlined", size: "small", shape: "circular" }, closeIconButtonProps),
|
|
104
247
|
React.createElement(XIcon, null))),
|
|
248
|
+
resizable && (React.createElement(ResizeHandle, { tabIndex: 0, role: "separator", "aria-orientation": placement === 'start' || placement === 'end' ? 'vertical' : 'horizontal', "aria-label": "Resize panel", "aria-valuemin": minWidth, "aria-valuemax": maxWidth, "aria-valuenow": panelWidth, onMouseDown: function (event) {
|
|
249
|
+
event.currentTarget.focus();
|
|
250
|
+
handleMouseDown(event);
|
|
251
|
+
}, onKeyDown: handleKeyDown, onClick: handleClick, ownerState: ownerState }, showDragHandle && React.createElement(DragIcon, { ownerState: ownerState }))),
|
|
105
252
|
!!title && React.createElement(PanelHeader, __assign({ title: title }, PanelHeaderProps)),
|
|
106
253
|
children))));
|
|
107
254
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { IStyledComponentProps } from '../styled';
|
|
3
|
+
export declare const floatingBarActionsComponentName = "QuantumFloatingBarActions";
|
|
4
|
+
export type IFloatingBarActionsProps = IStyledComponentProps<{
|
|
5
|
+
props: {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
defaultComponent: 'div';
|
|
9
|
+
}>;
|
|
10
|
+
export declare const FloatingBarActions: React.ForwardRefExoticComponent<{
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref" | "children"> & import("../styled").IStyledCommonProps & React.RefAttributes<HTMLDivElement>>;
|