@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
@@ -54,17 +54,33 @@ var __rest = (this && this.__rest) || function (s, e) {
54
54
  }
55
55
  return t;
56
56
  };
57
+ var __read = (this && this.__read) || function (o, n) {
58
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
59
+ if (!m) return o;
60
+ var i = m.call(o), r, ar = [], e;
61
+ try {
62
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
63
+ }
64
+ catch (error) { e = { error: error }; }
65
+ finally {
66
+ try {
67
+ if (r && !r.done && (m = i["return"])) m.call(i);
68
+ }
69
+ finally { if (e) throw e.error; }
70
+ }
71
+ return ar;
72
+ };
57
73
  Object.defineProperty(exports, "__esModule", { value: true });
58
74
  exports.Panel = void 0;
59
75
  var React = __importStar(require("react"));
76
+ var icon_1 = require("../../icon");
77
+ var icon_button_1 = require("../../icon-button");
60
78
  var styled_1 = require("../../styled");
61
79
  var classes_1 = require("../../styles/classes");
62
80
  var utils_1 = require("../../utils");
63
- var panel_classes_1 = require("./panel-classes");
64
- var icon_button_1 = require("../../icon-button");
65
- var icon_1 = require("../../icon");
66
81
  var panel_context_1 = require("../panel-context");
67
82
  var panel_header_1 = require("../panel-header");
