@qoretechnologies/reqore 0.78.5-pr.708.g432b59a → 0.78.5-pr.708.g79d92e0

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 (49) hide show
  1. package/dist/components/Drawer/index.d.ts +172 -0
  2. package/dist/components/Drawer/index.d.ts.map +1 -1
  3. package/dist/components/Drawer/index.js +260 -14
  4. package/dist/components/Drawer/index.js.map +1 -1
  5. package/dist/components/FadeScroller/index.d.ts.map +1 -1
  6. package/dist/components/FadeScroller/index.js +47 -17
  7. package/dist/components/FadeScroller/index.js.map +1 -1
  8. package/dist/components/Modal/index.d.ts +12 -2
  9. package/dist/components/Modal/index.d.ts.map +1 -1
  10. package/dist/components/Modal/index.js +2 -2
  11. package/dist/components/Modal/index.js.map +1 -1
  12. package/dist/components/Notifications/notification.d.ts +11 -1
  13. package/dist/components/Notifications/notification.d.ts.map +1 -1
  14. package/dist/components/Notifications/notification.js +96 -19
  15. package/dist/components/Notifications/notification.js.map +1 -1
  16. package/dist/components/RichTextEditor/index.d.ts.map +1 -1
  17. package/dist/components/RichTextEditor/index.js +19 -1
  18. package/dist/components/RichTextEditor/index.js.map +1 -1
  19. package/dist/components/Textarea/index.d.ts.map +1 -1
  20. package/dist/components/Textarea/index.js +14 -1
  21. package/dist/components/Textarea/index.js.map +1 -1
  22. package/dist/components/Tier/group.d.ts +5 -4
  23. package/dist/components/Tier/group.d.ts.map +1 -1
  24. package/dist/components/Tier/group.js +43 -122
  25. package/dist/components/Tier/group.js.map +1 -1
  26. package/dist/containers/ReqoreProvider.d.ts.map +1 -1
  27. package/dist/containers/ReqoreProvider.js +6 -8
  28. package/dist/containers/ReqoreProvider.js.map +1 -1
  29. package/dist/helpers/gestures.d.ts +30 -0
  30. package/dist/helpers/gestures.d.ts.map +1 -0
  31. package/dist/helpers/gestures.js +36 -0
  32. package/dist/helpers/gestures.js.map +1 -0
  33. package/dist/hooks/useDragToScroll.d.ts +6 -3
  34. package/dist/hooks/useDragToScroll.d.ts.map +1 -1
  35. package/dist/hooks/useDragToScroll.js +6 -3
  36. package/dist/hooks/useDragToScroll.js.map +1 -1
  37. package/dist/hooks/usePointerDrag.d.ts +77 -0
  38. package/dist/hooks/usePointerDrag.d.ts.map +1 -0
  39. package/dist/hooks/usePointerDrag.js +202 -0
  40. package/dist/hooks/usePointerDrag.js.map +1 -0
  41. package/dist/hooks/useReqoreMedia.d.ts +24 -0
  42. package/dist/hooks/useReqoreMedia.d.ts.map +1 -0
  43. package/dist/hooks/useReqoreMedia.js +32 -0
  44. package/dist/hooks/useReqoreMedia.js.map +1 -0
  45. package/dist/index.d.ts +4 -0
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +17 -3
  48. package/dist/index.js.map +1 -1
  49. package/package.json +1 -1
@@ -1,7 +1,131 @@
1
1
  import { IReqoreTheme } from '../../constants/theme';
2
2
  import type { IReqoreConfirmationModal } from '../../containers/ReqoreProvider';
3
+ import { IPointerDragDelta } from '../../hooks/usePointerDrag';
3
4
  import { IReqorePanelProps } from '../Panel';
4
5
  export type TPosition = 'top' | 'bottom' | 'left' | 'right';
