@jetbrains/ring-ui-built 8.0.0-beta.10 → 8.0.0-beta.11

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.
@@ -0,0 +1,3 @@
1
+ var styles = {"islandContent":"ring-island-content","header":"ring-island-header","islandTitle":"ring-island-title","scrollableWrapper":"ring-island-scrollableWrapper","panel":"ring-panel-panel","container":"ring-dialog-container","nativeDialog":"ring-dialog-nativeDialog","innerContainer":"ring-dialog-innerContainer","content":"ring-dialog-content","resized":"ring-dialog-resized","clickableOverlay":"ring-dialog-clickableOverlay","closeIcon":"ring-dialog-closeIcon","closeButton":"ring-dialog-closeButton","moveHandle":"ring-dialog-moveHandle","movable":"ring-dialog-movable","resizeHandle":"ring-dialog-resizeHandle","resizeMarker":"ring-dialog-resizeMarker","documentWithoutScroll":"ring-dialog-documentWithoutScroll","popupTarget":"ring-dialog-popupTarget","dense":"ring-dialog-dense"};
2
+
3
+ export { styles as s };
@@ -11,7 +11,6 @@ import '../login-dialog/login-dialog.js';
11
11
  import '../dialog/dialog.js';
12
12
  import 'react-dom';
13
13
  import 'classnames';
14
- import '@jetbrains/icons/close';
15
14
  import '../island/island.js';
16
15
  import '../global/data-tests.js';
17
16
  import '../island/adaptive-island-hoc.js';
@@ -31,6 +30,19 @@ import '../global/sniffer.js';
31
30
  import 'sniffr';
32
31
  import '../tab-trap/tab-trap.js';
33
32
  import '../global/dom.js';
33
+ import '../popup/popup.target.js';
34
+ import '../popup/popup.js';
35
+ import '../popup/position.js';
36
+ import '../popup/popup.consts.js';
37
+ import '../popup/position-css.js';
38
+ import '../_helpers/theme.js';
39
+ import '../global/get-viewport-size.js';
40
+ import '../dialog/dialog-body-scroll-preventer.js';
41
+ import 'scrollbar-width';
42
+ import '../_helpers/dialog.js';
43
+ import '../dialog/dialog-controls.js';
44
+ import '@jetbrains/icons/close';
45
+ import '@jetbrains/icons/resize-corner-12px';
34
46
  import '../button/button.js';
35
47
  import '@jetbrains/icons/chevron-down';
36
48
  import '@jetbrains/icons/chevron-12px-down';
@@ -40,14 +52,7 @@ import '../_helpers/icon-svg.js';
40
52
  import '../global/memoize.js';
41
53
  import '../link/clickable-link.js';
42
54
  import '../_helpers/button.classes.js';
43
- import '../popup/popup.target.js';
44
- import '../popup/popup.js';
45
- import '../popup/position.js';
46
- import '../popup/popup.consts.js';
47
- import '../popup/position-css.js';
48
- import '../_helpers/theme.js';
49
- import '../_helpers/dialog-body-scroll-preventer.js';
50
- import 'scrollbar-width';
55
+ import '../dialog/dialog-geometry.js';
51
56
  import '../loader-screen/loader-screen.js';
52
57
  import '../loader/loader.js';
53
58
  import '../_helpers/loader-core.js';
@@ -12,7 +12,6 @@ import '../global/schedule-raf.js';
12
12
  import '../island/adaptive-island-hoc.js';
13
13
  import '../global/linear-function.js';
14
14
  import 'react-dom';
15
- import '@jetbrains/icons/close';
16
15
  import '../island/island.js';
17
16
  import '../global/data-tests.js';
18
17
  import '../island/header.js';
@@ -32,18 +31,24 @@ import '../popup/position.js';
32
31
  import '../popup/popup.consts.js';
33
32
  import '../popup/position-css.js';
34
33
  import '../_helpers/theme.js';
35
- import '../_helpers/dialog-body-scroll-preventer.js';
34
+ import '../global/get-viewport-size.js';
35
+ import '../dialog/dialog-body-scroll-preventer.js';
36
36
  import 'scrollbar-width';
37
- import '@jetbrains/icons/chevron-down';
38
- import '@jetbrains/icons/chevron-12px-down';
37
+ import '../_helpers/dialog.js';
38
+ import '../dialog/dialog-controls.js';
39
+ import '@jetbrains/icons/close';
40
+ import '@jetbrains/icons/resize-corner-12px';
39
41
  import '../icon/icon.js';
