@qoretechnologies/reqore 0.78.1-pr.708.g9e025c6 → 0.78.1-pr.714.g8232ee3

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 (112) hide show
  1. package/dist/components/Button/index.d.ts.map +1 -1
  2. package/dist/components/Button/index.js +1 -1
  3. package/dist/components/Button/index.js.map +1 -1
  4. package/dist/components/ButtonRail/index.d.ts.map +1 -1
  5. package/dist/components/ButtonRail/index.js +1 -9
  6. package/dist/components/ButtonRail/index.js.map +1 -1
  7. package/dist/components/DataView/index.d.ts.map +1 -1
  8. package/dist/components/DataView/index.js +4 -1
  9. package/dist/components/DataView/index.js.map +1 -1
  10. package/dist/components/Drawer/index.d.ts +172 -0
  11. package/dist/components/Drawer/index.d.ts.map +1 -1
  12. package/dist/components/Drawer/index.js +260 -14
  13. package/dist/components/Drawer/index.js.map +1 -1
  14. package/dist/components/FadeScroller/index.d.ts.map +1 -1
  15. package/dist/components/FadeScroller/index.js +44 -170
  16. package/dist/components/FadeScroller/index.js.map +1 -1
  17. package/dist/components/FeatureCard/index.d.ts +27 -2
  18. package/dist/components/FeatureCard/index.d.ts.map +1 -1
  19. package/dist/components/FeatureCard/index.js +18 -4
  20. package/dist/components/FeatureCard/index.js.map +1 -1
  21. package/dist/components/Input/index.d.ts.map +1 -1
  22. package/dist/components/Input/index.js +1 -1
  23. package/dist/components/Input/index.js.map +1 -1
  24. package/dist/components/Layout/index.d.ts +12 -1
  25. package/dist/components/Layout/index.d.ts.map +1 -1
  26. package/dist/components/Layout/index.js +10 -6
  27. package/dist/components/Layout/index.js.map +1 -1
  28. package/dist/components/Modal/index.d.ts +12 -2
  29. package/dist/components/Modal/index.d.ts.map +1 -1
  30. package/dist/components/Modal/index.js +2 -2
  31. package/dist/components/Modal/index.js.map +1 -1
  32. package/dist/components/Notifications/notification.d.ts +11 -1
  33. package/dist/components/Notifications/notification.d.ts.map +1 -1
  34. package/dist/components/Notifications/notification.js +96 -19
  35. package/dist/components/Notifications/notification.js.map +1 -1
  36. package/dist/components/Panel/index.d.ts +35 -1
  37. package/dist/components/Panel/index.d.ts.map +1 -1
  38. package/dist/components/Panel/index.js +42 -21
  39. package/dist/components/Panel/index.js.map +1 -1
  40. package/dist/components/Popover/index.d.ts.map +1 -1
  41. package/dist/components/Popover/index.js +0 -14
  42. package/dist/components/Popover/index.js.map +1 -1
  43. package/dist/components/RichTextEditor/index.d.ts.map +1 -1
  44. package/dist/components/RichTextEditor/index.js +4 -14
  45. package/dist/components/RichTextEditor/index.js.map +1 -1
  46. package/dist/components/SegmentedControl/index.d.ts +14 -2
  47. package/dist/components/SegmentedControl/index.d.ts.map +1 -1
  48. package/dist/components/SegmentedControl/index.js +34 -24
  49. package/dist/components/SegmentedControl/index.js.map +1 -1
  50. package/dist/components/Statistic/index.d.ts +35 -0
  51. package/dist/components/Statistic/index.d.ts.map +1 -1
  52. package/dist/components/Statistic/index.js +26 -4
  53. package/dist/components/Statistic/index.js.map +1 -1
  54. package/dist/components/Tier/group.d.ts +135 -0
  55. package/dist/components/Tier/group.d.ts.map +1 -0
  56. package/dist/components/Tier/group.js +528 -0
  57. package/dist/components/Tier/group.js.map +1 -0
  58. package/dist/components/Tier/index.d.ts +84 -1
  59. package/dist/components/Tier/index.d.ts.map +1 -1
  60. package/dist/components/Tier/index.js +213 -5
  61. package/dist/components/Tier/index.js.map +1 -1
  62. package/dist/components/Timeline/index.d.ts +14 -0
  63. package/dist/components/Timeline/index.d.ts.map +1 -1
  64. package/dist/components/Timeline/index.js +27 -12
  65. package/dist/components/Timeline/index.js.map +1 -1
  66. package/dist/constants/fonts.d.ts +1 -1
  67. package/dist/constants/fonts.js +1 -1
  68. package/dist/constants/theme.d.ts +14 -0
  69. package/dist/constants/theme.d.ts.map +1 -1
  70. package/dist/constants/theme.js.map +1 -1
  71. package/dist/containers/ReqoreProvider.d.ts.map +1 -1
  72. package/dist/containers/ReqoreProvider.js +6 -8
  73. package/dist/containers/ReqoreProvider.js.map +1 -1
  74. package/dist/containers/UIProvider.d.ts +9 -0
  75. package/dist/containers/UIProvider.d.ts.map +1 -1
  76. package/dist/containers/UIProvider.js +8 -4
  77. package/dist/containers/UIProvider.js.map +1 -1
  78. package/dist/helpers/gestures.d.ts +30 -0
  79. package/dist/helpers/gestures.d.ts.map +1 -0
  80. package/dist/helpers/gestures.js +36 -0
  81. package/dist/helpers/gestures.js.map +1 -0
  82. package/dist/helpers/utils.d.ts +6 -0
  83. package/dist/helpers/utils.d.ts.map +1 -1
  84. package/dist/helpers/utils.js +14 -1
  85. package/dist/helpers/utils.js.map +1 -1
  86. package/dist/hooks/useCountUp.d.ts +71 -0
  87. package/dist/hooks/useCountUp.d.ts.map +1 -0
  88. package/dist/hooks/useCountUp.js +210 -0
  89. package/dist/hooks/useCountUp.js.map +1 -0
  90. package/dist/hooks/useNarrowContainer.d.ts +5 -0
  91. package/dist/hooks/useNarrowContainer.d.ts.map +1 -1
  92. package/dist/hooks/useNarrowContainer.js +17 -0
  93. package/dist/hooks/useNarrowContainer.js.map +1 -1
  94. package/dist/hooks/usePointerDrag.d.ts +77 -0
  95. package/dist/hooks/usePointerDrag.d.ts.map +1 -0
  96. package/dist/hooks/usePointerDrag.js +192 -0
  97. package/dist/hooks/usePointerDrag.js.map +1 -0
  98. package/dist/hooks/usePrefersReducedMotion.d.ts +13 -0
  99. package/dist/hooks/usePrefersReducedMotion.d.ts.map +1 -0
  100. package/dist/hooks/usePrefersReducedMotion.js +42 -0
  101. package/dist/hooks/usePrefersReducedMotion.js.map +1 -0
  102. package/dist/hooks/useReqoreMedia.d.ts +24 -0
  103. package/dist/hooks/useReqoreMedia.d.ts.map +1 -0
  104. package/dist/hooks/useReqoreMedia.js +32 -0
  105. package/dist/hooks/useReqoreMedia.js.map +1 -0
  106. package/dist/index.d.ts +5 -0
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +19 -3
  109. package/dist/index.js.map +1 -1
  110. package/dist/types/global.d.ts +8 -0
  111. package/dist/types/global.d.ts.map +1 -1
  112. 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":"AAOA,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;;;;;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K,CAAC,EAAE,CAAC,kBAAkB,CAsjBrD,CAAC"}