6
+ /**
7
+ * The viewport width (px, inclusive) at or below which a `responsiveLayout`
8
+ * drawer becomes a sheet when the caller names no breakpoint. 900 is the
9
+ * number qorus-ide converged on for every one of its drawers: a 620–720px
10
+ * side panel in a 900px window leaves a sliver of page that is not usable
11
+ * anyway, so the sheet is the honest layout there. The provider's own
12
+ * `isMobile` (≤ 480px) is too narrow for drawers that wide — at 600px such a
13
+ * panel covers the viewport with its handle off-screen — and
14
+ * `isMobileOrTablet` (≤ 1200px) would put sheets on landscape tablets.
15
+ */
16
+ export declare const DRAWER_SHEET_BREAKPOINT = 900;
17
+ /**
18
+ * Which viewport width switches a `responsiveLayout` drawer into a sheet:
19
+ * `'mobile'` is the provider's `isMobile` (≤ 480px), `'tablet'` is its
20
+ * `isMobileOrTablet` (≤ 1200px), and a number is a width in px, inclusive.
21
+ * Omitted, it is `DRAWER_SHEET_BREAKPOINT`. Reqore owns these numbers; a
22
+ * consumer never carries a media query of its own for this.
23
+ */
24
+ export type TReqoreDrawerResponsiveBreakpoint = 'mobile' | 'tablet' | number;
25
+ export interface IReqoreDrawerResponsiveLayout {
26
+ /** Which viewport width switches the layout. Defaults to `DRAWER_SHEET_BREAKPOINT` (900px). */
27
+ below?: TReqoreDrawerResponsiveBreakpoint;
28
+ /** The edge the sheet attaches to while the layout is active. Defaults to `'bottom'`. */
29
+ position?: TPosition;
30
+ /** The sheet's size on the axis it occupies. Defaults to `'100%'`. */
31
+ size?: string;
32
+ /**
33
+ * The cap on that axis. Defaults to `'90vh'` — the same cap every drawer has
34
+ * on its cross axis by default, so a bottom sheet rises to 90% of the screen
35
+ * and leaves a strip of page above it where a tap on the backdrop closes it.
36
+ * Pass `'100%'` for an edge-to-edge sheet. Separate from the drawer's own
37
+ * `maxSize` on purpose: that one caps the SIDE drawer's width, and a value
38
+ * meant as a width must never become a sheet's height.
39
+ */
40
+ maxSize?: string;
41
+ }
42
+ export interface IReqoreDrawerResolvedResponsiveLayout {
43
+ /** Whether the sheet layout is in force for the current viewport. */
44
+ active: boolean;
45
+ /** The edge the sheet attaches to; only set while `active`. */
46
+ position?: TPosition;
47
+ /** The sheet's size on its axis; only set while `active`. */
48
+ size?: string;
49
+ /** The cap on that axis; only set while `active`. */
50
+ maxSize?: string;
51
+ }
52
+ export declare const DRAWER_RESPONSIVE_LAYOUT_DEFAULTS: Required<IReqoreDrawerResponsiveLayout>;
53
+ /**
54
+ * What the resolver needs to know about the viewport. The two named flags are
55
+ * the provider's; `belowSheetBreakpoint` answers "is the viewport at or below
56
+ * the numeric `below` (or `DRAWER_SHEET_BREAKPOINT` when none is given)" and
57
+ * is ignored when `below` names a provider breakpoint. The component evaluates
58
+ * it with one media query; a consumer calling the resolver itself evaluates
59
+ * it however it already measures the viewport.
60
+ */
61
+ export interface IReqoreDrawerResponsiveViewport {
62
+ isMobile: boolean;
63
+ isMobileOrTablet: boolean;
64
+ belowSheetBreakpoint: boolean;
65
+ }
66
+ /**
67
+ * Decides whether a drawer's `responsiveLayout` is in force, and with what
68
+ * geometry. Pure, so the decision is unit-testable without a viewport: jsdom
69
+ * has no `matchMedia`, so every breakpoint is fixed `false` in unit tests, and
70
+ * the rendered sheet is proven in a real browser instead — the
71
+ * `Dialogs/Drawer` `ResponsiveSheet*` stories do that at 380px and 800px.
72
+ *
73
+ * A modal (`_isModal`) is never turned into a sheet: it is already centred
74
+ * and sized for its content, and it has no edge to attach to.
75
+ */
76
+ export declare const resolveDrawerResponsiveLayout: (responsiveLayout: boolean | IReqoreDrawerResponsiveLayout | undefined, viewport: IReqoreDrawerResponsiveViewport, isModal?: boolean) => IReqoreDrawerResolvedResponsiveLayout;
77
+ /**
78
+ * The px width behind a `responsiveLayout` config's numeric `below`, or the
79
+ * default when it names a provider breakpoint or nothing — the component
80
+ * always subscribes to exactly one query, so a hook never comes and goes.
81
+ */
82
+ export declare const drawerSheetBreakpointPx: (responsiveLayout: boolean | IReqoreDrawerResponsiveLayout | undefined) => number;
83
+ /** An offset of the drawer's box from where it would otherwise sit, in px. */
84
+ export interface IReqoreDrawerDragOffset {
85
+ x: number;
86
+ y: number;
87
+ }
88
+ /**
89
+ * What a sheet dragged by `delta` does. `offset` is where to draw it meanwhile: it follows the
90
+ * finger toward the edge it is attached to and stays put when pulled the other way — a bottom
91
+ * sheet is not lifted off its edge. `closes` is whether letting go here closes it: past
92
+ * `SWIPE.distance` of its `size` on that axis, or with a flick (`SWIPE.velocity`) toward the edge.
93
+ */
94
+ export declare const getSheetSwipe: (position: TPosition, delta: IPointerDragDelta, size: number) => {
95
+ offset: IReqoreDrawerDragOffset;
96
+ closes: boolean;
97
+ };
98
+ /** What a modal's drag is held within. */
99
+ export interface IReqoreModalDragBounds {
100
+ /** The box with no offset applied: where the modal sits at rest. */
101
+ box: {
102
+ left: number;
103
+ top: number;
104
+ width: number;
105
+ height: number;
106
+ };
107
+ viewport: {
108
+ width: number;
109
+ height: number;
110
+ };
111
+ /** The height of the title bar, the part that has to stay reachable. */
112
+ handleHeight: number;
113
+ }
114
+ /**
115
+ * `offset` held so the modal's title bar stays whole in the viewport: the box's left and right
116
+ * edges inside it, the bar fully below the top and above the bottom. The title bar is what the
117
+ * modal is dragged and closed by, and one pushed off-screen has no way back. A box wider than
118
+ * the viewport cannot satisfy that on its axis; it is held to always span the viewport instead.
119
+ */
120
+ export declare const clampModalDragOffset: (offset: IReqoreDrawerDragOffset, { box, viewport, handleHeight }: IReqoreModalDragBounds) => IReqoreDrawerDragOffset;
121
+ /**
122
+ * Whether a press at `target` lands on the drawer's own title bar — the handle a sheet is swiped
123
+ * and a modal dragged by — and not on a control in it. The bar is the drawer panel's direct
124
+ * `.reqore-panel-title`; a panel in the drawer's content has one of its own, and that one is
125
+ * not a handle. A press on a button (the close control, an action), a link, a field or the
126
+ * actions' control group is theirs.
127
+ */
128
+ export declare const isDrawerHeaderGrab: (target: EventTarget | null, box: HTMLElement) => boolean;
5
129
  /** The floor an EDGE drawer cannot be dragged below, on the axis it resizes. */
6
130
  export declare const DRAWER_MIN_SIZE = "150px";
7
131
  /**
@@ -116,6 +240,54 @@ export interface IReqoreDrawerProps extends Omit<IReqorePanelProps, 'size' | 're
116
240
  confirmOnClose?: boolean | IReqoreConfirmationModal;
117
241
  /** Whether to trap focus within the drawer when open. Defaults to true for modals and drawers with backdrop. */
118
242
  focusTrap?: boolean;
