@helloimjolopez-pathway/pathway-components 0.10.1 → 0.11.0
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/components/bottom-sheet/bottom-sheet.jsx +14 -18
- package/components/popover-menu/popover-menu.jsx +746 -0
- package/components/spinner/spinner.jsx +205 -0
- package/components/toggle-button/toggle-button.jsx +16 -6
- package/dist/pathway-accounting-sidenav.js +195 -8
- package/dist/pathway-components.js +226 -99
- package/dist/pathway-sidenav.js +195 -8
- package/package.json +4 -3
- package/components/dropdown/dropdown.jsx +0 -482
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* as a PopoverMenu; that choice belongs to the host (TopNav, SideNav, a row's
|
|
38
38
|
* More menu), which renders a BottomSheet or a Dropdown. It does not draw the
|
|
39
39
|
* rows either: the Body is a slot, and a menu in it is the real
|
|
40
|
-
* `
|
|
40
|
+
* `PopoverMenuItem` / `PopoverMenuSeparator` from popover-menu.jsx, never a copy.
|
|
41
41
|
*
|
|
42
42
|
* WHY THERE IS NO DRAWER LIBRARY. The Figma description names Vaul Drawer on
|
|
43
43
|
* Radix Dialog. The component package ships with React as its only peer
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
import React, { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
51
51
|
import { createPortal } from "react-dom";
|
|
52
52
|
import { ActionIcon } from "../icon/action-icon.jsx";
|
|
53
|
-
import {
|
|
53
|
+
import { PopoverMenuList, PopoverMenuClose } from "../popover-menu/popover-menu.jsx";
|
|
54
54
|
import { useReducedMotion } from "../_shared/use-reduced-motion.jsx";
|
|
55
55
|
|
|
56
56
|
const C = (n) => `var(--semantic-color-${n})`;
|
|
@@ -135,7 +135,7 @@ function useInjectedStyles() {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
const FOCUSABLE = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
138
|
-
const MENU_ITEMS = '[role="menuitem"]
|
|
138
|
+
const MENU_ITEMS = ':is([role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]):not([aria-disabled="true"])';
|
|
139
139
|
|
|
140
140
|
/** BottomSheet.Handle: the drag affordance. Hidden from assistive technology:
|
|
141
141
|
* Close, Esc and the overlay are the accessible ways to close. */
|
|
@@ -201,8 +201,11 @@ export function BottomSheetOverlay({ onClick, animation, opacity }) {
|
|
|
201
201
|
* menu item chosen.
|
|
202
202
|
* @param {string} title Header Title. Also the dialog's name.
|
|
203
203
|
* @param {node} children The Body slot.
|
|
204
|
-
* @param {boolean} menu The Body is a menu:
|
|
205
|
-
*
|
|
204
|
+
* @param {boolean} menu The Body is a menu: a PopoverMenuList named
|
|
205
|
+
* by the title (role=menu, arrow keys, Home,
|
|
206
|
+
* End, typeahead). Use with PopoverMenuItem rows.
|
|
207
|
+
* @param {object} menuProps Passed to that PopoverMenuList: selectionMode,
|
|
208
|
+
* selectedKeys, onSelectionChange, onAction.
|
|
206
209
|
* @param {boolean} showHandle Figma `Show Handle`. Default true.
|
|
207
210
|
* @param {node} footer BottomSheet.Footer's Actions. Figma
|
|
208
211
|
* `Show Footer` is true when this is given.
|
|
@@ -229,6 +232,7 @@ export function BottomSheet({
|
|
|
229
232
|
title,
|
|
230
233
|
children,
|
|
231
234
|
menu = false,
|
|
235
|
+
menuProps,
|
|
232
236
|
showHandle = true,
|
|
233
237
|
footer,
|
|
234
238
|
showBack = false,
|
|
@@ -333,16 +337,7 @@ export function BottomSheet({
|
|
|
333
337
|
else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first.focus(); }
|
|
334
338
|
return;
|
|
335
339
|
}
|
|
336
|
-
|
|
337
|
-
const list = [...body.current.querySelectorAll(MENU_ITEMS)];
|
|
338
|
-
if (!list.length) return;
|
|
339
|
-
const here = list.indexOf(document.activeElement);
|
|
340
|
-
let next = null;
|
|
341
|
-
if (e.key === "ArrowDown") next = (here + 1) % list.length;
|
|
342
|
-
else if (e.key === "ArrowUp") next = (here - 1 + list.length) % list.length;
|
|
343
|
-
else if (e.key === "Home") next = 0;
|
|
344
|
-
else if (e.key === "End") next = list.length - 1;
|
|
345
|
-
if (next !== null) { e.preventDefault(); list[next].focus(); }
|
|
340
|
+
// Arrows, Home, End and typeahead in a menu Body belong to PopoverMenuList.
|
|
346
341
|
};
|
|
347
342
|
|
|
348
343
|
/* Swipe down to close. It starts anywhere on the sheet, but inside the Body
|
|
@@ -410,7 +405,6 @@ export function BottomSheet({
|
|
|
410
405
|
closeLabel={closeLabel} backLabel={backLabel} />
|
|
411
406
|
</div>
|
|
412
407
|
<div ref={body} className="pw-bottom-sheet__body" data-part="body"
|
|
413
|
-
role={menu ? "menu" : undefined} aria-labelledby={menu ? titleId : undefined}
|
|
414
408
|
style={{
|
|
415
409
|
display: "flex", flexDirection: "column", gap: L.bodyGap, minHeight: 0, flex: "0 1 auto",
|
|
416
410
|
overflowY: "auto", overflowX: "hidden", overscrollBehavior: "contain",
|
|
@@ -418,8 +412,10 @@ export function BottomSheet({
|
|
|
418
412
|
? `0 ${L.bodyPad} ${L.bodyPad}`
|
|
419
413
|
: `0 ${L.bodyPad} calc(${L.bodyPad} + env(safe-area-inset-bottom, 0px))`,
|
|
420
414
|
}}>
|
|
421
|
-
{/* Choosing a
|
|
422
|
-
<
|
|
415
|
+
{/* Choosing a PopoverMenuItem closes the sheet, as it closes a PopoverMenu. */}
|
|
416
|
+
<PopoverMenuClose.Provider value={requestClose}>
|
|
417
|
+
{menu ? <PopoverMenuList bare label={title} {...menuProps}>{children}</PopoverMenuList> : children}
|
|
418
|
+
</PopoverMenuClose.Provider>
|
|
423
419
|
</div>
|
|
424
420
|
{footer && <BottomSheetFooter>{footer}</BottomSheetFooter>}
|
|
425
421
|
</div>
|