@@ -71,7 +71,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
71
71
  return (mod && mod.__esModule) ? mod : { "default": mod };
72
72
  };
73
73
  Object.defineProperty(exports, "__esModule", { value: true });
74
- exports.ReqoreDrawer = exports.StyledDrawerResizable = exports.StyledCloseWrapper = exports.StyledWrapper = exports.MODAL_MIN_HEIGHT = exports.MODAL_MIN_WIDTH = exports.DRAWER_MIN_SIZE = void 0;
74
+ 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;
75
75
  var jsx_runtime_1 = require("react/jsx-runtime");
76
76
  var web_1 = require("@react-spring/web");
77
77
  var re_resizable_1 = require("re-resizable");
@@ -79,13 +79,133 @@ var react_1 = require("react");
79
79
  var react_dom_1 = require("react-dom");
80
80
  var styled_components_1 = __importStar(require("styled-components"));
81
81
  var __1 = require("../..");
82
+ var useReqoreMedia_1 = require("../../hooks/useReqoreMedia");
82
83
  var animations_1 = require("../../constants/animations");
83
84
  var ThemeProvider_1 = __importDefault(require("../../containers/ThemeProvider"));
85
+ var gestures_1 = require("../../helpers/gestures");
84
86
  var useFocusTrap_1 = require("../../hooks/useFocusTrap");