83
+ var panel_classes_1 = require("./panel-classes");
68
84
  var widthBySize = {
69
85
  small: 320,
70
86
  medium: 360,
@@ -76,8 +92,9 @@ var Root = (0, styled_1.styled)('div', {
76
92
  slot: 'Root',
77
93
  })(function (_a) {
78
94
  var _b;
95
+ var _c;
79
96
  var ownerState = _a.ownerState, theme = _a.theme;
80
- var width = widthBySize[ownerState.size];
97
+ var width = (_c = ownerState.width) !== null && _c !== void 0 ? _c : widthBySize[ownerState.size];
81
98
  var isOpen = ownerState.variant === 'permanent' || ownerState.isOpen;
82
99
  var marginProp = ownerState.placement === 'start' ? 'marginRight' : 'marginLeft';
83
100
  return __assign({ transition: theme.transitions.create(['margin'], {
@@ -91,8 +108,9 @@ var Content = (0, styled_1.styled)('div', {
91
108
  name: panel_classes_1.panelComponentName,
92
109
  slot: 'Content',
93
110
  })(function (_a) {
111
+ var _b;
94
112
  var ownerState = _a.ownerState, theme = _a.theme;
95
- var width = widthBySize[ownerState.size];
113
+ var width = (_b = ownerState.width) !== null && _b !== void 0 ? _b : widthBySize[ownerState.size];
96
114
  var isOpen = ownerState.variant === 'permanent' || ownerState.isOpen;
97
115
  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'], {
98
116
  duration: isOpen ? theme.transitions.duration.enteringScreen : theme.transitions.duration.leavingScreen,
@@ -117,11 +135,135 @@ var CloseButton = (0, styled_1.styled)(icon_button_1.IconButton, {
117
135
  slot: 'CloseButton',
118
136
  })({
119
137
  position: 'absolute',
120
- top: 23,
138
+ top: 24,
121
139
  right: 24,
122
140
  });
141
+ var ResizeHandle = (0, styled_1.styled)('div', {
142
+ name: panel_classes_1.panelComponentName,
143
+ slot: 'ResizeHandle',
144
+ })(function (_a) {
145
+ var ownerState = _a.ownerState, theme = _a.theme;
146
+ return (__assign({ width: '16px', cursor: 'ew-resize', position: 'absolute', top: 0, bottom: 0, zIndex: 1, outline: 'none', transition: theme.transitions.create(['all'], {
147
+ duration: theme.transitions.duration.shortest,
148
+ }) }, (ownerState.placement === 'start'
149
+ ? {
150
+ right: -16,
151
+ '&:hover, &:focus, &:focus-visible': {
152
+ boxShadow: "inset 2px 0 0 0 ".concat(theme.tokens.color_border_brand_primary),
153
+ },
154
+ }
155
+ : {
156
+ left: -16,
157
+ '&:hover, &:focus, &:focus-visible': {
158
+ boxShadow: "inset -2px 0 0 0 ".concat(theme.tokens.color_border_brand_primary),
159
+ },
160
+ })));
161
+ });
162
+ var DragIcon = (0, styled_1.styled)('div', {
163
+ name: panel_classes_1.panelComponentName,
164
+ slot: 'ResizeIcon',
165
+ })(function (_a) {
166
+ var ownerState = _a.ownerState, theme = _a.theme;
167
+ 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'
168
+ ? {
169
+ right: 10,
170
+ }
171
+ : {
172
+ left: 10,
173
+ })), { '&:after': {
174
+ content: '""',
175
+ display: 'block',
176
+ background: theme.tokens.color_bg_layer_bold,
177
+ width: 4,
178
+ height: 40,
179
+ borderRadius: 4,
180
+ alignItems: 'center',
181
+ } }), (ownerState.placement === 'start'
182
+ ? {
183
+ justifyContent: 'flex-start',
184
+ }
185
+ : {
186
+ justifyContent: 'flex-end',
187
+ })));
188
+ });
123
189
  exports.Panel = React.forwardRef(function (props, ref) {
124
- 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"]);
190
+ 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"]);
191
+ var _k = __read(React.useState(widthBySize[size]), 2), panelWidth = _k[0], setPanelWidth = _k[1];
192
+ var _l = __read(React.useState(false), 2), isDragging = _l[0], setIsDragging = _l[1];
193
+ var lastSyncedSizeRef = React.useRef(size);
194
+ var panelRef = React.useRef(null);
195
+ var dragStartRef = React.useRef(null);
196
+ var isDraggingRef = React.useRef(false);
197
+ React.useEffect(function () {
198
+ if (size === lastSyncedSizeRef.current || isDragging) {
199
+ return;
200
+ }
201
+ setPanelWidth(widthBySize[size]);
202
+ lastSyncedSizeRef.current = size;
203
+ }, [size, isDragging]);
204
+ React.useEffect(function () {
205
+ var handleDocumentMouseMove = function (dragEvent) {
206
+ if (!isDraggingRef.current || !dragStartRef.current) {
207
+ return;
208
+ }
209
+ var _a = dragStartRef.current, startX = _a.startX, startWidth = _a.startWidth;
210
+ var deltaX = dragEvent.clientX - startX;
211
+ var tentativeWidth = placement === 'start' ? startWidth + deltaX : startWidth - deltaX;
212
+ var nextWidth = Math.min(maxWidth, Math.max(minWidth, tentativeWidth));
213
+ setPanelWidth(nextWidth);
214
+ };
215
+ var handleDocumentMouseUp = function () {
216
+ isDraggingRef.current = false;
217
+ dragStartRef.current = null;
218
+ setIsDragging(false);
219
+ };
220
+ document.addEventListener('mousemove', handleDocumentMouseMove);
221
+ document.addEventListener('mouseup', handleDocumentMouseUp);
222
+ return function () {
223
+ document.removeEventListener('mousemove', handleDocumentMouseMove);
224
+ document.removeEventListener('mouseup', handleDocumentMouseUp);
225
+ };
226
+ }, [placement, maxWidth, minWidth]);
227
+ var handleMouseDown = function (e) {
228
+ if (!resizable)
229
+ return;
230
+ e.preventDefault();
231
+ e.stopPropagation();
232
+ var startX = e.clientX;
233
+ var startWidth = panelRef.current ? panelRef.current.offsetWidth : 0;
234
+ dragStartRef.current = { startX: startX, startWidth: startWidth };
235
+ isDraggingRef.current = true;
236
+ setIsDragging(true);
237
+ };
238
+ var handleClick = function (e) {
239
+ e.preventDefault();
240
+ e.stopPropagation();
241
+ };
242
+ var handleKeyDown = function (e) {
243
+ if (!resizable) {
244
+ return;
245
+ }
246
+ var step = 16;
247
+ var delta = 0;
248
+ if (placement === 'start') {
249
+ if (e.key === 'ArrowRight')
250
+ delta = step;
251
+ if (e.key === 'ArrowLeft')
252
+ delta = -step;
253
+ }
254
+ else {
255
+ if (e.key === 'ArrowLeft')
256
+ delta = step;
257
+ if (e.key === 'ArrowRight')
258
+ delta = -step;
259
+ }
260
+ if (delta === 0) {
261
+ return;
262
+ }
263
+ e.preventDefault();
264
+ e.stopPropagation();
265
+ setPanelWidth(function (currentWidth) { return Math.min(maxWidth, Math.max(minWidth, currentWidth + delta)); });
266
+ };
125
267
  var classes = (0, classes_1.useMergedClasses)(panel_classes_1.panelClasses, panel_classes_1.getPanelUtilityClass, propClasses);
126
268
  var offsetTop = propOffsetTop != null ? propOffsetTop : isFixed ? 'appbar' : 0;
127
269
  var ownerState = {
@@ -131,13 +273,18 @@ exports.Panel = React.forwardRef(function (props, ref) {
131
273
  size: size,
132
274
  isFixed: isFixed,
133
275
  offsetTop: offsetTop,
276
+ width: panelWidth,
134
277
  };
135
278
  var showCloseButton = variant !== 'permanent' && !!onClose;
136
279
  return (React.createElement(Root, __assign({ ref: ref, ownerState: ownerState, className: (0, utils_1.clsx)(classes.root, classes["size".concat((0, utils_1.capitalize)(size))], classes["variant".concat((0, utils_1.capitalize)(variant))], classes["placement".concat((0, utils_1.capitalize)(placement))], isFixed && classes.fixed, isOpen && classes.open, className) }, rootProps),
137
280
  React.createElement(panel_context_1.PanelContext.Provider, { value: __assign(__assign({}, ownerState), { isCloseButtonVisible: showCloseButton }) },
138
- React.createElement(Content, { className: classes.content, ownerState: ownerState },
281
+ React.createElement(Content, { ref: panelRef, className: classes.content, ownerState: ownerState },
139
282
  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),
140
283
  React.createElement(icon_1.XIcon, null))),
284
+ 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) {
285
+ event.currentTarget.focus();
286
+ handleMouseDown(event);
287
+ }, onKeyDown: handleKeyDown, onClick: handleClick, ownerState: ownerState }, showDragHandle && React.createElement(DragIcon, { ownerState: ownerState }))),
141
288
  !!title && React.createElement(panel_header_1.PanelHeader, __assign({ title: title }, PanelHeaderProps)),
142
289
  children))));
143
290
  });
@@ -21,6 +21,8 @@ export interface IPanelContextValue {
21
21
  * @default end
22
22
  * */
23
23
  placement: PanelPlacement;
24
+ /** Resizable panel */
25
+ resizable?: boolean;
24
26
  /** Sets panel to open or closed if variant is floating or persistent. Permanent panels cannot be closed. */
25
27
  isOpen?: boolean;
26
28
  /** sets position to fixed.*/
@@ -42,6 +42,7 @@ exports.PanelContext = React.createContext({
42
42
  size: exports.defaultPanelSize,
43
43
  placement: exports.defaultPanelPlacement,
44
44
  variant: exports.defaultPanelVariant,
45
+ resizable: false,
45
46
  isOpen: true,
46
47
  isFixed: false,
47
48
  isCloseButtonVisible: false,