@eqtylab/equality 3.7.0 → 3.8.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/dist/index.d.cts CHANGED
@@ -1018,16 +1018,22 @@ declare const useTheme: () => readonly [Theme$1 | undefined, (theme: Theme$1) =>
1018
1018
  */
1019
1019
  declare const CODE_BLOCK_ATTRIBUTE = "data-equality-code-block";
1020
1020
  /**
1021
- * Queue a rescan of every mounted code block, coalescing a frame's worth of mounts into one pass.
1021
+ * Queue a rescan of every code block in `root`, coalescing a frame's worth of mounts into one pass.
1022
1022
  *
1023
- * Scanning is document-wide by necessity: each `highlightAll` clears the ranges the last one
1024
- * registered, so a per-block call would erase every other block on the page. Blocks inside a
1025
- * shadow root are out of reach.
1023
+ * `root` is the tree the block lives in, as `pre.getRootNode()` returns it, and defaults to the
1024
+ * document. Blocks are found by querying that tree, and a query never crosses a shadow boundary,
1025
+ * so a block inside a shadow root is only found by passing its root. Scanning is tree-wide rather
1026
+ * than per block because each pass replaces the ranges the previous one registered, so a per-block
1027
+ * call would erase the other blocks.
1026
1028
  *
1027
- * Passes are serialized for the same reason. `highlightAll` collects its elements before awaiting
1028
- * their grammars and clears every registered range once they land, so overlapping passes let the
1029
- * slower one finish last and wipe the blocks it was too early to see.
1029
+ * The highlighter forgets every range it registered on each pass, whatever tree it scanned, so a
1030
+ * pass on a shadow root clears the document's blocks and the reverse; the two cannot both stay
1031
+ * highlighted until upstream scopes that to the scanned tree.
1032
+ *
1033
+ * Passes are serialized. `highlightAll` collects its elements before awaiting their grammars and
1034
+ * clears the registered ranges once they land, so overlapping passes let the slower one finish
1035
+ * last and wipe the blocks it was too early to see.
1030
1036
  */
1031
- declare const scheduleHighlight: () => Promise<void>;
1037
+ declare const scheduleHighlight: (root?: Node) => Promise<void>;
1032
1038
 
1033
1039
  export { Alert, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, Avatar, AvatarFallback, AvatarImage, Badge, type BadgeDisplayMode, type BadgeProps, BarGraph, type BarGraphProps, BarGraphSegment, type BarGraphSegmentProps, BgGradient, Button, type ButtonProps, CODE_BLOCK_ATTRIBUTE, Card, CardContent, CardContentHeader, type CardContentHeaderProps, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CodeBlock, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ControlStatusBadge, type ControlStatusBadgeDisplayMode, CopyButton, type CopyButtonProps, DateRangePicker, Dialog, DialogClose, DialogContainer, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogHeaderIcon, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DisplayField, type DisplayFieldProps, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerHeaderActions, DrawerInnerContent, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuEmpty, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSearch, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, ELEVATION, type Elevation, EmptyTableState, FilterDropdown, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormatDate, type FormatDateDisplayMode, type FormatDateProps, Heading, Icon, IconButton, type IconButtonProps, type IconProps, InfoCard, Input, type InputProps, Label, ListOrGridViewToggle, LoadingOverlay, MetricCard, MotionCollapsibleContent, NotFound, PORTAL_ROOT_ID, Pagination, PanelLabel, Popover, PopoverContent, PopoverTrigger, PortalContainerProvider, Progress, ProgressIndicator, type ProgressIndicatorProps, ProgressIndicatorStep, type ProgressIndicatorStepProps, RadialGraph, type RadialGraphProps, RadioDropdown, RadioGroup, RadioGroupItem, ResourceBadge, type ResourceDisplayMode, type ResourceType, ScrollArea, ScrollBar, SearchBar, SectionHeading, type SegmentedControlOption, SegmentedControls, type SegmentedControlsDisplay, type SegmentedControlsProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContainer, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetHeaderIcon, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Skeleton, SortButton, type SortField, type SortMode, type SortOrder, SortSelector, Spinner, Switch, TableBody, TableCaption, TableCell, TableContainer, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContainer, TabsContent, TabsList, TabsTrigger, Textarea, type Theme, ThemeProvider, Toast, ToastAction, type ToastActionElement, ToastClose, ToastContainer, ToastDescription, type ToastProps$1 as ToastProps, ToastProvider, ToastRoot, ToastTitle, ToastViewport, Toaster, type ToasterToast, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TruncatedDescription, type ViewMode, type ViewOrder, badgeVariants, buttonVariants, reducer, scheduleHighlight, toast, useFormField, usePortalContainer, useTheme, useToast };
package/dist/index.d.ts CHANGED
@@ -1018,16 +1018,22 @@ declare const useTheme: () => readonly [Theme$1 | undefined, (theme: Theme$1) =>
1018
1018
  */
1019
1019
  declare const CODE_BLOCK_ATTRIBUTE = "data-equality-code-block";
1020
1020
  /**
1021
- * Queue a rescan of every mounted code block, coalescing a frame's worth of mounts into one pass.
1021
+ * Queue a rescan of every code block in `root`, coalescing a frame's worth of mounts into one pass.
1022
1022
  *
1023
- * Scanning is document-wide by necessity: each `highlightAll` clears the ranges the last one
1024
- * registered, so a per-block call would erase every other block on the page. Blocks inside a
1025
- * shadow root are out of reach.
1023
+ * `root` is the tree the block lives in, as `pre.getRootNode()` returns it, and defaults to the
1024
+ * document. Blocks are found by querying that tree, and a query never crosses a shadow boundary,
1025
+ * so a block inside a shadow root is only found by passing its root. Scanning is tree-wide rather
1026
+ * than per block because each pass replaces the ranges the previous one registered, so a per-block
1027
+ * call would erase the other blocks.
1026
1028
  *
1027
- * Passes are serialized for the same reason. `highlightAll` collects its elements before awaiting
1028
- * their grammars and clears every registered range once they land, so overlapping passes let the
1029
- * slower one finish last and wipe the blocks it was too early to see.
1029
+ * The highlighter forgets every range it registered on each pass, whatever tree it scanned, so a
1030
+ * pass on a shadow root clears the document's blocks and the reverse; the two cannot both stay
1031
+ * highlighted until upstream scopes that to the scanned tree.
1032
+ *
1033
+ * Passes are serialized. `highlightAll` collects its elements before awaiting their grammars and
1034
+ * clears the registered ranges once they land, so overlapping passes let the slower one finish
1035
+ * last and wipe the blocks it was too early to see.
1030
1036
  */
1031
- declare const scheduleHighlight: () => Promise<void>;
1037
+ declare const scheduleHighlight: (root?: Node) => Promise<void>;
1032
1038
 
1033
1039
  export { Alert, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, Avatar, AvatarFallback, AvatarImage, Badge, type BadgeDisplayMode, type BadgeProps, BarGraph, type BarGraphProps, BarGraphSegment, type BarGraphSegmentProps, BgGradient, Button, type ButtonProps, CODE_BLOCK_ATTRIBUTE, Card, CardContent, CardContentHeader, type CardContentHeaderProps, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CodeBlock, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ControlStatusBadge, type ControlStatusBadgeDisplayMode, CopyButton, type CopyButtonProps, DateRangePicker, Dialog, DialogClose, DialogContainer, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogHeaderIcon, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DisplayField, type DisplayFieldProps, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerHeaderActions, DrawerInnerContent, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuEmpty, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSearch, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, ELEVATION, type Elevation, EmptyTableState, FilterDropdown, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormatDate, type FormatDateDisplayMode, type FormatDateProps, Heading, Icon, IconButton, type IconButtonProps, type IconProps, InfoCard, Input, type InputProps, Label, ListOrGridViewToggle, LoadingOverlay, MetricCard, MotionCollapsibleContent, NotFound, PORTAL_ROOT_ID, Pagination, PanelLabel, Popover, PopoverContent, PopoverTrigger, PortalContainerProvider, Progress, ProgressIndicator, type ProgressIndicatorProps, ProgressIndicatorStep, type ProgressIndicatorStepProps, RadialGraph, type RadialGraphProps, RadioDropdown, RadioGroup, RadioGroupItem, ResourceBadge, type ResourceDisplayMode, type ResourceType, ScrollArea, ScrollBar, SearchBar, SectionHeading, type SegmentedControlOption, SegmentedControls, type SegmentedControlsDisplay, type SegmentedControlsProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContainer, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetHeaderIcon, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Skeleton, SortButton, type SortField, type SortMode, type SortOrder, SortSelector, Spinner, Switch, TableBody, TableCaption, TableCell, TableContainer, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContainer, TabsContent, TabsList, TabsTrigger, Textarea, type Theme, ThemeProvider, Toast, ToastAction, type ToastActionElement, ToastClose, ToastContainer, ToastDescription, type ToastProps$1 as ToastProps, ToastProvider, ToastRoot, ToastTitle, ToastViewport, Toaster, type ToasterToast, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TruncatedDescription, type ViewMode, type ViewOrder, badgeVariants, buttonVariants, reducer, scheduleHighlight, toast, useFormField, usePortalContainer, useTheme, useToast };
package/dist/index.js CHANGED
@@ -1124,23 +1124,25 @@ function CopyButton({
1124
1124
  var CODE_BLOCK_ATTRIBUTE = "data-equality-code-block";
1125
1125
  var SELECTOR = `pre[${CODE_BLOCK_ATTRIBUTE}] > code`;
1126
1126
  var tail = Promise.resolve();
1127
- var queued = null;
1127
+ var queued = /* @__PURE__ */ new Map();
1128
1128
  var isSupported = () => typeof window !== "undefined" && typeof CSS !== "undefined" && Boolean(CSS.highlights);
1129
- var scheduleHighlight = () => {
1129
+ var scheduleHighlight = (root) => {
1130
1130
  if (!isSupported()) return Promise.resolve();
1131
- if (queued) return queued;
1131
+ const tree = root ?? document;
1132
+ const pending = queued.get(tree);
1133
+ if (pending) return pending;
1132
1134
  const pass = tail.then(
1133
1135
  () => new Promise((resolve) => {
1134
1136
  window.requestAnimationFrame(() => {
1135
- queued = null;
1136
- highlightAll({ selector: SELECTOR }).then(
1137
+ queued.delete(tree);
1138
+ highlightAll({ root: tree, selector: SELECTOR }).then(
1137
1139
  () => resolve(),
1138
1140
  () => resolve()
1139
1141
  );
1140
1142
  });
1141
1143
  })
1142
1144
  );
1143
- queued = pass;
1145
+ queued.set(tree, pass);
1144
1146
  tail = pass;
1145
1147
  return pass;
1146
1148
  };
@@ -1154,9 +1156,11 @@ var CodeBlock = ({
1154
1156
  copy,
1155
1157
  lineNumbers = false
1156
1158
  }) => {
1159
+ const preRef = useRef(null);
1157
1160
  useEffect(() => {
1158
- void scheduleHighlight();
1159
- return () => void scheduleHighlight();
1161
+ const root = preRef.current?.getRootNode();
1162
+ void scheduleHighlight(root);
1163
+ return () => void scheduleHighlight(root);
1160
1164
  }, [code, language]);
1161
1165
  const gutter = useMemo(() => {
1162
1166
  if (!lineNumbers) return null;
@@ -1180,7 +1184,7 @@ var CodeBlock = ({
1180
1184
  "aria-label": title ? `${title}, code block` : "Code block",
1181
1185
  children: /* @__PURE__ */ jsxs("div", { className: cn(styles15.body, { [styles15.numbered]: lineNumbers }), children: [
1182
1186
  gutter && /* @__PURE__ */ jsx("pre", { "aria-hidden": "true", className: styles15.gutter, children: gutter }),
1183
- /* @__PURE__ */ jsx("pre", { className: styles15.pre, ...{ [CODE_BLOCK_ATTRIBUTE]: "" }, children: /* @__PURE__ */ jsx(
1187
+ /* @__PURE__ */ jsx("pre", { ref: preRef, className: styles15.pre, ...{ [CODE_BLOCK_ATTRIBUTE]: "" }, children: /* @__PURE__ */ jsx(
1184
1188
  "code",
1185
1189
  {
1186
1190
  className: cn(styles15.code, `language-${language}`, { [styles15.wrap]: !lineNumbers }),