243
+ /**
244
+ * Become a full-width sheet on small screens instead of a fixed-size edge
245
+ * panel. OPT-IN, because it changes geometry a caller may have sized for.
246
+ *
247
+ * A `size='720px'` right-hand drawer is unusable at 380px: it covers the
248
+ * whole viewport, its resize handle sits off-screen and nothing says why
249
+ * the page behind it stopped responding. With `responsiveLayout`, at or
250
+ * below the breakpoint — `DRAWER_SHEET_BREAKPOINT` (900px) unless `below`
251
+ * says `'mobile'` (≤ 480px), `'tablet'` (≤ 1200px) or a px number — the
252
+ * drawer attaches to the bottom edge (or the `position` given), takes
253
+ * `100%` of that axis (or the `size` given) up to a `maxSize` of `90vh`
254
+ * (or the one given; `'100%'` for edge to edge), and drops the affordances
255
+ * that make no sense on a sheet — `resizable`, `hidable` and `floating` are
256
+ * off while the layout is active, and a drawer the user had hidden on a
257
+ * wide screen is shown again rather than left hidden with no control to
258
+ * bring it back. Above the breakpoint nothing changes.
259
+ *
260
+ * These defaults are qorus-ide's `useResponsiveDrawerProps` behaviour moved
261
+ * into the library: bottom, full width, 90% of the height, at 900px. Pass
262
+ * `true` for them, or `{ below, position, size, maxSize }` to tune them.
263
+ * The root carries `.reqore-drawer-sheet` while the layout is active, so a
264
+ * story or test can assert which branch rendered.
265
+ *
266
+ * Reqore owns the breakpoints: consumers must not hand-roll a `matchMedia`
267
+ * for this — that is exactly the local workaround this prop replaces.
268
+ * Modals (`ReqoreModal`) ignore it; they are centred and content-sized
269
+ * already.
270
+ */
271
+ responsiveLayout?: boolean | IReqoreDrawerResponsiveLayout;
272
+ /**
273
+ * Whether the sheet can be pushed away. While `responsiveLayout` has made the drawer a sheet,
274
+ * dragging its title bar toward the edge it is attached to follows the finger, and letting go
275
+ * past `SWIPE.distance` (18%) of the sheet's size on that axis — or with a flick toward the
276
+ * edge — closes it through the same path as the close button, so `confirmOnClose` still asks
277
+ * first. A shorter drag springs back; at once under `prefers-reduced-motion` or with
278
+ * `animations.dialogs` off. The title bar alone is the handle (not a button, an action or a
279
+ * field in it), so the content scrolls as it always did, and every sheet `position` swipes
280
+ * toward its own edge. The box carries `.reqore-drawer-swipeable` while it is on and
281
+ * `.reqore-drawer-dragging` during a drag. Default `true`: a sheet a finger cannot push away
282
+ * reads as stuck. Nothing outside the sheet layout, and nothing without an `onClose`.
283
+ */
284
+ swipeToClose?: boolean;
285
+ /**
286
+ * `ReqoreModal`'s `draggable`, handed over under another name so that the HTML attribute of
287
+ * that name never reaches the DOM — it would start the browser's own drag of the panel.
288
+ * @internal
289
+ */
290
+ _draggable?: boolean;
119
291
  }
120
292
  export interface IReqoreDrawerStyle extends IReqoreDrawerProps {
121
293
  theme: IReqoreTheme;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Drawer/index.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAMhF,OAAO,EAAsB,iBAAiB,EAAe,MAAM,UAAU,CAAC;AAG9E,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5D,gFAAgF;AAChF,eAAO,MAAM,eAAe,UAAU,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,mCAAmC;AACnC,eAAO,MAAM,gBAAgB,SAAS,CAAC;AAEvC,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,WAAW,CAAC;IACvF,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,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,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,KAAK,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,KAQzB,CAAC;AAEF,eAAO,MAAM,kBAAkB,KA+C9B,CAAC;AAEF,eAAO,MAAM,qBAAqB,KAqDjC,CAAC;AAsCF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAsjBrD,CAAC"}
@@ -38,7 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  return (mod && mod.__esModule) ? mod : { "default": mod };
39
39
  };
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
- exports.ReqoreDrawer = exports.StyledDrawerResizable = exports.StyledCloseWrapper = exports.StyledWrapper = exports.MODAL_MIN_HEIGHT = exports.MODAL_MIN_WIDTH = exports.DRAWER_MIN_SIZE = void 0;
41
+ exports.ReqoreDrawer = exports.StyledDrawerResizable = exports.StyledCloseWrapper = exports.StyledWrapper = exports.MODAL_MIN_HEIGHT = exports.MODAL_MIN_WIDTH = exports.DRAWER_MIN_SIZE = exports.isDrawerHeaderGrab = exports.clampModalDragOffset = exports.getSheetSwipe = exports.drawerSheetBreakpointPx = exports.resolveDrawerResponsiveLayout = exports.DRAWER_RESPONSIVE_LAYOUT_DEFAULTS = exports.DRAWER_SHEET_BREAKPOINT = void 0;
42
42
  var jsx_runtime_1 = require("react/jsx-runtime");
43
43
  var web_1 = require("@react-spring/web");
44
44
  var re_resizable_1 = require("re-resizable");
@@ -47,13 +47,133 @@ var react_dom_1 = require("react-dom");
47
47
  var styled_components_1 = require("styled-components");
48
48
  var styled_1 = __importDefault(require("../../helpers/styled"));
49
49
  var __1 = require("../..");
50
+ var useReqoreMedia_1 = require("../../hooks/useReqoreMedia");
50
51
  var animations_1 = require("../../constants/animations");
51
52
  var ThemeProvider_1 = __importDefault(require("../../containers/ThemeProvider"));
53
+ var gestures_1 = require("../../helpers/gestures");
52
54
  var useFocusTrap_1 = require("../../hooks/useFocusTrap");
55
+ var usePointerDrag_1 = require("../../hooks/usePointerDrag");
56
+ var usePrefersReducedMotion_1 = require("../../hooks/usePrefersReducedMotion");
53
57
  var useTheme_1 = require("../../hooks/useTheme");
54
58
  var Button_1 = __importDefault(require("../Button"));
55
59
  var Panel_1 = require("../Panel");
56
60
  var backdrop_1 = require("./backdrop");
