@langchain/macaw-components 1.7.16 → 1.7.17

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.
@@ -6,6 +6,15 @@ import { Text } from "../Text/Text.js";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
8
8
  //#region packages/components/src/components/Tooltip/Tooltip.tsx
9
+ var focusFromKeyboard = true;
10
+ if (typeof document !== "undefined") {
11
+ document.addEventListener("keydown", (event) => {
12
+ if (!event.metaKey && !event.altKey && !event.ctrlKey) focusFromKeyboard = true;
13
+ }, true);
14
+ document.addEventListener("pointerdown", () => {
15
+ focusFromKeyboard = false;
16
+ }, true);
17
+ }
9
18
  function Tooltip({ title, description, children, tooltipClassName, side = "top", sideOffset = 10, align = "center", alignOffset = 0, invert = false, delayDuration = 300, disabled = false, blockTriggerEvents = false, open, onOpenChange, disableHoverableContent = true }) {
10
19
  const zIndex = useZIndex(zIndices.tooltipOverlay);
11
20
  if (!title && !description || disabled) return children;
@@ -16,6 +25,9 @@ function Tooltip({ title, description, children, tooltipClassName, side = "top",
16
25
  disableHoverableContent,
17
26
  children: [/* @__PURE__ */ jsx(TooltipPrimitive.Trigger, {
18
27
  asChild: true,
28
+ onFocus: (e) => {
29
+ if (!focusFromKeyboard) e.preventDefault();
30
+ },
19
31
  onPointerDown: (e) => {
20
32
  if (blockTriggerEvents) {
21
33
  e.preventDefault();
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","names":[],"sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip';\n\nimport { cn } from '../../utils/cn';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\nimport { Text } from '../Text';\n\nexport type TooltipProps = {\n title?: string | ReactNode;\n description?: ReactNode;\n children: ReactNode;\n tooltipClassName?: string;\n side?: 'top' | 'bottom' | 'left' | 'right';\n sideOffset?: number;\n align?: 'start' | 'center' | 'end';\n alignOffset?: number;\n invert?: boolean;\n delayDuration?: number;\n disabled?: boolean;\n blockTriggerEvents?: boolean;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n disableHoverableContent?: boolean;\n};\n\n// Tooltip sets two opinionated defaults — override with caution:\n// - delayDuration=300: prevents tooltips from blocking clicks\n// - disableHoverableContent=true: dismisses the tooltip when hovering off the trigger\nexport function Tooltip({\n title,\n description,\n children,\n tooltipClassName,\n side = 'top',\n sideOffset = 10,\n align = 'center',\n alignOffset = 0,\n invert = false,\n delayDuration = 300,\n disabled = false,\n blockTriggerEvents = false,\n open,\n onOpenChange,\n disableHoverableContent = true,\n}: TooltipProps) {\n const zIndex = useZIndex(zIndices.tooltipOverlay);\n\n if ((!title && !description) || disabled) {\n return children;\n }\n\n return (\n <TooltipPrimitive.Root\n delayDuration={delayDuration}\n open={open}\n onOpenChange={onOpenChange}\n disableHoverableContent={disableHoverableContent}\n >\n <TooltipPrimitive.Trigger\n asChild\n onPointerDown={(e) => {\n if (blockTriggerEvents) {\n e.preventDefault();\n e.stopPropagation();\n }\n }}\n >\n {children}\n </TooltipPrimitive.Trigger>\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content\n sideOffset={sideOffset}\n side={side}\n align={align}\n alignOffset={alignOffset}\n collisionPadding={8}\n className={cn(\n 'max-w-[320px] overflow-hidden rounded-md border border-subtle bg-popover p-space-2 text-sm shadow-md',\n 'animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',\n tooltipClassName,\n invert && 'invert'\n )}\n style={{ zIndex }}\n >\n <ZIndexProvider value={zIndex}>\n <div className=\"flex flex-col gap-space-2 text-xxs\">\n {typeof title === 'string' ? (\n <Text\n variant=\"sm\"\n data-target=\"title\"\n className={!tooltipClassName ? 'text-primary' : ''}\n >\n {title}\n </Text>\n ) : (\n title\n )}\n {description && (\n <Text\n variant=\"sm\"\n className={!tooltipClassName ? 'text-secondary' : ''}\n data-target=\"description\"\n >\n {description}\n </Text>\n )}\n </div>\n </ZIndexProvider>\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n </TooltipPrimitive.Root>\n );\n}\n"],"mappings":";;;;;;;;AA+BA,SAAgB,QAAQ,EACtB,OACA,aACA,UACA,kBACA,OAAO,OACP,aAAa,IACb,QAAQ,UACR,cAAc,GACd,SAAS,OACT,gBAAgB,KAChB,WAAW,OACX,qBAAqB,OACrB,MACA,cACA,0BAA0B,QACX;CACf,MAAM,SAAS,UAAU,SAAS,cAAc;CAEhD,IAAK,CAAC,SAAS,CAAC,eAAgB,UAC9B,OAAO;CAGT,OACE,qBAAC,iBAAiB,MAAlB;EACiB;EACT;EACQ;EACW;EAJ3B,UAAA,CAME,oBAAC,iBAAiB,SAAlB;GACE,SAAA;GACA,gBAAgB,MAAM;IACpB,IAAI,oBAAoB;KACtB,EAAE,eAAe;KACjB,EAAE,gBAAgB;IACpB;GACF;GAEC;EACuB,CAAA,GAC1B,oBAAC,iBAAiB,QAAlB,EAAA,UACE,oBAAC,iBAAiB,SAAlB;GACc;GACN;GACC;GACM;GACb,kBAAkB;GAClB,WAAW,GACT,wGACA,8RACA,kBACA,UAAU,QACZ;GACA,OAAO,EAAE,OAAO;GAEhB,UAAA,oBAAC,gBAAD;IAAgB,OAAO;IACrB,UAAA,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACG,OAAO,UAAU,WAChB,oBAAC,MAAD;MACE,SAAQ;MACR,eAAY;MACZ,WAAW,CAAC,mBAAmB,iBAAiB;MAE/C,UAAA;KACG,CAAA,IAEN,OAED,eACC,oBAAC,MAAD;MACE,SAAQ;MACR,WAAW,CAAC,mBAAmB,mBAAmB;MAClD,eAAY;MAEX,UAAA;KACG,CAAA,CAEL;;GACS,CAAA;EACQ,CAAA,EACH,CAAA,CACJ;;AAE3B"}
1
+ {"version":3,"file":"Tooltip.js","names":[],"sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip';\n\nimport { cn } from '../../utils/cn';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\nimport { Text } from '../Text';\n\nexport type TooltipProps = {\n title?: string | ReactNode;\n description?: ReactNode;\n children: ReactNode;\n tooltipClassName?: string;\n side?: 'top' | 'bottom' | 'left' | 'right';\n sideOffset?: number;\n align?: 'start' | 'center' | 'end';\n alignOffset?: number;\n invert?: boolean;\n delayDuration?: number;\n disabled?: boolean;\n blockTriggerEvents?: boolean;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n disableHoverableContent?: boolean;\n};\n\nlet focusFromKeyboard = true;\n\nif (typeof document !== 'undefined') {\n document.addEventListener(\n 'keydown',\n (event) => {\n if (!event.metaKey && !event.altKey && !event.ctrlKey) {\n focusFromKeyboard = true;\n }\n },\n true\n );\n document.addEventListener(\n 'pointerdown',\n () => {\n focusFromKeyboard = false;\n },\n true\n );\n}\n\n// Tooltip sets two opinionated defaults — override with caution:\n// - delayDuration=300: prevents tooltips from blocking clicks\n// - disableHoverableContent=true: dismisses the tooltip when hovering off the trigger\nexport function Tooltip({\n title,\n description,\n children,\n tooltipClassName,\n side = 'top',\n sideOffset = 10,\n align = 'center',\n alignOffset = 0,\n invert = false,\n delayDuration = 300,\n disabled = false,\n blockTriggerEvents = false,\n open,\n onOpenChange,\n disableHoverableContent = true,\n}: TooltipProps) {\n const zIndex = useZIndex(zIndices.tooltipOverlay);\n\n if ((!title && !description) || disabled) {\n return children;\n }\n\n return (\n <TooltipPrimitive.Root\n delayDuration={delayDuration}\n open={open}\n onOpenChange={onOpenChange}\n disableHoverableContent={disableHoverableContent}\n >\n <TooltipPrimitive.Trigger\n asChild\n onFocus={(e) => {\n if (!focusFromKeyboard) e.preventDefault();\n }}\n onPointerDown={(e) => {\n if (blockTriggerEvents) {\n e.preventDefault();\n e.stopPropagation();\n }\n }}\n >\n {children}\n </TooltipPrimitive.Trigger>\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content\n sideOffset={sideOffset}\n side={side}\n align={align}\n alignOffset={alignOffset}\n collisionPadding={8}\n className={cn(\n 'max-w-[320px] overflow-hidden rounded-md border border-subtle bg-popover p-space-2 text-sm shadow-md',\n 'animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',\n tooltipClassName,\n invert && 'invert'\n )}\n style={{ zIndex }}\n >\n <ZIndexProvider value={zIndex}>\n <div className=\"flex flex-col gap-space-2 text-xxs\">\n {typeof title === 'string' ? (\n <Text\n variant=\"sm\"\n data-target=\"title\"\n className={!tooltipClassName ? 'text-primary' : ''}\n >\n {title}\n </Text>\n ) : (\n title\n )}\n {description && (\n <Text\n variant=\"sm\"\n className={!tooltipClassName ? 'text-secondary' : ''}\n data-target=\"description\"\n >\n {description}\n </Text>\n )}\n </div>\n </ZIndexProvider>\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n </TooltipPrimitive.Root>\n );\n}\n"],"mappings":";;;;;;;;AA4BA,IAAI,oBAAoB;AAExB,IAAI,OAAO,aAAa,aAAa;CACnC,SAAS,iBACP,YACC,UAAU;EACT,IAAI,CAAC,MAAM,WAAW,CAAC,MAAM,UAAU,CAAC,MAAM,SAC5C,oBAAoB;CAExB,GACA,IACF;CACA,SAAS,iBACP,qBACM;EACJ,oBAAoB;CACtB,GACA,IACF;AACF;AAKA,SAAgB,QAAQ,EACtB,OACA,aACA,UACA,kBACA,OAAO,OACP,aAAa,IACb,QAAQ,UACR,cAAc,GACd,SAAS,OACT,gBAAgB,KAChB,WAAW,OACX,qBAAqB,OACrB,MACA,cACA,0BAA0B,QACX;CACf,MAAM,SAAS,UAAU,SAAS,cAAc;CAEhD,IAAK,CAAC,SAAS,CAAC,eAAgB,UAC9B,OAAO;CAGT,OACE,qBAAC,iBAAiB,MAAlB;EACiB;EACT;EACQ;EACW;EAJ3B,UAAA,CAME,oBAAC,iBAAiB,SAAlB;GACE,SAAA;GACA,UAAU,MAAM;IACd,IAAI,CAAC,mBAAmB,EAAE,eAAe;GAC3C;GACA,gBAAgB,MAAM;IACpB,IAAI,oBAAoB;KACtB,EAAE,eAAe;KACjB,EAAE,gBAAgB;IACpB;GACF;GAEC;EACuB,CAAA,GAC1B,oBAAC,iBAAiB,QAAlB,EAAA,UACE,oBAAC,iBAAiB,SAAlB;GACc;GACN;GACC;GACM;GACb,kBAAkB;GAClB,WAAW,GACT,wGACA,8RACA,kBACA,UAAU,QACZ;GACA,OAAO,EAAE,OAAO;GAEhB,UAAA,oBAAC,gBAAD;IAAgB,OAAO;IACrB,UAAA,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACG,OAAO,UAAU,WAChB,oBAAC,MAAD;MACE,SAAQ;MACR,eAAY;MACZ,WAAW,CAAC,mBAAmB,iBAAiB;MAE/C,UAAA;KACG,CAAA,IAEN,OAED,eACC,oBAAC,MAAD;MACE,SAAQ;MACR,WAAW,CAAC,mBAAmB,mBAAmB;MAClD,eAAY;MAEX,UAAA;KACG,CAAA,CAEL;;GACS,CAAA;EACQ,CAAA,EACH,CAAA,CACJ;;AAE3B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/macaw-components",
3
- "version": "1.7.16",
3
+ "version": "1.7.17",
4
4
  "description": "React components and usage guidance for the Macaw Design System.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -661,7 +661,7 @@
661
661
  "@fontsource/fira-code": "^5.2.7",
662
662
  "@fontsource/inter": "^5.2.8",
663
663
  "@headlessui/react": "^2.2.10",
664
- "@langchain/macaw-tokens": "1.7.16",
664
+ "@langchain/macaw-tokens": "1.7.17",
665
665
  "@lezer/common": "^1.2.1",
666
666
  "@lezer/highlight": "^1.2.0",
667
667
  "@lezer/yaml": "^1.0.4",