87
+ var usePointerDrag_1 = require("../../hooks/usePointerDrag");
88
+ var usePrefersReducedMotion_1 = require("../../hooks/usePrefersReducedMotion");
85
89
  var useTheme_1 = require("../../hooks/useTheme");
86
90
  var Button_1 = __importDefault(require("../Button"));
87
91
  var Panel_1 = require("../Panel");
88
92
  var backdrop_1 = require("./backdrop");
93
+ /**
94
+ * The viewport width (px, inclusive) at or below which a `responsiveLayout`
95
+ * drawer becomes a sheet when the caller names no breakpoint. 900 is the
96
+ * number qorus-ide converged on for every one of its drawers: a 620–720px
97
+ * side panel in a 900px window leaves a sliver of page that is not usable
98
+ * anyway, so the sheet is the honest layout there. The provider's own
99
+ * `isMobile` (≤ 480px) is too narrow for drawers that wide — at 600px such a
100
+ * panel covers the viewport with its handle off-screen — and
101
+ * `isMobileOrTablet` (≤ 1200px) would put sheets on landscape tablets.
102
+ */
103
+ exports.DRAWER_SHEET_BREAKPOINT = 900;
104
+ exports.DRAWER_RESPONSIVE_LAYOUT_DEFAULTS = {
105
+ below: exports.DRAWER_SHEET_BREAKPOINT,
106
+ position: 'bottom',
107
+ size: '100%',
108
+ maxSize: '90vh',
109
+ };
110
+ /**
111
+ * Decides whether a drawer's `responsiveLayout` is in force, and with what
112
+ * geometry. Pure, so the decision is unit-testable without a viewport: jsdom
113
+ * has no `matchMedia`, so every breakpoint is fixed `false` in unit tests, and
114
+ * the rendered sheet is proven in a real browser instead — the
115
+ * `Dialogs/Drawer` `ResponsiveSheet*` stories do that at 380px and 800px.
116
+ *
117
+ * A modal (`_isModal`) is never turned into a sheet: it is already centred
118
+ * and sized for its content, and it has no edge to attach to.
119
+ */
120
+ var resolveDrawerResponsiveLayout = function (responsiveLayout, viewport, isModal) {
121
+ var _a, _b, _c, _d;
122
+ if (!responsiveLayout || isModal) {
123
+ return { active: false };
124
+ }
125
+ var config = responsiveLayout === true ? {} : responsiveLayout;
126
+ var below = (_a = config.below) !== null && _a !== void 0 ? _a : exports.DRAWER_RESPONSIVE_LAYOUT_DEFAULTS.below;
127
+ var active = below === 'mobile'
128
+ ? viewport.isMobile
129
+ : below === 'tablet'
130
+ ? viewport.isMobileOrTablet
131
+ : viewport.belowSheetBreakpoint;
132
+ if (!active) {
133
+ return { active: false };
134
+ }
135
+ return {
136
+ active: true,
137
+ position: (_b = config.position) !== null && _b !== void 0 ? _b : exports.DRAWER_RESPONSIVE_LAYOUT_DEFAULTS.position,
138
+ size: (_c = config.size) !== null && _c !== void 0 ? _c : exports.DRAWER_RESPONSIVE_LAYOUT_DEFAULTS.size,
139
+ maxSize: (_d = config.maxSize) !== null && _d !== void 0 ? _d : exports.DRAWER_RESPONSIVE_LAYOUT_DEFAULTS.maxSize,
140
+ };
141
+ };
142
+ exports.resolveDrawerResponsiveLayout = resolveDrawerResponsiveLayout;
143
+ /**
144
+ * The px width behind a `responsiveLayout` config's numeric `below`, or the
145
+ * default when it names a provider breakpoint or nothing — the component
146
+ * always subscribes to exactly one query, so a hook never comes and goes.
147
+ */
148
+ var drawerSheetBreakpointPx = function (responsiveLayout) {
149
+ return responsiveLayout && responsiveLayout !== true && typeof responsiveLayout.below === 'number'
150
+ ? responsiveLayout.below
151
+ : exports.DRAWER_SHEET_BREAKPOINT;
152
+ };
153
+ exports.drawerSheetBreakpointPx = drawerSheetBreakpointPx;
154
+ /**
155
+ * What a sheet dragged by `delta` does. `offset` is where to draw it meanwhile: it follows the
156
+ * finger toward the edge it is attached to and stays put when pulled the other way — a bottom
157
+ * sheet is not lifted off its edge. `closes` is whether letting go here closes it: past
158
+ * `SWIPE.distance` of its `size` on that axis, or with a flick (`SWIPE.velocity`) toward the edge.
159
+ */
160
+ var getSheetSwipe = function (position, delta, size) {
161
+ var vertical = position === 'top' || position === 'bottom';
162
+ var towardEdge = position === 'bottom' || position === 'right' ? 1 : -1;
163
+ var distance = towardEdge * (vertical ? delta.dy : delta.dx);
164
+ var velocity = towardEdge * (vertical ? delta.vy : delta.vx);
165
+ var travel = distance > 0 ? towardEdge * distance : 0;
166
+ return {
167
+ offset: vertical ? { x: 0, y: travel } : { x: travel, y: 0 },
168
+ closes: (0, gestures_1.getSwipeStep)(distance, velocity, size) === 1,
169
+ };
170
+ };
171
+ exports.getSheetSwipe = getSheetSwipe;
172
+ var clampBetween = function (value, a, b) {
173
+ return Math.min(Math.max(value, Math.min(a, b)), Math.max(a, b));
174
+ };
175
+ /**
176
+ * `offset` held so the modal's title bar stays whole in the viewport: the box's left and right
177
+ * edges inside it, the bar fully below the top and above the bottom. The title bar is what the
178
+ * modal is dragged and closed by, and one pushed off-screen has no way back. A box wider than
179
+ * the viewport cannot satisfy that on its axis; it is held to always span the viewport instead.
180
+ */
181
+ var clampModalDragOffset = function (offset, _a) {
182
+ var box = _a.box, viewport = _a.viewport, handleHeight = _a.handleHeight;
183
+ return ({
184
+ x: clampBetween(offset.x, -box.left, viewport.width - box.left - box.width),
185
+ y: clampBetween(offset.y, -box.top, viewport.height - box.top - handleHeight),
186
+ });
187
+ };
188
+ exports.clampModalDragOffset = clampModalDragOffset;
189
+ /**
190
+ * Whether a press at `target` lands on the drawer's own title bar — the handle a sheet is swiped
191
+ * and a modal dragged by — and not on a control in it. The bar is the drawer panel's direct
192
+ * `.reqore-panel-title`; a panel in the drawer's content has one of its own, and that one is
193
+ * not a handle. A press on a button (the close control, an action), a link, a field or the
194
+ * actions' control group is theirs.
195
+ */
196
+ var isDrawerHeaderGrab = function (target, box) {
197
+ var _a;
198
+ if (!(target instanceof Element)) {
199
+ return false;
200
+ }
201
+ var bar = target.closest('.reqore-panel-title');
202
+ if (!bar || !((_a = bar.parentElement) === null || _a === void 0 ? void 0 : _a.classList.contains('reqore-drawer')) || !box.contains(bar)) {
203
+ return false;
204
+ }
205
+ var control = target.closest(usePointerDrag_1.DRAG_CONTROL_SELECTOR);
206
+ return !control || !bar.contains(control);
207
+ };
208
+ exports.isDrawerHeaderGrab = isDrawerHeaderGrab;
89
209
  /** The floor an EDGE drawer cannot be dragged below, on the axis it resizes. */