61
+ /**
62
+ * The viewport width (px, inclusive) at or below which a `responsiveLayout`
63
+ * drawer becomes a sheet when the caller names no breakpoint. 900 is the
64
+ * number qorus-ide converged on for every one of its drawers: a 620–720px
65
+ * side panel in a 900px window leaves a sliver of page that is not usable
66
+ * anyway, so the sheet is the honest layout there. The provider's own
67
+ * `isMobile` (≤ 480px) is too narrow for drawers that wide — at 600px such a
68
+ * panel covers the viewport with its handle off-screen — and
69
+ * `isMobileOrTablet` (≤ 1200px) would put sheets on landscape tablets.
70
+ */
71
+ exports.DRAWER_SHEET_BREAKPOINT = 900;
72
+ exports.DRAWER_RESPONSIVE_LAYOUT_DEFAULTS = {
73
+ below: exports.DRAWER_SHEET_BREAKPOINT,
74
+ position: 'bottom',
75
+ size: '100%',
76
+ maxSize: '90vh',
77
+ };
78
+ /**
79
+ * Decides whether a drawer's `responsiveLayout` is in force, and with what
80
+ * geometry. Pure, so the decision is unit-testable without a viewport: jsdom
81
+ * has no `matchMedia`, so every breakpoint is fixed `false` in unit tests, and
82
+ * the rendered sheet is proven in a real browser instead — the
83
+ * `Dialogs/Drawer` `ResponsiveSheet*` stories do that at 380px and 800px.
84
+ *
85
+ * A modal (`_isModal`) is never turned into a sheet: it is already centred
86
+ * and sized for its content, and it has no edge to attach to.
87
+ */
88
+ var resolveDrawerResponsiveLayout = function (responsiveLayout, viewport, isModal) {
89
+ var _a, _b, _c, _d;
90
+ if (!responsiveLayout || isModal) {
91
+ return { active: false };
92
+ }
93
+ var config = responsiveLayout === true ? {} : responsiveLayout;
94
+ var below = (_a = config.below) !== null && _a !== void 0 ? _a : exports.DRAWER_RESPONSIVE_LAYOUT_DEFAULTS.below;
95
+ var active = below === 'mobile'
96
+ ? viewport.isMobile
97
+ : below === 'tablet'
98
+ ? viewport.isMobileOrTablet
99
+ : viewport.belowSheetBreakpoint;
100
+ if (!active) {
101
+ return { active: false };
102
+ }
103
+ return {
104
+ active: true,
105
+ position: (_b = config.position) !== null && _b !== void 0 ? _b : exports.DRAWER_RESPONSIVE_LAYOUT_DEFAULTS.position,
106
+ size: (_c = config.size) !== null && _c !== void 0 ? _c : exports.DRAWER_RESPONSIVE_LAYOUT_DEFAULTS.size,
107
+ maxSize: (_d = config.maxSize) !== null && _d !== void 0 ? _d : exports.DRAWER_RESPONSIVE_LAYOUT_DEFAULTS.maxSize,
108
+ };
109
+ };
110
+ exports.resolveDrawerResponsiveLayout = resolveDrawerResponsiveLayout;
111
+ /**
112
+ * The px width behind a `responsiveLayout` config's numeric `below`, or the
113
+ * default when it names a provider breakpoint or nothing — the component
114
+ * always subscribes to exactly one query, so a hook never comes and goes.
115
+ */
116
+ var drawerSheetBreakpointPx = function (responsiveLayout) {
117
+ return responsiveLayout && responsiveLayout !== true && typeof responsiveLayout.below === 'number'
118
+ ? responsiveLayout.below
119
+ : exports.DRAWER_SHEET_BREAKPOINT;
120
+ };
121
+ exports.drawerSheetBreakpointPx = drawerSheetBreakpointPx;
122
+ /**
123
+ * What a sheet dragged by `delta` does. `offset` is where to draw it meanwhile: it follows the
124
+ * finger toward the edge it is attached to and stays put when pulled the other way — a bottom
125
+ * sheet is not lifted off its edge. `closes` is whether letting go here closes it: past
126
+ * `SWIPE.distance` of its `size` on that axis, or with a flick (`SWIPE.velocity`) toward the edge.
127
+ */
128
+ var getSheetSwipe = function (position, delta, size) {
129
+ var vertical = position === 'top' || position === 'bottom';
130
+ var towardEdge = position === 'bottom' || position === 'right' ? 1 : -1;
131
+ var distance = towardEdge * (vertical ? delta.dy : delta.dx);
132
+ var velocity = towardEdge * (vertical ? delta.vy : delta.vx);
133
+ var travel = distance > 0 ? towardEdge * distance : 0;
134
+ return {
135
+ offset: vertical ? { x: 0, y: travel } : { x: travel, y: 0 },
136
+ closes: (0, gestures_1.getSwipeStep)(distance, velocity, size) === 1,
137
+ };
138
+ };
139
+ exports.getSheetSwipe = getSheetSwipe;
140
+ var clampBetween = function (value, a, b) {
141
+ return Math.min(Math.max(value, Math.min(a, b)), Math.max(a, b));
142
+ };
143
+ /**
144
+ * `offset` held so the modal's title bar stays whole in the viewport: the box's left and right
145
+ * edges inside it, the bar fully below the top and above the bottom. The title bar is what the
146
+ * modal is dragged and closed by, and one pushed off-screen has no way back. A box wider than
147
+ * the viewport cannot satisfy that on its axis; it is held to always span the viewport instead.
148
+ */
149
+ var clampModalDragOffset = function (offset, _a) {
150
+ var box = _a.box, viewport = _a.viewport, handleHeight = _a.handleHeight;
151
+ return ({
152
+ x: clampBetween(offset.x, -box.left, viewport.width - box.left - box.width),
153
+ y: clampBetween(offset.y, -box.top, viewport.height - box.top - handleHeight),
154
+ });
155
+ };
156
+ exports.clampModalDragOffset = clampModalDragOffset;
157
+ /**
158
+ * Whether a press at `target` lands on the drawer's own title bar — the handle a sheet is swiped
159
+ * and a modal dragged by — and not on a control in it. The bar is the drawer panel's direct
160
+ * `.reqore-panel-title`; a panel in the drawer's content has one of its own, and that one is
161
+ * not a handle. A press on a button (the close control, an action), a link, a field or the
162
+ * actions' control group is theirs.
163
+ */
164
+ var isDrawerHeaderGrab = function (target, box) {
165
+ var _a;
166
+ if (!(target instanceof Element)) {
167
+ return false;
168
+ }
169
+ var bar = target.closest('.reqore-panel-title');
170
+ if (!bar || !((_a = bar.parentElement) === null || _a === void 0 ? void 0 : _a.classList.contains('reqore-drawer')) || !box.contains(bar)) {
171
+ return false;
172
+ }
173
+ var control = target.closest(usePointerDrag_1.DRAG_CONTROL_SELECTOR);
174
+ return !control || !bar.contains(control);
175
+ };
176
+ exports.isDrawerHeaderGrab = isDrawerHeaderGrab;
57
177
  /** The floor an EDGE drawer cannot be dragged below, on the axis it resizes. */
