@alexgorbatchev/shadcn 0.0.140 → 0.0.141

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.
@@ -5354,4 +5354,98 @@ function BillingUsage2({ plan, price, period, metrics, onManage, pending, densit
5354
5354
  ]
5355
5355
  });
5356
5356
  }
5357
- export { ButtonLink2, ContextMenu2, ContextMenuPortal2, ContextMenuTrigger2, ContextMenuContent2, ActionsMenu2, ActionsMenuTrigger2, ActionsMenuContextTarget2, ActionsMenuContextContent2, FormDialog2, Accordion2, AccordionItem2, AccordionTrigger2, AccordionContent2, OptionCardGroup2, OptionCheckboxGroup2, OptionCard2, OptionCheckboxCard2, EmptyState3, PageMessage2, ActionBar2, ActionBarRow2, ErrorSummary2, ErrorSummaryItem2, Outline2, OutlineSection2, OutlineItem2, formatDataLabel2, DataViewer2, JsonViewer2, AlertDialog2, AlertDialogTrigger2, AlertDialogPortal2, AlertDialogOverlay2, AlertDialogContent2, AlertDialogHeader2, AlertDialogFooter2, AlertDialogMedia2, AlertDialogTitle2, AlertDialogDescription2, AlertDialogAction2, AlertDialogCancel2, DensityProvider2, collectLayoutViolations2, LayoutGuard2, ScrollGuard2, ThemeProvider2, AspectRatio2, Breadcrumb2, BreadcrumbList2, BreadcrumbItem2, BreadcrumbLink2, BreadcrumbPage2, BreadcrumbSeparator2, BreadcrumbEllipsis2, buttonGroupVariants2, ButtonGroup2, ButtonGroupText2, ButtonGroupSeparator2, DescriptionList2, DescriptionListItem2, DescriptionTerm2, DescriptionDetails2, ItemGroup2, ItemSeparator2, Item2, ItemMedia2, ItemContent2, ItemTitle2, ItemDescription2, ItemActions2, ItemHeader2, ItemFooter2, Pagination2, PaginationContent2, PaginationItem2, PaginationLink2, PaginationPrevious2, PaginationNext2, PaginationEllipsis2, Menubar2, MenubarMenu2, MenubarGroup2, MenubarPortal2, MenubarTrigger2, MenubarContent2, MenubarItem2, MenubarCheckboxItem2, MenubarRadioGroup2, MenubarRadioItem2, MenubarLabel2, MenubarSeparator2, MenubarShortcut2, MenubarSub2, MenubarSubTrigger2, MenubarSubContent2, NavigationMenu2, NavigationMenuList2, NavigationMenuItem2, navigationMenuTriggerStyle2, NavigationMenuTrigger2, NavigationMenuContent2, NavigationMenuPositioner2, NavigationMenuLink2, NavigationMenuIndicator2, ToastProvider2, ToastPortal2, ToastViewport2, Toast2, ToastContent2, ToastTitle2, ToastDescription2, ToastAction2, ToastClose2, ToastToaster2, createToastManager2, useToastManager2, markerVariants2, Marker2, MarkerIcon2, MarkerContent2, BubbleGroup2, Bubble2, BubbleContent2, BubbleReactions2, MessageGroup2, Message2, MessageAvatar2, MessageContent2, MessageHeader2, MessageFooter2, MessageThread2, MessageThreadSummary2, MessageThreadReplies2, Attachment2, AttachmentMedia2, AttachmentContent2, AttachmentTitle2, AttachmentDescription2, AttachmentActions2, AttachmentAction2, AttachmentTrigger2, AttachmentGroup2, InlineEdit2, StarRating2, ReviewList2, ChoiceTable2, ConfirmationDialog2, ImagePicker2, Meter2, MeterLabel2, MeterValue2, MeterTrack2, MeterIndicator2, ToolbarToggleChip2, Stepper2, StepperList2, StepperTrigger2, StepperIndicator2, StepperContent2, AppShell2, Stack2, Grid2, GridItem2, Container2, Text2, Heading2, quoteVariants2, Quote2, ReadMore2, SkipLink2, WeatherSummary2, WeatherForecast2, PageHeader2, PanelHeader2, PageIntro2, WorkspaceSwitcher2, AccountMenu2, StatCard2, AuthForm2, SettingsSection2, TagInput2, FilterChip2, FilterBar2, BarList2, StatusTracker2, DashboardLayout2, BillingUsage2 };
5357
+ // src/components/SelectionAction.tsx
5358
+ import { useLayoutEffect as useLayoutEffect4, useState as useState10 } from "react";
5359
+ import { createPortal } from "react-dom";
5360
+ var GAP = 6;
5361
+ var MARGIN = 8;
5362
+ function clamp(value, low, high) {
5363
+ return Math.max(low, Math.min(value, high));
5364
+ }
5365
+ function SelectionAction2({
5366
+ anchor,
5367
+ isInsideAnchor,
5368
+ attributes,
5369
+ children
5370
+ }) {
5371
+ const [host, setHost] = useState10();
5372
+ useLayoutEffect4(() => {
5373
+ const element = anchor.ownerDocument.createElement("div");
5374
+ element.dataset.slot = "selection-action";
5375
+ element.dataset.scroll = "none";
5376
+ element.className = "fixed z-50 flex max-w-[calc(100vw-1rem)] flex-wrap items-center gap-2";
5377
+ element.style.inset = "0 auto auto 0";
5378
+ element.style.visibility = "hidden";
5379
+ for (const [name, value] of Object.entries(attributes ?? {}))
5380
+ element.setAttribute(name, value);
5381
+ if (isInsideAnchor)
5382
+ anchor.append(element);
5383
+ else
5384
+ anchor.after(element);
5385
+ setHost(element);
5386
+ return () => element.remove();
5387
+ }, [anchor, isInsideAnchor, attributes]);
5388
+ useLayoutEffect4(() => {
5389
+ const doc = anchor.ownerDocument;
5390
+ const view = doc.defaultView;
5391
+ if (!host || !view)
5392
+ return;
5393
+ let frame = 0;
5394
+ let left = 0;
5395
+ let top = 0;
5396
+ const place = () => {
5397
+ frame = view.requestAnimationFrame(place);
5398
+ const selection = doc.getSelection();
5399
+ const range = selection?.rangeCount === 1 && !selection.isCollapsed ? selection.getRangeAt(0) : undefined;
5400
+ const viewport = view.visualViewport;
5401
+ const minX = (viewport?.offsetLeft ?? 0) + MARGIN;
5402
+ const minY = (viewport?.offsetTop ?? 0) + MARGIN;
5403
+ const maxX = minX + (viewport?.width ?? view.innerWidth) - 2 * MARGIN;
5404
+ const maxY = minY + (viewport?.height ?? view.innerHeight) - 2 * MARGIN;
5405
+ const lines = Array.from(range?.getClientRects() ?? []).filter((rect) => rect.width > 0 && rect.height > 0 && rect.bottom > minY && rect.top < maxY);
5406
+ const first = lines[0];
5407
+ const last = lines.at(-1);
5408
+ if (!first || !last || !range || !anchor.contains(range.endContainer)) {
5409
+ host.style.visibility = "hidden";
5410
+ return;
5411
+ }
5412
+ const block = anchor.getBoundingClientRect();
5413
+ const box = host.getBoundingClientRect();
5414
+ const { width, height } = box;
5415
+ const belowBlock = block.bottom + GAP;
5416
+ const aboveBlock = block.top - GAP - height;
5417
+ const besideBlock = block.right + GAP;
5418
+ const nearAbove = first.top - GAP - height;
5419
+ const nearBelow = last.bottom + GAP;
5420
+ let x = last.left;
5421
+ let y = nearBelow;
5422
+ if (belowBlock >= nearBelow && belowBlock <= nearBelow + height && belowBlock + height <= maxY) {
5423
+ y = belowBlock;
5424
+ } else if (block.width > 0 && besideBlock >= last.right + GAP && besideBlock + width <= maxX) {
5425
+ x = besideBlock;
5426
+ y = last.top + (last.height - height) / 2;
5427
+ } else if (aboveBlock >= minY && aboveBlock <= nearAbove && aboveBlock >= nearAbove - height) {
5428
+ x = first.left;
5429
+ y = aboveBlock;
5430
+ } else if (nearBelow + height > maxY && nearAbove >= minY) {
5431
+ x = first.left;
5432
+ y = nearAbove;
5433
+ }
5434
+ const nextLeft = left + clamp(x, minX, maxX - width) - box.left;
5435
+ const nextTop = top + clamp(y, minY, maxY - height) - box.top;
5436
+ if (Math.abs(nextLeft - left) >= 0.5) {
5437
+ left = nextLeft;
5438
+ host.style.left = `${left}px`;
5439
+ }
5440
+ if (Math.abs(nextTop - top) >= 0.5) {
5441
+ top = nextTop;
5442
+ host.style.top = `${top}px`;
5443
+ }
5444
+ host.style.visibility = "";
5445
+ };
5446
+ place();
5447
+ return () => view.cancelAnimationFrame(frame);
5448
+ }, [anchor, host]);
5449
+ return host ? createPortal(children, host) : null;
5450
+ }
5451
+ export { ButtonLink2, ContextMenu2, ContextMenuPortal2, ContextMenuTrigger2, ContextMenuContent2, ActionsMenu2, ActionsMenuTrigger2, ActionsMenuContextTarget2, ActionsMenuContextContent2, FormDialog2, Accordion2, AccordionItem2, AccordionTrigger2, AccordionContent2, OptionCardGroup2, OptionCheckboxGroup2, OptionCard2, OptionCheckboxCard2, EmptyState3, PageMessage2, ActionBar2, ActionBarRow2, ErrorSummary2, ErrorSummaryItem2, Outline2, OutlineSection2, OutlineItem2, formatDataLabel2, DataViewer2, JsonViewer2, AlertDialog2, AlertDialogTrigger2, AlertDialogPortal2, AlertDialogOverlay2, AlertDialogContent2, AlertDialogHeader2, AlertDialogFooter2, AlertDialogMedia2, AlertDialogTitle2, AlertDialogDescription2, AlertDialogAction2, AlertDialogCancel2, DensityProvider2, collectLayoutViolations2, LayoutGuard2, ScrollGuard2, ThemeProvider2, AspectRatio2, Breadcrumb2, BreadcrumbList2, BreadcrumbItem2, BreadcrumbLink2, BreadcrumbPage2, BreadcrumbSeparator2, BreadcrumbEllipsis2, buttonGroupVariants2, ButtonGroup2, ButtonGroupText2, ButtonGroupSeparator2, DescriptionList2, DescriptionListItem2, DescriptionTerm2, DescriptionDetails2, ItemGroup2, ItemSeparator2, Item2, ItemMedia2, ItemContent2, ItemTitle2, ItemDescription2, ItemActions2, ItemHeader2, ItemFooter2, Pagination2, PaginationContent2, PaginationItem2, PaginationLink2, PaginationPrevious2, PaginationNext2, PaginationEllipsis2, Menubar2, MenubarMenu2, MenubarGroup2, MenubarPortal2, MenubarTrigger2, MenubarContent2, MenubarItem2, MenubarCheckboxItem2, MenubarRadioGroup2, MenubarRadioItem2, MenubarLabel2, MenubarSeparator2, MenubarShortcut2, MenubarSub2, MenubarSubTrigger2, MenubarSubContent2, NavigationMenu2, NavigationMenuList2, NavigationMenuItem2, navigationMenuTriggerStyle2, NavigationMenuTrigger2, NavigationMenuContent2, NavigationMenuPositioner2, NavigationMenuLink2, NavigationMenuIndicator2, ToastProvider2, ToastPortal2, ToastViewport2, Toast2, ToastContent2, ToastTitle2, ToastDescription2, ToastAction2, ToastClose2, ToastToaster2, createToastManager2, useToastManager2, markerVariants2, Marker2, MarkerIcon2, MarkerContent2, BubbleGroup2, Bubble2, BubbleContent2, BubbleReactions2, MessageGroup2, Message2, MessageAvatar2, MessageContent2, MessageHeader2, MessageFooter2, MessageThread2, MessageThreadSummary2, MessageThreadReplies2, Attachment2, AttachmentMedia2, AttachmentContent2, AttachmentTitle2, AttachmentDescription2, AttachmentActions2, AttachmentAction2, AttachmentTrigger2, AttachmentGroup2, InlineEdit2, StarRating2, ReviewList2, ChoiceTable2, ConfirmationDialog2, ImagePicker2, Meter2, MeterLabel2, MeterValue2, MeterTrack2, MeterIndicator2, ToolbarToggleChip2, Stepper2, StepperList2, StepperTrigger2, StepperIndicator2, StepperContent2, AppShell2, Stack2, Grid2, GridItem2, Container2, Text2, Heading2, quoteVariants2, Quote2, ReadMore2, SkipLink2, WeatherSummary2, WeatherForecast2, PageHeader2, PanelHeader2, PageIntro2, WorkspaceSwitcher2, AccountMenu2, StatCard2, AuthForm2, SettingsSection2, TagInput2, FilterChip2, FilterBar2, BarList2, StatusTracker2, DashboardLayout2, BillingUsage2, SelectionAction2 };
@@ -0,0 +1,13 @@
1
+ import type { ReactElement, ReactNode } from "react";
2
+ interface ISelectionActionProps {
3
+ /** The block where the action should appear in keyboard navigation order. */
4
+ anchor: Element;
5
+ /** Append to the anchor when it is the surrounding content container. */
6
+ isInsideAnchor?: boolean;
7
+ /** Mark the host so applications can exclude it from text extraction. */
8
+ attributes?: Readonly<Record<`data-${string}`, string>>;
9
+ children: ReactNode;
10
+ }
11
+ /** Floating actions for a native text selection, kept beside the selected lines as the layout changes. */
12
+ export declare function SelectionAction({ anchor, isInsideAnchor, attributes, children, }: ISelectionActionProps): ReactElement | null;
13
+ export {};
@@ -26,7 +26,7 @@ import {
26
26
  PaginationPrevious2,
27
27
  PaginationNext2,
28
28
  PaginationEllipsis2
29
- } from "../../chunk-188rnmhk.js";
29
+ } from "../../chunk-5r3f8n1r.js";
30
30
  import {
31
31
  MenuPopup,
32
32
  MenuItem2,
package/dist/index.d.ts CHANGED
@@ -177,3 +177,4 @@ export { LayoutGuard } from "./components/LayoutGuard.js";
177
177
  export type { ILayoutGuardProps } from "./components/LayoutGuard.js";
178
178
  export { collectLayoutViolations } from "./utils/collectLayoutViolations.js";
179
179
  export type { ILayoutViolation } from "./utils/collectLayoutViolations.js";
180
+ export { SelectionAction } from "./components/SelectionAction.js";
package/dist/index.js CHANGED
@@ -186,8 +186,9 @@ import {
186
186
  BarList2,
187
187
  StatusTracker2,
188
188
  DashboardLayout2,
189
- BillingUsage2
190
- } from "./chunk-188rnmhk.js";
189
+ BillingUsage2,
190
+ SelectionAction2
191
+ } from "./chunk-5r3f8n1r.js";
191
192
  import {
192
193
  Combobox2,
193
194
  ComboboxValue2,
@@ -825,6 +826,7 @@ export {
825
826
  SelectSeparator2 as SelectSeparator,
826
827
  SelectTrigger2 as SelectTrigger,
827
828
  SelectValue2 as SelectValue,
829
+ SelectionAction2 as SelectionAction,
828
830
  Separator2 as Separator,
829
831
  SettingsSection2 as SettingsSection,
830
832
  Sheet2 as Sheet,
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.140",
2054
+ version: "0.0.141",
2055
2055
  description: "Sharp, monospace React components with compact, comfortable, and touch densities.",
2056
2056
  license: "MIT",
2057
2057
  repository: {
@@ -0,0 +1,37 @@
1
+ # SelectionAction
2
+
3
+ Story: Actions/SelectionAction
4
+ Source: src/components/stories/actions/SelectionAction.stories.tsx
5
+
6
+ [Full source and local helpers](https://github.com/alexgorbatchev/shadcn/blob/main/src/components/stories/actions/SelectionAction.stories.tsx)
7
+
8
+ ## Public imports
9
+
10
+ ```tsx
11
+ import { Button, SelectionAction } from "@alexgorbatchev/shadcn";
12
+ ```
13
+
14
+ ## Supporting imports
15
+
16
+ ```tsx
17
+ import { useEffect, useRef, useState } from "react";
18
+ import type { ReactElement } from "react";
19
+ ```
20
+
21
+ ## Default component
22
+
23
+ ```tsx
24
+ SelectionAction
25
+ ```
26
+
27
+ ## Examples
28
+
29
+ Storybook CSF excerpts. Default args and render apply unless overridden. Local helpers, fixtures, decorators, and providers may be required; these are reference excerpts, not standalone consumer modules. Interaction tests are omitted.
30
+
31
+ ### FollowsSelectionInTallBlock
32
+
33
+ ```tsx
34
+ {
35
+ render: () => <SelectionExample />
36
+ }
37
+ ```
package/llms.txt CHANGED
@@ -13,6 +13,7 @@ Generated from the public package exports and Storybook sources.
13
13
  - [Button](./llms/components/actions/Button.md)
14
14
  - [ButtonGroup](./llms/components/actions/ButtonGroup.md)
15
15
  - [ButtonLink](./llms/components/actions/ButtonLink.md)
16
+ - [SelectionAction](./llms/components/actions/SelectionAction.md)
16
17
  - [Toggle](./llms/components/actions/Toggle.md)
17
18
  - [ToggleGroup](./llms/components/actions/ToggleGroup.md)
18
19
  - [Toolbar](./llms/components/actions/Toolbar.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexgorbatchev/shadcn",
3
- "version": "0.0.140",
3
+ "version": "0.0.141",
4
4
  "description": "Sharp, monospace React components with compact, comfortable, and touch densities.",
5
5
  "license": "MIT",
6
6
  "repository": {