@geckoui/geckoui 2.0.2 → 2.0.4

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 CHANGED
@@ -3110,6 +3110,8 @@ interface BaseSelectProps extends PropsWithChildren, SelectButtonProps {
3110
3110
  disabled?: boolean;
3111
3111
  /**
3112
3112
  * Whether to show the input for filtering the options
3113
+ * `true` or `"dropdown"`: a search box at the top of the menu
3114
+ * `"inline"`: typed straight into the button
3113
3115
  * Default is false
3114
3116
  * */
3115
3117
  filterable?: boolean | "inline" | "dropdown";
@@ -5550,6 +5552,16 @@ interface DrawerProps {
5550
5552
  * Default is true
5551
5553
  * */
5552
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;
5553
5565
  /**
5554
5566
  * Inline styles for the drawer root.
5555
5567
  * `GeckoUIProvider` uses it to stack drawers opened with `Drawer.show()`.
@@ -5577,6 +5589,10 @@ interface DrawerProps {
5577
5589
  * </Drawer>
5578
5590
  * ```
5579
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
+ *
5580
5596
  * @example
5581
5597
  * Mobile navigation menu:
5582
5598
  *
@@ -5597,7 +5613,7 @@ interface DrawerProps {
5597
5613
  * </Drawer>
5598
5614
  * ```
5599
5615
  */
5600
- 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;
5601
5617
  declare namespace Drawer {
5602
5618
  var show: (node: ReactNode, options?: Omit<DrawerProps, "open" | "children">) => string;
5603
5619
  var dismiss: (id?: string) => void;
package/dist/index.d.ts CHANGED
@@ -3110,6 +3110,8 @@ interface BaseSelectProps extends PropsWithChildren, SelectButtonProps {
3110
3110
  disabled?: boolean;
3111
3111
  /**
3112
3112
  * Whether to show the input for filtering the options
3113
+ * `true` or `"dropdown"`: a search box at the top of the menu
3114
+ * `"inline"`: typed straight into the button
3113
3115
  * Default is false
3114
3116
  * */
3115
3117
  filterable?: boolean | "inline" | "dropdown";
@@ -5550,6 +5552,16 @@ interface DrawerProps {
5550
5552
  * Default is true
5551
5553
  * */
5552
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;
5553
5565
  /**
5554
5566
  * Inline styles for the drawer root.
5555
5567
  * `GeckoUIProvider` uses it to stack drawers opened with `Drawer.show()`.
@@ -5577,6 +5589,10 @@ interface DrawerProps {
5577
5589
  * </Drawer>
5578
5590
  * ```
5579
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
+ *
5580
5596
  * @example
5581
5597
  * Mobile navigation menu:
5582
5598
  *
@@ -5597,7 +5613,7 @@ interface DrawerProps {
5597
5613
  * </Drawer>
5598
5614
  * ```
5599
5615
  */
5600
- 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;
5601
5617
  declare namespace Drawer {
5602
5618
  var show: (node: ReactNode, options?: Omit<DrawerProps, "open" | "children">) => string;
5603
5619
  var dismiss: (id?: string) => void;
package/dist/index.js CHANGED
@@ -6635,7 +6635,7 @@ function SelectButton(_a) {
6635
6635
  if (trigger) {
6636
6636
  return trigger;
6637
6637
  }
6638
- const filterable = _filterable === true || _filterable === "inline";
6638
+ const filterable = _filterable === "inline";
6639
6639
  return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
6640
6640
  "div",
6641
6641
  __spreadProps(__spreadValues(__spreadProps(__spreadValues({
@@ -6740,7 +6740,7 @@ function SelectButtonContent() {
6740
6740
  closeMenu,
6741
6741
  disabled
6742
6742
  } = useSelect();
6743
- const filterable = _filterable === true || _filterable === "inline";
6743
+ const filterable = _filterable === "inline";
6744
6744
  const { preventDefault, attachPreventDefault } = usePreventDefault_default();
6745
6745
  if (multiple && Array.isArray(value) && !!(value == null ? void 0 : value.length)) {
6746
6746
  const selectedOptions = sortMultiSelectValue(value, options).map((o) => {
@@ -6919,7 +6919,7 @@ var SelectMenu = (_a) => {
6919
6919
  if (!open || disabled) {
6920
6920
  return null;
6921
6921
  }
6922
- const hasDropdownSearch = filterable === "dropdown";
6922
+ const hasDropdownSearch = filterable === true || filterable === "dropdown";
6923
6923
  return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
6924
6924
  "div",
6925
6925
  __spreadProps(__spreadValues({
@@ -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,14 +9541,18 @@ 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 wasOpen = (0, import_react81.useRef)(open);
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 (wasOpen.current === open) return;
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);
9553
+ }, [closing]);
9554
+ (0, import_react81.useLayoutEffect)(() => {
9555
+ if (drawerRef.current) drawerRef.current.inert = !open;
9551
9556
  }, [open]);
9552
9557
  const onCloseRef = (0, import_react81.useRef)(onClose);
9553
9558
  onCloseRef.current = onClose;
@@ -9583,7 +9588,7 @@ function Drawer({
9583
9588
  className: classNames("GeckoUIDrawer__drawer", className),
9584
9589
  role: "dialog",
9585
9590
  "aria-modal": !allowClickOutside,
9586
- children
9591
+ children: (open || closing || keepMounted) && children
9587
9592
  }
9588
9593
  )
9589
9594
  ] });
package/dist/index.mjs CHANGED
@@ -6501,7 +6501,7 @@ function SelectButton(_a) {
6501
6501
  if (trigger) {
6502
6502
  return trigger;
6503
6503
  }
6504
- const filterable = _filterable === true || _filterable === "inline";
6504
+ const filterable = _filterable === "inline";
6505
6505
  return /* @__PURE__ */ jsxs30(
6506
6506
  "div",
6507
6507
  __spreadProps(__spreadValues(__spreadProps(__spreadValues({
@@ -6606,7 +6606,7 @@ function SelectButtonContent() {
6606
6606
  closeMenu,
6607
6607
  disabled
6608
6608
  } = useSelect();
6609
- const filterable = _filterable === true || _filterable === "inline";
6609
+ const filterable = _filterable === "inline";
6610
6610
  const { preventDefault, attachPreventDefault } = usePreventDefault_default();
6611
6611
  if (multiple && Array.isArray(value) && !!(value == null ? void 0 : value.length)) {
6612
6612
  const selectedOptions = sortMultiSelectValue(value, options).map((o) => {
@@ -6785,7 +6785,7 @@ var SelectMenu = (_a) => {
6785
6785
  if (!open || disabled) {
6786
6786
  return null;
6787
6787
  }
6788
- const hasDropdownSearch = filterable === "dropdown";
6788
+ const hasDropdownSearch = filterable === true || filterable === "dropdown";
6789
6789
  return /* @__PURE__ */ jsxs31(
6790
6790
  "div",
6791
6791
  __spreadProps(__spreadValues({
@@ -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, useLayoutEffect as useLayoutEffect2, useRef as useRef33, useState as useState29 } 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,14 +9416,18 @@ function Drawer({
9415
9416
  const ready = readyFor === placement;
9416
9417
  const visible = open && ready;
9417
9418
  const [closing, setClosing] = useState29(false);
9418
- const wasOpen = useRef33(open);
9419
+ const [prevOpen, setPrevOpen] = useState29(open);
9420
+ if (prevOpen !== open) {
9421
+ setPrevOpen(open);
9422
+ setClosing(!open);
9423
+ }
9419
9424
  useEffect22(() => {
9420
- if (wasOpen.current === open) return;
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);
9428
+ }, [closing]);
9429
+ useLayoutEffect2(() => {
9430
+ if (drawerRef.current) drawerRef.current.inert = !open;
9426
9431
  }, [open]);
9427
9432
  const onCloseRef = useRef33(onClose);
9428
9433
  onCloseRef.current = onClose;
@@ -9458,7 +9463,7 @@ function Drawer({
9458
9463
  className: classNames("GeckoUIDrawer__drawer", className),
9459
9464
  role: "dialog",
9460
9465
  "aria-modal": !allowClickOutside,
9461
- children
9466
+ children: (open || closing || keepMounted) && children
9462
9467
  }
9463
9468
  )
9464
9469
  ] });
package/dist/styles.css CHANGED
@@ -5392,7 +5392,9 @@
5392
5392
  }
5393
5393
  .GeckoUISelectButton__search__input[data-initial] {
5394
5394
  position: absolute;
5395
+ right: calc(var(--spacing, 0.25rem) * 3);
5395
5396
  left: calc(var(--spacing, 0.25rem) * 3);
5397
+ width: auto;
5396
5398
  }
5397
5399
  .GeckoUISelectButton__search__input[data-readonly] {
5398
5400
  width: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geckoui/geckoui",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "license": "MIT",
5
5
  "description": "The only thing our Gecko eats is bugs!",
6
6
  "keywords": [