@geckoui/geckoui 2.0.3 → 2.0.5
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.
- package/dist/index.d.mts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +18 -10
- package/dist/index.mjs +19 -11
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -5552,6 +5552,16 @@ interface DrawerProps {
|
|
|
5552
5552
|
* Default is true
|
|
5553
5553
|
* */
|
|
5554
5554
|
dismissOnEscape?: boolean;
|
|
5555
|
+
/**
|
|
5556
|
+
* Keep the children in the DOM while the drawer is closed.
|
|
5557
|
+
* By default they unmount once the slide out finishes, so a form inside starts fresh on
|
|
5558
|
+
* every open and an `autoFocus` field only takes focus when it is shown.
|
|
5559
|
+
* A closed drawer is inert either way: nothing in it can be focused or reached by
|
|
5560
|
+
* assistive technology.
|
|
5561
|
+
*
|
|
5562
|
+
* Default: false
|
|
5563
|
+
* */
|
|
5564
|
+
keepMounted?: boolean;
|
|
5555
5565
|
/**
|
|
5556
5566
|
* Inline styles for the drawer root.
|
|
5557
5567
|
* `GeckoUIProvider` uses it to stack drawers opened with `Drawer.show()`.
|
|
@@ -5579,6 +5589,10 @@ interface DrawerProps {
|
|
|
5579
5589
|
* </Drawer>
|
|
5580
5590
|
* ```
|
|
5581
5591
|
*
|
|
5592
|
+
* Closed drawers unmount their children once the slide out finishes, so a form inside
|
|
5593
|
+
* starts fresh on every open and an `autoFocus` field only takes focus when it is shown.
|
|
5594
|
+
* Pass `keepMounted` to keep the children alive while closed instead.
|
|
5595
|
+
*
|
|
5582
5596
|
* @example
|
|
5583
5597
|
* Mobile navigation menu:
|
|
5584
5598
|
*
|
|
@@ -5599,7 +5613,7 @@ interface DrawerProps {
|
|
|
5599
5613
|
* </Drawer>
|
|
5600
5614
|
* ```
|
|
5601
5615
|
*/
|
|
5602
|
-
declare function Drawer({ open, allowClickOutside, onClose, hideBackdrop, placement, backdropClassName, className, children, dismissOnEscape, style }: DrawerProps): react_jsx_runtime.JSX.Element;
|
|
5616
|
+
declare function Drawer({ open, allowClickOutside, onClose, hideBackdrop, placement, backdropClassName, className, children, dismissOnEscape, keepMounted, style }: DrawerProps): react_jsx_runtime.JSX.Element;
|
|
5603
5617
|
declare namespace Drawer {
|
|
5604
5618
|
var show: (node: ReactNode, options?: Omit<DrawerProps, "open" | "children">) => string;
|
|
5605
5619
|
var dismiss: (id?: string) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -5552,6 +5552,16 @@ interface DrawerProps {
|
|
|
5552
5552
|
* Default is true
|
|
5553
5553
|
* */
|
|
5554
5554
|
dismissOnEscape?: boolean;
|
|
5555
|
+
/**
|
|
5556
|
+
* Keep the children in the DOM while the drawer is closed.
|
|
5557
|
+
* By default they unmount once the slide out finishes, so a form inside starts fresh on
|
|
5558
|
+
* every open and an `autoFocus` field only takes focus when it is shown.
|
|
5559
|
+
* A closed drawer is inert either way: nothing in it can be focused or reached by
|
|
5560
|
+
* assistive technology.
|
|
5561
|
+
*
|
|
5562
|
+
* Default: false
|
|
5563
|
+
* */
|
|
5564
|
+
keepMounted?: boolean;
|
|
5555
5565
|
/**
|
|
5556
5566
|
* Inline styles for the drawer root.
|
|
5557
5567
|
* `GeckoUIProvider` uses it to stack drawers opened with `Drawer.show()`.
|
|
@@ -5579,6 +5589,10 @@ interface DrawerProps {
|
|
|
5579
5589
|
* </Drawer>
|
|
5580
5590
|
* ```
|
|
5581
5591
|
*
|
|
5592
|
+
* Closed drawers unmount their children once the slide out finishes, so a form inside
|
|
5593
|
+
* starts fresh on every open and an `autoFocus` field only takes focus when it is shown.
|
|
5594
|
+
* Pass `keepMounted` to keep the children alive while closed instead.
|
|
5595
|
+
*
|
|
5582
5596
|
* @example
|
|
5583
5597
|
* Mobile navigation menu:
|
|
5584
5598
|
*
|
|
@@ -5599,7 +5613,7 @@ interface DrawerProps {
|
|
|
5599
5613
|
* </Drawer>
|
|
5600
5614
|
* ```
|
|
5601
5615
|
*/
|
|
5602
|
-
declare function Drawer({ open, allowClickOutside, onClose, hideBackdrop, placement, backdropClassName, className, children, dismissOnEscape, style }: DrawerProps): react_jsx_runtime.JSX.Element;
|
|
5616
|
+
declare function Drawer({ open, allowClickOutside, onClose, hideBackdrop, placement, backdropClassName, className, children, dismissOnEscape, keepMounted, style }: DrawerProps): react_jsx_runtime.JSX.Element;
|
|
5603
5617
|
declare namespace Drawer {
|
|
5604
5618
|
var show: (node: ReactNode, options?: Omit<DrawerProps, "open" | "children">) => string;
|
|
5605
5619
|
var dismiss: (id?: string) => void;
|
package/dist/index.js
CHANGED
|
@@ -9529,6 +9529,7 @@ function Drawer({
|
|
|
9529
9529
|
className,
|
|
9530
9530
|
children,
|
|
9531
9531
|
dismissOnEscape = true,
|
|
9532
|
+
keepMounted = false,
|
|
9532
9533
|
style
|
|
9533
9534
|
}) {
|
|
9534
9535
|
const drawerRef = (0, import_react81.useRef)(null);
|
|
@@ -9540,15 +9541,16 @@ function Drawer({
|
|
|
9540
9541
|
const ready = readyFor === placement;
|
|
9541
9542
|
const visible = open && ready;
|
|
9542
9543
|
const [closing, setClosing] = (0, import_react81.useState)(false);
|
|
9543
|
-
const
|
|
9544
|
+
const [prevOpen, setPrevOpen] = (0, import_react81.useState)(open);
|
|
9545
|
+
if (prevOpen !== open) {
|
|
9546
|
+
setPrevOpen(open);
|
|
9547
|
+
setClosing(!open);
|
|
9548
|
+
}
|
|
9544
9549
|
(0, import_react81.useEffect)(() => {
|
|
9545
|
-
if (
|
|
9546
|
-
wasOpen.current = open;
|
|
9547
|
-
if (open) return;
|
|
9548
|
-
setClosing(true);
|
|
9550
|
+
if (!closing) return;
|
|
9549
9551
|
const timer = setTimeout(() => setClosing(false), OVERLAY_ANIMATION_DURATION);
|
|
9550
9552
|
return () => clearTimeout(timer);
|
|
9551
|
-
}, [
|
|
9553
|
+
}, [closing]);
|
|
9552
9554
|
const onCloseRef = (0, import_react81.useRef)(onClose);
|
|
9553
9555
|
onCloseRef.current = onClose;
|
|
9554
9556
|
const handleDismiss = (0, import_react81.useCallback)(() => {
|
|
@@ -9575,19 +9577,25 @@ function Drawer({
|
|
|
9575
9577
|
),
|
|
9576
9578
|
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
9577
9579
|
"div",
|
|
9578
|
-
{
|
|
9580
|
+
__spreadProps(__spreadValues({
|
|
9579
9581
|
ref: drawerRef,
|
|
9580
9582
|
"data-placement": placement,
|
|
9581
9583
|
"data-state": visible ? "open" : "closed",
|
|
9582
9584
|
"data-instant": !ready || void 0,
|
|
9583
9585
|
className: classNames("GeckoUIDrawer__drawer", className),
|
|
9584
9586
|
role: "dialog",
|
|
9585
|
-
"aria-modal": !allowClickOutside
|
|
9586
|
-
|
|
9587
|
-
|
|
9587
|
+
"aria-modal": !allowClickOutside
|
|
9588
|
+
}, inertProps(!open)), {
|
|
9589
|
+
children: (open || closing || keepMounted) && children
|
|
9590
|
+
})
|
|
9588
9591
|
)
|
|
9589
9592
|
] });
|
|
9590
9593
|
}
|
|
9594
|
+
var INERT_IS_BOOLEAN = Number(import_react81.version.split(".")[0]) >= 19;
|
|
9595
|
+
function inertProps(inert) {
|
|
9596
|
+
if (INERT_IS_BOOLEAN) return { inert };
|
|
9597
|
+
return inert ? { inert: "" } : {};
|
|
9598
|
+
}
|
|
9591
9599
|
Drawer.show = (node, options = {}) => {
|
|
9592
9600
|
var _a;
|
|
9593
9601
|
(_a = document.activeElement) == null ? void 0 : _a.blur();
|
package/dist/index.mjs
CHANGED
|
@@ -9392,7 +9392,7 @@ import { useCallback as useCallback10, useEffect as useEffect23, useRef as useRe
|
|
|
9392
9392
|
import { createPortal as createPortal2 } from "react-dom";
|
|
9393
9393
|
|
|
9394
9394
|
// src/components/Drawer/Drawer.tsx
|
|
9395
|
-
import { useCallback as useCallback9, useEffect as useEffect22, useRef as useRef33, useState as useState29 } from "react";
|
|
9395
|
+
import { useCallback as useCallback9, useEffect as useEffect22, useRef as useRef33, useState as useState29, version } from "react";
|
|
9396
9396
|
import { jsx as jsx97, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
9397
9397
|
function Drawer({
|
|
9398
9398
|
open = false,
|
|
@@ -9404,6 +9404,7 @@ function Drawer({
|
|
|
9404
9404
|
className,
|
|
9405
9405
|
children,
|
|
9406
9406
|
dismissOnEscape = true,
|
|
9407
|
+
keepMounted = false,
|
|
9407
9408
|
style
|
|
9408
9409
|
}) {
|
|
9409
9410
|
const drawerRef = useRef33(null);
|
|
@@ -9415,15 +9416,16 @@ function Drawer({
|
|
|
9415
9416
|
const ready = readyFor === placement;
|
|
9416
9417
|
const visible = open && ready;
|
|
9417
9418
|
const [closing, setClosing] = useState29(false);
|
|
9418
|
-
const
|
|
9419
|
+
const [prevOpen, setPrevOpen] = useState29(open);
|
|
9420
|
+
if (prevOpen !== open) {
|
|
9421
|
+
setPrevOpen(open);
|
|
9422
|
+
setClosing(!open);
|
|
9423
|
+
}
|
|
9419
9424
|
useEffect22(() => {
|
|
9420
|
-
if (
|
|
9421
|
-
wasOpen.current = open;
|
|
9422
|
-
if (open) return;
|
|
9423
|
-
setClosing(true);
|
|
9425
|
+
if (!closing) return;
|
|
9424
9426
|
const timer = setTimeout(() => setClosing(false), OVERLAY_ANIMATION_DURATION);
|
|
9425
9427
|
return () => clearTimeout(timer);
|
|
9426
|
-
}, [
|
|
9428
|
+
}, [closing]);
|
|
9427
9429
|
const onCloseRef = useRef33(onClose);
|
|
9428
9430
|
onCloseRef.current = onClose;
|
|
9429
9431
|
const handleDismiss = useCallback9(() => {
|
|
@@ -9450,19 +9452,25 @@ function Drawer({
|
|
|
9450
9452
|
),
|
|
9451
9453
|
/* @__PURE__ */ jsx97(
|
|
9452
9454
|
"div",
|
|
9453
|
-
{
|
|
9455
|
+
__spreadProps(__spreadValues({
|
|
9454
9456
|
ref: drawerRef,
|
|
9455
9457
|
"data-placement": placement,
|
|
9456
9458
|
"data-state": visible ? "open" : "closed",
|
|
9457
9459
|
"data-instant": !ready || void 0,
|
|
9458
9460
|
className: classNames("GeckoUIDrawer__drawer", className),
|
|
9459
9461
|
role: "dialog",
|
|
9460
|
-
"aria-modal": !allowClickOutside
|
|
9461
|
-
|
|
9462
|
-
|
|
9462
|
+
"aria-modal": !allowClickOutside
|
|
9463
|
+
}, inertProps(!open)), {
|
|
9464
|
+
children: (open || closing || keepMounted) && children
|
|
9465
|
+
})
|
|
9463
9466
|
)
|
|
9464
9467
|
] });
|
|
9465
9468
|
}
|
|
9469
|
+
var INERT_IS_BOOLEAN = Number(version.split(".")[0]) >= 19;
|
|
9470
|
+
function inertProps(inert) {
|
|
9471
|
+
if (INERT_IS_BOOLEAN) return { inert };
|
|
9472
|
+
return inert ? { inert: "" } : {};
|
|
9473
|
+
}
|
|
9466
9474
|
Drawer.show = (node, options = {}) => {
|
|
9467
9475
|
var _a;
|
|
9468
9476
|
(_a = document.activeElement) == null ? void 0 : _a.blur();
|