90
210
  exports.DRAWER_MIN_SIZE = '150px';
91
211
  /**
@@ -154,7 +274,13 @@ exports.StyledCloseWrapper = styled_components_1.default.div(templateObject_6 ||
154
274
  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 "])));
155
275
  }
156
276
  });
157
- exports.StyledDrawerResizable = (0, styled_components_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) {
277
+ exports.StyledDrawerResizable = (0, styled_components_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) {
278
+ var $handle = _a.$handle;
279
+ 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');
280
+ }, function (_a) {
281
+ var $handle = _a.$handle, $dragging = _a.$dragging;
282
+ 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');
283
+ }, function (_a) {
158
284
  var $edgelessPosition = _a.$edgelessPosition;
159
285
  if (!$edgelessPosition) {
160
286
  return undefined;
@@ -167,7 +293,7 @@ exports.StyledDrawerResizable = (0, styled_components_1.default)(web_1.animated.
167
293
  top: ['top', 'left', 'right'],
168
294
  bottom: ['bottom', 'left', 'right'],
169
295
  };
170
- 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); }));
296
+ 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); }));
171
297
  });
172
298
  /**
173
299
  * It returns an icon name based on the position and whether the panel is hidden or not
@@ -203,10 +329,10 @@ var getSpringConfig = function (isModal, position, floating) {
203
329
  };
204
330
  };
205
331
  exports.ReqoreDrawer = (0, react_1.memo)(function (_a) {
206
- 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,
332
+ 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,
207
333
  // No default here: the fallback differs per layout (see the Resizable
208
334
  // below), and a default would make "the caller said nothing" unreadable.
209
- 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"]);
335
+ 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"]);
210
336
  // Ref for the drawer wrapper to enable focus trapping
211
337
  var drawerRef = (0, react_1.useRef)(null);
212
338
  var animations = (0, __1.useReqoreProperty)('animations');
@@ -214,6 +340,24 @@ exports.ReqoreDrawer = (0, react_1.memo)(function (_a) {
214
340
  var customPortalId = (0, __1.useReqoreProperty)('customPortalId');
215
341
  var getAndIncreaseZIndex = (0, __1.useReqoreProperty)('getAndIncreaseZIndex');
216
342
  var theme = (0, useTheme_1.useReqoreTheme)('main', customTheme, intent, undefined, inheritCustomTheme);
343
+ var isMobile = (0, __1.useReqoreProperty)('isMobile');
344
+ var isMobileOrTablet = (0, __1.useReqoreProperty)('isMobileOrTablet');
345
+ // One query, always subscribed (a hook cannot come and go with the prop):
346
+ // the numeric sheet breakpoint, or the default when a provider breakpoint
347
+ // is named and this flag is ignored anyway.
348
+ var belowSheetBreakpoint = (0, useReqoreMedia_1.useReqoreMedia)("(max-width: ".concat((0, exports.drawerSheetBreakpointPx)(responsiveLayout), "px)"));
349
+ // The sheet decision is made once per render from the breakpoints, and
350
+ // every geometry input below is derived from it, so the rest of the
351
+ // component never has to ask "is the layout active?" again.
352
+ var sheet = (0, react_1.useMemo)(function () {
353
+ return (0, exports.resolveDrawerResponsiveLayout)(responsiveLayout, { isMobile: isMobile, isMobileOrTablet: isMobileOrTablet, belowSheetBreakpoint: belowSheetBreakpoint }, _isModal);
354
+ }, [responsiveLayout, isMobile, isMobileOrTablet, belowSheetBreakpoint, _isModal]);
355
+ var position = sheet.active ? sheet.position : positionProp;
356
+ var size = sheet.active ? sheet.size : sizeProp;
357
+ var maxSize = sheet.active ? sheet.maxSize : maxSizeProp;
358
+ var resizable = sheet.active ? false : resizableProp;
359
+ var hidable = sheet.active ? false : hidableProp;
360
+ var floating = sheet.active ? false : floatingProp;
217
361
  var layout = (0, react_1.useMemo)(function () {
218
362
  return _isModal
219
363
  ? 'center'
@@ -222,6 +366,10 @@ exports.ReqoreDrawer = (0, react_1.memo)(function (_a) {
222
366
  : 'vertical';
223
367
  }, [position, _isModal]);
224
368
  var _f = (0, react_1.useState)(isHidden || false), _isHidden = _f[0], setIsHidden = _f[1];
369
+ // A sheet has no hide control, so a drawer hidden on a wide screen is shown
370
+ // again when the layout becomes active; the user's choice is kept in
371
+ // `_isHidden` and honoured again once the viewport widens.
372
+ var hidden = sheet.active ? false : _isHidden;
225
373
  var _g = (0, react_1.useState)({
226
374
  width: width || (layout === 'horizontal' ? 'auto' : size || '300px'),
227
375
  height: height || (layout === 'vertical' ? 'auto' : size || '300px'),
@@ -231,7 +379,7 @@ exports.ReqoreDrawer = (0, react_1.memo)(function (_a) {
231
379
  var shouldTrapFocus = focusTrap !== null && focusTrap !== void 0 ? focusTrap : (_isModal || hasBackdrop);
232
380
  // Use focus trap to keep focus within the drawer when open
233
381
  (0, useFocusTrap_1.useFocusTrap)(drawerRef, {
234
- active: isOpen && shouldTrapFocus && !_isHidden,
382
+ active: isOpen && shouldTrapFocus && !hidden,
235
383
  restoreFocus: true,
236
384
  autoFocus: true,
237
385
  });
@@ -288,6 +436,102 @@ exports.ReqoreDrawer = (0, react_1.memo)(function (_a) {
288
436
  }
289
437
  }
290
438
  : undefined;
439
+ var isHoverCapable = (0, __1.useReqoreProperty)('isHoverCapable');
440
+ var reducedMotion = (0, usePrefersReducedMotion_1.usePrefersReducedMotion)();
441
+ // Motion that is not the finger's own — a sheet let go early springing back — is instant
442
+ // when the user asked for less of it, or when dialog animations are off.
443
+ var immediateMotion = animations.dialogs === false || reducedMotion;
444
+ // A sheet with nothing to close into cannot be swiped. A modal is dragged only where the
445
+ // pointer can hover: the `move` cursor on its title bar is the affordance, and on a touch
446
+ // screen a press on a header belongs to the page.
447
+ var swipeable = sheet.active && swipeToClose !== false && !!onClose;
448
+ var draggable = !!_isModal && !!_draggable && isHoverCapable;
449
+ var _h = (0, web_1.useSpring)(function () { return ({ x: 0, y: 0, config: animations_1.SPRING_CONFIG }); }), drag = _h[0], dragApi = _h[1];
450
+ var dragStartRef = (0, react_1.useRef)(null);
451
+ var _j = (0, react_1.useState)(false), closedBySwipe = _j[0], setClosedBySwipe = _j[1];
452
+ var _k = (0, usePointerDrag_1.usePointerDrag)({
453
+ enabled: swipeable || draggable,
454
+ // A sheet moves on one axis, so a press that scrolls along the other is not a swipe.
455
+ axis: draggable ? 'both' : layout === 'horizontal' ? 'y' : 'x',
456
+ canStart: function (event) { return (0, exports.isDrawerHeaderGrab)(event.target, event.currentTarget); },
457
+ onStart: function (box) {
458
+ var _a, _b;
459
+ var rect = box.getBoundingClientRect();
460
+ var offset = { x: drag.x.get(), y: drag.y.get() };
461
+ dragStartRef.current = {
462
+ offset: offset,
463
+ size: layout === 'horizontal' ? rect.height : rect.width,
464
+ bounds: draggable
465
+ ? {
466
+ box: {
467
+ left: rect.left - offset.x,
468
+ top: rect.top - offset.y,
469
+ width: rect.width,
470
+ height: rect.height,
471
+ },
472
+ viewport: {
473
+ width: document.documentElement.clientWidth,
474
+ height: document.documentElement.clientHeight,
475
+ },
476
+ handleHeight: (_b = (_a = box
477
+ .querySelector(':scope > .reqore-drawer > .reqore-panel-title')) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height) !== null && _b !== void 0 ? _b : 0,
478
+ }
479
+ : undefined,
480
+ };
481
+ },
482
+ onMove: function (delta) {
483
+ var start = dragStartRef.current;
484
+ if (!start) {
485
+ return;
486
+ }
487
+ dragApi.set(start.bounds
488
+ ? (0, exports.clampModalDragOffset)({ x: start.offset.x + delta.dx, y: start.offset.y + delta.dy }, start.bounds)
489
+ : (0, exports.getSheetSwipe)(position, delta, start.size).offset);
490
+ },
491
+ onEnd: function (delta, committed) {
492
+ var start = dragStartRef.current;
493
+ dragStartRef.current = null;
494
+ // A modal stays where it was let go.
495
+ if (!start || start.bounds) {
496
+ return;
497
+ }
498
+ if (committed && (0, exports.getSheetSwipe)(position, delta, start.size).closes) {
499
+ // Closed from where the finger left it: the leave transition carries on from there.
500
+ setClosedBySwipe(true);
501
+ handleClose === null || handleClose === void 0 ? void 0 : handleClose();
502
+ }
503
+ else {
504
+ dragApi.start({ x: 0, y: 0, immediate: immediateMotion });
505
+ }
506
+ },
507
+ }), dragging = _k.dragging, dragHandlers = _k.handlers;
508
+ // A sheet whose swipe asked to close but is still open — `confirmOnClose` is asking, or the
509
+ // caller closes it later — springs back meanwhile; one that did close keeps its offset, so
510
+ // the leave transition carries on from where the finger left it.
511
+ (0, react_1.useEffect)(function () {
512
+ if (!closedBySwipe) {
513
+ return;
514
+ }
515
+ setClosedBySwipe(false);
516
+ if (isOpen) {
517
+ dragApi.start({ x: 0, y: 0, immediate: immediateMotion });
518
+ }
519
+ }, [closedBySwipe, isOpen]);
520
+ // Wherever the box was dragged to, it opens in its place next time.
521
+ (0, react_1.useEffect)(function () {
522
+ if (isOpen) {
523
+ dragApi.set({ x: 0, y: 0 });
524
+ }
525
+ }, [isOpen]);
526
+ // The box's `transform`: the drag's own translate ahead of whatever the enter / leave spring
527
+ // sets (a modal scales in), so neither overwrites the other. Nothing at rest, so a sheet
528
+ // keeps the plain box it always had.
529
+ var dragTransform = (0, react_1.useCallback)(function (spring) {
530
+ var own = (0, web_1.to)([drag.x, drag.y], function (x, y) {
531
+ return x || y ? "translate3d(".concat(x, "px, ").concat(y, "px, 0)") : '';
532
+ });
533
+ return spring ? (0, web_1.to)([own, spring], function (a, b) { return "".concat(a, " ").concat(b).trim(); }) : own;
534
+ }, [drag.x, drag.y]);
291
535
  var closeButtonProps = (0, react_1.useMemo)(function () { return (__assign({ className: 'reqore-drawer-close-button' }, (rest.closeButtonProps || {}))); }, [rest.closeButtonProps]);
292
536
  var panelStyle = (0, react_1.useMemo)(function () { return (__assign({ width: '100%', maxHeight: '100%' }, rest.style)); }, [JSON.stringify(rest.style)]);
293
537
  var resizeableStyle = (0, react_1.useMemo)(function () {
@@ -351,18 +595,18 @@ exports.ReqoreDrawer = (0, react_1.memo)(function (_a) {
351
595
  width: _isModal
352
596
  ? _size.width
353
597
  : layout === 'vertical'
354
- ? _isHidden
598
+ ? hidden
355
599
  ? 0
356
600
  : _size.width
357
601
  : 'auto',
358
602
  height: _isModal
359
603
  ? _size.height
360
604
  : layout === 'horizontal'
361
- ? _isHidden
605
+ ? hidden
362
606
  ? 0
363
607
  : _size.height
364
608
  : 'auto',
365
- }); }, [_isModal, layout, _isHidden, _size]);
609
+ }); }, [_isModal, layout, hidden, _size]);
366
610
  var onHideToggleClick = (0, react_1.useCallback)(function () {
367
611
  setIsHidden(!_isHidden);
368
612
  onHideToggle === null || onHideToggle === void 0 ? void 0 : onHideToggle(!_isHidden);
@@ -409,22 +653,24 @@ exports.ReqoreDrawer = (0, react_1.memo)(function (_a) {
409
653
  };
410
654
  }, [resizable, position, _isModal]);
411
655
  return (0, react_dom_1.createPortal)(transitions(function (styles, item) {
412
- 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'
656
+ 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'
413
657
  ? minHeight || minSize || exports.MODAL_MIN_HEIGHT
414
658
  : layout === 'horizontal'
415
- ? _isHidden
659
+ ? hidden
416
660
  ? 0
417
661
  : minSize || exports.DRAWER_MIN_SIZE
418
662
  : undefined, maxWidth: layout === 'vertical' || layout === 'center' ? maxSize || '90vw' : undefined, minWidth: layout === 'center'
419
663
  ? minWidth || minSize || exports.MODAL_MIN_WIDTH
420
664
  : layout === 'vertical'
421
- ? _isHidden
665
+ ? hidden
422
666
  ? 0
423
667
  : minSize || exports.DRAWER_MIN_SIZE
424
668
  : undefined, as: exports.StyledDrawerResizable }, {
425
669
  $edgelessPosition: !floating && !_isModal ? position : undefined,
426
- }, { 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;
670
+ $handle: draggable ? 'drag' : swipeable ? 'swipe' : undefined,
671
+ $dragging: dragging,
672
+ }, 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;
427
673
  }), document.querySelector(customPortalId || '#reqore-portal'));
428
674
  });
429
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9;
675
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11;
430
676
  //# sourceMappingURL=index.js.map