@broberg/app-shell 0.21.0 → 0.22.1

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/preact.d.cts CHANGED
@@ -49,6 +49,10 @@ interface NavAction {
49
49
  confirm?: {
50
50
  label: string;
51
51
  };
52
+ /** F092.32 — a dimmed value right-aligned before the chevron («Type …… All ›»). */
53
+ value?: string;
54
+ /** F092.32 — a divider line before this item, to separate groups. */
55
+ separator?: boolean;
52
56
  }
53
57
  interface NavSection<Icon = unknown> {
54
58
  /** A sub-heading inside one group, e.g. "I dag" / "I går". */
package/dist/preact.d.ts CHANGED
@@ -49,6 +49,10 @@ interface NavAction {
49
49
  confirm?: {
50
50
  label: string;
51
51
  };
52
+ /** F092.32 — a dimmed value right-aligned before the chevron («Type …… All ›»). */
53
+ value?: string;
54
+ /** F092.32 — a divider line before this item, to separate groups. */
55
+ separator?: boolean;
52
56
  }
53
57
  interface NavSection<Icon = unknown> {
54
58
  /** A sub-heading inside one group, e.g. "I dag" / "I går". */
package/dist/preact.js CHANGED
@@ -544,6 +544,7 @@ function ItemActionsMenu(props) {
544
544
  const [pos, setPos] = useState(void 0);
545
545
  const view = stack[stack.length - 1];
546
546
  const closed = useRef(false);
547
+ const [kbd, setKbd] = useState(() => props.anchor.matches(":focus-visible"));
547
548
  const close = (refocus = true) => {
548
549
  if (closed.current) return;
549
550
  closed.current = true;
@@ -575,7 +576,7 @@ function ItemActionsMenu(props) {
575
576
  useLayoutEffect(() => {
576
577
  const r = props.anchor.getBoundingClientRect();
577
578
  const vw = window.innerWidth, vh = window.innerHeight, m = 8;
578
- const w = Math.min(240, vw - 2 * m);
579
+ const w = Math.min(Math.max(240, menu.current?.offsetWidth ?? 0), vw - 2 * m);
579
580
  const h = menu.current?.offsetHeight ?? 0;
580
581
  const start = props.placement === "up-start";
581
582
  const left = Math.max(m, Math.min(start ? r.left : r.right - w, vw - w - m));
@@ -583,7 +584,7 @@ function ItemActionsMenu(props) {
583
584
  const fitsAbove = r.top - 4 - h >= m;
584
585
  const below = start ? !fitsAbove : props.placement === "down" || fitsBelow || !fitsAbove;
585
586
  const top = below ? Math.min(r.bottom + 4, vh - m - h) : r.top - 4 - h;
586
- setPos({ position: "fixed", left: `${left}px`, top: `${Math.max(m, top)}px`, width: `${w}px` });
587
+ setPos({ position: "fixed", left: `${left}px`, top: `${Math.max(m, top)}px` });
587
588
  }, [stack.length]);
588
589
  useLayoutEffect(() => {
589
590
  if (!pos) return;
@@ -619,6 +620,7 @@ function ItemActionsMenu(props) {
619
620
  const view2 = stack2[stack2.length - 1];
620
621
  if (!view2) return;
621
622
  e.stopPropagation();
623
+ setKbd(true);
622
624
  if (e.key === "Escape") {
623
625
  e.preventDefault();
624
626
  return close();
@@ -661,40 +663,44 @@ function ItemActionsMenu(props) {
661
663
  "div",
662
664
  {
663
665
  ref: menu,
664
- class: "bas-rowmenu",
666
+ class: "bas-rowmenu" + (kbd ? " is-kbd" : ""),
665
667
  role: "menu",
666
668
  tabIndex: -1,
667
669
  "aria-label": view.kind === "list" && view.title ? view.title : props.label,
668
670
  "data-testid": `${pre}-menu`,
669
- style: pos ?? { position: "fixed", visibility: "hidden" },
671
+ style: pos ?? { position: "fixed", left: "0px", top: "0px", visibility: "hidden" },
670
672
  onKeyDown,
671
673
  children: [
672
674
  stack.length > 1 ? /* @__PURE__ */ jsxs("button", { type: "button", class: "bas-rowmenu__back", "data-testid": `${pre}-back`, "aria-label": t.back, onClick: back, children: [
673
675
  /* @__PURE__ */ jsx(IconChevronLeft, {}),
674
676
  /* @__PURE__ */ jsx("span", { children: view.kind === "list" ? view.title : view.action.label })
675
677
  ] }) : null,
676
- view.kind === "list" ? view.actions.map((a, i) => /* @__PURE__ */ jsxs(
677
- "button",
678
- {
679
- type: "button",
680
- role: "menuitem",
681
- ref: (el) => {
682
- items.current[i] = el;
678
+ view.kind === "list" ? view.actions.map((a, i) => [
679
+ a.separator ? /* @__PURE__ */ jsx("div", { class: "bas-rowmenu__sep", role: "separator" }, `${a.id}-sep`) : null,
680
+ /* @__PURE__ */ jsxs(
681
+ "button",
682
+ {
683
+ type: "button",
684
+ role: "menuitem",
685
+ ref: (el) => {
686
+ items.current[i] = el;
687
+ },
688
+ tabIndex: i === hi ? 0 : -1,
689
+ class: "bas-rowmenu__item" + (i === hi ? " is-active" : "") + (a.danger ? " is-danger" : "") + (armed === a.id ? " is-armed" : ""),
690
+ "data-testid": `${pre}-action-${a.id}`,
691
+ onMouseEnter: () => setHi(i),
692
+ onFocus: () => setHi(i),
693
+ onClick: () => pick(a),
694
+ children: [
695
+ a.icon ? /* @__PURE__ */ jsx("span", { class: "bas-rowmenu__icon", children: a.icon }) : null,
696
+ /* @__PURE__ */ jsx("span", { class: "bas-rowmenu__label", children: armed === a.id && a.confirm ? a.confirm.label : a.label }),
697
+ a.value ? /* @__PURE__ */ jsx("span", { class: "bas-rowmenu__value", "data-testid": `${pre}-action-${a.id}-value`, children: a.value }) : null,
698
+ a.submenu?.length ? /* @__PURE__ */ jsx(IconChevronRight, {}) : a.kbd ? /* @__PURE__ */ jsx("kbd", { class: "bas-rowmenu__kbd", children: a.kbd.toUpperCase() }) : null
699
+ ]
683
700
  },
684
- tabIndex: i === hi ? 0 : -1,
685
- class: "bas-rowmenu__item" + (i === hi ? " is-active" : "") + (a.danger ? " is-danger" : "") + (armed === a.id ? " is-armed" : ""),
686
- "data-testid": `${pre}-action-${a.id}`,
687
- onMouseEnter: () => setHi(i),
688
- onFocus: () => setHi(i),
689
- onClick: () => pick(a),
690
- children: [
691
- a.icon ? /* @__PURE__ */ jsx("span", { class: "bas-rowmenu__icon", children: a.icon }) : null,
692
- /* @__PURE__ */ jsx("span", { class: "bas-rowmenu__label", children: armed === a.id && a.confirm ? a.confirm.label : a.label }),
693
- a.submenu?.length ? /* @__PURE__ */ jsx(IconChevronRight, {}) : a.kbd ? /* @__PURE__ */ jsx("kbd", { class: "bas-rowmenu__kbd", children: a.kbd.toUpperCase() }) : null
694
- ]
695
- },
696
- a.id
697
- )) : /* @__PURE__ */ jsxs(
701
+ a.id
702
+ )
703
+ ]) : /* @__PURE__ */ jsxs(
698
704
  "form",
699
705
  {
700
706
  class: "bas-rowmenu__form",