40
42
  import 'util-deprecate';
41
43
  import '../icon/icon.constants.js';
42
44
  import '../_helpers/icon-svg.js';
43
45
  import '../global/memoize.js';
46
+ import '@jetbrains/icons/chevron-down';
47
+ import '@jetbrains/icons/chevron-12px-down';
44
48
  import '../link/clickable-link.js';
45
49
  import '../global/controls-height.js';
46
50
  import '../_helpers/button.classes.js';
51
+ import '../dialog/dialog-geometry.js';
47
52
  import '../_helpers/heading.js';
48
53
 
49
54
  var styles = {"dialog":"ring-auth-dialog-dialog","content":"ring-auth-dialog-content ring-global-font","button":"ring-auth-dialog-button","firstButton":"ring-auth-dialog-firstButton ring-auth-dialog-button","title":"ring-auth-dialog-title","logo":"ring-auth-dialog-logo","error":"ring-auth-dialog-error"};
@@ -15,7 +15,6 @@ import '../island/adaptive-island-hoc.js';
15
15
  import '../global/linear-function.js';
16
16
  import '../dialog/dialog.js';
17
17
  import 'react-dom';
18
- import '@jetbrains/icons/close';
19
18
  import '../island/island.js';
20
19
  import '../global/data-tests.js';
21
20
  import '../island/header.js';
@@ -28,6 +27,19 @@ import '../global/sniffer.js';
28
27
  import 'sniffr';
29
28
  import '../tab-trap/tab-trap.js';
30
29
  import '../global/dom.js';
30
+ import '../popup/popup.target.js';
31
+ import '../popup/popup.js';
32
+ import '../popup/position.js';
33
+ import '../popup/popup.consts.js';
34
+ import '../popup/position-css.js';
35
+ import '../_helpers/theme.js';
36
+ import '../global/get-viewport-size.js';
37
+ import '../dialog/dialog-body-scroll-preventer.js';
38
+ import 'scrollbar-width';
39
+ import '../_helpers/dialog.js';
40
+ import '../dialog/dialog-controls.js';
41
+ import '@jetbrains/icons/close';
42
+ import '@jetbrains/icons/resize-corner-12px';
31
43
  import '../button/button.js';
32
44
  import '@jetbrains/icons/chevron-down';
33
45
  import '@jetbrains/icons/chevron-12px-down';
@@ -37,14 +49,7 @@ import '../_helpers/icon-svg.js';
37
49
  import '../global/memoize.js';
38
50
  import '../link/clickable-link.js';
39
51
  import '../_helpers/button.classes.js';
40
- import '../popup/popup.target.js';
41
- import '../popup/popup.js';
42
- import '../popup/position.js';
43
- import '../popup/popup.consts.js';
44
- import '../popup/position-css.js';
45
- import '../_helpers/theme.js';
46
- import '../_helpers/dialog-body-scroll-preventer.js';
47
- import 'scrollbar-width';
52
+ import '../dialog/dialog-geometry.js';
48
53
  import '../heading/heading.js';
49
54
  import '../_helpers/heading.js';
50
55
 
@@ -54,6 +59,9 @@ const reactRoot = createRoot(containerElement);
54
59
  * Renders AuthDialog into virtual node to skip maintaining container
55
60
  */
