@alexgorbatchev/shadcn 0.0.129 → 0.0.131

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.
@@ -9,7 +9,7 @@ import {
9
9
  MenuItem2,
10
10
  DropdownMenu2,
11
11
  DropdownMenuTrigger2
12
- } from "./chunk-dbxmw9ya.js";
12
+ } from "./chunk-zrmtxp7r.js";
13
13
  import {
14
14
  mono
15
15
  } from "./chunk-fgmcbtyt.js";
@@ -39,7 +39,7 @@ import {
39
39
  MenuShortcut2,
40
40
  DropdownMenu2,
41
41
  DropdownMenuTrigger2
42
- } from "./chunk-dbxmw9ya.js";
42
+ } from "./chunk-zrmtxp7r.js";
43
43
  import {
44
44
  Alert2,
45
45
  AlertTitle2,
@@ -631,8 +631,8 @@ function FoldToggle({ fold, descriptionId }) {
631
631
  return null;
632
632
  return /* @__PURE__ */ jsx6(Button2, {
633
633
  type: "button",
634
- variant: "link",
635
- size: "sm",
634
+ variant: "outline",
635
+ size: "xs",
636
636
  "data-slot": "option-card-fold",
637
637
  "aria-expanded": fold.isOpen,
638
638
  "aria-controls": descriptionId,
@@ -660,7 +660,31 @@ function OptionCard2({
660
660
  }) {
661
661
  const ids = useOptionCardIds();
662
662
  const fold = useFold(descriptionLines);
663
- const content = { label, description, descriptionLines, recommended, recommendedLabel, reason, image, marker };
663
+ const radioMarker = /* @__PURE__ */ jsxs4("span", {
664
+ className: "flex items-start gap-1.5",
665
+ children: [
666
+ /* @__PURE__ */ jsx6("span", {
667
+ "data-slot": "option-card-radio",
668
+ className: "mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border border-input group-data-checked/option-card:border-primary",
669
+ children: /* @__PURE__ */ jsx6("span", {
670
+ className: "hidden size-2 rounded-full bg-primary group-data-checked/option-card:block forced-colors:bg-[Highlight]"
671
+ })
672
+ }),
673
+ marker ?? /* @__PURE__ */ jsx6("span", {
674
+ className: "before:content-[counter(option-card,lower-alpha)]"
675
+ })
676
+ ]
677
+ });
678
+ const content = {
679
+ label,
680
+ description,
681
+ descriptionLines,
682
+ recommended,
683
+ recommendedLabel,
684
+ reason,
685
+ image,
686
+ marker: radioMarker
687
+ };
664
688
  return /* @__PURE__ */ jsxs4("div", {
665
689
  "data-slot": "option-card-item",
666
690
  className: "relative min-w-0",
@@ -38,7 +38,8 @@ function MenuPortal({ container, ref, children, ...props }) {
38
38
  function usePointAnchor(point) {
39
39
  const x = point?.clientX;
40
40
  const y = point?.clientY;
41
- return useMemo(() => x === undefined || y === undefined ? undefined : { getBoundingClientRect: () => DOMRect.fromRect({ x, y, width: 0, height: 0 }) }, [x, y]);
41
+ const height = point?.height ?? 0;
42
+ return useMemo(() => x === undefined || y === undefined ? undefined : { getBoundingClientRect: () => DOMRect.fromRect({ x, y, width: 0, height }) }, [x, y, height]);
42
43
  }
43
44
  function MenuPopup({
44
45
  density,
@@ -39,7 +39,11 @@ interface IOptionCardContentProps {
39
39
  marker?: ReactNode;
40
40
  }
41
41
  type OptionCardProps = Omit<RadioPrimitive.Root.Props, "children"> & IDensityProps & IOptionCardContentProps;
42
- /** One option of an `OptionCardGroup`: a bordered card with a leading letter, a bold label and a muted description. */
42
+ /**
43
+ * One option of an `OptionCardGroup`: a bordered card with a leading radio mark and letter, a bold label and a muted
44
+ * description. The radio mark shows the choice by shape as well as colour, and sets single choice apart from an
45
+ * `OptionCheckboxCard`'s checkbox.
46
+ */
43
47
  declare function OptionCard({ label, description, descriptionLines, recommended, recommendedLabel, reason, image, marker, density, className, ...props }: OptionCardProps): ReactElement;
44
48
  type OptionCheckboxCardProps = Omit<CheckboxPrimitive.Root.Props, "children"> & IDensityProps & IOptionCardContentProps;
45
49
  /**
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  RegenerateMenu2
3
- } from "../../../chunk-b6472409.js";
4
- import"../../../chunk-dbxmw9ya.js";
3
+ } from "../../../chunk-aasp54x3.js";
4
+ import"../../../chunk-zrmtxp7r.js";
5
5
  import"../../../chunk-2sx8m8b2.js";
6
6
  import"../../../chunk-x90xmrba.js";
7
7
  import"../../../chunk-jpvw9xqy.js";
@@ -481,10 +481,10 @@ import {
481
481
  import {
482
482
  RecommendationCard2
483
483
  } from "../../chunk-x3gz994f.js";
484
- import"../../chunk-dbxmw9ya.js";
484
+ import"../../chunk-zrmtxp7r.js";
485
485
  import {
486
486
  RegenerateMenu2
487
- } from "../../chunk-b6472409.js";
487
+ } from "../../chunk-aasp54x3.js";
488
488
  import {
489
489
  ResearchReport2
490
490
  } from "../../chunk-fdhssr0q.js";
@@ -26,7 +26,7 @@ import {
26
26
  PaginationPrevious2,
27
27
  PaginationNext2,
28
28
  PaginationEllipsis2
29
- } from "../../chunk-k7c5h30v.js";
29
+ } from "../../chunk-bw2stfag.js";
30
30
  import {
31
31
  MenuPopup,
32
32
  MenuItem2,
@@ -34,7 +34,7 @@ import {
34
34
  MenuRadioItem2,
35
35
  DropdownMenu2,
36
36
  DropdownMenuTrigger2
37
- } from "../../chunk-dbxmw9ya.js";
37
+ } from "../../chunk-zrmtxp7r.js";
38
38
  import {
39
39
  Alert2,
40
40
  AlertTitle2,
package/dist/index.js CHANGED
@@ -187,7 +187,7 @@ import {
187
187
  StatusTracker2,
188
188
  DashboardLayout2,
189
189
  BillingUsage2
190
- } from "./chunk-k7c5h30v.js";
190
+ } from "./chunk-bw2stfag.js";
191
191
  import {
192
192
  Combobox2,
193
193
  ComboboxValue2,
@@ -266,7 +266,7 @@ import {
266
266
  MenuShortcut2,
267
267
  DropdownMenu2,
268
268
  DropdownMenuTrigger2
269
- } from "./chunk-dbxmw9ya.js";
269
+ } from "./chunk-zrmtxp7r.js";
270
270
  import {
271
271
  Empty2,
272
272
  EmptyHeader2,
@@ -28,13 +28,21 @@ export type MenuSubTriggerProps = Menu.SubmenuTrigger.Props & IMenuInsetProps;
28
28
  export type MenuCheckboxItemProps = Menu.CheckboxItem.Props & IMenuInsetProps;
29
29
  export type MenuRadioItemProps = Menu.RadioItem.Props & IMenuInsetProps;
30
30
  /** A viewport point in CSS pixels, such as the right-click event that asked for a menu. */
31
- export type MenuPoint = Pick<MouseEvent, "clientX" | "clientY">;
31
+ /**
32
+ * Where a menu opens without a trigger. A pointer gives a point; a keyboard opening on a row gives the row's top and
33
+ * `height`, so the menu opens below the row and, where it does not fit, flips above it instead of over it.
34
+ */
35
+ export type MenuPoint = Pick<MouseEvent, "clientX" | "clientY"> & {
36
+ height?: number;
37
+ };
32
38
  export type MenuPopupProps = Menu.Popup.Props & Pick<Menu.Positioner.Props, "align" | "alignOffset" | "side" | "sideOffset"> & IDensityProps & {
33
39
  width?: "content" | "anchor";
34
40
  /**
35
41
  * Opens the menu at this viewport point instead of at its trigger, as a context menu opens at the pointer. The
36
42
  * menu's top start corner sits on the point; where the menu does not fit, it flips to the side with room and then
37
- * shifts until it lies wholly inside the viewport. `side`, `align` and their offsets are ignored.
43
+ * shifts until it lies wholly inside the viewport. With a `height`, the point is the top of a box that tall, such as
44
+ * the row a keyboard opened the menu from: the menu opens below it or above it, never over it. `side`, `align` and
45
+ * their offsets are ignored.
38
46
  */
39
47
  point?: MenuPoint;
40
48
  };
package/dist/prototype.js CHANGED
@@ -2051,7 +2051,7 @@ var program = new Command;
2051
2051
  // package.json
2052
2052
  var package_default = {
2053
2053
  name: "@alexgorbatchev/shadcn",
2054
- version: "0.0.129",
2054
+ version: "0.0.131",
2055
2055
  description: "Sharp, monospace React components with compact and comfortable densities.",
2056
2056
  license: "MIT",
2057
2057
  repository: {
@@ -14,7 +14,7 @@ import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuGro
14
14
  ## Supporting imports
15
15
 
16
16
  ```tsx
17
- import { useState, type ReactElement } from "react";
17
+ import { useState, type KeyboardEvent, type ReactElement } from "react";
18
18
  import {
19
19
  BellIcon,
20
20
  MailIcon,
@@ -690,6 +690,47 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
690
690
  }
691
691
  ```
692
692
 
693
+ ### AtRowFromKeyboard
694
+
695
+ ```tsx
696
+ {
697
+ render: function Render() {
698
+ const [point, setPoint] = useState<MenuPoint>();
699
+ const [row, setRow] = useState<string>();
700
+ const openAt = (name: string, element: HTMLElement) => {
701
+ const rect = element.getBoundingClientRect();
702
+ setRow(name);
703
+ setPoint({ clientX: rect.left + 16, clientY: rect.top, height: rect.height });
704
+ };
705
+ const rowProps = (name: string) => ({
706
+ role: "button",
707
+ tabIndex: 0,
708
+ className: "rounded-sm border border-border px-2 py-1",
709
+ onKeyDown: (event: KeyboardEvent<HTMLDivElement>) => {
710
+ if (event.key !== "F10" || !event.shiftKey)
711
+ return;
712
+ event.preventDefault();
713
+ openAt(name, event.currentTarget);
714
+ },
715
+ });
716
+ return (<div className="flex h-[calc(100vh-2rem)] flex-col justify-between">
717
+ <div {...rowProps("Alpha")}>Alpha</div>
718
+ <div {...rowProps("Bravo")}>Bravo</div>
719
+ <DropdownMenu open={point !== undefined} onOpenChange={(isOpen) => !isOpen && setPoint(undefined)}>
720
+ <DropdownMenuContent point={point} aria-label={`Actions for ${row ?? "row"}`}>
721
+ <DropdownMenuGroup>
722
+ <DropdownMenuLabel>{row}</DropdownMenuLabel>
723
+ <DropdownMenuItem>Open</DropdownMenuItem>
724
+ <DropdownMenuItem>Rename</DropdownMenuItem>
725
+ <DropdownMenuItem>Move</DropdownMenuItem>
726
+ </DropdownMenuGroup>
727
+ </DropdownMenuContent>
728
+ </DropdownMenu>
729
+ </div>);
730
+ }
731
+ }
732
+ ```
733
+
693
734
  ### FilterableSubmenu
694
735
 
695
736
  ```tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexgorbatchev/shadcn",
3
- "version": "0.0.129",
3
+ "version": "0.0.131",
4
4
  "description": "Sharp, monospace React components with compact and comfortable densities.",
5
5
  "license": "MIT",
6
6
  "repository": {