58
178
  exports.DRAWER_MIN_SIZE = '150px';
59
179
  /**
@@ -122,7 +242,13 @@ exports.StyledCloseWrapper = styled_1.default.div(templateObject_6 || (templateO
122
242
  return (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: flex;\n flex-flow: column;\n top: 0;\n margin-left: -35px;\n > * {\n margin-top: 5px;\n }\n "], ["\n display: flex;\n flex-flow: column;\n top: 0;\n margin-left: -35px;\n > * {\n margin-top: 5px;\n }\n "])));
123
243
  }
124
244
  });
125
- exports.StyledDrawerResizable = (0, styled_1.default)(web_1.animated.div)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n pointer-events: auto;\n\n ", "\n"], ["\n pointer-events: auto;\n\n ", "\n"])), function (_a) {
245
+ exports.StyledDrawerResizable = (0, styled_1.default)(web_1.animated.div)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n pointer-events: auto;\n\n ", "\n\n ", "\n\n ", "\n"], ["\n pointer-events: auto;\n\n ", "\n\n ", "\n\n ", "\n"])), function (_a) {
246
+ var $handle = _a.$handle;
247
+ return $handle && (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n /* The drawer's own title bar, not that of a panel in its content. The browser must not\n pan or zoom from a press there: the drag is ours. */\n > .reqore-drawer > .reqore-panel-title {\n touch-action: none;\n cursor: ", ";\n }\n "], ["\n /* The drawer's own title bar, not that of a panel in its content. The browser must not\n pan or zoom from a press there: the drag is ours. */\n > .reqore-drawer > .reqore-panel-title {\n touch-action: none;\n cursor: ", ";\n }\n "])), $handle === 'drag' ? 'move' : 'grab');
248
+ }, function (_a) {
249
+ var $handle = _a.$handle, $dragging = _a.$dragging;
250
+ return $dragging && (0, styled_components_1.css)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n user-select: none;\n\n > .reqore-drawer > .reqore-panel-title {\n cursor: ", ";\n }\n "], ["\n user-select: none;\n\n > .reqore-drawer > .reqore-panel-title {\n cursor: ", ";\n }\n "])), $handle === 'drag' ? 'move' : 'grabbing');
251
+ }, function (_a) {
126
252
  var $edgelessPosition = _a.$edgelessPosition;
127
253
  if (!$edgelessPosition) {
128
254
  return undefined;
@@ -135,7 +261,7 @@ exports.StyledDrawerResizable = (0, styled_1.default)(web_1.animated.div)(templa
135
261
  top: ['top', 'left', 'right'],
136
262
  bottom: ['bottom', 'left', 'right'],
137
263
  };
138
- return (0, styled_components_1.css)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n > .reqore-drawer {\n ", "\n }\n "], ["\n > .reqore-drawer {\n ", "\n }\n "])), sidesToStrip[$edgelessPosition].map(function (side) { return (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n border-", ": none;\n "], ["\n border-", ": none;\n "])), side); }));
264
+ return (0, styled_components_1.css)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n > .reqore-drawer {\n ", "\n }\n "], ["\n > .reqore-drawer {\n ", "\n }\n "])), sidesToStrip[$edgelessPosition].map(function (side) { return (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n border-", ": none;\n "], ["\n border-", ": none;\n "])), side); }));
139
265
  });