56
61
  function renderAuthDialog(props) {
62
+ if (!containerElement.isConnected) {
63
+ document.body.appendChild(containerElement);
64
+ }
57
65
  reactRoot.render(/*#__PURE__*/jsx(ControlsHeightContext, {
58
66
  value: getGlobalControlsHeight(),
59
67
  children: /*#__PURE__*/jsx(AuthDialog, {
@@ -8,7 +8,6 @@ import HeaderWrapper from '../island/header.js';
8
8
  import ContentWrapper from '../island/content.js';
9
9
  import Panel from '../panel/panel.js';
10
10
  import 'react-dom';
11
- import '@jetbrains/icons/close';
12
11
  import '../island/island.js';
13
12
  import '../global/data-tests.js';
14
13
  import '../island/adaptive-island-hoc.js';
@@ -32,18 +31,24 @@ import '../popup/position.js';
32
31
  import '../popup/popup.consts.js';
33
32
  import '../popup/position-css.js';
34
33
  import '../_helpers/theme.js';
35
- import '../_helpers/dialog-body-scroll-preventer.js';
34
+ import '../global/get-viewport-size.js';
35
+ import '../dialog/dialog-body-scroll-preventer.js';
36
36
  import 'scrollbar-width';
37
- import '@jetbrains/icons/chevron-down';
38
- import '@jetbrains/icons/chevron-12px-down';
37
+ import '../_helpers/dialog.js';
38
+ import '../dialog/dialog-controls.js';
39
+ import '@jetbrains/icons/close';
40
+ import '@jetbrains/icons/resize-corner-12px';
39
41
  import '../icon/icon.js';
40
42
  import 'util-deprecate';
41
43
  import '../icon/icon.constants.js';
42
44
  import '../_helpers/icon-svg.js';
43
45
  import '../global/memoize.js';
46
+ import '@jetbrains/icons/chevron-down';
47
+ import '@jetbrains/icons/chevron-12px-down';
44
48
  import '../link/clickable-link.js';
45
49
  import '../global/controls-height.js';
46
50
  import '../_helpers/button.classes.js';
51
+ import '../dialog/dialog-geometry.js';
47
52
 
48
53
  class Confirm extends PureComponent {
49
54
  static defaultProps = {
@@ -77,6 +82,23 @@ class Confirm extends PureComponent {
77
82
  onReject,
78
83
  native
79
84
  } = this.props;
85
+ const actions = [/*#__PURE__*/jsx(Button, {
86
+ "data-test": "confirm-reject-button",
87
+ onClick: onReject,
88
+ disabled: inProgress,
89
+ primary: cancelIsDefault,
90
+ children: rejectLabel
91
+ }, 'reject'), /*#__PURE__*/jsx(Button, {
92
+ "data-test": "confirm-ok-button",
93
+ primary: !cancelIsDefault,
94
+ loader: inProgress,
95
+ disabled: inProgress,
96
+ onClick: onConfirm,
97
+ children: confirmLabel
98
+ }, 'confirm')];
99
+ if (cancelIsDefault) {
100
+ actions.reverse();
101
+ }
80
102
  return /*#__PURE__*/jsxs(Dialog, {
81
103
  label: text || (typeof description === 'string' ? description : undefined),
82
104
  className: className,
@@ -89,21 +111,8 @@ class Confirm extends PureComponent {
89
111
  children: text
90
112
  }), description && /*#__PURE__*/jsx(ContentWrapper, {
91
113
  children: description
92
- }), /*#__PURE__*/jsxs(Panel, {
93
- children: [/*#__PURE__*/jsx(Button, {
94
- "data-test": "confirm-ok-button",
95
- primary: !cancelIsDefault,
96
- loader: inProgress,
97
- disabled: inProgress,
98
- onClick: onConfirm,
99
- children: confirmLabel
100
- }), /*#__PURE__*/jsx(Button, {
101
- "data-test": "confirm-reject-button",
102
- onClick: onReject,
103
- disabled: inProgress,
104
- primary: cancelIsDefault,
105
- children: rejectLabel
106
- })]
114
+ }), /*#__PURE__*/jsx(Panel, {
115
+ children: actions
107
116
  })]
108
117
  });
109
118
  }
@@ -6,7 +6,6 @@ import 'react';
6
6
  import '../dialog/dialog.js';
7
7
  import 'react-dom';
8
8
  import 'classnames';
9
- import '@jetbrains/icons/close';
10
9
  import '../island/island.js';
11
10
  import '../global/data-tests.js';
12
11
  import '../island/adaptive-island-hoc.js';
@@ -26,6 +25,20 @@ import '../global/sniffer.js';
26
25
  import 'sniffr';
27
26
  import '../tab-trap/tab-trap.js';
28
27
  import '../global/dom.js';
28
+ import '../popup/popup.target.js';
29
+ import '../popup/popup.js';
30
+ import '../global/configuration.js';
31
+ import '../popup/position.js';
32
+ import '../popup/popup.consts.js';
33
+ import '../popup/position-css.js';
34
+ import '../_helpers/theme.js';
35
+ import '../global/get-viewport-size.js';
36
+ import '../dialog/dialog-body-scroll-preventer.js';
37
+ import 'scrollbar-width';
38
+ import '../_helpers/dialog.js';
39
+ import '../dialog/dialog-controls.js';
40
+ import '@jetbrains/icons/close';
41
+ import '@jetbrains/icons/resize-corner-12px';
29
42
  import '../button/button.js';
30
43
  import '@jetbrains/icons/chevron-down';
31
44
  import '@jetbrains/icons/chevron-12px-down';
@@ -36,15 +49,7 @@ import '../_helpers/icon-svg.js';
36
49
  import '../global/memoize.js';
37
50
  import '../link/clickable-link.js';
38
51
  import '../_helpers/button.classes.js';
39
- import '../global/configuration.js';
40
- import '../popup/popup.target.js';
41
- import '../popup/popup.js';
42
- import '../popup/position.js';
43
- import '../popup/popup.consts.js';
44
- import '../popup/position-css.js';
45
- import '../_helpers/theme.js';
46
- import '../_helpers/dialog-body-scroll-preventer.js';
47
- import 'scrollbar-width';
52
+ import '../dialog/dialog-geometry.js';
48
53
  import '../panel/panel.js';
49
54
 
50
55
  const containerElement = document.createElement('div');
@@ -53,6 +58,9 @@ const reactRoot = createRoot(containerElement);
53
58
  * Renders Confirm into virtual node to skip maintaining container
54
59
  */
55
60
  function renderConfirm(props) {
61
+ if (!containerElement.isConnected) {
62
+ document.body.appendChild(containerElement);
63
+ }
56
64
  const {
57
65
  buttonsHeight = getGlobalControlsHeight(),
58
66
  ...restProps
@@ -1,2 +1,49 @@
1
- import 'scrollbar-width';
2
- export { d as default, p as preventerFactory } from '../_helpers/dialog-body-scroll-preventer.js';
1
+ import scrollbarWidth from 'scrollbar-width';
2
+ import { s as styles } from '../_helpers/dialog.js';
3
+
4
+ const isPrevented = new Set();
5
+ let previousDocumentWidth = null;
6
+ const prevent = key => {
7
+ if (isPrevented.has(key)) {
8
+ return;
9
+ }
10
+ isPrevented.add(key);
11
+ if (isPrevented.size > 1) {
12
+ return;
13
+ }
14
+ const documentHasScroll = document.documentElement.scrollHeight > window.innerHeight || getComputedStyle(document.documentElement).overflowY === 'scroll';
15
+ document.documentElement.classList.add(styles.documentWithoutScroll);
16
+ const scrollWidth = scrollbarWidth();
17
+ const {
18
+ scrollbarGutter
19
+ } = getComputedStyle(document.documentElement);
20
+ const documentHasScrollbarGutter = scrollbarGutter === 'stable' || scrollbarGutter === 'both-edges';
21
+ if (documentHasScroll && scrollWidth !== null && scrollWidth !== undefined && scrollWidth > 0 && !documentHasScrollbarGutter) {
22
+ previousDocumentWidth = document.documentElement.style.width;
23
+ document.documentElement.style.width = `calc(100% - ${scrollWidth}px)`;
24
+ }
25
+ };
26
+ const reset = key => {
27
+ if (isPrevented.size === 0) {
28
+ return;
29
+ }
30
+ isPrevented.delete(key);
31
+ if (isPrevented.size > 0) {
32
+ return;
33
+ }
34
+ document.documentElement.classList.remove(styles.documentWithoutScroll);
35
+ if (previousDocumentWidth !== null && previousDocumentWidth !== undefined) {
36
+ document.documentElement.style.width = previousDocumentWidth;
37
+ previousDocumentWidth = null;
38
+ }
39
+ };
40
+ const preventerFactory = key => {
41
+ const preventerKey = key || Math.random();
42
+ return {
43
+ prevent: () => prevent(preventerKey),
44
+ reset: () => reset(preventerKey)
45
+ };
46
+ };
47
+ var dialogBodyScrollPreventer = preventerFactory('default-preventer');
48
+
49
+ export { dialogBodyScrollPreventer as default, preventerFactory };
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import type { InteractionDirection } from './dialog-geometry';
3
+ interface DialogControlsProps {
4
+ movable: boolean | undefined;
5
+ resizable: boolean | undefined;
6
+ showCloseButton: boolean;
7
+ closeButtonTitle: string | undefined;
8
+ onCloseClick: React.MouseEventHandler<HTMLElement>;
9
+ onStartInteraction: (event: React.PointerEvent<HTMLElement>, direction: InteractionDirection) => void;
10
+ onStopInteraction: React.PointerEventHandler<HTMLElement>;
11
+ }
12
+ export default function DialogControls({ movable, resizable, showCloseButton, closeButtonTitle, onCloseClick, onStartInteraction, onStopInteraction, }: DialogControlsProps): React.JSX.Element;
13
+ export {};
@@ -0,0 +1,113 @@
1
+ import { c } from 'react/compiler-runtime';
2
+ import 'react';
3
+ import closeIcon from '@jetbrains/icons/close';
4
+ import resizeIcon from '@jetbrains/icons/resize-corner-12px';
5
+ import { Button } from '../button/button.js';
6
+ import Icon from '../icon/icon.js';
7
+ import { s as styles } from '../_helpers/dialog.js';
8
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
9
+ import 'classnames';
10
+ import '@jetbrains/icons/chevron-down';
11
+ import '@jetbrains/icons/chevron-12px-down';
12
+ import '../link/clickable-link.js';
13
+ import '../global/controls-height.js';
14
+ import 'util-deprecate';
15
+ import '../global/configuration.js';
16
+ import '../_helpers/button.classes.js';
17
+ import '../icon/icon.constants.js';
18
+ import '../_helpers/icon-svg.js';
19
+ import '../global/memoize.js';
20
+
21
+ const resizeDirections = ['n', 'ne', 'e', 's', 'sw', 'w', 'nw', 'se'];
22
+ function DialogControls(t0) {
23
+ const $ = c(16);
24
+ if ($[0] !== "3b5393fdb3ab1f8cc9dae0ff6911750d56209b75ddbd239bbce35cfb2f2ab34c") {
25
+ for (let $i = 0; $i < 16; $i += 1) {
26
+ $[$i] = Symbol.for("react.memo_cache_sentinel");
27
+ }
28
+ $[0] = "3b5393fdb3ab1f8cc9dae0ff6911750d56209b75ddbd239bbce35cfb2f2ab34c";
29
+ }
30
+ const {
31
+ movable,
32
+ resizable,
33
+ showCloseButton,
34
+ closeButtonTitle,
35
+ onCloseClick,
36
+ onStartInteraction,
37
+ onStopInteraction
38
+ } = t0;
39
+ let t1;
40
+ if ($[1] !== movable || $[2] !== onStopInteraction) {
41
+ t1 = movable && /*#__PURE__*/jsx("div", {
42
+ "aria-hidden": "true",
43
+ className: styles.moveHandle,
44
+ "data-ring-dialog-move-handle": "",
45
+ "data-test": "ring-dialog-move-handle",
46
+ onLostPointerCapture: onStopInteraction
47
+ });
48
+ $[1] = movable;
49
+ $[2] = onStopInteraction;
50
+ $[3] = t1;
51
+ } else {
52
+ t1 = $[3];
53
+ }
54
+ let t2;
55
+ if ($[4] !== closeButtonTitle || $[5] !== onCloseClick || $[6] !== showCloseButton) {
56
+ t2 = showCloseButton && /*#__PURE__*/jsx(Button, {
57
+ icon: closeIcon,
58
+ "data-test": "ring-dialog-close-button",
59
+ className: styles.closeButton,
60
+ iconClassName: styles.closeIcon,
61
+ onClick: onCloseClick,
62
+ title: closeButtonTitle,
63
+ "aria-label": closeButtonTitle || "close dialog"
64
+ });
65
+ $[4] = closeButtonTitle;
66
+ $[5] = onCloseClick;
67
+ $[6] = showCloseButton;
68
+ $[7] = t2;
69
+ } else {
70
+ t2 = $[7];
71
+ }
72
+ let t3;
73
+ if ($[8] !== onStartInteraction || $[9] !== onStopInteraction || $[10] !== resizable) {
74
+ t3 = resizable && /*#__PURE__*/jsxs(Fragment, {
75
+ children: [resizeDirections.map(direction => /*#__PURE__*/jsx("div", {
76
+ "aria-hidden": "true",
77
+ className: styles.resizeHandle,
78
+ "data-resize-direction": direction,
79
+ "data-test": `ring-dialog-resize-handle-${direction}`,
80
+ onPointerDown: event => onStartInteraction(event, direction),
81
+ onPointerUp: onStopInteraction,
82
+ onPointerCancel: onStopInteraction,
83
+ onLostPointerCapture: onStopInteraction
84
+ }, direction)), /*#__PURE__*/jsx(Icon, {
85
+ "aria-hidden": "true",
86
+ className: styles.resizeMarker,
87
+ "data-test": "ring-dialog-resize-marker",
88
+ glyph: resizeIcon
89
+ })]
90
+ });
91
+ $[8] = onStartInteraction;
92
+ $[9] = onStopInteraction;
93
+ $[10] = resizable;
94
+ $[11] = t3;
95
+ } else {
96
+ t3 = $[11];
97
+ }
98
+ let t4;
99
+ if ($[12] !== t1 || $[13] !== t2 || $[14] !== t3) {
100
+ t4 = /*#__PURE__*/jsxs(Fragment, {
101
+ children: [t1, t2, t3]
102
+ });
103
+ $[12] = t1;
104
+ $[13] = t2;
105
+ $[14] = t3;
106
+ $[15] = t4;
107
+ } else {
108
+ t4 = $[15];
109
+ }
110
+ return t4;
111
+ }
112
+
113
+ export { DialogControls as default };
@@ -0,0 +1,31 @@
1
+ export type ResizeDirection = 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw';
2
+ export type InteractionDirection = 'move' | ResizeDirection;
3
+ export interface Geometry {
4
+ left: number;
5
+ top: number;
6
+ width: number;
7
+ height: number;
8
+ }
9
+ export interface DialogState {
10
+ shortcutsScope: string;
11
+ geometry: Geometry | null;
12
+ resized: boolean;
13
+ }
14
+ export interface Interaction {
15
+ pointerId: number;
16
+ direction: InteractionDirection;
17
+ startX: number;
18
+ startY: number;
19
+ minWidth: number;
20
+ minHeight: number;
21
+ geometry: Geometry;
22
+ }
23
+ export declare const getNativeTabIndex: (autoFocusFirst: boolean | undefined) => -1 | undefined;
24
+ export declare const getTrapDisabled: (trapFocus: boolean, trapDisabled: boolean | undefined) => boolean;
25
+ export declare const getResizeMinimum: (element: Element) => {
26
+ minWidth: number;
27
+ minHeight: number;
28
+ };
29
+ export declare const moveGeometry: (start: Geometry, dx: number, dy: number, viewportWidth: number, viewportHeight: number) => Geometry;
30
+ export declare const fitGeometry: (geometry: Geometry, viewportWidth: number, viewportHeight: number) => Geometry;
31
+ export declare const resizeGeometry: ({ geometry: start, direction, minWidth, minHeight }: Interaction, dx: number, dy: number, viewportWidth: number, viewportHeight: number) => Geometry;
@@ -0,0 +1,63 @@
1
+ import 'core-js/modules/es.array.includes.js';
2
+
3
+ const MIN_WIDTH = 256;
4
+ const MIN_HEIGHT = 160;
5
+ const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
6
+ const getNativeTabIndex = autoFocusFirst => autoFocusFirst ? undefined : -1;
7
+ const getTrapDisabled = (trapFocus, trapDisabled) => trapDisabled !== null && trapDisabled !== void 0 ? trapDisabled : !trapFocus;
8
+ const getResizeMinimum = element => {
9
+ const {
10
+ minWidth,
11
+ minHeight
12
+ } = getComputedStyle(element);
13
+ const parsedWidth = parseFloat(minWidth);
14
+ const parsedHeight = parseFloat(minHeight);
15
+ return {
16
+ minWidth: Number.isNaN(parsedWidth) ? MIN_WIDTH : parsedWidth,
17
+ minHeight: Number.isNaN(parsedHeight) ? MIN_HEIGHT : parsedHeight
18
+ };
19
+ };
20
+ const moveGeometry = (start, dx, dy, viewportWidth, viewportHeight) => ({
21
+ ...start,
22
+ left: clamp(start.left + dx, 0, Math.max(0, viewportWidth - start.width)),
23
+ top: clamp(start.top + dy, 0, Math.max(0, viewportHeight - start.height))
24
+ });
25
+ const fitGeometry = (geometry, viewportWidth, viewportHeight) => {
26
+ const width = Math.min(geometry.width, viewportWidth);
27
+ const height = Math.min(geometry.height, viewportHeight);
28
+ return {
29
+ left: clamp(geometry.left, 0, Math.max(0, viewportWidth - width)),
30
+ top: clamp(geometry.top, 0, Math.max(0, viewportHeight - height)),
31
+ width,
32
+ height
33
+ };
34
+ };
35
+ const resizeGeometry = ({
36
+ geometry: start,
37
+ direction,
38
+ minWidth,
39
+ minHeight
40
+ }, dx, dy, viewportWidth, viewportHeight) => {
41
+ let left = start.left;
42
+ let right = start.left + start.width;
43
+ let top = start.top;
44
+ let bottom = start.top + start.height;
45
+ if (direction.includes('w')) {
46
+ left = clamp(start.left + dx, 0, right - Math.min(minWidth, right));
47
+ } else if (direction.includes('e')) {
48
+ right = clamp(right + dx, left + Math.min(minWidth, viewportWidth - left), viewportWidth);
49
+ }
50
+ if (direction.includes('n')) {
51
+ top = clamp(start.top + dy, 0, bottom - Math.min(minHeight, bottom));
52
+ } else if (direction.includes('s')) {
53
+ bottom = clamp(bottom + dy, top + Math.min(minHeight, viewportHeight - top), viewportHeight);
54
+ }
55
+ return {
56
+ left,
57
+ top,
58
+ width: right - left,
59
+ height: bottom - top
60
+ };
61
+ };
62
+
63
+ export { fitGeometry, getNativeTabIndex, getResizeMinimum, getTrapDisabled, moveGeometry, resizeGeometry };
@@ -1,6 +1,7 @@
1
1
  import { PureComponent } from 'react';
2
2
  import * as React from 'react';
3
3
  import { type TabTrapObject, type TabTrapProps } from '../tab-trap/tab-trap';
4
+ import { type DialogState, type Interaction, type InteractionDirection } from './dialog-geometry';
4
5
  import type { ShortcutsScopeOptions } from '../shortcuts/core';
5
6
  export interface DialogProps extends Partial<TabTrapProps> {
6
7
  show: boolean;
@@ -11,8 +12,9 @@ export interface DialogProps extends Partial<TabTrapProps> {
11
12
  onCloseAttempt: (event: React.MouseEvent<HTMLElement> | KeyboardEvent) => void;
12
13
  showCloseButton: boolean;
13
14
  shortcutOptions: ShortcutsScopeOptions;
14
- closeButtonInside: boolean;
15
15
  closeButtonTitle?: string;
16
+ movable?: boolean;
17
+ resizable?: boolean;
16
18
  trapFocus: boolean;
17
19
  contentClassName?: string | null | undefined;
18
20
  portalTarget?: Element | null | undefined;
@@ -22,11 +24,9 @@ export interface DialogProps extends Partial<TabTrapProps> {
22
24
  modal?: boolean;
23
25
  preventBodyScroll?: boolean;
24
26
  }
25
- export default class Dialog extends PureComponent<DialogProps> {
27
+ export default class Dialog extends PureComponent<DialogProps, DialogState> {
26
28
  static defaultProps: Partial<DialogProps>;
27
- state: {
28
- shortcutsScope: string;
29
- };
29
+ state: DialogState;
30
30
  componentDidMount(): void;
31
31
  componentDidUpdate(prevProps: DialogProps): void;
32
32
  componentWillUnmount(): void;
@@ -45,6 +45,14 @@ export default class Dialog extends PureComponent<DialogProps> {
45
45
  dialog?: HTMLElement | null;
46
46
  dialogRef: (tabTrapObj: TabTrapObject | null) => void;
47
47
  nativeDialog: React.RefObject<HTMLDialogElement | null>;
48
+ innerContainer: React.RefObject<HTMLDivElement | null>;
49
+ interaction: Interaction | null;
50
+ resizeMinimum: Pick<Interaction, 'minWidth' | 'minHeight'> | null;
51
+ fitGeometryToViewport: () => void;
52
+ startInteraction: (event: React.PointerEvent<HTMLElement>, direction: InteractionDirection) => void;
53
+ continueInteraction: (event: React.PointerEvent<HTMLElement>) => void;
54
+ stopInteraction: (event: React.PointerEvent<HTMLElement>) => void;
55
+ startMove: (event: React.PointerEvent<HTMLElement>) => void;
48
56
  render(): false | React.JSX.Element;
49
57
  }
50
58
  export type DialogAttrs = React.JSX.LibraryManagedAttributes<typeof Dialog, DialogProps>;