@auth0/quantum-product 2.9.5 → 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.
Files changed (42) hide show
  1. package/chip/chip.js +1 -1
  2. package/date-picker/date-picker-popover.js +33 -17
  3. package/date-picker/date-picker-state.d.ts +1 -1
  4. package/date-picker/date-picker-types.d.ts +2 -0
  5. package/date-picker/date-picker-utils.d.ts +1 -0
  6. package/date-picker/date-picker-utils.js +5 -4
  7. package/date-picker/date-picker.js +32 -6
  8. package/esm/chip/chip.js +1 -1
  9. package/esm/date-picker/date-picker-popover.js +34 -18
  10. package/esm/date-picker/date-picker-utils.js +4 -3
  11. package/esm/date-picker/date-picker.js +32 -6
  12. package/esm/floating-bar/floating-bar-actions.js +34 -0
  13. package/esm/floating-bar/floating-bar-context.js +13 -0
  14. package/esm/floating-bar/floating-bar-description.js +24 -0
  15. package/esm/floating-bar/floating-bar-icon.js +32 -0
  16. package/esm/floating-bar/floating-bar-scroll.js +68 -0
  17. package/esm/floating-bar/floating-bar.js +206 -0
  18. package/esm/floating-bar/index.js +6 -0
  19. package/esm/index.js +1 -0
  20. package/esm/panel/panel/panel.js +155 -8
  21. package/esm/panel/panel-context.js +1 -0
  22. package/floating-bar/floating-bar-actions.d.ts +12 -0
  23. package/floating-bar/floating-bar-actions.js +70 -0
  24. package/floating-bar/floating-bar-context.d.ts +11 -0
  25. package/floating-bar/floating-bar-context.js +52 -0
  26. package/floating-bar/floating-bar-description.d.ts +12 -0
  27. package/floating-bar/floating-bar-description.js +60 -0
  28. package/floating-bar/floating-bar-icon.d.ts +12 -0
  29. package/floating-bar/floating-bar-icon.js +68 -0
  30. package/floating-bar/floating-bar-scroll.d.ts +11 -0
  31. package/floating-bar/floating-bar-scroll.js +104 -0
  32. package/floating-bar/floating-bar.d.ts +17 -0
  33. package/floating-bar/floating-bar.js +242 -0
  34. package/floating-bar/index.d.ts +12 -0
  35. package/floating-bar/index.js +17 -0
  36. package/index.d.ts +1 -0
  37. package/index.js +1 -0
  38. package/package.json +2 -2
  39. package/panel/panel/panel.d.ts +21 -3
  40. package/panel/panel/panel.js +155 -8
  41. package/panel/panel-context.d.ts +2 -0
  42. package/panel/panel-context.js +1 -0
@@ -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';
@@ -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: 23,
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
  });
@@ -6,6 +6,7 @@ export var PanelContext = React.createContext({
6
6
  size: defaultPanelSize,
7
7
  placement: defaultPanelPlacement,
8
8
  variant: defaultPanelVariant,
9
+ resizable: false,
9
10
  isOpen: true,
10
11
  isFixed: false,
11
12
  isCloseButtonVisible: false,
@@ -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>>;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ exports.FloatingBarActions = exports.floatingBarActionsComponentName = void 0;
48
+ var React = __importStar(require("react"));
49
+ var styled_1 = require("../styled");
50
+ var floating_bar_context_1 = require("./floating-bar-context");
51
+ exports.floatingBarActionsComponentName = 'QuantumFloatingBarActions';
52
+ var Root = (0, styled_1.styled)('div', {
53
+ name: exports.floatingBarActionsComponentName,
54
+ slot: 'Root',
55
+ })(function (_a) {
56
+ var theme = _a.theme, ownerState = _a.ownerState;
57
+ return ({
58
+ display: 'flex',
59
+ gap: theme.spacing(1),
60
+ alignItems: 'center',
61
+ justifyContent: ownerState.orientation === 'vertical' ? 'flex-end' : 'flex-start',
62
+ marginLeft: ownerState.orientation === 'horizontal' ? 'auto' : 0,
63
+ width: ownerState.orientation === 'vertical' ? '100%' : 'auto',
64
+ flexShrink: 0,
65
+ });
66
+ });
67
+ exports.FloatingBarActions = React.forwardRef(function FloatingBarActions(props, ref) {
68
+ var orientation = (0, floating_bar_context_1.useFloatingBarOrientation)();
69
+ return React.createElement(Root, __assign({ ref: ref, ownerState: { orientation: orientation } }, props));
70
+ });
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ export type FloatingBarOrientation = 'horizontal' | 'vertical';
3
+ export interface IFloatingBarContextValue {
4
+ orientation: FloatingBarOrientation;
5
+ scrollProgress: number;
6
+ }
7
+ export declare const FloatingBarOrientationContext: React.Context<FloatingBarOrientation>;
8
+ export declare const FloatingBarScrollProgressContext: React.Context<number>;
9
+ export declare const useFloatingBarOrientation: () => FloatingBarOrientation;
10
+ export declare const useFloatingBarScrollProgress: () => number;
11
+ export declare const useFloatingBarContext: () => IFloatingBarContextValue;
@@ -0,0 +1,52 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.useFloatingBarContext = exports.useFloatingBarScrollProgress = exports.useFloatingBarOrientation = exports.FloatingBarScrollProgressContext = exports.FloatingBarOrientationContext = void 0;
37
+ var React = __importStar(require("react"));
38
+ exports.FloatingBarOrientationContext = React.createContext('horizontal');
39
+ exports.FloatingBarScrollProgressContext = React.createContext(0);
40
+ var useFloatingBarOrientation = function () { return React.useContext(exports.FloatingBarOrientationContext); };
41
+ exports.useFloatingBarOrientation = useFloatingBarOrientation;
42
+ var useFloatingBarScrollProgress = function () { return React.useContext(exports.FloatingBarScrollProgressContext); };
43
+ exports.useFloatingBarScrollProgress = useFloatingBarScrollProgress;
44
+ var useFloatingBarContext = function () {
45
+ var orientation = (0, exports.useFloatingBarOrientation)();
46
+ var scrollProgress = (0, exports.useFloatingBarScrollProgress)();
47
+ return React.useMemo(function () { return ({
48
+ orientation: orientation,
49
+ scrollProgress: scrollProgress,
50
+ }); }, [orientation, scrollProgress]);
51
+ };
52
+ exports.useFloatingBarContext = useFloatingBarContext;