140
266
  /**
141
267
  * It returns an icon name based on the position and whether the panel is hidden or not
@@ -171,10 +297,10 @@ var getSpringConfig = function (isModal, position, floating) {
171
297
  };
172
298
  };
173
299
  exports.ReqoreDrawer = (0, react_1.memo)(function (_a) {
174
- var children = _a.children, isOpen = _a.isOpen, isHidden = _a.isHidden, customTheme = _a.customTheme, inheritCustomTheme = _a.inheritCustomTheme, _b = _a.position, position = _b === void 0 ? 'right' : _b, maxSize = _a.maxSize,
300
+ var children = _a.children, isOpen = _a.isOpen, isHidden = _a.isHidden, customTheme = _a.customTheme, inheritCustomTheme = _a.inheritCustomTheme, _b = _a.position, positionProp = _b === void 0 ? 'right' : _b, maxSizeProp = _a.maxSize,
175
301
  // No default here: the fallback differs per layout (see the Resizable
176
302
  // below), and a default would make "the caller said nothing" unreadable.
177
- minSize = _a.minSize, minWidth = _a.minWidth, minHeight = _a.minHeight, onClose = _a.onClose, _c = _a.hasBackdrop, hasBackdrop = _c === void 0 ? true : _c, size = _a.size, _d = _a.resizable, resizable = _d === void 0 ? true : _d, hidable = _a.hidable, onHideToggle = _a.onHideToggle, className = _a.className, flat = _a.flat, floating = _a.floating, blur = _a.blur, opacity = _a.opacity, intent = _a.intent, _isModal = _a._isModal, width = _a.width, height = _a.height, _e = _a.actions, actions = _e === void 0 ? [] : _e, customZIndex = _a.customZIndex, panelSize = _a.panelSize, confirmOnClose = _a.confirmOnClose, focusTrap = _a.focusTrap, rest = __rest(_a, ["children", "isOpen", "isHidden", "customTheme", "inheritCustomTheme", "position", "maxSize", "minSize", "minWidth", "minHeight", "onClose", "hasBackdrop", "size", "resizable", "hidable", "onHideToggle", "className", "flat", "floating", "blur", "opacity", "intent", "_isModal", "width", "height", "actions", "customZIndex", "panelSize", "confirmOnClose", "focusTrap"]);
303
+ minSize = _a.minSize, minWidth = _a.minWidth, minHeight = _a.minHeight, onClose = _a.onClose, _c = _a.hasBackdrop, hasBackdrop = _c === void 0 ? true : _c, sizeProp = _a.size, _d = _a.resizable, resizableProp = _d === void 0 ? true : _d, hidableProp = _a.hidable, onHideToggle = _a.onHideToggle, className = _a.className, flat = _a.flat, floatingProp = _a.floating, responsiveLayout = _a.responsiveLayout, swipeToClose = _a.swipeToClose, _draggable = _a._draggable, blur = _a.blur, opacity = _a.opacity, intent = _a.intent, _isModal = _a._isModal, width = _a.width, height = _a.height, _e = _a.actions, actions = _e === void 0 ? [] : _e, customZIndex = _a.customZIndex, panelSize = _a.panelSize, confirmOnClose = _a.confirmOnClose, focusTrap = _a.focusTrap, rest = __rest(_a, ["children", "isOpen", "isHidden", "customTheme", "inheritCustomTheme", "position", "maxSize", "minSize", "minWidth", "minHeight", "onClose", "hasBackdrop", "size", "resizable", "hidable", "onHideToggle", "className", "flat", "floating", "responsiveLayout", "swipeToClose", "_draggable", "blur", "opacity", "intent", "_isModal", "width", "height", "actions", "customZIndex", "panelSize", "confirmOnClose", "focusTrap"]);
178
304
  // Ref for the drawer wrapper to enable focus trapping
179
305
  var drawerRef = (0, react_1.useRef)(null);
180
306
  var animations = (0, __1.useReqoreProperty)('animations');
@@ -182,6 +308,24 @@ exports.ReqoreDrawer = (0, react_1.memo)(function (_a) {
182
308
  var customPortalId = (0, __1.useReqoreProperty)('customPortalId');
183
309
  var getAndIncreaseZIndex = (0, __1.useReqoreProperty)('getAndIncreaseZIndex');
184
310
  var theme = (0, useTheme_1.useReqoreTheme)('main', customTheme, intent, undefined, inheritCustomTheme);
311
+ var isMobile = (0, __1.useReqoreProperty)('isMobile');
312
+ var isMobileOrTablet = (0, __1.useReqoreProperty)('isMobileOrTablet');
313
+ // One query, always subscribed (a hook cannot come and go with the prop):
314
+ // the numeric sheet breakpoint, or the default when a provider breakpoint
315
+ // is named and this flag is ignored anyway.
316
+ var belowSheetBreakpoint = (0, useReqoreMedia_1.useReqoreMedia)("(max-width: ".concat((0, exports.drawerSheetBreakpointPx)(responsiveLayout), "px)"));
317
+ // The sheet decision is made once per render from the breakpoints, and
318
+ // every geometry input below is derived from it, so the rest of the
319
+ // component never has to ask "is the layout active?" again.
320
+ var sheet = (0, react_1.useMemo)(function () {
321
+ return (0, exports.resolveDrawerResponsiveLayout)(responsiveLayout, { isMobile: isMobile, isMobileOrTablet: isMobileOrTablet, belowSheetBreakpoint: belowSheetBreakpoint }, _isModal);
322
+ }, [responsiveLayout, isMobile, isMobileOrTablet, belowSheetBreakpoint, _isModal]);
323
+ var position = sheet.active ? sheet.position : positionProp;
324
+ var size = sheet.active ? sheet.size : sizeProp;
325
+ var maxSize = sheet.active ? sheet.maxSize : maxSizeProp;
326
+ var resizable = sheet.active ? false : resizableProp;
327
+ var hidable = sheet.active ? false : hidableProp;
328
+ var floating = sheet.active ? false : floatingProp;
185
329
  var layout = (0, react_1.useMemo)(function () {
186
330
  return _isModal
187
331
  ? 'center'
@@ -190,6 +334,10 @@ exports.ReqoreDrawer = (0, react_1.memo)(function (_a) {
190
334
  : 'vertical';
191
335
  }, [position, _isModal]);
192
336
  var _f = (0, react_1.useState)(isHidden || false), _isHidden = _f[0], setIsHidden = _f[1];
337
+ // A sheet has no hide control, so a drawer hidden on a wide screen is shown
338
+ // again when the layout becomes active; the user's choice is kept in
339
+ // `_isHidden` and honoured again once the viewport widens.
340
+ var hidden = sheet.active ? false : _isHidden;
193
341
  var _g = (0, react_1.useState)({
194
342
  width: width || (layout === 'horizontal' ? 'auto' : size || '300px'),
195
343
  height: height || (layout === 'vertical' ? 'auto' : size || '300px'),
@@ -199,7 +347,7 @@ exports.ReqoreDrawer = (0, react_1.memo)(function (_a) {
199
347
  var shouldTrapFocus = focusTrap !== null && focusTrap !== void 0 ? focusTrap : (_isModal || hasBackdrop);
200
348
  // Use focus trap to keep focus within the drawer when open
201
349
  (0, useFocusTrap_1.useFocusTrap)(drawerRef, {
202
- active: isOpen && shouldTrapFocus && !_isHidden,
350
+ active: isOpen && shouldTrapFocus && !hidden,
203
351
  restoreFocus: true,
204
352
  autoFocus: true,
205
353
  });
@@ -256,6 +404,102 @@ exports.ReqoreDrawer = (0, react_1.memo)(function (_a) {
256
404
  }
257
405
  }
258
406
  : undefined;
407
+ var isHoverCapable = (0, __1.useReqoreProperty)('isHoverCapable');
408
+ var reducedMotion = (0, usePrefersReducedMotion_1.usePrefersReducedMotion)();
409
+ // Motion that is not the finger's own — a sheet let go early springing back — is instant
410
+ // when the user asked for less of it, or when dialog animations are off.
411
+ var immediateMotion = animations.dialogs === false || reducedMotion;
412
+ // A sheet with nothing to close into cannot be swiped. A modal is dragged only where the
413
+ // pointer can hover: the `move` cursor on its title bar is the affordance, and on a touch
414
+ // screen a press on a header belongs to the page.
415
+ var swipeable = sheet.active && swipeToClose !== false && !!onClose;
416
+ var draggable = !!_isModal && !!_draggable && isHoverCapable;
417
+ var _h = (0, web_1.useSpring)(function () { return ({ x: 0, y: 0, config: animations_1.SPRING_CONFIG }); }), drag = _h[0], dragApi = _h[1];
418
+ var dragStartRef = (0, react_1.useRef)(null);
419
+ var _j = (0, react_1.useState)(false), closedBySwipe = _j[0], setClosedBySwipe = _j[1];
420
+ var _k = (0, usePointerDrag_1.usePointerDrag)({
421
+ enabled: swipeable || draggable,
422
+ // A sheet moves on one axis, so a press that scrolls along the other is not a swipe.
423
+ axis: draggable ? 'both' : layout === 'horizontal' ? 'y' : 'x',
424
+ canStart: function (event) { return (0, exports.isDrawerHeaderGrab)(event.target, event.currentTarget); },
425
+ onStart: function (box) {
426
+ var _a, _b;
427
+ var rect = box.getBoundingClientRect();
428
+ var offset = { x: drag.x.get(), y: drag.y.get() };
429
+ dragStartRef.current = {
430
+ offset: offset,
431
+ size: layout === 'horizontal' ? rect.height : rect.width,
432
+ bounds: draggable
433
+ ? {
434
+ box: {
435
+ left: rect.left - offset.x,
436
+ top: rect.top - offset.y,
437
+ width: rect.width,
438
+ height: rect.height,
439
+ },
440
+ viewport: {
441
+ width: document.documentElement.clientWidth,
442
+ height: document.documentElement.clientHeight,
443
+ },
444
+ handleHeight: (_b = (_a = box
445
+ .querySelector(':scope > .reqore-drawer > .reqore-panel-title')) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height) !== null && _b !== void 0 ? _b : 0,
446
+ }
447
+ : undefined,
448
+ };
449
+ },
450
+ onMove: function (delta) {
451
+ var start = dragStartRef.current;
452
+ if (!start) {
453
+ return;
454
+ }
455
+ dragApi.set(start.bounds
456
+ ? (0, exports.clampModalDragOffset)({ x: start.offset.x + delta.dx, y: start.offset.y + delta.dy }, start.bounds)
457
+ : (0, exports.getSheetSwipe)(position, delta, start.size).offset);
458
+ },
459
+ onEnd: function (delta, committed) {
460
+ var start = dragStartRef.current;
461
+ dragStartRef.current = null;
462
+ // A modal stays where it was let go.
463
+ if (!start || start.bounds) {
464
+ return;
465
+ }
466
+ if (committed && (0, exports.getSheetSwipe)(position, delta, start.size).closes) {
467
+ // Closed from where the finger left it: the leave transition carries on from there.
468
+ setClosedBySwipe(true);
469
+ handleClose === null || handleClose === void 0 ? void 0 : handleClose();
470
+ }
471
+ else {
472
+ dragApi.start({ x: 0, y: 0, immediate: immediateMotion });
473
+ }
474
+ },
475
+ }), dragging = _k.dragging, dragHandlers = _k.handlers;
476
+ // A sheet whose swipe asked to close but is still open — `confirmOnClose` is asking, or the
477
+ // caller closes it later — springs back meanwhile; one that did close keeps its offset, so
478
+ // the leave transition carries on from where the finger left it.
479
+ (0, react_1.useEffect)(function () {
480
+ if (!closedBySwipe) {
481
+ return;
482
+ }
483
+ setClosedBySwipe(false);
484
+ if (isOpen) {
485
+ dragApi.start({ x: 0, y: 0, immediate: immediateMotion });
486
+ }
487
+ }, [closedBySwipe, isOpen]);
488
+ // Wherever the box was dragged to, it opens in its place next time.
489
+ (0, react_1.useEffect)(function () {
490
+ if (isOpen) {
491
+ dragApi.set({ x: 0, y: 0 });
492
+ }
493
+ }, [isOpen]);
494
+ // The box's `transform`: the drag's own translate ahead of whatever the enter / leave spring
495
+ // sets (a modal scales in), so neither overwrites the other. Nothing at rest, so a sheet
496
+ // keeps the plain box it always had.
497
+ var dragTransform = (0, react_1.useCallback)(function (spring) {
498
+ var own = (0, web_1.to)([drag.x, drag.y], function (x, y) {
499
+ return x || y ? "translate3d(".concat(x, "px, ").concat(y, "px, 0)") : '';
500
+ });
501
+ return spring ? (0, web_1.to)([own, spring], function (a, b) { return "".concat(a, " ").concat(b).trim(); }) : own;
502
+ }, [drag.x, drag.y]);
259
503
  var closeButtonProps = (0, react_1.useMemo)(function () { return (__assign({ className: 'reqore-drawer-close-button' }, (rest.closeButtonProps || {}))); }, [rest.closeButtonProps]);
260
504
  var panelStyle = (0, react_1.useMemo)(function () { return (__assign({ width: '100%', maxHeight: '100%' }, rest.style)); }, [JSON.stringify(rest.style)]);
261
505
  var resizeableStyle = (0, react_1.useMemo)(function () {
@@ -319,18 +563,18 @@ exports.ReqoreDrawer = (0, react_1.memo)(function (_a) {
319
563
  width: _isModal
320
564
  ? _size.width
321
565
  : layout === 'vertical'
322
- ? _isHidden
566
+ ? hidden
323
567
  ? 0
324
568
  : _size.width
325
569
  : 'auto',
326
570
  height: _isModal
327
571
  ? _size.height
328
572
  : layout === 'horizontal'
329
- ? _isHidden
573
+ ? hidden
330
574
  ? 0
331
575
  : _size.height
332
576
  : 'auto',
333
- }); }, [_isModal, layout, _isHidden, _size]);
577
+ }); }, [_isModal, layout, hidden, _size]);
334
578
  var onHideToggleClick = (0, react_1.useCallback)(function () {
335
579
  setIsHidden(!_isHidden);
336
580
  onHideToggle === null || onHideToggle === void 0 ? void 0 : onHideToggle(!_isHidden);
@@ -377,22 +621,24 @@ exports.ReqoreDrawer = (0, react_1.memo)(function (_a) {
377
621
  };
378
622
  }, [resizable, position, _isModal]);
379
623
  return (0, react_dom_1.createPortal)(transitions(function (styles, item) {
380
- return item ? ((0, jsx_runtime_1.jsxs)(ThemeProvider_1.default, { theme: theme, customTheme: customTheme, children: [hasBackdrop && !_isHidden ? ((0, jsx_runtime_1.jsx)(backdrop_1.ReqoreBackdrop, { onClose: handleClose, zIndex: zIndex, blur: blur, opacity: styles.opacity })) : null, (0, jsx_runtime_1.jsx)(exports.StyledWrapper, { ref: drawerRef, zIndex: wrapperZIndex, className: 'reqore-drawer-wrapper', role: _isModal || hasBackdrop ? 'dialog' : undefined, "aria-modal": _isModal || hasBackdrop ? 'true' : undefined, children: (0, jsx_runtime_1.jsxs)(re_resizable_1.Resizable, __assign({ className: "".concat(className || '', " reqore-drawer-resizable"), maxHeight: layout === 'horizontal' || layout === 'center' ? maxSize || '90vh' : undefined, minHeight: layout === 'center'
624
+ return item ? ((0, jsx_runtime_1.jsxs)(ThemeProvider_1.default, { theme: theme, customTheme: customTheme, children: [hasBackdrop && !hidden ? ((0, jsx_runtime_1.jsx)(backdrop_1.ReqoreBackdrop, { onClose: handleClose, zIndex: zIndex, blur: blur, opacity: styles.opacity })) : null, (0, jsx_runtime_1.jsx)(exports.StyledWrapper, { ref: drawerRef, zIndex: wrapperZIndex, className: 'reqore-drawer-wrapper', role: _isModal || hasBackdrop ? 'dialog' : undefined, "aria-modal": _isModal || hasBackdrop ? 'true' : undefined, children: (0, jsx_runtime_1.jsxs)(re_resizable_1.Resizable, __assign({ className: "".concat(className || '', " reqore-drawer-resizable").concat(sheet.active ? ' reqore-drawer-sheet' : '').concat(swipeable ? ' reqore-drawer-swipeable' : '').concat(draggable ? ' reqore-drawer-draggable' : '').concat(dragging ? ' reqore-drawer-dragging' : ''), maxHeight: layout === 'horizontal' || layout === 'center' ? maxSize || '90vh' : undefined, minHeight: layout === 'center'
381
625
  ? minHeight || minSize || exports.MODAL_MIN_HEIGHT
382
626
  : layout === 'horizontal'
383
- ? _isHidden
627
+ ? hidden
384
628
  ? 0
385
629
  : minSize || exports.DRAWER_MIN_SIZE
386
630
  : undefined, maxWidth: layout === 'vertical' || layout === 'center' ? maxSize || '90vw' : undefined, minWidth: layout === 'center'
387
631
  ? minWidth || minSize || exports.MODAL_MIN_WIDTH
388
632
  : layout === 'vertical'
389
- ? _isHidden
633
+ ? hidden
390
634
  ? 0
391
635
  : minSize || exports.DRAWER_MIN_SIZE
392
636
  : undefined, as: exports.StyledDrawerResizable }, {
393
637
  $edgelessPosition: !floating && !_isModal ? position : undefined,
394
- }, { style: __assign(__assign({}, resizeableStyle), styles), handleWrapperStyle: handleWrapperStyle, size: sizeObject, onResize: handleResize, enable: enable, children: [_isHidden && hidable ? ((0, jsx_runtime_1.jsx)(exports.StyledCloseWrapper, { className: 'reqore-drawer-controls', position: position, w: layout === 'vertical' ? 0 : _size.width, h: layout === 'horizontal' ? 0 : _size.height, children: (0, jsx_runtime_1.jsx)(Button_1.default, { flat: true, customTheme: theme, className: 'reqore-drawer-control reqore-drawer-hide-button', icon: getHideShowIcon(position, _isHidden), onClick: onHideToggleClick }) })) : null, !_isHidden && ((0, jsx_runtime_1.jsx)(Panel_1.ReqorePanel, __assign({}, rest, { size: panelSize, opacity: opacity, blur: hasBackdrop ? 0 : blur, actions: _actions, customTheme: customTheme, intent: intent, rounded: floating || _isModal ? true : false, flat: flat, onClose: handleClose, closeButtonProps: closeButtonProps, className: "reqore-drawer", style: panelStyle, children: children })))] })) })] })) : null;
638
+ $handle: draggable ? 'drag' : swipeable ? 'swipe' : undefined,
639
+ $dragging: dragging,
640
+ }, dragHandlers, { style: __assign(__assign(__assign({}, resizeableStyle), styles), { transform: dragTransform(styles.transform) }), handleWrapperStyle: handleWrapperStyle, size: sizeObject, onResize: handleResize, enable: enable, children: [hidden && hidable ? ((0, jsx_runtime_1.jsx)(exports.StyledCloseWrapper, { className: 'reqore-drawer-controls', position: position, w: layout === 'vertical' ? 0 : _size.width, h: layout === 'horizontal' ? 0 : _size.height, children: (0, jsx_runtime_1.jsx)(Button_1.default, { flat: true, customTheme: theme, className: 'reqore-drawer-control reqore-drawer-hide-button', icon: getHideShowIcon(position, _isHidden), onClick: onHideToggleClick }) })) : null, !hidden && ((0, jsx_runtime_1.jsx)(Panel_1.ReqorePanel, __assign({}, rest, { size: panelSize, opacity: opacity, blur: hasBackdrop ? 0 : blur, actions: _actions, customTheme: customTheme, intent: intent, rounded: floating || _isModal ? true : false, flat: flat, onClose: handleClose, closeButtonProps: closeButtonProps, className: "reqore-drawer", style: panelStyle, children: children })))] })) })] })) : null;
395
641
  }), document.querySelector(customPortalId || '#reqore-portal'));
396
642
  });
397
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9;
643
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11;
398
644
  //# sourceMappingURL=index.js.map