@helloimjolopez-pathway/pathway-components 0.10.0 → 0.10.2

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.
@@ -16,14 +16,14 @@
16
16
  * Outline & Fill stroke v1 Subtle, Figma Strong (Neutral Bold, accents plain).
17
17
  * Neutral Naked text v1 Neutral/Bold, Figma Neutral/Base.
18
18
  * Stroke placement Inside the badge, which keeps its size in every style
19
- * (Small 20, Medium and Large 22). An inset box-shadow
19
+ * (Small 20, Medium 22, Large 24). An inset box-shadow
20
20
  * draws it without changing the box.
21
21
  * Figma's default leading icon is the placeholder `error`; in code the icon is
22
22
  * passed explicitly, so existing call sites render exactly as before.
23
23
  *
24
24
  * DISMISSIBLE and INTERACTIVE, every size, with or without icons:
25
25
  * outer frame invisible, min width and height Accessibility/Touch Target/AA
26
- * (44). The pill keeps its size (20 / 22 / 22) inside it.
26
+ * (44). The badge keeps its size (20 / 22 / 24) inside it.
27
27
  * Focus Ring wraps Container.Main, padding FocusRing/Offset, ring outside
28
28
  * when Focused.
29
29
  * Container.Main the badge: fill, stroke inside, CornerRadius/Large;
@@ -101,8 +101,8 @@ const ACTION = (s) => {
101
101
 
102
102
  export const BADGE_SIZE_SPEC = {
103
103
  Small: { fontSize: "font-size-xs", lineHeight: "line-height-xs-single", icon: 11, ico: 12, contentMax: 200, height: 20 },
104
- Medium: { fontSize: "font-size-xs", lineHeight: "line-height-xs-single", icon: 12, ico: 14, contentMax: 196 },
105
- Large: { fontSize: "font-size-s", lineHeight: "line-height-xs-single", icon: 14, ico: 16, contentMax: 192 },
104
+ Medium: { fontSize: "font-size-xs", lineHeight: "line-height-xs-single", icon: 12, ico: 14, contentMax: 196, height: 22 },
105
+ Large: { fontSize: "font-size-s", lineHeight: "line-height-xs-single", icon: 14, ico: 16, contentMax: 192, height: 24 },
106
106
  };
107
107
 
108
108
  /** Layout constants. Static keeps v1's asymmetric padding; the other types use T.pill / T.text. */
@@ -147,7 +147,7 @@ const strokeShadow = (stroke) => (stroke ? `inset 0 0 0 ${L.border} ${stroke}` :
147
147
  const focusRing = (focused) => (focused
148
148
  ? { outline: `${T.ringWidth} solid ${T.ring}`, outlineOffset: T.ringOffset }
149
149
  : { outline: "none" });
150
- /* Small has a fixed height (20) with its 12 text centred, so it needs no top and bottom padding. */
150
+ /* Every size has a fixed height (Small 20, Medium 22, Large 24) with its text centred, so none needs top and bottom padding. */
151
151
  const fixedHeight = (spec) => (spec.height ? { height: spec.height, paddingTop: 0, paddingBottom: 0 } : {});
152
152
  const transition = `background ${T.duration} ${T.easing}, color ${T.duration} ${T.easing}, box-shadow ${T.duration} ${T.easing}`;
153
153
 
@@ -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
- * `DropdownItem` / `DropdownDivider` from dropdown.jsx, never a copy.
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 { DropdownClose } from "../dropdown/dropdown.jsx";
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"]:not([disabled]), [role="menuitemradio"]:not([disabled]), [role="menuitemcheckbox"]:not([disabled])';
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: role=menu, arrow keys,
205
- * Home and End. Use with DropdownItem rows.
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
- if (!menu || !body.current || !body.current.contains(document.activeElement)) return;
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 DropdownItem closes the sheet, as it closes a Dropdown. */}
422
- <DropdownClose.Provider value={requestClose}>{children}</DropdownClose.Provider>
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>