@economic/taco 8.1.2-hanger-base-ui.4 → 8.1.3-alpha.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.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
- const popover = require("@base-ui/react/popover");
4
+ const PopoverPrimitive = require("@radix-ui/react-popover");
5
5
  function _interopNamespaceDefault(e) {
6
6
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
7
7
  if (e) {
@@ -19,8 +19,9 @@ function _interopNamespaceDefault(e) {
19
19
  return Object.freeze(n);
20
20
  }
21
21
  const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
22
+ const PopoverPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(PopoverPrimitive);
22
23
  const UnstyledArrow = React__namespace.forwardRef(function PopoverArrow(props, ref) {
23
- return /* @__PURE__ */ React__namespace.createElement(popover.Popover.Arrow, { className: "pointer-events-none h-[11px] w-[30px] data-[side=bottom]:top-[-10px] data-[side=left]:right-[-20px] data-[side=right]:left-[-20px] data-[side=top]:bottom-[-10px] data-[side=left]:rotate-90 data-[side=right]:-rotate-90 data-[side=top]:rotate-180" }, /* @__PURE__ */ React__namespace.createElement("svg", { ...props, ref, viewBox: "0 19 30 11" }, /* @__PURE__ */ React__namespace.createElement(
24
+ return /* @__PURE__ */ React__namespace.createElement(PopoverPrimitive__namespace.Arrow, { className: "pointer-events-none -mt-px", asChild: true, offset: 2, width: 30, height: 11 }, /* @__PURE__ */ React__namespace.createElement("svg", { ...props, ref, viewBox: "0 19 30 11", style: { transform: "rotateZ(180deg)" } }, /* @__PURE__ */ React__namespace.createElement(
24
25
  "path",
25
26
  {
26
27
  className: "fill-current text-blue-500",
@@ -1 +1 @@
1
- {"version":3,"file":"Arrow.cjs","sources":["../../../src/components/Hanger/Arrow.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Popover as PopoverPrimitive } from '@base-ui/react/popover';\n\nexport const UnstyledArrow = React.forwardRef<SVGSVGElement, React.SVGAttributes<SVGElement>>(function PopoverArrow(props, ref) {\n return (\n <PopoverPrimitive.Arrow className=\"pointer-events-none h-[11px] w-[30px] data-[side=bottom]:top-[-10px] data-[side=left]:right-[-20px] data-[side=right]:left-[-20px] data-[side=top]:bottom-[-10px] data-[side=left]:rotate-90 data-[side=right]:-rotate-90 data-[side=top]:rotate-180\">\n <svg {...props} ref={ref} viewBox=\"0 19 30 11\">\n <path\n className=\"fill-current text-blue-500\"\n d=\"M23.7,27.1L17,19.9C16.5,19.3,15.8,19,15,19s-1.6,0.3-2.1,0.9l-6.6,7.2C5.3,28.1,3.4,29,2,29h26 C26.7,29,24.6,28.1,23.7,27.1z\"></path>\n <path\n className=\"fill-current\"\n d=\"M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z\"></path>\n </svg>\n </PopoverPrimitive.Arrow>\n );\n});\n"],"names":["React","PopoverPrimitive"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGO,MAAM,gBAAgBA,iBAAM,WAA2D,SAAS,aAAa,OAAO,KAAK;AAC5H,SACKA,iCAAA,cAAAC,QAAA,QAAiB,OAAjB,EAAuB,WAAU,uPAAA,GAC7BD,iCAAA,cAAA,OAAA,EAAK,GAAG,OAAO,KAAU,SAAQ,aAC9B,GAAAA,iCAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAU;AAAA,MACV,GAAE;AAAA,IAAA;AAAA,EACN,GAAAA,iCAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAU;AAAA,MACV,GAAE;AAAA,IAAA;AAAA,EAAA,CACV,CACJ;AAER,CAAC;;"}
1
+ {"version":3,"file":"Arrow.cjs","sources":["../../../src/components/Hanger/Arrow.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\n\nexport const UnstyledArrow = React.forwardRef<SVGSVGElement, React.SVGAttributes<SVGElement>>(function PopoverArrow(props, ref) {\n return (\n <PopoverPrimitive.Arrow className=\"pointer-events-none -mt-px\" asChild offset={2} width={30} height={11}>\n <svg {...props} ref={ref} viewBox=\"0 19 30 11\" style={{ transform: 'rotateZ(180deg)' }}>\n <path\n className=\"fill-current text-blue-500\"\n d=\"M23.7,27.1L17,19.9C16.5,19.3,15.8,19,15,19s-1.6,0.3-2.1,0.9l-6.6,7.2C5.3,28.1,3.4,29,2,29h26 C26.7,29,24.6,28.1,23.7,27.1z\"></path>\n <path\n className=\"fill-current\"\n d=\"M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z\"></path>\n </svg>\n </PopoverPrimitive.Arrow>\n );\n});\n"],"names":["React","PopoverPrimitive"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAGO,MAAM,gBAAgBA,iBAAM,WAA2D,SAAS,aAAa,OAAO,KAAK;AAExH,SAAAA,iCAAA,cAACC,4BAAiB,OAAjB,EAAuB,WAAU,8BAA6B,SAAO,MAAC,QAAQ,GAAG,OAAO,IAAI,QAAQ,MACjGD,iCAAA,cAAC,OAAK,EAAA,GAAG,OAAO,KAAU,SAAQ,cAAa,OAAO,EAAE,WAAW,kBAAA,EAC/D,GAAAA,iCAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAU;AAAA,MACV,GAAE;AAAA,IAAA;AAAA,EACN,GAAAA,iCAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAU;AAAA,MACV,GAAE;AAAA,IAAA;AAAA,EAAA,CACV,CACJ;AAER,CAAC;;"}
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
- import { Popover } from "@base-ui/react/popover";
2
+ import * as PopoverPrimitive from "@radix-ui/react-popover";
3
3
  const UnstyledArrow = React.forwardRef(function PopoverArrow(props, ref) {
4
- return /* @__PURE__ */ React.createElement(Popover.Arrow, { className: "pointer-events-none h-[11px] w-[30px] data-[side=bottom]:top-[-10px] data-[side=left]:right-[-20px] data-[side=right]:left-[-20px] data-[side=top]:bottom-[-10px] data-[side=left]:rotate-90 data-[side=right]:-rotate-90 data-[side=top]:rotate-180" }, /* @__PURE__ */ React.createElement("svg", { ...props, ref, viewBox: "0 19 30 11" }, /* @__PURE__ */ React.createElement(
4
+ return /* @__PURE__ */ React.createElement(PopoverPrimitive.Arrow, { className: "pointer-events-none -mt-px", asChild: true, offset: 2, width: 30, height: 11 }, /* @__PURE__ */ React.createElement("svg", { ...props, ref, viewBox: "0 19 30 11", style: { transform: "rotateZ(180deg)" } }, /* @__PURE__ */ React.createElement(
5
5
  "path",
6
6
  {
7
7
  className: "fill-current text-blue-500",
@@ -1 +1 @@
1
- {"version":3,"file":"Arrow.js","sources":["../../../src/components/Hanger/Arrow.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Popover as PopoverPrimitive } from '@base-ui/react/popover';\n\nexport const UnstyledArrow = React.forwardRef<SVGSVGElement, React.SVGAttributes<SVGElement>>(function PopoverArrow(props, ref) {\n return (\n <PopoverPrimitive.Arrow className=\"pointer-events-none h-[11px] w-[30px] data-[side=bottom]:top-[-10px] data-[side=left]:right-[-20px] data-[side=right]:left-[-20px] data-[side=top]:bottom-[-10px] data-[side=left]:rotate-90 data-[side=right]:-rotate-90 data-[side=top]:rotate-180\">\n <svg {...props} ref={ref} viewBox=\"0 19 30 11\">\n <path\n className=\"fill-current text-blue-500\"\n d=\"M23.7,27.1L17,19.9C16.5,19.3,15.8,19,15,19s-1.6,0.3-2.1,0.9l-6.6,7.2C5.3,28.1,3.4,29,2,29h26 C26.7,29,24.6,28.1,23.7,27.1z\"></path>\n <path\n className=\"fill-current\"\n d=\"M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z\"></path>\n </svg>\n </PopoverPrimitive.Arrow>\n );\n});\n"],"names":["PopoverPrimitive"],"mappings":";;AAGO,MAAM,gBAAgB,MAAM,WAA2D,SAAS,aAAa,OAAO,KAAK;AAC5H,SACK,sBAAA,cAAAA,QAAiB,OAAjB,EAAuB,WAAU,uPAAA,GAC7B,sBAAA,cAAA,OAAA,EAAK,GAAG,OAAO,KAAU,SAAQ,aAC9B,GAAA,sBAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAU;AAAA,MACV,GAAE;AAAA,IAAA;AAAA,EACN,GAAA,sBAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAU;AAAA,MACV,GAAE;AAAA,IAAA;AAAA,EAAA,CACV,CACJ;AAER,CAAC;"}
1
+ {"version":3,"file":"Arrow.js","sources":["../../../src/components/Hanger/Arrow.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\n\nexport const UnstyledArrow = React.forwardRef<SVGSVGElement, React.SVGAttributes<SVGElement>>(function PopoverArrow(props, ref) {\n return (\n <PopoverPrimitive.Arrow className=\"pointer-events-none -mt-px\" asChild offset={2} width={30} height={11}>\n <svg {...props} ref={ref} viewBox=\"0 19 30 11\" style={{ transform: 'rotateZ(180deg)' }}>\n <path\n className=\"fill-current text-blue-500\"\n d=\"M23.7,27.1L17,19.9C16.5,19.3,15.8,19,15,19s-1.6,0.3-2.1,0.9l-6.6,7.2C5.3,28.1,3.4,29,2,29h26 C26.7,29,24.6,28.1,23.7,27.1z\"></path>\n <path\n className=\"fill-current\"\n d=\"M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z\"></path>\n </svg>\n </PopoverPrimitive.Arrow>\n );\n});\n"],"names":[],"mappings":";;AAGO,MAAM,gBAAgB,MAAM,WAA2D,SAAS,aAAa,OAAO,KAAK;AAExH,SAAA,sBAAA,cAAC,iBAAiB,OAAjB,EAAuB,WAAU,8BAA6B,SAAO,MAAC,QAAQ,GAAG,OAAO,IAAI,QAAQ,MACjG,sBAAA,cAAC,OAAK,EAAA,GAAG,OAAO,KAAU,SAAQ,cAAa,OAAO,EAAE,WAAW,kBAAA,EAC/D,GAAA,sBAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAU;AAAA,MACV,GAAE;AAAA,IAAA;AAAA,EACN,GAAA,sBAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAU;AAAA,MACV,GAAE;AAAA,IAAA;AAAA,EAAA,CACV,CACJ;AAER,CAAC;"}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
4
  const cn = require("clsx");
5
- const popover = require("@base-ui/react/popover");
5
+ const PopoverPrimitive = require("@radix-ui/react-popover");
6
6
  const IconButton = require("../IconButton/IconButton.cjs");
7
7
  const Arrow = require("./Arrow.cjs");
8
8
  const Localization = require("../Provider/Localization.cjs");
@@ -25,69 +25,75 @@ function _interopNamespaceDefault(e) {
25
25
  return Object.freeze(n);
26
26
  }
27
27
  const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
28
+ const PopoverPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(PopoverPrimitive);
28
29
  const HangerContext = React__namespace.createContext({
29
- anchorRef: { current: null },
30
- onClose: void 0
30
+ onClose: void 0,
31
+ props: {},
32
+ ref: null
31
33
  });
32
- const Anchor = React__namespace.forwardRef(function HangerAnchor(props) {
33
- return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, props.children);
34
+ const Anchor = React__namespace.forwardRef(function HangerAnchor(props, externalRef) {
35
+ var _a;
36
+ const { ref: parentRef, props: parentProps } = React__namespace.useContext(HangerContext);
37
+ const refCallback = mergeRefs.mergeRefs([parentRef, externalRef]);
38
+ let children = props.children;
39
+ if (React__namespace.isValidElement(props.children) && typeof ((_a = props.children) == null ? void 0 : _a.type) === "function") {
40
+ console.warn(
41
+ `Hanger.Anchor requires its child to forwardRef so that it can attach to the dom element. Did you mean to wrap '${props.children.type.name}' in React.forwardRef()? Taco has wrapped '${props.children.type.name}' in a 'span' to maintain functionality, but this may cause unintended behaviour`
42
+ );
43
+ children = /* @__PURE__ */ React__namespace.createElement("span", null, props.children);
44
+ }
45
+ return /* @__PURE__ */ React__namespace.createElement(PopoverPrimitive__namespace.Anchor, { ...parentProps, ...props, ref: refCallback, asChild: true }, children);
34
46
  });
35
47
  const Title = React__namespace.forwardRef(function DialogTitle(props, ref) {
36
48
  const className = cn("mb-1 text-base font-bold flex w-full", props.className);
37
49
  return /* @__PURE__ */ React__namespace.createElement("span", { ...props, className, ref });
38
50
  });
39
51
  const Content = React__namespace.forwardRef(function HangerContent(props, ref) {
40
- const { placement: side, hideWhenDetached = false, container, ...popoverContentProps } = props;
52
+ const { placement: side, hideWhenDetached = false, container } = props;
41
53
  const context = React__namespace.useContext(HangerContext);
42
54
  const { texts } = Localization.useLocalization();
43
55
  const className = cn(
44
56
  "wcag-blue-500 border border-transparent rounded p-3 pr-12 yt-shadow focus:border-transparent max-w-sm print:hidden",
45
57
  props.className
46
58
  );
47
- return /* @__PURE__ */ React__namespace.createElement(popover.Popover.Portal, { container }, /* @__PURE__ */ React__namespace.createElement(
48
- popover.Popover.Positioner,
59
+ const handleInteractOutside = (event) => {
60
+ event.preventDefault();
61
+ };
62
+ return /* @__PURE__ */ React__namespace.createElement(PopoverPrimitive__namespace.Portal, { container }, /* @__PURE__ */ React__namespace.createElement(
63
+ PopoverPrimitive__namespace.Content,
49
64
  {
50
- anchor: context.anchorRef,
51
- className: hideWhenDetached ? "data-[anchor-hidden]:hidden" : void 0,
65
+ className,
66
+ "data-taco": "hanger",
67
+ onInteractOutside: handleInteractOutside,
52
68
  side,
53
- sideOffset: 11
69
+ sideOffset: 1,
70
+ ref,
71
+ hideWhenDetached
54
72
  },
55
- /* @__PURE__ */ React__namespace.createElement(popover.Popover.Popup, { ...popoverContentProps, className, "data-taco": "hanger", ref }, props.children, /* @__PURE__ */ React__namespace.createElement(Arrow.UnstyledArrow, { className: "text-blue-500" }), /* @__PURE__ */ React__namespace.createElement(
56
- popover.Popover.Close,
73
+ props.children,
74
+ /* @__PURE__ */ React__namespace.createElement(Arrow.UnstyledArrow, { className: "text-blue-500" }),
75
+ /* @__PURE__ */ React__namespace.createElement(PopoverPrimitive__namespace.Close, { asChild: true }, /* @__PURE__ */ React__namespace.createElement(
76
+ IconButton.IconButton,
57
77
  {
58
- render: /* @__PURE__ */ React__namespace.createElement(
59
- IconButton.IconButton,
60
- {
61
- appearance: "primary",
62
- "aria-label": texts.hanger.close,
63
- className: "absolute right-0 top-0 mx-2 mt-2 text-white",
64
- icon: "close",
65
- onClick: context.onClose
66
- }
67
- )
78
+ appearance: "primary",
79
+ "aria-label": texts.hanger.close,
80
+ className: "absolute right-0 top-0 ml-2 mr-2 mt-2 text-white",
81
+ icon: "close",
82
+ onClick: context.onClose
68
83
  }
69
84
  ))
70
85
  ));
71
86
  });
72
87
  const Hanger = React__namespace.forwardRef(function Hanger2(props, ref) {
73
88
  const { anchor, children, defaultOpen = true, onClose, ...otherProps } = props;
74
- const anchorRef = React__namespace.useRef(null);
75
- const combinedRef = mergeRefs.mergeRefs([anchorRef, ref]);
76
- const context = React__namespace.useMemo(() => ({ anchorRef, onClose }), [onClose]);
89
+ const context = React__namespace.useMemo(() => ({ onClose, props: otherProps, ref }), [onClose, otherProps]);
77
90
  const [open, setOpen] = React__namespace.useState(false);
78
91
  React__namespace.useEffect(() => {
79
92
  if (defaultOpen) {
80
93
  setOpen(defaultOpen);
81
94
  }
82
95
  }, []);
83
- const handleOpenChange = (nextOpen, eventDetails) => {
84
- if (!nextOpen && (eventDetails.reason === "outside-press" || eventDetails.reason === "focus-out")) {
85
- eventDetails.cancel();
86
- return;
87
- }
88
- setOpen(nextOpen);
89
- };
90
- return /* @__PURE__ */ React__namespace.createElement(HangerContext.Provider, { value: context }, /* @__PURE__ */ React__namespace.createElement("span", { ...otherProps, ref: combinedRef }, /* @__PURE__ */ React__namespace.createElement(popover.Popover.Root, { open, onOpenChange: handleOpenChange }, anchor, children)));
96
+ return /* @__PURE__ */ React__namespace.createElement(HangerContext.Provider, { value: context }, /* @__PURE__ */ React__namespace.createElement(PopoverPrimitive__namespace.Root, { key: String(open), defaultOpen: open }, anchor && /* @__PURE__ */ React__namespace.createElement(Anchor, null, anchor), children));
91
97
  });
92
98
  Hanger.Anchor = Anchor;
93
99
  Hanger.Content = Content;
@@ -1 +1 @@
1
- {"version":3,"file":"Hanger.cjs","sources":["../../../src/components/Hanger/Hanger.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport { Popover as PopoverPrimitive } from '@base-ui/react/popover';\n\nimport { IconButton } from '../IconButton/IconButton';\nimport { Placement } from '../..';\nimport { UnstyledArrow } from './Arrow';\nimport { useLocalization } from '../Provider/Localization';\nimport { mergeRefs } from '../../utils/mergeRefs';\nimport './Hanger.css';\n\ntype HangerContextValue = {\n /** Handler called when hanger closes by user interaction */\n onClose?: () => void;\n anchorRef: React.RefObject<HTMLElement>;\n};\nconst HangerContext = React.createContext<HangerContextValue>({\n anchorRef: { current: null },\n onClose: undefined,\n});\n\nexport type HangerTexts = {\n /** Aria-label for the close icon button of hanger */\n close: string;\n};\n\nexport type HangerAnchorProps = React.HTMLAttributes<HTMLElement>;\n// Passthrough the surrounding Hanger root owns the single DOM wrapper that serves as the anchor.\n// `Hanger.Anchor` remains in the JSX API for backward compatibility and to signal intent.\nconst Anchor = React.forwardRef<HTMLElement, HangerAnchorProps>(function HangerAnchor(props) {\n return <>{props.children}</>;\n});\n\nexport type HangerTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function DialogTitle(props: HangerTitleProps, ref: React.Ref<HTMLHeadingElement>) {\n const className = cn('mb-1 text-base font-bold flex w-full', props.className);\n return <span {...props} className={className} ref={ref} />;\n});\n\nexport type HangerContentProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Set the position of the Hanger relative to its achor. Default value is `bottom` */\n placement?: Placement;\n hideWhenDetached?: boolean;\n container?: HTMLElement | null;\n};\n\nconst Content = React.forwardRef(function HangerContent(props: HangerContentProps, ref: React.Ref<HTMLDivElement>) {\n const { placement: side, hideWhenDetached = false, container, ...popoverContentProps } = props;\n const context = React.useContext(HangerContext);\n const { texts } = useLocalization();\n const className = cn(\n 'wcag-blue-500 border border-transparent rounded p-3 pr-12 yt-shadow focus:border-transparent max-w-sm print:hidden',\n props.className\n );\n\n return (\n <PopoverPrimitive.Portal container={container}>\n <PopoverPrimitive.Positioner\n anchor={context.anchorRef}\n className={hideWhenDetached ? 'data-[anchor-hidden]:hidden' : undefined}\n side={side}\n sideOffset={11}>\n <PopoverPrimitive.Popup {...popoverContentProps} className={className} data-taco=\"hanger\" ref={ref}>\n {props.children}\n <UnstyledArrow className=\"text-blue-500\" />\n <PopoverPrimitive.Close\n render={\n <IconButton\n appearance=\"primary\"\n aria-label={texts.hanger.close}\n className=\"absolute right-0 top-0 mx-2 mt-2 text-white\"\n icon=\"close\"\n onClick={context.onClose}\n />\n }\n />\n </PopoverPrimitive.Popup>\n </PopoverPrimitive.Positioner>\n </PopoverPrimitive.Portal>\n );\n});\n\nexport type HangerProps = React.PropsWithChildren<{\n /** An anchor to be used for the hanger, should not be set if `children` already contains an anchor */\n anchor?: JSX.Element;\n /**\n * Shows or hides hanger depending on the value\n * @defaultValue true\n */\n defaultOpen?: boolean;\n /** Handler called when user closes the hanger */\n onClose?: () => void;\n}>;\n\nexport type ForwardedHangerWithStatics = React.ForwardRefExoticComponent<HangerProps & React.RefAttributes<HTMLElement>> & {\n Anchor: React.ForwardRefExoticComponent<HangerAnchorProps>;\n Content: React.ForwardRefExoticComponent<HangerContentProps>;\n Title: React.ForwardRefExoticComponent<HangerTitleProps>;\n};\n\nexport const Hanger = React.forwardRef<HTMLSpanElement, HangerProps>(function Hanger(props, ref) {\n const { anchor, children, defaultOpen = true, onClose, ...otherProps } = props;\n const anchorRef = React.useRef<HTMLElement>(null);\n const combinedRef = mergeRefs([anchorRef as React.MutableRefObject<HTMLElement | null>, ref]);\n const context = React.useMemo(() => ({ anchorRef, onClose }), [onClose]);\n\n // we do this to ensure hangers are mounted after their containers, e.g. if the container is another portal\n const [open, setOpen] = React.useState(false);\n React.useEffect(() => {\n if (defaultOpen) {\n setOpen(defaultOpen);\n }\n }, []);\n\n // Hanger should only close from its close button, matching the previous Radix onInteractOutside behavior.\n const handleOpenChange = (nextOpen: boolean, eventDetails: PopoverPrimitive.Root.ChangeEventDetails) => {\n if (!nextOpen && (eventDetails.reason === 'outside-press' || eventDetails.reason === 'focus-out')) {\n eventDetails.cancel();\n return;\n }\n\n setOpen(nextOpen);\n };\n\n // Single inline <span> wrapper: serves as the Floating UI anchor (its rect matches the\n // in-flow trigger child) and contains the FloatingFocusManager guard spans Base UI injects\n // when open, so they aren't siblings of the Hanger in parent IntersectionObservers\n // (e.g. OverflowGroup's) and don't get counted as overflowed children.\n return (\n <HangerContext.Provider value={context}>\n <span {...otherProps} ref={combinedRef as React.Ref<HTMLSpanElement>}>\n <PopoverPrimitive.Root open={open} onOpenChange={handleOpenChange}>\n {/* Anchor via the `anchor` prop. */}\n {anchor}\n {/* Composition (<Hanger.Anchor>) and the popup Content (portaled out) come through {children}. */}\n {children}\n </PopoverPrimitive.Root>\n </span>\n </HangerContext.Provider>\n );\n}) as ForwardedHangerWithStatics;\nHanger.Anchor = Anchor;\nHanger.Content = Content;\nHanger.Title = Title;\n"],"names":["React","useLocalization","PopoverPrimitive","UnstyledArrow","IconButton","Hanger","mergeRefs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAM,gBAAgBA,iBAAM,cAAkC;AAAA,EAC1D,WAAW,EAAE,SAAS,KAAK;AAAA,EAC3B,SAAS;AACb,CA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AM,SAASJ,iBAAM,WAAyC,SAASK,QAAO,OAAO,KAAK;AACvF,QAAA,EAAE,QAAQ,UAAU,cAAc,MAAM,SAAS,GAAG,eAAe;AACnE,QAAA,YAAYL,iBAAM,OAAoB,IAAI;AAChD,QAAM,cAAcM,UAAA,UAAU,CAAC,WAAyD,GAAG,CAAC;AACtF,QAAA,UAAUN,iBAAM,QAAQ,OAAO,EAAE,WAAW,QAAQ,IAAI,CAAC,OAAO,CAAC;AAGvE,QAAM,CAAC,MAAM,OAAO,IAAIA,iBAAM,SAAS,KAAK;AAC5CA,mBAAM,UAAU,MAAM;AAClB,QAAI,aAAa;AACb,cAAQ,WAAW;AAAA,IAAA;AAAA,EAE3B,GAAG,EAAE;AAGC,QAAA,mBAAmB,CAAC,UAAmB,iBAA2D;AACpG,QAAI,CAAC,aAAa,aAAa,WAAW,mBAAmB,aAAa,WAAW,cAAc;AAC/F,mBAAa,OAAO;AACpB;AAAA,IAAA;AAGJ,YAAQ,QAAQ;AAAA,EACpB;AAOI,SAAAA,iCAAA,cAAC,cAAc,UAAd,EAAuB,OAAO,QAC3B,GAAAA,iCAAA,cAAC,QAAM,EAAA,GAAG,YAAY,KAAK,eACtBA,iCAAA,cAAAE,QAAAA,QAAiB,MAAjB,EAAsB,MAAY,cAAc,iBAE5C,GAAA,QAEA,QACL,CACJ,CACJ;AAER,CAAC;AACD,OAAO,SAAS;AAChB,OAAO,UAAU;AACjB,OAAO,QAAQ;;;"}
1
+ {"version":3,"file":"Hanger.cjs","sources":["../../../src/components/Hanger/Hanger.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\n\nimport { IconButton } from '../IconButton/IconButton';\nimport { Placement } from '../..';\nimport { UnstyledArrow } from './Arrow';\nimport { useLocalization } from '../Provider/Localization';\nimport { mergeRefs } from '../../utils/mergeRefs';\nimport './Hanger.css';\n\ntype HangerContextValue = {\n /** Handler called when hanger closes by user interaction */\n onClose?: () => void;\n props: Record<string, any>;\n ref: React.Ref<HTMLElement>;\n};\nconst HangerContext = React.createContext<HangerContextValue>({\n onClose: undefined,\n props: {},\n ref: null,\n});\n\nexport type HangerTexts = {\n /** Aria-label for the close icon button of hanger */\n close: string;\n};\n\nexport type HangerAnchorProps = React.HTMLAttributes<HTMLDivElement>;\nconst Anchor = React.forwardRef(function HangerAnchor(props: HangerAnchorProps, externalRef: React.Ref<HTMLDivElement>) {\n const { ref: parentRef, props: parentProps } = React.useContext(HangerContext);\n const refCallback = mergeRefs([parentRef, externalRef]);\n\n let children = props.children;\n\n if (React.isValidElement(props.children) && typeof props.children?.type === 'function') {\n // oxlint-disable-next-line no-console\n console.warn(\n `Hanger.Anchor requires its child to forwardRef so that it can attach to the dom element. Did you mean to wrap '${props.children.type.name}' in React.forwardRef()? Taco has wrapped '${props.children.type.name}' in a 'span' to maintain functionality, but this may cause unintended behaviour`\n );\n children = <span>{props.children}</span>;\n }\n\n return (\n <PopoverPrimitive.Anchor {...parentProps} {...props} ref={refCallback} asChild>\n {children}\n </PopoverPrimitive.Anchor>\n );\n});\n\nexport type HangerTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function DialogTitle(props: HangerTitleProps, ref: React.Ref<HTMLHeadingElement>) {\n const className = cn('mb-1 text-base font-bold flex w-full', props.className);\n return <span {...props} className={className} ref={ref} />;\n});\n\nexport type HangerContentProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Set the position of the Hanger relative to its achor. Default value is `bottom` */\n placement?: Placement;\n hideWhenDetached?: boolean;\n container?: HTMLElement | null;\n};\n\nconst Content = React.forwardRef(function HangerContent(props: HangerContentProps, ref: React.Ref<HTMLDivElement>) {\n const { placement: side, hideWhenDetached = false, container } = props;\n const context = React.useContext(HangerContext);\n const { texts } = useLocalization();\n const className = cn(\n 'wcag-blue-500 border border-transparent rounded p-3 pr-12 yt-shadow focus:border-transparent max-w-sm print:hidden',\n props.className\n );\n const handleInteractOutside = (event: CustomEvent): void => {\n event.preventDefault();\n };\n\n return (\n <PopoverPrimitive.Portal container={container}>\n <PopoverPrimitive.Content\n className={className}\n data-taco=\"hanger\"\n onInteractOutside={handleInteractOutside}\n side={side}\n sideOffset={1}\n ref={ref}\n hideWhenDetached={hideWhenDetached}>\n {props.children}\n <UnstyledArrow className=\"text-blue-500\" />\n <PopoverPrimitive.Close asChild>\n <IconButton\n appearance=\"primary\"\n aria-label={texts.hanger.close}\n className=\"absolute right-0 top-0 ml-2 mr-2 mt-2 text-white\"\n icon=\"close\"\n onClick={context.onClose}\n />\n </PopoverPrimitive.Close>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n );\n});\n\nexport type HangerProps = React.PropsWithChildren<{\n /** An anchor to be used for the hanger, should not be set if `children` already contains an anchor */\n anchor?: JSX.Element;\n /**\n * Shows or hides hanger depending on the value\n * @defaultValue true\n */\n defaultOpen?: boolean;\n /** Handler called when user closes the hanger */\n onClose?: () => void;\n}>;\n\nexport type ForwardedHangerWithStatics = React.ForwardRefExoticComponent<HangerProps & React.RefAttributes<HTMLElement>> & {\n Anchor: React.ForwardRefExoticComponent<HangerAnchorProps>;\n Content: React.ForwardRefExoticComponent<HangerContentProps>;\n Title: React.ForwardRefExoticComponent<HangerTitleProps>;\n};\n\nexport const Hanger = React.forwardRef<HTMLElement, HangerProps>(function Hanger(props, ref) {\n const { anchor, children, defaultOpen = true, onClose, ...otherProps } = props;\n const context = React.useMemo(() => ({ onClose, props: otherProps, ref }), [onClose, otherProps]);\n\n // we do this to ensure hangers are mounted after their containers, e.g. if the container is another portal\n const [open, setOpen] = React.useState(false);\n React.useEffect(() => {\n if (defaultOpen) {\n setOpen(defaultOpen);\n }\n }, []);\n\n return (\n <HangerContext.Provider value={context}>\n <PopoverPrimitive.Root key={String(open)} defaultOpen={open}>\n {anchor && <Anchor>{anchor}</Anchor>}\n {children}\n </PopoverPrimitive.Root>\n </HangerContext.Provider>\n );\n}) as ForwardedHangerWithStatics;\nHanger.Anchor = Anchor;\nHanger.Content = Content;\nHanger.Title = Title;\n"],"names":["React","mergeRefs","PopoverPrimitive","useLocalization","UnstyledArrow","IconButton","Hanger"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAM,gBAAgBA,iBAAM,cAAkC;AAAA,EAC1D,SAAS;AAAA,EACT,OAAO,CAAC;AAAA,EACR,KAAK;AACT,CAAC;AAQD,MAAM,SAASA,iBAAM,WAAW,SAAS,aAAa,OAA0B,aAAwC;;AAC9G,QAAA,EAAE,KAAK,WAAW,OAAO,gBAAgBA,iBAAM,WAAW,aAAa;AAC7E,QAAM,cAAcC,UAAA,UAAU,CAAC,WAAW,WAAW,CAAC;AAEtD,MAAI,WAAW,MAAM;AAEjB,MAAAD,iBAAM,eAAe,MAAM,QAAQ,KAAK,SAAO,WAAM,aAAN,mBAAgB,UAAS,YAAY;AAE5E,YAAA;AAAA,MACJ,kHAAkH,MAAM,SAAS,KAAK,IAAI,8CAA8C,MAAM,SAAS,KAAK,IAAI;AAAA,IACpN;AACW,eAAAA,iCAAA,cAAC,QAAM,MAAA,MAAM,QAAS;AAAA,EAAA;AAGrC,SACKA,iCAAA,cAAAE,4BAAiB,QAAjB,EAAyB,GAAG,aAAc,GAAG,OAAO,KAAK,aAAa,SAAO,KAAA,GACzE,QACL;AAER,CAAC;AAGM,MAAM,QAAQF,iBAAM,WAAW,SAAS,YAAY,OAAyB,KAAoC;AACpH,QAAM,YAAY,GAAG,wCAAwC,MAAM,SAAS;AAC5E,SAAQA,iCAAA,cAAA,QAAA,EAAM,GAAG,OAAO,WAAsB,KAAU;AAC5D,CAAC;AASD,MAAM,UAAUA,iBAAM,WAAW,SAAS,cAAc,OAA2B,KAAgC;AAC/G,QAAM,EAAE,WAAW,MAAM,mBAAmB,OAAO,cAAc;AAC3D,QAAA,UAAUA,iBAAM,WAAW,aAAa;AACxC,QAAA,EAAE,MAAM,IAAIG,6BAAgB;AAClC,QAAM,YAAY;AAAA,IACd;AAA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;AACD,OAAO,SAAS;AAChB,OAAO,UAAU;AACjB,OAAO,QAAQ;;;"}
@@ -4,7 +4,7 @@ export type HangerTexts = {
4
4
  /** Aria-label for the close icon button of hanger */
5
5
  close: string;
6
6
  };
7
- export type HangerAnchorProps = React.HTMLAttributes<HTMLElement>;
7
+ export type HangerAnchorProps = React.HTMLAttributes<HTMLDivElement>;
8
8
  export type HangerTitleProps = React.HTMLAttributes<HTMLHeadingElement>;
9
9
  export declare const Title: React.ForwardRefExoticComponent<HangerTitleProps & React.RefAttributes<HTMLHeadingElement>>;
10
10
  export type HangerContentProps = React.HTMLAttributes<HTMLDivElement> & {
@@ -1,74 +1,79 @@
1
1
  import * as React from "react";
2
2
  import cn from "clsx";
3
- import { Popover } from "@base-ui/react/popover";
3
+ import * as PopoverPrimitive from "@radix-ui/react-popover";
4
4
  import { IconButton } from "../IconButton/IconButton.js";
5
5
  import { UnstyledArrow } from "./Arrow.js";
6
6
  import { useLocalization } from "../Provider/Localization.js";
7
7
  import { mergeRefs } from "../../utils/mergeRefs.js";
8
8
  /* empty css */
9
9
  const HangerContext = React.createContext({
10
- anchorRef: { current: null },
11
- onClose: void 0
10
+ onClose: void 0,
11
+ props: {},
12
+ ref: null
12
13
  });
13
- const Anchor = React.forwardRef(function HangerAnchor(props) {
14
- return /* @__PURE__ */ React.createElement(React.Fragment, null, props.children);
14
+ const Anchor = React.forwardRef(function HangerAnchor(props, externalRef) {
15
+ var _a;
16
+ const { ref: parentRef, props: parentProps } = React.useContext(HangerContext);
17
+ const refCallback = mergeRefs([parentRef, externalRef]);
18
+ let children = props.children;
19
+ if (React.isValidElement(props.children) && typeof ((_a = props.children) == null ? void 0 : _a.type) === "function") {
20
+ console.warn(
21
+ `Hanger.Anchor requires its child to forwardRef so that it can attach to the dom element. Did you mean to wrap '${props.children.type.name}' in React.forwardRef()? Taco has wrapped '${props.children.type.name}' in a 'span' to maintain functionality, but this may cause unintended behaviour`
22
+ );
23
+ children = /* @__PURE__ */ React.createElement("span", null, props.children);
24
+ }
25
+ return /* @__PURE__ */ React.createElement(PopoverPrimitive.Anchor, { ...parentProps, ...props, ref: refCallback, asChild: true }, children);
15
26
  });
16
27
  const Title = React.forwardRef(function DialogTitle(props, ref) {
17
28
  const className = cn("mb-1 text-base font-bold flex w-full", props.className);
18
29
  return /* @__PURE__ */ React.createElement("span", { ...props, className, ref });
19
30
  });
20
31
  const Content = React.forwardRef(function HangerContent(props, ref) {
21
- const { placement: side, hideWhenDetached = false, container, ...popoverContentProps } = props;
32
+ const { placement: side, hideWhenDetached = false, container } = props;
22
33
  const context = React.useContext(HangerContext);
23
34
  const { texts } = useLocalization();
24
35
  const className = cn(
25
36
  "wcag-blue-500 border border-transparent rounded p-3 pr-12 yt-shadow focus:border-transparent max-w-sm print:hidden",
26
37
  props.className
27
38
  );
28
- return /* @__PURE__ */ React.createElement(Popover.Portal, { container }, /* @__PURE__ */ React.createElement(
29
- Popover.Positioner,
39
+ const handleInteractOutside = (event) => {
40
+ event.preventDefault();
41
+ };
42
+ return /* @__PURE__ */ React.createElement(PopoverPrimitive.Portal, { container }, /* @__PURE__ */ React.createElement(
43
+ PopoverPrimitive.Content,
30
44
  {
31
- anchor: context.anchorRef,
32
- className: hideWhenDetached ? "data-[anchor-hidden]:hidden" : void 0,
45
+ className,
46
+ "data-taco": "hanger",
47
+ onInteractOutside: handleInteractOutside,
33
48
  side,
34
- sideOffset: 11
49
+ sideOffset: 1,
50
+ ref,
51
+ hideWhenDetached
35
52
  },
36
- /* @__PURE__ */ React.createElement(Popover.Popup, { ...popoverContentProps, className, "data-taco": "hanger", ref }, props.children, /* @__PURE__ */ React.createElement(UnstyledArrow, { className: "text-blue-500" }), /* @__PURE__ */ React.createElement(
37
- Popover.Close,
53
+ props.children,
54
+ /* @__PURE__ */ React.createElement(UnstyledArrow, { className: "text-blue-500" }),
55
+ /* @__PURE__ */ React.createElement(PopoverPrimitive.Close, { asChild: true }, /* @__PURE__ */ React.createElement(
56
+ IconButton,
38
57
  {
39
- render: /* @__PURE__ */ React.createElement(
40
- IconButton,
41
- {
42
- appearance: "primary",
43
- "aria-label": texts.hanger.close,
44
- className: "absolute right-0 top-0 mx-2 mt-2 text-white",
45
- icon: "close",
46
- onClick: context.onClose
47
- }
48
- )
58
+ appearance: "primary",
59
+ "aria-label": texts.hanger.close,
60
+ className: "absolute right-0 top-0 ml-2 mr-2 mt-2 text-white",
61
+ icon: "close",
62
+ onClick: context.onClose
49
63
  }
50
64
  ))
51
65
  ));
52
66
  });
53
67
  const Hanger = React.forwardRef(function Hanger2(props, ref) {
54
68
  const { anchor, children, defaultOpen = true, onClose, ...otherProps } = props;
55
- const anchorRef = React.useRef(null);
56
- const combinedRef = mergeRefs([anchorRef, ref]);
57
- const context = React.useMemo(() => ({ anchorRef, onClose }), [onClose]);
69
+ const context = React.useMemo(() => ({ onClose, props: otherProps, ref }), [onClose, otherProps]);
58
70
  const [open, setOpen] = React.useState(false);
59
71
  React.useEffect(() => {
60
72
  if (defaultOpen) {
61
73
  setOpen(defaultOpen);
62
74
  }
63
75
  }, []);
64
- const handleOpenChange = (nextOpen, eventDetails) => {
65
- if (!nextOpen && (eventDetails.reason === "outside-press" || eventDetails.reason === "focus-out")) {
66
- eventDetails.cancel();
67
- return;
68
- }
69
- setOpen(nextOpen);
70
- };
71
- return /* @__PURE__ */ React.createElement(HangerContext.Provider, { value: context }, /* @__PURE__ */ React.createElement("span", { ...otherProps, ref: combinedRef }, /* @__PURE__ */ React.createElement(Popover.Root, { open, onOpenChange: handleOpenChange }, anchor, children)));
76
+ return /* @__PURE__ */ React.createElement(HangerContext.Provider, { value: context }, /* @__PURE__ */ React.createElement(PopoverPrimitive.Root, { key: String(open), defaultOpen: open }, anchor && /* @__PURE__ */ React.createElement(Anchor, null, anchor), children));
72
77
  });
73
78
  Hanger.Anchor = Anchor;
74
79
  Hanger.Content = Content;
@@ -1 +1 @@
1
- {"version":3,"file":"Hanger.js","sources":["../../../src/components/Hanger/Hanger.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport { Popover as PopoverPrimitive } from '@base-ui/react/popover';\n\nimport { IconButton } from '../IconButton/IconButton';\nimport { Placement } from '../..';\nimport { UnstyledArrow } from './Arrow';\nimport { useLocalization } from '../Provider/Localization';\nimport { mergeRefs } from '../../utils/mergeRefs';\nimport './Hanger.css';\n\ntype HangerContextValue = {\n /** Handler called when hanger closes by user interaction */\n onClose?: () => void;\n anchorRef: React.RefObject<HTMLElement>;\n};\nconst HangerContext = React.createContext<HangerContextValue>({\n anchorRef: { current: null },\n onClose: undefined,\n});\n\nexport type HangerTexts = {\n /** Aria-label for the close icon button of hanger */\n close: string;\n};\n\nexport type HangerAnchorProps = React.HTMLAttributes<HTMLElement>;\n// Passthrough the surrounding Hanger root owns the single DOM wrapper that serves as the anchor.\n// `Hanger.Anchor` remains in the JSX API for backward compatibility and to signal intent.\nconst Anchor = React.forwardRef<HTMLElement, HangerAnchorProps>(function HangerAnchor(props) {\n return <>{props.children}</>;\n});\n\nexport type HangerTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function DialogTitle(props: HangerTitleProps, ref: React.Ref<HTMLHeadingElement>) {\n const className = cn('mb-1 text-base font-bold flex w-full', props.className);\n return <span {...props} className={className} ref={ref} />;\n});\n\nexport type HangerContentProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Set the position of the Hanger relative to its achor. Default value is `bottom` */\n placement?: Placement;\n hideWhenDetached?: boolean;\n container?: HTMLElement | null;\n};\n\nconst Content = React.forwardRef(function HangerContent(props: HangerContentProps, ref: React.Ref<HTMLDivElement>) {\n const { placement: side, hideWhenDetached = false, container, ...popoverContentProps } = props;\n const context = React.useContext(HangerContext);\n const { texts } = useLocalization();\n const className = cn(\n 'wcag-blue-500 border border-transparent rounded p-3 pr-12 yt-shadow focus:border-transparent max-w-sm print:hidden',\n props.className\n );\n\n return (\n <PopoverPrimitive.Portal container={container}>\n <PopoverPrimitive.Positioner\n anchor={context.anchorRef}\n className={hideWhenDetached ? 'data-[anchor-hidden]:hidden' : undefined}\n side={side}\n sideOffset={11}>\n <PopoverPrimitive.Popup {...popoverContentProps} className={className} data-taco=\"hanger\" ref={ref}>\n {props.children}\n <UnstyledArrow className=\"text-blue-500\" />\n <PopoverPrimitive.Close\n render={\n <IconButton\n appearance=\"primary\"\n aria-label={texts.hanger.close}\n className=\"absolute right-0 top-0 mx-2 mt-2 text-white\"\n icon=\"close\"\n onClick={context.onClose}\n />\n }\n />\n </PopoverPrimitive.Popup>\n </PopoverPrimitive.Positioner>\n </PopoverPrimitive.Portal>\n );\n});\n\nexport type HangerProps = React.PropsWithChildren<{\n /** An anchor to be used for the hanger, should not be set if `children` already contains an anchor */\n anchor?: JSX.Element;\n /**\n * Shows or hides hanger depending on the value\n * @defaultValue true\n */\n defaultOpen?: boolean;\n /** Handler called when user closes the hanger */\n onClose?: () => void;\n}>;\n\nexport type ForwardedHangerWithStatics = React.ForwardRefExoticComponent<HangerProps & React.RefAttributes<HTMLElement>> & {\n Anchor: React.ForwardRefExoticComponent<HangerAnchorProps>;\n Content: React.ForwardRefExoticComponent<HangerContentProps>;\n Title: React.ForwardRefExoticComponent<HangerTitleProps>;\n};\n\nexport const Hanger = React.forwardRef<HTMLSpanElement, HangerProps>(function Hanger(props, ref) {\n const { anchor, children, defaultOpen = true, onClose, ...otherProps } = props;\n const anchorRef = React.useRef<HTMLElement>(null);\n const combinedRef = mergeRefs([anchorRef as React.MutableRefObject<HTMLElement | null>, ref]);\n const context = React.useMemo(() => ({ anchorRef, onClose }), [onClose]);\n\n // we do this to ensure hangers are mounted after their containers, e.g. if the container is another portal\n const [open, setOpen] = React.useState(false);\n React.useEffect(() => {\n if (defaultOpen) {\n setOpen(defaultOpen);\n }\n }, []);\n\n // Hanger should only close from its close button, matching the previous Radix onInteractOutside behavior.\n const handleOpenChange = (nextOpen: boolean, eventDetails: PopoverPrimitive.Root.ChangeEventDetails) => {\n if (!nextOpen && (eventDetails.reason === 'outside-press' || eventDetails.reason === 'focus-out')) {\n eventDetails.cancel();\n return;\n }\n\n setOpen(nextOpen);\n };\n\n // Single inline <span> wrapper: serves as the Floating UI anchor (its rect matches the\n // in-flow trigger child) and contains the FloatingFocusManager guard spans Base UI injects\n // when open, so they aren't siblings of the Hanger in parent IntersectionObservers\n // (e.g. OverflowGroup's) and don't get counted as overflowed children.\n return (\n <HangerContext.Provider value={context}>\n <span {...otherProps} ref={combinedRef as React.Ref<HTMLSpanElement>}>\n <PopoverPrimitive.Root open={open} onOpenChange={handleOpenChange}>\n {/* Anchor via the `anchor` prop. */}\n {anchor}\n {/* Composition (<Hanger.Anchor>) and the popup Content (portaled out) come through {children}. */}\n {children}\n </PopoverPrimitive.Root>\n </span>\n </HangerContext.Provider>\n );\n}) as ForwardedHangerWithStatics;\nHanger.Anchor = Anchor;\nHanger.Content = Content;\nHanger.Title = Title;\n"],"names":["PopoverPrimitive","Hanger"],"mappings":";;;;;;;;AAgBA,MAAM,gBAAgB,MAAM,cAAkC;AAAA,EAC1D,WAAW,EAAE,SAAS,KAAK;AAAA,EAC3B,SAAS;AACb,CAAC;AAUD,MAAM,SAAS,MAAM,WAA2C,SAAS,aAAa,OAAO;AAClF,SAAA,sBAAA,cAAA,MAAA,UAAA,MAAG,MAAM,QAAS;AAC7B,CAAC;AAGM,MAAM,QAAQ,MAAM,WAAW,SAAS,YAAY,OAAyB,KAAoC;AACpH,QAAM,YAAY,GAAG,wCAAwC,MAAM,SAAS;AAC5E,SAAQ,sBAAA,cAAA,QAAA,EAAM,GAAG,OAAO,WAAsB,KAAU;AAC5D,CAAC;AASD,MAAM,UAAU,MAAM,WAAW,SAAS,cAAc,OAA2B,KAAgC;AACzG,QAAA,EAAE,WAAW,MAAM,mBAAmB,OAAO,WAAW,GAAG,wBAAwB;AACnF,QAAA,UAAU,MAAM,WAAW,aAAa;AACxC,QAAA,EAAE,MAAM,IAAI,gBAAgB;AAClC,QAAM,YAAY;AAAA,IACd;AAAA,IACA,MA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AAA,EACpB;AAOI,SAAA,sBAAA,cAAC,cAAc,UAAd,EAAuB,OAAO,QAC3B,GAAA,sBAAA,cAAC,QAAM,EAAA,GAAG,YAAY,KAAK,eACtB,sBAAA,cAAAD,QAAiB,MAAjB,EAAsB,MAAY,cAAc,iBAE5C,GAAA,QAEA,QACL,CACJ,CACJ;AAER,CAAC;AACD,OAAO,SAAS;AAChB,OAAO,UAAU;AACjB,OAAO,QAAQ;"}
1
+ {"version":3,"file":"Hanger.js","sources":["../../../src/components/Hanger/Hanger.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\n\nimport { IconButton } from '../IconButton/IconButton';\nimport { Placement } from '../..';\nimport { UnstyledArrow } from './Arrow';\nimport { useLocalization } from '../Provider/Localization';\nimport { mergeRefs } from '../../utils/mergeRefs';\nimport './Hanger.css';\n\ntype HangerContextValue = {\n /** Handler called when hanger closes by user interaction */\n onClose?: () => void;\n props: Record<string, any>;\n ref: React.Ref<HTMLElement>;\n};\nconst HangerContext = React.createContext<HangerContextValue>({\n onClose: undefined,\n props: {},\n ref: null,\n});\n\nexport type HangerTexts = {\n /** Aria-label for the close icon button of hanger */\n close: string;\n};\n\nexport type HangerAnchorProps = React.HTMLAttributes<HTMLDivElement>;\nconst Anchor = React.forwardRef(function HangerAnchor(props: HangerAnchorProps, externalRef: React.Ref<HTMLDivElement>) {\n const { ref: parentRef, props: parentProps } = React.useContext(HangerContext);\n const refCallback = mergeRefs([parentRef, externalRef]);\n\n let children = props.children;\n\n if (React.isValidElement(props.children) && typeof props.children?.type === 'function') {\n // oxlint-disable-next-line no-console\n console.warn(\n `Hanger.Anchor requires its child to forwardRef so that it can attach to the dom element. Did you mean to wrap '${props.children.type.name}' in React.forwardRef()? Taco has wrapped '${props.children.type.name}' in a 'span' to maintain functionality, but this may cause unintended behaviour`\n );\n children = <span>{props.children}</span>;\n }\n\n return (\n <PopoverPrimitive.Anchor {...parentProps} {...props} ref={refCallback} asChild>\n {children}\n </PopoverPrimitive.Anchor>\n );\n});\n\nexport type HangerTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function DialogTitle(props: HangerTitleProps, ref: React.Ref<HTMLHeadingElement>) {\n const className = cn('mb-1 text-base font-bold flex w-full', props.className);\n return <span {...props} className={className} ref={ref} />;\n});\n\nexport type HangerContentProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Set the position of the Hanger relative to its achor. Default value is `bottom` */\n placement?: Placement;\n hideWhenDetached?: boolean;\n container?: HTMLElement | null;\n};\n\nconst Content = React.forwardRef(function HangerContent(props: HangerContentProps, ref: React.Ref<HTMLDivElement>) {\n const { placement: side, hideWhenDetached = false, container } = props;\n const context = React.useContext(HangerContext);\n const { texts } = useLocalization();\n const className = cn(\n 'wcag-blue-500 border border-transparent rounded p-3 pr-12 yt-shadow focus:border-transparent max-w-sm print:hidden',\n props.className\n );\n const handleInteractOutside = (event: CustomEvent): void => {\n event.preventDefault();\n };\n\n return (\n <PopoverPrimitive.Portal container={container}>\n <PopoverPrimitive.Content\n className={className}\n data-taco=\"hanger\"\n onInteractOutside={handleInteractOutside}\n side={side}\n sideOffset={1}\n ref={ref}\n hideWhenDetached={hideWhenDetached}>\n {props.children}\n <UnstyledArrow className=\"text-blue-500\" />\n <PopoverPrimitive.Close asChild>\n <IconButton\n appearance=\"primary\"\n aria-label={texts.hanger.close}\n className=\"absolute right-0 top-0 ml-2 mr-2 mt-2 text-white\"\n icon=\"close\"\n onClick={context.onClose}\n />\n </PopoverPrimitive.Close>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n );\n});\n\nexport type HangerProps = React.PropsWithChildren<{\n /** An anchor to be used for the hanger, should not be set if `children` already contains an anchor */\n anchor?: JSX.Element;\n /**\n * Shows or hides hanger depending on the value\n * @defaultValue true\n */\n defaultOpen?: boolean;\n /** Handler called when user closes the hanger */\n onClose?: () => void;\n}>;\n\nexport type ForwardedHangerWithStatics = React.ForwardRefExoticComponent<HangerProps & React.RefAttributes<HTMLElement>> & {\n Anchor: React.ForwardRefExoticComponent<HangerAnchorProps>;\n Content: React.ForwardRefExoticComponent<HangerContentProps>;\n Title: React.ForwardRefExoticComponent<HangerTitleProps>;\n};\n\nexport const Hanger = React.forwardRef<HTMLElement, HangerProps>(function Hanger(props, ref) {\n const { anchor, children, defaultOpen = true, onClose, ...otherProps } = props;\n const context = React.useMemo(() => ({ onClose, props: otherProps, ref }), [onClose, otherProps]);\n\n // we do this to ensure hangers are mounted after their containers, e.g. if the container is another portal\n const [open, setOpen] = React.useState(false);\n React.useEffect(() => {\n if (defaultOpen) {\n setOpen(defaultOpen);\n }\n }, []);\n\n return (\n <HangerContext.Provider value={context}>\n <PopoverPrimitive.Root key={String(open)} defaultOpen={open}>\n {anchor && <Anchor>{anchor}</Anchor>}\n {children}\n </PopoverPrimitive.Root>\n </HangerContext.Provider>\n );\n}) as ForwardedHangerWithStatics;\nHanger.Anchor = Anchor;\nHanger.Content = Content;\nHanger.Title = Title;\n"],"names":["Hanger"],"mappings":";;;;;;;;AAiBA,MAAM,gBAAgB,MAAM,cAAkC;AAAA,EAC1D,SAAS;AAAA,EACT,OAAO,CAAC;AAAA,EACR,KAAK;AACT,CAAC;AAQD,MAAM,SAAS,MAAM,WAAW,SAAS,aAAa,OAA0B,aAAwC;;AAC9G,QAAA,EAAE,KAAK,WAAW,OAAO,gBAAgB,MAAM,WAAW,aAAa;AAC7E,QAAM,cAAc,UAAU,CAAC,WAAW,WAAW,CAAC;AAEtD,MAAI,WAAW,MAAM;AAEjB,MAAA,MAAM,eAAe,MAAM,QAAQ,KAAK,SAAO,WAAM,aAAN,mBAAgB,UAAS,YAAY;AAE5E,YAAA;AAAA,MACJ,kHAAkH,MAAM,SAAS,KAAK,IAAI,8CAA8C,MAAM,SAAS,KAAK,IAAI;AAAA,IACpN;AACW,eAAA,sBAAA,cAAC,QAAM,MAAA,MAAM,QAAS;AAAA,EAAA;AAGrC,SAC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AAM,SAAS,GAAG,eAAe;AACzE,QAAM,UAAU,MAAM,QAAQ,OAAO,EAAE,SAAS,OAAO,YAAY,IAAI,IAAI,CAAC,SAAS,UAAU,CAAC;AAGhG,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,KAAK;AAC5C,QAAM,UAAU,MAAM;AAClB,QAAI,aAAa;AACb,cAAQ,WAAW;AAAA,IAAA;AAAA,EAE3B,GAAG,EAAE;AAGD,SAAA,sBAAA,cAAC,cAAc,UAAd,EAAuB,OAAO,QAC3B,GAAA,sBAAA,cAAC,iBAAiB,MAAjB,EAAsB,KAAK,OAAO,IAAI,GAAG,aAAa,KAClD,GAAA,8CAAW,QAAQ,MAAA,MAAO,GAC1B,QACL,CACJ;AAER,CAAC;AACD,OAAO,SAAS;AAChB,OAAO,UAAU;AACjB,OAAO,QAAQ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useSelect.cjs","sources":["../../../src/components/Select/useSelect.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport { nanoid } from 'nanoid';\nimport { Popover as PopoverPrimitive } from '@base-ui/react/popover';\nimport { useLocalization } from '../Provider/Localization';\nimport { SelectProps } from './Select';\nimport { ListboxProps } from '../Listbox/Listbox';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { setInputValueByRef, findByValue, useFlattenedData, sanitizeItem } from '../Listbox/util';\nimport { ScrollableListItemValue } from '../Listbox/ScrollableList';\nimport { createCustomEvent } from '../../utils/input';\n\ntype InternalButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement>;\ntype InternalListboxProps = ListboxProps & { ref: React.ForwardedRef<HTMLInputElement> };\ntype InternalInputProps = React.InputHTMLAttributes<HTMLInputElement> & { ref: React.ForwardedRef<HTMLInputElement> };\n\ntype useSelect = React.HtmlHTMLAttributes<HTMLDivElement> & {\n button: InternalButtonProps;\n listbox: InternalListboxProps;\n input: InternalInputProps;\n popover: Pick<PopoverPrimitive.Root.Props, 'onOpenChange' | 'open'>;\n text: string | JSX.Element;\n more?: number;\n};\n\nexport const useSelect = (\n {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data = [],\n defaultValue,\n disabled,\n emptyValue,\n id: nativeId,\n multiselect,\n onBlur,\n onClick: _1,\n onChange,\n readOnly,\n tabIndex,\n value,\n ...otherProps\n }: SelectProps,\n ref: React.Ref<HTMLInputElement>\n): useSelect => {\n const { texts } = useLocalization();\n const flattenedData = useFlattenedData(data);\n const listboxInputRef = useMergedRef<HTMLInputElement>(ref);\n const [open, setOpen] = React.useState(false);\n const id = React.useMemo(() => nativeId || `select_${nanoid()}`, [nativeId]);\n const inputRef = React.useRef<HTMLInputElement>(null);\n const buttonId = `${id}-button`;\n // support 'escape' resetting to the value that was set when the listbox opened\n const [lastValue, setLastValue] = React.useState<ScrollableListItemValue | undefined>(value);\n\n React.useEffect(() => {\n setLastValue(value);\n }, [open]);\n\n React.useEffect(() => {\n if (value === undefined) {\n if (defaultValue !== undefined && findByValue(flattenedData, defaultValue)) {\n setInputValueByRef(inputRef.current, defaultValue);\n } else if (emptyValue !== undefined) {\n setInputValueByRef(inputRef.current, emptyValue);\n } else if (data.length > 0) {\n setInputValueByRef(inputRef.current, data[0]?.value);\n }\n } else if (!multiselect && !findByValue(flattenedData, value)) {\n if (emptyValue !== undefined) {\n setInputValueByRef(inputRef.current, emptyValue);\n } else if (data.length > 0) {\n setInputValueByRef(inputRef.current, data[0]?.value);\n }\n }\n }, []);\n\n // event handlers\n const handleButtonKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>): void => {\n if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {\n event.preventDefault();\n setOpen(true);\n }\n };\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>): void => {\n switch (event.key) {\n case 'Escape': {\n event.preventDefault();\n if (lastValue !== undefined) {\n setInputValueByRef(listboxInputRef.current, lastValue);\n }\n\n setOpen(false);\n break;\n }\n\n case 'Tab':\n case 'Enter': {\n if (event.key !== 'Tab') {\n event.preventDefault();\n }\n setOpen(false);\n break;\n }\n\n default:\n }\n\n if (otherProps.onKeyDown) {\n otherProps.onKeyDown(event);\n }\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>): void => {\n event.preventDefault();\n if (!multiselect) {\n setOpen(false);\n if (onBlur) {\n onBlur(createCustomEvent('blur') as unknown as React.FocusEvent<HTMLElement, Element>);\n }\n }\n };\n\n let text: string | JSX.Element = '';\n let more = 0;\n\n if (value !== undefined) {\n if (multiselect) {\n const selectedValues = value?.toString().split(',') || [];\n\n if (selectedValues.length === flattenedData.filter(item => !item.disabled).length) {\n text = texts.select.allOptionsSelected;\n } else {\n text = findByValue(flattenedData, selectedValues[0])?.text ?? '';\n more = selectedValues.length > 1 ? selectedValues.length - 1 : 0;\n }\n } else {\n const item = findByValue(flattenedData, value);\n\n if (item) {\n text = item.icon ? (\n <>\n {React.cloneElement(item.icon, {\n className: cn(item.icon.props.className, 'mr-1 -mt-px'),\n })}\n {item.text}\n </>\n ) : (\n item.text\n );\n }\n }\n }\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (onChange) {\n const item = findByValue(flattenedData, event.target.value);\n (event as any).detail = sanitizeItem(item);\n\n const indexes = item?.path?.split('.') ?? [];\n\n if (indexes.length > 1) {\n // we don't want to map the current item\n indexes.pop();\n // we need to rebuild the path as we map\n let lastPath: string;\n\n (event as any).detail.parents = indexes.map(i => {\n lastPath = lastPath ? [lastPath, i].join('.') : i;\n return sanitizeItem(flattenedData.find(i => i.path === lastPath));\n });\n }\n\n onChange(event);\n }\n };\n\n const handleButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (readOnly) {\n event.preventDefault();\n }\n };\n\n // select the value text if the select is readonly\n const handleButtonFocus = (event: React.FocusEvent<HTMLButtonElement>) => {\n if (readOnly) {\n const value = event.currentTarget.querySelector(':first-child');\n\n if (value) {\n window.getSelection()?.selectAllChildren?.(value);\n }\n }\n };\n\n const button: InternalButtonProps = {\n 'aria-haspopup': 'listbox' as const,\n 'aria-label': ariaLabel ? `${ariaLabel} ${text}` : undefined,\n 'aria-labelledby': ariaLabelledBy ? `${ariaLabelledBy} ${buttonId}` : undefined,\n 'aria-readonly': readOnly ? 'true' : undefined,\n disabled: disabled,\n id: buttonId,\n onClick: handleButtonClick,\n onFocus: handleButtonFocus,\n onKeyDown: !disabled && !readOnly ? handleButtonKeyDown : undefined,\n tabIndex,\n type: 'button',\n };\n\n const listbox: InternalListboxProps = {\n ...otherProps,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data,\n disabled,\n emptyValue,\n onBlur,\n onClick: handleListboxClick,\n onChange: event => {\n setInputValueByRef(inputRef.current, event.target.value);\n },\n onKeyDown: handleListboxKeyDown,\n ref: listboxInputRef,\n value,\n };\n\n const input: InternalInputProps = {\n onChange: handleInputChange,\n ref: inputRef,\n value: String(value ?? ''),\n };\n\n return {\n button,\n listbox,\n input,\n popover: {\n open,\n onOpenChange: setOpen,\n },\n text,\n more,\n };\n};\n"],"names":["useLocalization","useFlattenedData","useMergedRef","React","nanoid","findByValue","setInputValueByRef","_a","createCustomEvent","sanitizeItem","i","value","input"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,MAAM,YAAY,CACrB;AAAA,EACI,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,OAAO,CAAC;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,IAAI;AAAA,EACJ;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACP,GACA,QACY;;AACN,QAAA,EAAE,MAAM,IAAIA,6BAAgB;AAC5B,QAAA,gBAAgBC,sBAAiB,IAAI;AACrC,QAAA,kBAAkBC,0BAA+B,GAAG;AAC1D,QAAM,CAAC,MAAM,OAAO,IAAIC,iBAAM,SAAS,KAAK;AACtC,QAAA,KA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,IACA,SAAS;AAAA,IACT,UAAU,CAAS,UAAA;AACfL,WAAAA,mBAAmB,SAAS,SAAS,MAAM,OAAO,KAAK;AAAA,IAC3D;AAAA,IACA,WAAW;AAAA,IACX,KAAK;AAAA,IACL;AAAA,EACJ;AAEA,QAAMM,UAA4B;AAAA,IAC9B,UAAU;AAAA,IACV,KAAK;AAAA,IACL,OAAO,OAAO,SAAS,EAAE;AAAA,EAC7B;AAEO,SAAA;AAAA,IACH;AAAA,IACA;AAAA,IAAA,OACAA;AAAAA,IACA,SAAS;AAAA,MACL;AAAA,MACA,cAAc;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AACJ;;"}
1
+ {"version":3,"file":"useSelect.cjs","sources":["../../../src/components/Select/useSelect.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport { nanoid } from 'nanoid';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { useLocalization } from '../Provider/Localization';\nimport { SelectProps } from './Select';\nimport { ListboxProps } from '../Listbox/Listbox';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { setInputValueByRef, findByValue, useFlattenedData, sanitizeItem } from '../Listbox/util';\nimport { ScrollableListItemValue } from '../Listbox/ScrollableList';\nimport { createCustomEvent } from '../../utils/input';\n\ntype InternalButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement>;\ntype InternalListboxProps = ListboxProps & { ref: React.ForwardedRef<HTMLInputElement> };\ntype InternalInputProps = React.InputHTMLAttributes<HTMLInputElement> & { ref: React.ForwardedRef<HTMLInputElement> };\n\ntype useSelect = React.HtmlHTMLAttributes<HTMLDivElement> & {\n button: InternalButtonProps;\n listbox: InternalListboxProps;\n input: InternalInputProps;\n popover: Pick<PopoverPrimitive.PopoverProps, 'onOpenChange' | 'open'>;\n text: string | JSX.Element;\n more?: number;\n};\n\nexport const useSelect = (\n {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data = [],\n defaultValue,\n disabled,\n emptyValue,\n id: nativeId,\n multiselect,\n onBlur,\n onClick: _1,\n onChange,\n readOnly,\n tabIndex,\n value,\n ...otherProps\n }: SelectProps,\n ref: React.Ref<HTMLInputElement>\n): useSelect => {\n const { texts } = useLocalization();\n const flattenedData = useFlattenedData(data);\n const listboxInputRef = useMergedRef<HTMLInputElement>(ref);\n const [open, setOpen] = React.useState(false);\n const id = React.useMemo(() => nativeId || `select_${nanoid()}`, [nativeId]);\n const inputRef = React.useRef<HTMLInputElement>(null);\n const buttonId = `${id}-button`;\n // support 'escape' resetting to the value that was set when the listbox opened\n const [lastValue, setLastValue] = React.useState<ScrollableListItemValue | undefined>(value);\n\n React.useEffect(() => {\n setLastValue(value);\n }, [open]);\n\n React.useEffect(() => {\n if (value === undefined) {\n if (defaultValue !== undefined && findByValue(flattenedData, defaultValue)) {\n setInputValueByRef(inputRef.current, defaultValue);\n } else if (emptyValue !== undefined) {\n setInputValueByRef(inputRef.current, emptyValue);\n } else if (data.length > 0) {\n setInputValueByRef(inputRef.current, data[0]?.value);\n }\n } else if (!multiselect && !findByValue(flattenedData, value)) {\n if (emptyValue !== undefined) {\n setInputValueByRef(inputRef.current, emptyValue);\n } else if (data.length > 0) {\n setInputValueByRef(inputRef.current, data[0]?.value);\n }\n }\n }, []);\n\n // event handlers\n const handleButtonKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>): void => {\n if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {\n event.preventDefault();\n setOpen(true);\n }\n };\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>): void => {\n switch (event.key) {\n case 'Escape': {\n event.preventDefault();\n if (lastValue !== undefined) {\n setInputValueByRef(listboxInputRef.current, lastValue);\n }\n\n setOpen(false);\n break;\n }\n\n case 'Tab':\n case 'Enter': {\n if (event.key !== 'Tab') {\n event.preventDefault();\n }\n setOpen(false);\n break;\n }\n\n default:\n }\n\n if (otherProps.onKeyDown) {\n otherProps.onKeyDown(event);\n }\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>): void => {\n event.preventDefault();\n if (!multiselect) {\n setOpen(false);\n if (onBlur) {\n onBlur(createCustomEvent('blur') as unknown as React.FocusEvent<HTMLElement, Element>);\n }\n }\n };\n\n let text: string | JSX.Element = '';\n let more = 0;\n\n if (value !== undefined) {\n if (multiselect) {\n const selectedValues = value?.toString().split(',') || [];\n\n if (selectedValues.length === flattenedData.filter(item => !item.disabled).length) {\n text = texts.select.allOptionsSelected;\n } else {\n text = findByValue(flattenedData, selectedValues[0])?.text ?? '';\n more = selectedValues.length > 1 ? selectedValues.length - 1 : 0;\n }\n } else {\n const item = findByValue(flattenedData, value);\n\n if (item) {\n text = item.icon ? (\n <>\n {React.cloneElement(item.icon, {\n className: cn(item.icon.props.className, 'mr-1 -mt-px'),\n })}\n {item.text}\n </>\n ) : (\n item.text\n );\n }\n }\n }\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (onChange) {\n const item = findByValue(flattenedData, event.target.value);\n (event as any).detail = sanitizeItem(item);\n\n const indexes = item?.path?.split('.') ?? [];\n\n if (indexes.length > 1) {\n // we don't want to map the current item\n indexes.pop();\n // we need to rebuild the path as we map\n let lastPath: string;\n\n (event as any).detail.parents = indexes.map(i => {\n lastPath = lastPath ? [lastPath, i].join('.') : i;\n return sanitizeItem(flattenedData.find(i => i.path === lastPath));\n });\n }\n\n onChange(event);\n }\n };\n\n const handleButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (readOnly) {\n event.preventDefault();\n }\n };\n\n // select the value text if the select is readonly\n const handleButtonFocus = (event: React.FocusEvent<HTMLButtonElement>) => {\n if (readOnly) {\n const value = event.currentTarget.querySelector(':first-child');\n\n if (value) {\n window.getSelection()?.selectAllChildren?.(value);\n }\n }\n };\n\n const button: InternalButtonProps = {\n 'aria-haspopup': 'listbox' as const,\n 'aria-label': ariaLabel ? `${ariaLabel} ${text}` : undefined,\n 'aria-labelledby': ariaLabelledBy ? `${ariaLabelledBy} ${buttonId}` : undefined,\n 'aria-readonly': readOnly ? 'true' : undefined,\n disabled: disabled,\n id: buttonId,\n onClick: handleButtonClick,\n onFocus: handleButtonFocus,\n onKeyDown: !disabled && !readOnly ? handleButtonKeyDown : undefined,\n tabIndex,\n type: 'button',\n };\n\n const listbox: InternalListboxProps = {\n ...otherProps,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data,\n disabled,\n emptyValue,\n onBlur,\n onClick: handleListboxClick,\n onChange: event => {\n setInputValueByRef(inputRef.current, event.target.value);\n },\n onKeyDown: handleListboxKeyDown,\n ref: listboxInputRef,\n value,\n };\n\n const input: InternalInputProps = {\n onChange: handleInputChange,\n ref: inputRef,\n value: String(value ?? ''),\n };\n\n return {\n button,\n listbox,\n input,\n popover: {\n open,\n onOpenChange: setOpen,\n },\n text,\n more,\n };\n};\n"],"names":["useLocalization","useFlattenedData","useMergedRef","React","nanoid","findByValue","setInputValueByRef","_a","createCustomEvent","sanitizeItem","i","value","input"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,MAAM,YAAY,CACrB;AAAA,EACI,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,OAAO,CAAC;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,IAAI;AAAA,EACJ;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACP,GACA,QACY;;AACN,QAAA,EAAE,MAAM,IAAIA,6BAAgB;AAC5B,QAAA,gBAAgBC,sBAAiB,IAAI;AACrC,QAAA,kBAAkBC,0BAA+B,GAAG;AAC1D,QAAM,CAAC,MAAM,OAAO,IAAIC,iBAAM,SAAS,KAAK;AACtC,QAAA,KAAKA,iBAAM,QAAQ,MAAM,YAAY,UAAUC,cAAQ,CAAA,IAAI,CAAC,QAAQ,CAAC;AACrE,QAAA,WAAWD,iBAAM,OAAyB,IAAI;AAC9C,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AAA,IACX,KAAK;AAAA,IACL;AAAA,EACJ;AAEA,QAAMM,UAA4B;AAAA,IAC9B,UAAU;AAAA,IACV,KAAK;AAAA,IACL,OAAO,OAAO,SAAS,EAAE;AAAA,EAC7B;AAEO,SAAA;AAAA,IACH;AAAA,IACA;AAAA,IAAA,OACAA;AAAAA,IACA,SAAS;AAAA,MACL;AAAA,MACA,cAAc;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AACJ;;"}
@@ -1,7 +1,7 @@
1
- import { Popover as PopoverPrimitive } from '@base-ui/react/popover';
2
1
  import { SelectProps } from './Select';
3
2
  import { ListboxProps } from '../Listbox/Listbox';
4
3
  import * as React from 'react';
4
+ import * as PopoverPrimitive from '@radix-ui/react-popover';
5
5
  type InternalButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement>;
6
6
  type InternalListboxProps = ListboxProps & {
7
7
  ref: React.ForwardedRef<HTMLInputElement>;
@@ -13,7 +13,7 @@ type useSelect = React.HtmlHTMLAttributes<HTMLDivElement> & {
13
13
  button: InternalButtonProps;
14
14
  listbox: InternalListboxProps;
15
15
  input: InternalInputProps;
16
- popover: Pick<PopoverPrimitive.Root.Props, 'onOpenChange' | 'open'>;
16
+ popover: Pick<PopoverPrimitive.PopoverProps, 'onOpenChange' | 'open'>;
17
17
  text: string | JSX.Element;
18
18
  more?: number;
19
19
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useSelect.js","sources":["../../../src/components/Select/useSelect.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport { nanoid } from 'nanoid';\nimport { Popover as PopoverPrimitive } from '@base-ui/react/popover';\nimport { useLocalization } from '../Provider/Localization';\nimport { SelectProps } from './Select';\nimport { ListboxProps } from '../Listbox/Listbox';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { setInputValueByRef, findByValue, useFlattenedData, sanitizeItem } from '../Listbox/util';\nimport { ScrollableListItemValue } from '../Listbox/ScrollableList';\nimport { createCustomEvent } from '../../utils/input';\n\ntype InternalButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement>;\ntype InternalListboxProps = ListboxProps & { ref: React.ForwardedRef<HTMLInputElement> };\ntype InternalInputProps = React.InputHTMLAttributes<HTMLInputElement> & { ref: React.ForwardedRef<HTMLInputElement> };\n\ntype useSelect = React.HtmlHTMLAttributes<HTMLDivElement> & {\n button: InternalButtonProps;\n listbox: InternalListboxProps;\n input: InternalInputProps;\n popover: Pick<PopoverPrimitive.Root.Props, 'onOpenChange' | 'open'>;\n text: string | JSX.Element;\n more?: number;\n};\n\nexport const useSelect = (\n {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data = [],\n defaultValue,\n disabled,\n emptyValue,\n id: nativeId,\n multiselect,\n onBlur,\n onClick: _1,\n onChange,\n readOnly,\n tabIndex,\n value,\n ...otherProps\n }: SelectProps,\n ref: React.Ref<HTMLInputElement>\n): useSelect => {\n const { texts } = useLocalization();\n const flattenedData = useFlattenedData(data);\n const listboxInputRef = useMergedRef<HTMLInputElement>(ref);\n const [open, setOpen] = React.useState(false);\n const id = React.useMemo(() => nativeId || `select_${nanoid()}`, [nativeId]);\n const inputRef = React.useRef<HTMLInputElement>(null);\n const buttonId = `${id}-button`;\n // support 'escape' resetting to the value that was set when the listbox opened\n const [lastValue, setLastValue] = React.useState<ScrollableListItemValue | undefined>(value);\n\n React.useEffect(() => {\n setLastValue(value);\n }, [open]);\n\n React.useEffect(() => {\n if (value === undefined) {\n if (defaultValue !== undefined && findByValue(flattenedData, defaultValue)) {\n setInputValueByRef(inputRef.current, defaultValue);\n } else if (emptyValue !== undefined) {\n setInputValueByRef(inputRef.current, emptyValue);\n } else if (data.length > 0) {\n setInputValueByRef(inputRef.current, data[0]?.value);\n }\n } else if (!multiselect && !findByValue(flattenedData, value)) {\n if (emptyValue !== undefined) {\n setInputValueByRef(inputRef.current, emptyValue);\n } else if (data.length > 0) {\n setInputValueByRef(inputRef.current, data[0]?.value);\n }\n }\n }, []);\n\n // event handlers\n const handleButtonKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>): void => {\n if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {\n event.preventDefault();\n setOpen(true);\n }\n };\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>): void => {\n switch (event.key) {\n case 'Escape': {\n event.preventDefault();\n if (lastValue !== undefined) {\n setInputValueByRef(listboxInputRef.current, lastValue);\n }\n\n setOpen(false);\n break;\n }\n\n case 'Tab':\n case 'Enter': {\n if (event.key !== 'Tab') {\n event.preventDefault();\n }\n setOpen(false);\n break;\n }\n\n default:\n }\n\n if (otherProps.onKeyDown) {\n otherProps.onKeyDown(event);\n }\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>): void => {\n event.preventDefault();\n if (!multiselect) {\n setOpen(false);\n if (onBlur) {\n onBlur(createCustomEvent('blur') as unknown as React.FocusEvent<HTMLElement, Element>);\n }\n }\n };\n\n let text: string | JSX.Element = '';\n let more = 0;\n\n if (value !== undefined) {\n if (multiselect) {\n const selectedValues = value?.toString().split(',') || [];\n\n if (selectedValues.length === flattenedData.filter(item => !item.disabled).length) {\n text = texts.select.allOptionsSelected;\n } else {\n text = findByValue(flattenedData, selectedValues[0])?.text ?? '';\n more = selectedValues.length > 1 ? selectedValues.length - 1 : 0;\n }\n } else {\n const item = findByValue(flattenedData, value);\n\n if (item) {\n text = item.icon ? (\n <>\n {React.cloneElement(item.icon, {\n className: cn(item.icon.props.className, 'mr-1 -mt-px'),\n })}\n {item.text}\n </>\n ) : (\n item.text\n );\n }\n }\n }\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (onChange) {\n const item = findByValue(flattenedData, event.target.value);\n (event as any).detail = sanitizeItem(item);\n\n const indexes = item?.path?.split('.') ?? [];\n\n if (indexes.length > 1) {\n // we don't want to map the current item\n indexes.pop();\n // we need to rebuild the path as we map\n let lastPath: string;\n\n (event as any).detail.parents = indexes.map(i => {\n lastPath = lastPath ? [lastPath, i].join('.') : i;\n return sanitizeItem(flattenedData.find(i => i.path === lastPath));\n });\n }\n\n onChange(event);\n }\n };\n\n const handleButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (readOnly) {\n event.preventDefault();\n }\n };\n\n // select the value text if the select is readonly\n const handleButtonFocus = (event: React.FocusEvent<HTMLButtonElement>) => {\n if (readOnly) {\n const value = event.currentTarget.querySelector(':first-child');\n\n if (value) {\n window.getSelection()?.selectAllChildren?.(value);\n }\n }\n };\n\n const button: InternalButtonProps = {\n 'aria-haspopup': 'listbox' as const,\n 'aria-label': ariaLabel ? `${ariaLabel} ${text}` : undefined,\n 'aria-labelledby': ariaLabelledBy ? `${ariaLabelledBy} ${buttonId}` : undefined,\n 'aria-readonly': readOnly ? 'true' : undefined,\n disabled: disabled,\n id: buttonId,\n onClick: handleButtonClick,\n onFocus: handleButtonFocus,\n onKeyDown: !disabled && !readOnly ? handleButtonKeyDown : undefined,\n tabIndex,\n type: 'button',\n };\n\n const listbox: InternalListboxProps = {\n ...otherProps,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data,\n disabled,\n emptyValue,\n onBlur,\n onClick: handleListboxClick,\n onChange: event => {\n setInputValueByRef(inputRef.current, event.target.value);\n },\n onKeyDown: handleListboxKeyDown,\n ref: listboxInputRef,\n value,\n };\n\n const input: InternalInputProps = {\n onChange: handleInputChange,\n ref: inputRef,\n value: String(value ?? ''),\n };\n\n return {\n button,\n listbox,\n input,\n popover: {\n open,\n onOpenChange: setOpen,\n },\n text,\n more,\n };\n};\n"],"names":["_a","i","value"],"mappings":";;;;;;;AAyBO,MAAM,YAAY,CACrB;AAAA,EACI,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,OAAO,CAAC;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,IAAI;AAAA,EACJ;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AA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;AAEA,QAAM,UAAgC;AAAA,IAClC,GAAG;AAAA,IACH,cAAc;AAAA,IACd,mBAAmB;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,UAAU,CAAS,UAAA;AACf,yBAAmB,SAAS,SAAS,MAAM,OAAO,KAAK;AAAA,IAC3D;AAAA,IACA,WAAW;AAAA,IACX,KAAK;AAAA,IACL;AAAA,EACJ;AAEA,QAAM,QAA4B;AAAA,IAC9B,UAAU;AAAA,IACV,KAAK;AAAA,IACL,OAAO,OAAO,SAAS,EAAE;AAAA,EAC7B;AAEO,SAAA;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,MACL;AAAA,MACA,cAAc;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AACJ;"}
1
+ {"version":3,"file":"useSelect.js","sources":["../../../src/components/Select/useSelect.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport { nanoid } from 'nanoid';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { useLocalization } from '../Provider/Localization';\nimport { SelectProps } from './Select';\nimport { ListboxProps } from '../Listbox/Listbox';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { setInputValueByRef, findByValue, useFlattenedData, sanitizeItem } from '../Listbox/util';\nimport { ScrollableListItemValue } from '../Listbox/ScrollableList';\nimport { createCustomEvent } from '../../utils/input';\n\ntype InternalButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement>;\ntype InternalListboxProps = ListboxProps & { ref: React.ForwardedRef<HTMLInputElement> };\ntype InternalInputProps = React.InputHTMLAttributes<HTMLInputElement> & { ref: React.ForwardedRef<HTMLInputElement> };\n\ntype useSelect = React.HtmlHTMLAttributes<HTMLDivElement> & {\n button: InternalButtonProps;\n listbox: InternalListboxProps;\n input: InternalInputProps;\n popover: Pick<PopoverPrimitive.PopoverProps, 'onOpenChange' | 'open'>;\n text: string | JSX.Element;\n more?: number;\n};\n\nexport const useSelect = (\n {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data = [],\n defaultValue,\n disabled,\n emptyValue,\n id: nativeId,\n multiselect,\n onBlur,\n onClick: _1,\n onChange,\n readOnly,\n tabIndex,\n value,\n ...otherProps\n }: SelectProps,\n ref: React.Ref<HTMLInputElement>\n): useSelect => {\n const { texts } = useLocalization();\n const flattenedData = useFlattenedData(data);\n const listboxInputRef = useMergedRef<HTMLInputElement>(ref);\n const [open, setOpen] = React.useState(false);\n const id = React.useMemo(() => nativeId || `select_${nanoid()}`, [nativeId]);\n const inputRef = React.useRef<HTMLInputElement>(null);\n const buttonId = `${id}-button`;\n // support 'escape' resetting to the value that was set when the listbox opened\n const [lastValue, setLastValue] = React.useState<ScrollableListItemValue | undefined>(value);\n\n React.useEffect(() => {\n setLastValue(value);\n }, [open]);\n\n React.useEffect(() => {\n if (value === undefined) {\n if (defaultValue !== undefined && findByValue(flattenedData, defaultValue)) {\n setInputValueByRef(inputRef.current, defaultValue);\n } else if (emptyValue !== undefined) {\n setInputValueByRef(inputRef.current, emptyValue);\n } else if (data.length > 0) {\n setInputValueByRef(inputRef.current, data[0]?.value);\n }\n } else if (!multiselect && !findByValue(flattenedData, value)) {\n if (emptyValue !== undefined) {\n setInputValueByRef(inputRef.current, emptyValue);\n } else if (data.length > 0) {\n setInputValueByRef(inputRef.current, data[0]?.value);\n }\n }\n }, []);\n\n // event handlers\n const handleButtonKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>): void => {\n if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {\n event.preventDefault();\n setOpen(true);\n }\n };\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>): void => {\n switch (event.key) {\n case 'Escape': {\n event.preventDefault();\n if (lastValue !== undefined) {\n setInputValueByRef(listboxInputRef.current, lastValue);\n }\n\n setOpen(false);\n break;\n }\n\n case 'Tab':\n case 'Enter': {\n if (event.key !== 'Tab') {\n event.preventDefault();\n }\n setOpen(false);\n break;\n }\n\n default:\n }\n\n if (otherProps.onKeyDown) {\n otherProps.onKeyDown(event);\n }\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>): void => {\n event.preventDefault();\n if (!multiselect) {\n setOpen(false);\n if (onBlur) {\n onBlur(createCustomEvent('blur') as unknown as React.FocusEvent<HTMLElement, Element>);\n }\n }\n };\n\n let text: string | JSX.Element = '';\n let more = 0;\n\n if (value !== undefined) {\n if (multiselect) {\n const selectedValues = value?.toString().split(',') || [];\n\n if (selectedValues.length === flattenedData.filter(item => !item.disabled).length) {\n text = texts.select.allOptionsSelected;\n } else {\n text = findByValue(flattenedData, selectedValues[0])?.text ?? '';\n more = selectedValues.length > 1 ? selectedValues.length - 1 : 0;\n }\n } else {\n const item = findByValue(flattenedData, value);\n\n if (item) {\n text = item.icon ? (\n <>\n {React.cloneElement(item.icon, {\n className: cn(item.icon.props.className, 'mr-1 -mt-px'),\n })}\n {item.text}\n </>\n ) : (\n item.text\n );\n }\n }\n }\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (onChange) {\n const item = findByValue(flattenedData, event.target.value);\n (event as any).detail = sanitizeItem(item);\n\n const indexes = item?.path?.split('.') ?? [];\n\n if (indexes.length > 1) {\n // we don't want to map the current item\n indexes.pop();\n // we need to rebuild the path as we map\n let lastPath: string;\n\n (event as any).detail.parents = indexes.map(i => {\n lastPath = lastPath ? [lastPath, i].join('.') : i;\n return sanitizeItem(flattenedData.find(i => i.path === lastPath));\n });\n }\n\n onChange(event);\n }\n };\n\n const handleButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (readOnly) {\n event.preventDefault();\n }\n };\n\n // select the value text if the select is readonly\n const handleButtonFocus = (event: React.FocusEvent<HTMLButtonElement>) => {\n if (readOnly) {\n const value = event.currentTarget.querySelector(':first-child');\n\n if (value) {\n window.getSelection()?.selectAllChildren?.(value);\n }\n }\n };\n\n const button: InternalButtonProps = {\n 'aria-haspopup': 'listbox' as const,\n 'aria-label': ariaLabel ? `${ariaLabel} ${text}` : undefined,\n 'aria-labelledby': ariaLabelledBy ? `${ariaLabelledBy} ${buttonId}` : undefined,\n 'aria-readonly': readOnly ? 'true' : undefined,\n disabled: disabled,\n id: buttonId,\n onClick: handleButtonClick,\n onFocus: handleButtonFocus,\n onKeyDown: !disabled && !readOnly ? handleButtonKeyDown : undefined,\n tabIndex,\n type: 'button',\n };\n\n const listbox: InternalListboxProps = {\n ...otherProps,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data,\n disabled,\n emptyValue,\n onBlur,\n onClick: handleListboxClick,\n onChange: event => {\n setInputValueByRef(inputRef.current, event.target.value);\n },\n onKeyDown: handleListboxKeyDown,\n ref: listboxInputRef,\n value,\n };\n\n const input: InternalInputProps = {\n onChange: handleInputChange,\n ref: inputRef,\n value: String(value ?? ''),\n };\n\n return {\n button,\n listbox,\n input,\n popover: {\n open,\n onOpenChange: setOpen,\n },\n text,\n more,\n };\n};\n"],"names":["_a","i","value"],"mappings":";;;;;;;AAyBO,MAAM,YAAY,CACrB;AAAA,EACI,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,OAAO,CAAC;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,IAAI;AAAA,EACJ;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACP,GACA,QACY;;AACN,QAAA,EAAE,MAAM,IAAI,gBAAgB;AAC5B,QAAA,gBAAgB,iBAAiB,IAAI;AACrC,QAAA,kBAAkB,aAA+B,GAAG;AAC1D,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,KAAK;AACtC,QAAA,KAAK,MAAM,QAAQ,MAAM,YAAY,UAAU,OAAQ,CAAA,IAAI,CAAC,QAAQ,CAAC;AACrE,QAAA,WAAW,MAAM,OAAyB,IAAI;AAC9C,QAAA,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L,OAAO,OAAO,SAAS,EAAE;AAAA,EAC7B;AAEO,SAAA;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,MACL;AAAA,MACA,cAAc;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AACJ;"}
@@ -99,7 +99,7 @@ const DisplayRow = React.memo(
99
99
  attributes["data-row-selected"] = row.getIsSelected() || row.getIsAllSubRowsSelected() ? true : void 0;
100
100
  }
101
101
  let expandedRow;
102
- if (tableMeta.rowExpansion.isEnabled && row.getIsExpanded()) {
102
+ if (tableMeta.rowExpansion.isEnabled && row.getIsExpanded() && !row.getIsGrouped()) {
103
103
  attributes["data-row-expanded"] = true;
104
104
  expandedRow = (_c = (_b = (_a = tableMeta.rowExpansion).rowExpansionRenderer) == null ? void 0 : _b.call(_a, row.original)) == null ? void 0 : _c();
105
105
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DisplayRow.cjs","sources":["../../../../../../../src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport cn from 'clsx';\nimport { Cell } from '../../Columns/Cell/Cell';\nimport { TableRowRendererProps } from '../../../types';\nimport { TableRowWithMetaData } from '../../../../types';\nimport { isElementInteractive } from '../../../../../../utils/dom';\nimport { useDropTarget } from '../../../../../../utils/hooks/useDropTarget';\nimport { useResizeObserver } from '../../../../../../hooks/useResizeObserver';\nimport { mergeRefs } from '../../../../../../utils/mergeRefs';\n\nexport type DisplayRowProps<TType = unknown> = React.HTMLAttributes<HTMLTableRowElement> &\n TableRowRendererProps<TType> & {\n remeasureDependencies?: React.DependencyList;\n };\n\nexport const DisplayRow = React.memo(\n React.forwardRef<HTMLTableRowElement, DisplayRowProps>(function DisplayRow<TType = unknown>(\n props: DisplayRowProps<TType>,\n externalRef: React.Ref<HTMLTableRowElement>\n ) {\n const {\n children,\n cellRenderer: CellRenderer,\n index,\n measureRow,\n row,\n table,\n remeasureDependencies = [],\n ...otherAttributes\n } = props;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const attributes: any = {\n ...otherAttributes,\n 'data-row-id': row.id,\n 'data-row-index': index,\n tabIndex: -1,\n };\n\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLTableRowElement>) => {\n const clickedElement = event.target as HTMLElement;\n\n if (!event.currentTarget?.contains(event.target as HTMLElement) || isElementInteractive(clickedElement)) {\n return;\n }\n\n tableMeta.rowClick.handleClick(event, row.original);\n },\n [row.original]\n );\n const handlePointerDown = React.useCallback(() => {\n requestAnimationFrame(() => tableMeta.rowActive.setRowActiveIndex(index));\n }, [index]);\n\n // row active\n if (tableMeta.rowActive.isEnabled) {\n attributes['data-row-active'] = tableMeta.rowActive.rowActiveIndex === index ? true : undefined;\n // we use pointerdown because it let's us picks up clicks on components inside the row, e.g. checkboxes\n attributes.onPointerDown = handlePointerDown;\n }\n\n // row click\n if (tableMeta.rowClick.isEnabled(row.original)) {\n attributes.onClick = handleClick;\n }\n\n // row drag\n if (tableMeta.rowDrag.isEnabled) {\n attributes['aria-grabbed'] = !!tableMeta.rowDrag.dragging[row.id];\n attributes.draggable = true;\n const GHOST_ELEMENT_ID = 'taco_table_dragging';\n\n attributes.onDragStart = (event: React.DragEvent): void => {\n let rows = [row];\n\n if (row.getCanSelect()) {\n rows = row.getIsSelected() ? table.getSelectedRowModel().rows : [row, ...table.getSelectedRowModel().rows];\n }\n\n const data = rows.map(row => row.original);\n\n tableMeta.rowDrag.setDragging?.(\n rows.reduce((dragging, rowBeingDragged) => ({ ...dragging, [rowBeingDragged.id]: true }), {})\n );\n\n // set a default data value so that the consumer doesn't have to\n event.dataTransfer.setData('text', JSON.stringify(data));\n\n const showPlaceholder = (text: string) => {\n const ghost = document.createElement('div');\n ghost.id = GHOST_ELEMENT_ID;\n ghost.className = 'wcag-blue rounded flex w-48 p-4 absolute -ml-[100vw]';\n ghost.innerText = text;\n document.body.append(ghost);\n event.dataTransfer.setDragImage(ghost, 0, 0);\n };\n\n const setDataTransfer = (text: string) => event.dataTransfer.setData('text', text);\n\n tableMeta.rowDrag.handleRowDrag?.(data, showPlaceholder, setDataTransfer);\n };\n\n attributes.onDragEnd = (): void => {\n document.getElementById(GHOST_ELEMENT_ID)?.remove();\n tableMeta.rowDrag.setDragging?.({});\n };\n }\n\n // row drop\n const [isDraggedOver, dropTargetProps] = useDropTarget(event => tableMeta.rowDrop.handleDrop?.(event, row.original));\n\n if (tableMeta.rowDrop.isEnabled) {\n attributes.onDragEnter = dropTargetProps?.onDragEnter;\n attributes.onDragLeave = dropTargetProps?.onDragLeave;\n attributes.onDragOver = dropTargetProps?.onDragOver;\n attributes.onDrop = dropTargetProps?.onDrop;\n attributes['data-row-dragged-over'] = isDraggedOver;\n }\n\n // row grouping\n if (table.options.enableGrouping) {\n attributes['data-row-group'] = row.getIsGrouped() ? true : undefined;\n }\n\n // row selection\n if (row.getCanSelect()) {\n attributes['data-row-selected'] = row.getIsSelected() || row.getIsAllSubRowsSelected() ? true : undefined;\n }\n\n // row expansion\n let expandedRow;\n\n if (tableMeta.rowExpansion.isEnabled && row.getIsExpanded()) {\n attributes['data-row-expanded'] = true;\n expandedRow = tableMeta.rowExpansion.rowExpansionRenderer?.(row.original)?.();\n }\n\n const rowMeta = (row.original as TableRowWithMetaData<TType>)._meta;\n\n if (rowMeta?.layout) {\n attributes['data-row-meta-layout'] = rowMeta.layout;\n }\n\n const ref = React.useRef<HTMLTableRowElement>(null);\n const expansionRef = React.useRef<HTMLTableRowElement>(null);\n const expandedRowSize = useResizeObserver(expansionRef, !!expandedRow);\n\n React.useEffect(() => {\n const rowHeight = ref.current?.getBoundingClientRect().height ?? 0;\n const expansionHeight = expansionRef.current?.getBoundingClientRect().height ?? 0;\n\n measureRow(rowHeight + expansionHeight);\n }, [expansionRef.current, expandedRowSize?.height, ...remeasureDependencies]);\n\n const className = cn('group/row', otherAttributes.className, {\n 'hover:cursor-grab': tableMeta.rowDrag.isEnabled && typeof attributes.onClick !== 'function',\n 'hover:cursor-pointer': typeof attributes.onClick === 'function',\n });\n\n const isGrouped = row.getIsGrouped();\n\n const mergedRef = mergeRefs([ref, externalRef]);\n\n return (\n <>\n <tr {...attributes} className={className} ref={mergedRef}>\n {children}\n {row\n .getVisibleCells()\n // Filter out the row actions cell from rendering in Grouped Row\n .filter(cell => !(isGrouped && cell.column.id === '__actions'))\n .map((cell, cellIndex) => (\n <Cell key={cell.id} cell={cell} index={cellIndex} renderer={CellRenderer} />\n ))}\n </tr>\n {expandedRow ? (\n <tr data-row-parent-id={row.id} ref={expansionRef}>\n <td className=\"col-span-full\">{expandedRow}</td>\n </tr>\n ) : null}\n </>\n );\n })\n) as <TType = unknown>(props: DisplayRowProps<TType> & { ref?: React.Ref<HTMLTableRowElement> }) => JSX.Element;\n"],"names":["DisplayRow","_a","isElementInteractive","row","_b","_c","useDropTarget","useResizeObserver","mergeRefs","Cell"],"mappings":";;;;;;;;;AAgBO,MAAM,aAAa,MAAM;AAAA,EAC5B,MAAM,WAAiD,SAASA,YAC5D,OACA,aACF;;AACQ,UAAA;AAAA,MACF;AAAA,MACA,cAAc;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,wBAAwB,CAAC;AAAA,MACzB,GAAG;AAAA,IAAA,IACH;AACE,UAAA,YAAY,MAAM,QAAQ;AAEhC,UAAM,aAAkB;AAAA,MACpB,GAAG;AAAA,MACH,eAAe,IAAI;AAAA,MACnB,kBAAkB;AAAA,MAClB,UAAU;AAAA,IACd;AAEA,UAAM,cAAc,MAAM;AAAA,MACtB,CAAC,UAAiD;;AAC9C,cAAM,iBAAiB,MAAM;AAEzB,YAAA,GAACC,MAAA,MAAM,kBAAN,gBAAAA,IAAqB,SAAS,MAAM,YAA0BC,yBAAqB,cAAc,GAAG;AACrG;AAAA,QAAA;AAGJ,kBAAU,SAAS,YAAY,OAAO,IAAI,QAAQ;AAAA,MACtD;AAAA,MACA,C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AC3D,UAAM,kBAAkBM,kBAAA,kBAAkB,cAAc,CAAC,CAAC,WAAW;AAErE,UAAM,UAAU,MAAM;;AAClB,YAAM,cAAYN,MAAA,IAAI,YAAJ,gBAAAA,IAAa,wBAAwB,WAAU;AACjE,YAAM,oBAAkBG,MAAA,aAAa,YAAb,gBAAAA,IAAsB,wBAAwB,WAAU;AAEhF,iBAAW,YAAY,eAAe;AAAA,IAAA,GACvC,CAAC,aAAa,SAAS,mDAAiB,QAAQ,GAAG,qBAAqB,CAAC;AAE5E,UAAM,YAAY,GAAG,aAAa,gBAAgB,WAAW;AAAA,MACzD,qBAAqB,UAAU,QAAQ,aAAa,OAAO,WAAW,YAAY;AAAA,MAClF,wBAAwB,OAAO,WAAW,YAAY;AAAA,IAAA,CACzD;AAEK,UAAA,YAAY,IAAI,aAAa;AAEnC,UAAM,YAAYI,UAAA,UAAU,CAAC,KAAK,WAAW,CAAC;AAG1C,WAAA,sBAAA,cAAA,MAAA,UAAA,MACK,sBAAA,cAAA,MAAA,EAAI,GAAG,YAAY,WAAsB,KAAK,UAAA,GAC1C,UACA,IACI,gBAAgB,EAEhB,OAAO,CAAQ,SAAA,EAAE,aAAa,KAAK,OAAO,OAAO,YAAY,EAC7D,IAAI,CAAC,MAAM,cACR,sBAAA,cAACC,aAAK,KAAK,KAAK,IAAI,MAAY,OAAO,WAAW,UAAU,aAAc,CAAA,CAC7E,CACT,GACC,cACG,sBAAA,cAAC,QAAG,sBAAoB,IAAI,IAAI,KAAK,aACjC,GAAA,sBAAA,cAAC,MAAG,EAAA,WAAU,gBAAiB,GAAA,WAAY,CAC/C,IACA,IACR;AAAA,EAEP,CAAA;AACL;;"}
1
+ {"version":3,"file":"DisplayRow.cjs","sources":["../../../../../../../src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport cn from 'clsx';\nimport { Cell } from '../../Columns/Cell/Cell';\nimport { TableRowRendererProps } from '../../../types';\nimport { TableRowWithMetaData } from '../../../../types';\nimport { isElementInteractive } from '../../../../../../utils/dom';\nimport { useDropTarget } from '../../../../../../utils/hooks/useDropTarget';\nimport { useResizeObserver } from '../../../../../../hooks/useResizeObserver';\nimport { mergeRefs } from '../../../../../../utils/mergeRefs';\n\nexport type DisplayRowProps<TType = unknown> = React.HTMLAttributes<HTMLTableRowElement> &\n TableRowRendererProps<TType> & {\n remeasureDependencies?: React.DependencyList;\n };\n\nexport const DisplayRow = React.memo(\n React.forwardRef<HTMLTableRowElement, DisplayRowProps>(function DisplayRow<TType = unknown>(\n props: DisplayRowProps<TType>,\n externalRef: React.Ref<HTMLTableRowElement>\n ) {\n const {\n children,\n cellRenderer: CellRenderer,\n index,\n measureRow,\n row,\n table,\n remeasureDependencies = [],\n ...otherAttributes\n } = props;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const attributes: any = {\n ...otherAttributes,\n 'data-row-id': row.id,\n 'data-row-index': index,\n tabIndex: -1,\n };\n\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLTableRowElement>) => {\n const clickedElement = event.target as HTMLElement;\n\n if (!event.currentTarget?.contains(event.target as HTMLElement) || isElementInteractive(clickedElement)) {\n return;\n }\n\n tableMeta.rowClick.handleClick(event, row.original);\n },\n [row.original]\n );\n const handlePointerDown = React.useCallback(() => {\n requestAnimationFrame(() => tableMeta.rowActive.setRowActiveIndex(index));\n }, [index]);\n\n // row active\n if (tableMeta.rowActive.isEnabled) {\n attributes['data-row-active'] = tableMeta.rowActive.rowActiveIndex === index ? true : undefined;\n // we use pointerdown because it let's us picks up clicks on components inside the row, e.g. checkboxes\n attributes.onPointerDown = handlePointerDown;\n }\n\n // row click\n if (tableMeta.rowClick.isEnabled(row.original)) {\n attributes.onClick = handleClick;\n }\n\n // row drag\n if (tableMeta.rowDrag.isEnabled) {\n attributes['aria-grabbed'] = !!tableMeta.rowDrag.dragging[row.id];\n attributes.draggable = true;\n const GHOST_ELEMENT_ID = 'taco_table_dragging';\n\n attributes.onDragStart = (event: React.DragEvent): void => {\n let rows = [row];\n\n if (row.getCanSelect()) {\n rows = row.getIsSelected() ? table.getSelectedRowModel().rows : [row, ...table.getSelectedRowModel().rows];\n }\n\n const data = rows.map(row => row.original);\n\n tableMeta.rowDrag.setDragging?.(\n rows.reduce((dragging, rowBeingDragged) => ({ ...dragging, [rowBeingDragged.id]: true }), {})\n );\n\n // set a default data value so that the consumer doesn't have to\n event.dataTransfer.setData('text', JSON.stringify(data));\n\n const showPlaceholder = (text: string) => {\n const ghost = document.createElement('div');\n ghost.id = GHOST_ELEMENT_ID;\n ghost.className = 'wcag-blue rounded flex w-48 p-4 absolute -ml-[100vw]';\n ghost.innerText = text;\n document.body.append(ghost);\n event.dataTransfer.setDragImage(ghost, 0, 0);\n };\n\n const setDataTransfer = (text: string) => event.dataTransfer.setData('text', text);\n\n tableMeta.rowDrag.handleRowDrag?.(data, showPlaceholder, setDataTransfer);\n };\n\n attributes.onDragEnd = (): void => {\n document.getElementById(GHOST_ELEMENT_ID)?.remove();\n tableMeta.rowDrag.setDragging?.({});\n };\n }\n\n // row drop\n const [isDraggedOver, dropTargetProps] = useDropTarget(event => tableMeta.rowDrop.handleDrop?.(event, row.original));\n\n if (tableMeta.rowDrop.isEnabled) {\n attributes.onDragEnter = dropTargetProps?.onDragEnter;\n attributes.onDragLeave = dropTargetProps?.onDragLeave;\n attributes.onDragOver = dropTargetProps?.onDragOver;\n attributes.onDrop = dropTargetProps?.onDrop;\n attributes['data-row-dragged-over'] = isDraggedOver;\n }\n\n // row grouping\n if (table.options.enableGrouping) {\n attributes['data-row-group'] = row.getIsGrouped() ? true : undefined;\n }\n\n // row selection\n if (row.getCanSelect()) {\n attributes['data-row-selected'] = row.getIsSelected() || row.getIsAllSubRowsSelected() ? true : undefined;\n }\n\n // row expansion\n // When grouping is enabled, a group header row also reports getIsExpanded() === true\n // when its children are visible. Skip the renderer in that case — otherwise row.original\n // (the first child's data) gets rendered as expansion content under the header.\n let expandedRow;\n\n if (tableMeta.rowExpansion.isEnabled && row.getIsExpanded() && !row.getIsGrouped()) {\n attributes['data-row-expanded'] = true;\n expandedRow = tableMeta.rowExpansion.rowExpansionRenderer?.(row.original)?.();\n }\n\n const rowMeta = (row.original as TableRowWithMetaData<TType>)._meta;\n\n if (rowMeta?.layout) {\n attributes['data-row-meta-layout'] = rowMeta.layout;\n }\n\n const ref = React.useRef<HTMLTableRowElement>(null);\n const expansionRef = React.useRef<HTMLTableRowElement>(null);\n const expandedRowSize = useResizeObserver(expansionRef, !!expandedRow);\n\n React.useEffect(() => {\n const rowHeight = ref.current?.getBoundingClientRect().height ?? 0;\n const expansionHeight = expansionRef.current?.getBoundingClientRect().height ?? 0;\n\n measureRow(rowHeight + expansionHeight);\n }, [expansionRef.current, expandedRowSize?.height, ...remeasureDependencies]);\n\n const className = cn('group/row', otherAttributes.className, {\n 'hover:cursor-grab': tableMeta.rowDrag.isEnabled && typeof attributes.onClick !== 'function',\n 'hover:cursor-pointer': typeof attributes.onClick === 'function',\n });\n\n const isGrouped = row.getIsGrouped();\n\n const mergedRef = mergeRefs([ref, externalRef]);\n\n return (\n <>\n <tr {...attributes} className={className} ref={mergedRef}>\n {children}\n {row\n .getVisibleCells()\n // Filter out the row actions cell from rendering in Grouped Row\n .filter(cell => !(isGrouped && cell.column.id === '__actions'))\n .map((cell, cellIndex) => (\n <Cell key={cell.id} cell={cell} index={cellIndex} renderer={CellRenderer} />\n ))}\n </tr>\n {expandedRow ? (\n <tr data-row-parent-id={row.id} ref={expansionRef}>\n <td className=\"col-span-full\">{expandedRow}</td>\n </tr>\n ) : null}\n </>\n );\n })\n) as <TType = unknown>(props: DisplayRowProps<TType> & { ref?: React.Ref<HTMLTableRowElement> }) => JSX.Element;\n"],"names":["DisplayRow","_a","isElementInteractive","row","_b","_c","useDropTarget","useResizeObserver","mergeRefs","Cell"],"mappings":";;;;;;;;;AAgBO,MAAM,aAAa,MAAM;AAAA,E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,MAAA,EAAI,GAAG,YAAY,WAAsB,KAAK,UAAA,GAC1C,UACA,IACI,gBAAgB,EAEhB,OAAO,CAAQ,SAAA,EAAE,aAAa,KAAK,OAAO,OAAO,YAAY,EAC7D,IAAI,CAAC,MAAM,cACR,sBAAA,cAACC,aAAK,KAAK,KAAK,IAAI,MAAY,OAAO,WAAW,UAAU,aAAc,CAAA,CAC7E,CACT,GACC,cACG,sBAAA,cAAC,QAAG,sBAAoB,IAAI,IAAI,KAAK,aACjC,GAAA,sBAAA,cAAC,MAAG,EAAA,WAAU,gBAAiB,GAAA,WAAY,CAC/C,IACA,IACR;AAAA,EAEP,CAAA;AACL;;"}
@@ -97,7 +97,7 @@ const DisplayRow = React__default.memo(
97
97
  attributes["data-row-selected"] = row.getIsSelected() || row.getIsAllSubRowsSelected() ? true : void 0;
98
98
  }
99
99
  let expandedRow;
100
- if (tableMeta.rowExpansion.isEnabled && row.getIsExpanded()) {
100
+ if (tableMeta.rowExpansion.isEnabled && row.getIsExpanded() && !row.getIsGrouped()) {
101
101
  attributes["data-row-expanded"] = true;
102
102
  expandedRow = (_c = (_b = (_a = tableMeta.rowExpansion).rowExpansionRenderer) == null ? void 0 : _b.call(_a, row.original)) == null ? void 0 : _c();
103
103
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DisplayRow.js","sources":["../../../../../../../src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport cn from 'clsx';\nimport { Cell } from '../../Columns/Cell/Cell';\nimport { TableRowRendererProps } from '../../../types';\nimport { TableRowWithMetaData } from '../../../../types';\nimport { isElementInteractive } from '../../../../../../utils/dom';\nimport { useDropTarget } from '../../../../../../utils/hooks/useDropTarget';\nimport { useResizeObserver } from '../../../../../../hooks/useResizeObserver';\nimport { mergeRefs } from '../../../../../../utils/mergeRefs';\n\nexport type DisplayRowProps<TType = unknown> = React.HTMLAttributes<HTMLTableRowElement> &\n TableRowRendererProps<TType> & {\n remeasureDependencies?: React.DependencyList;\n };\n\nexport const DisplayRow = React.memo(\n React.forwardRef<HTMLTableRowElement, DisplayRowProps>(function DisplayRow<TType = unknown>(\n props: DisplayRowProps<TType>,\n externalRef: React.Ref<HTMLTableRowElement>\n ) {\n const {\n children,\n cellRenderer: CellRenderer,\n index,\n measureRow,\n row,\n table,\n remeasureDependencies = [],\n ...otherAttributes\n } = props;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const attributes: any = {\n ...otherAttributes,\n 'data-row-id': row.id,\n 'data-row-index': index,\n tabIndex: -1,\n };\n\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLTableRowElement>) => {\n const clickedElement = event.target as HTMLElement;\n\n if (!event.currentTarget?.contains(event.target as HTMLElement) || isElementInteractive(clickedElement)) {\n return;\n }\n\n tableMeta.rowClick.handleClick(event, row.original);\n },\n [row.original]\n );\n const handlePointerDown = React.useCallback(() => {\n requestAnimationFrame(() => tableMeta.rowActive.setRowActiveIndex(index));\n }, [index]);\n\n // row active\n if (tableMeta.rowActive.isEnabled) {\n attributes['data-row-active'] = tableMeta.rowActive.rowActiveIndex === index ? true : undefined;\n // we use pointerdown because it let's us picks up clicks on components inside the row, e.g. checkboxes\n attributes.onPointerDown = handlePointerDown;\n }\n\n // row click\n if (tableMeta.rowClick.isEnabled(row.original)) {\n attributes.onClick = handleClick;\n }\n\n // row drag\n if (tableMeta.rowDrag.isEnabled) {\n attributes['aria-grabbed'] = !!tableMeta.rowDrag.dragging[row.id];\n attributes.draggable = true;\n const GHOST_ELEMENT_ID = 'taco_table_dragging';\n\n attributes.onDragStart = (event: React.DragEvent): void => {\n let rows = [row];\n\n if (row.getCanSelect()) {\n rows = row.getIsSelected() ? table.getSelectedRowModel().rows : [row, ...table.getSelectedRowModel().rows];\n }\n\n const data = rows.map(row => row.original);\n\n tableMeta.rowDrag.setDragging?.(\n rows.reduce((dragging, rowBeingDragged) => ({ ...dragging, [rowBeingDragged.id]: true }), {})\n );\n\n // set a default data value so that the consumer doesn't have to\n event.dataTransfer.setData('text', JSON.stringify(data));\n\n const showPlaceholder = (text: string) => {\n const ghost = document.createElement('div');\n ghost.id = GHOST_ELEMENT_ID;\n ghost.className = 'wcag-blue rounded flex w-48 p-4 absolute -ml-[100vw]';\n ghost.innerText = text;\n document.body.append(ghost);\n event.dataTransfer.setDragImage(ghost, 0, 0);\n };\n\n const setDataTransfer = (text: string) => event.dataTransfer.setData('text', text);\n\n tableMeta.rowDrag.handleRowDrag?.(data, showPlaceholder, setDataTransfer);\n };\n\n attributes.onDragEnd = (): void => {\n document.getElementById(GHOST_ELEMENT_ID)?.remove();\n tableMeta.rowDrag.setDragging?.({});\n };\n }\n\n // row drop\n const [isDraggedOver, dropTargetProps] = useDropTarget(event => tableMeta.rowDrop.handleDrop?.(event, row.original));\n\n if (tableMeta.rowDrop.isEnabled) {\n attributes.onDragEnter = dropTargetProps?.onDragEnter;\n attributes.onDragLeave = dropTargetProps?.onDragLeave;\n attributes.onDragOver = dropTargetProps?.onDragOver;\n attributes.onDrop = dropTargetProps?.onDrop;\n attributes['data-row-dragged-over'] = isDraggedOver;\n }\n\n // row grouping\n if (table.options.enableGrouping) {\n attributes['data-row-group'] = row.getIsGrouped() ? true : undefined;\n }\n\n // row selection\n if (row.getCanSelect()) {\n attributes['data-row-selected'] = row.getIsSelected() || row.getIsAllSubRowsSelected() ? true : undefined;\n }\n\n // row expansion\n let expandedRow;\n\n if (tableMeta.rowExpansion.isEnabled && row.getIsExpanded()) {\n attributes['data-row-expanded'] = true;\n expandedRow = tableMeta.rowExpansion.rowExpansionRenderer?.(row.original)?.();\n }\n\n const rowMeta = (row.original as TableRowWithMetaData<TType>)._meta;\n\n if (rowMeta?.layout) {\n attributes['data-row-meta-layout'] = rowMeta.layout;\n }\n\n const ref = React.useRef<HTMLTableRowElement>(null);\n const expansionRef = React.useRef<HTMLTableRowElement>(null);\n const expandedRowSize = useResizeObserver(expansionRef, !!expandedRow);\n\n React.useEffect(() => {\n const rowHeight = ref.current?.getBoundingClientRect().height ?? 0;\n const expansionHeight = expansionRef.current?.getBoundingClientRect().height ?? 0;\n\n measureRow(rowHeight + expansionHeight);\n }, [expansionRef.current, expandedRowSize?.height, ...remeasureDependencies]);\n\n const className = cn('group/row', otherAttributes.className, {\n 'hover:cursor-grab': tableMeta.rowDrag.isEnabled && typeof attributes.onClick !== 'function',\n 'hover:cursor-pointer': typeof attributes.onClick === 'function',\n });\n\n const isGrouped = row.getIsGrouped();\n\n const mergedRef = mergeRefs([ref, externalRef]);\n\n return (\n <>\n <tr {...attributes} className={className} ref={mergedRef}>\n {children}\n {row\n .getVisibleCells()\n // Filter out the row actions cell from rendering in Grouped Row\n .filter(cell => !(isGrouped && cell.column.id === '__actions'))\n .map((cell, cellIndex) => (\n <Cell key={cell.id} cell={cell} index={cellIndex} renderer={CellRenderer} />\n ))}\n </tr>\n {expandedRow ? (\n <tr data-row-parent-id={row.id} ref={expansionRef}>\n <td className=\"col-span-full\">{expandedRow}</td>\n </tr>\n ) : null}\n </>\n );\n })\n) as <TType = unknown>(props: DisplayRowProps<TType> & { ref?: React.Ref<HTMLTableRowElement> }) => JSX.Element;\n"],"names":["React","DisplayRow","_a","row","_b","_c"],"mappings":";;;;;;;AAgBO,MAAM,aAAaA,eAAM;AAAA,EAC5BA,eAAM,WAAiD,SAASC,YAC5D,OACA,aACF;;AACQ,UAAA;AAAA,MACF;AAAA,MACA,cAAc;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,wBAAwB,CAAC;AAAA,MACzB,GAAG;AAAA,IAAA,IACH;AACE,UAAA,YAAY,MAAM,QAAQ;AAEhC,UAAM,aAAkB;AAAA,MACpB,GAAG;AAAA,MACH,eAAe,IAAI;AAAA,MACnB,kBAAkB;AAAA,MAClB,UAAU;AAAA,IACd;AAEA,UAAM,cAAcD,eAAM;AAAA,MACtB,CAAC,UAAiD;;AAC9C,cAAM,iBAAiB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playRow.js","sources":["../../../../../../../src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport cn from 'clsx';\nimport { Cell } from '../../Columns/Cell/Cell';\nimport { TableRowRendererProps } from '../../../types';\nimport { TableRowWithMetaData } from '../../../../types';\nimport { isElementInteractive } from '../../../../../../utils/dom';\nimport { useDropTarget } from '../../../../../../utils/hooks/useDropTarget';\nimport { useResizeObserver } from '../../../../../../hooks/useResizeObserver';\nimport { mergeRefs } from '../../../../../../utils/mergeRefs';\n\nexport type DisplayRowProps<TType = unknown> = React.HTMLAttributes<HTMLTableRowElement> &\n TableRowRendererProps<TType> & {\n remeasureDependencies?: React.DependencyList;\n };\n\nexport const DisplayRow = React.memo(\n React.forwardRef<HTMLTableRowElement, DisplayRowProps>(function DisplayRow<TType = unknown>(\n props: DisplayRowProps<TType>,\n externalRef: React.Ref<HTMLTableRowElement>\n ) {\n const {\n children,\n cellRenderer: CellRenderer,\n index,\n measureRow,\n row,\n table,\n remeasureDependencies = [],\n ...otherAttributes\n } = props;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const attributes: any = {\n ...otherAttributes,\n 'data-row-id': row.id,\n 'data-row-index': index,\n tabIndex: -1,\n };\n\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLTableRowElement>) => {\n const clickedElement = event.target as HTMLElement;\n\n if (!event.currentTarget?.contains(event.target as HTMLElement) || isElementInteractive(clickedElement)) {\n return;\n }\n\n tableMeta.rowClick.handleClick(event, row.original);\n },\n [row.original]\n );\n const handlePointerDown = React.useCallback(() => {\n requestAnimationFrame(() => tableMeta.rowActive.setRowActiveIndex(index));\n }, [index]);\n\n // row active\n if (tableMeta.rowActive.isEnabled) {\n attributes['data-row-active'] = tableMeta.rowActive.rowActiveIndex === index ? true : undefined;\n // we use pointerdown because it let's us picks up clicks on components inside the row, e.g. checkboxes\n attributes.onPointerDown = handlePointerDown;\n }\n\n // row click\n if (tableMeta.rowClick.isEnabled(row.original)) {\n attributes.onClick = handleClick;\n }\n\n // row drag\n if (tableMeta.rowDrag.isEnabled) {\n attributes['aria-grabbed'] = !!tableMeta.rowDrag.dragging[row.id];\n attributes.draggable = true;\n const GHOST_ELEMENT_ID = 'taco_table_dragging';\n\n attributes.onDragStart = (event: React.DragEvent): void => {\n let rows = [row];\n\n if (row.getCanSelect()) {\n rows = row.getIsSelected() ? table.getSelectedRowModel().rows : [row, ...table.getSelectedRowModel().rows];\n }\n\n const data = rows.map(row => row.original);\n\n tableMeta.rowDrag.setDragging?.(\n rows.reduce((dragging, rowBeingDragged) => ({ ...dragging, [rowBeingDragged.id]: true }), {})\n );\n\n // set a default data value so that the consumer doesn't have to\n event.dataTransfer.setData('text', JSON.stringify(data));\n\n const showPlaceholder = (text: string) => {\n const ghost = document.createElement('div');\n ghost.id = GHOST_ELEMENT_ID;\n ghost.className = 'wcag-blue rounded flex w-48 p-4 absolute -ml-[100vw]';\n ghost.innerText = text;\n document.body.append(ghost);\n event.dataTransfer.setDragImage(ghost, 0, 0);\n };\n\n const setDataTransfer = (text: string) => event.dataTransfer.setData('text', text);\n\n tableMeta.rowDrag.handleRowDrag?.(data, showPlaceholder, setDataTransfer);\n };\n\n attributes.onDragEnd = (): void => {\n document.getElementById(GHOST_ELEMENT_ID)?.remove();\n tableMeta.rowDrag.setDragging?.({});\n };\n }\n\n // row drop\n const [isDraggedOver, dropTargetProps] = useDropTarget(event => tableMeta.rowDrop.handleDrop?.(event, row.original));\n\n if (tableMeta.rowDrop.isEnabled) {\n attributes.onDragEnter = dropTargetProps?.onDragEnter;\n attributes.onDragLeave = dropTargetProps?.onDragLeave;\n attributes.onDragOver = dropTargetProps?.onDragOver;\n attributes.onDrop = dropTargetProps?.onDrop;\n attributes['data-row-dragged-over'] = isDraggedOver;\n }\n\n // row grouping\n if (table.options.enableGrouping) {\n attributes['data-row-group'] = row.getIsGrouped() ? true : undefined;\n }\n\n // row selection\n if (row.getCanSelect()) {\n attributes['data-row-selected'] = row.getIsSelected() || row.getIsAllSubRowsSelected() ? true : undefined;\n }\n\n // row expansion\n // When grouping is enabled, a group header row also reports getIsExpanded() === true\n // when its children are visible. Skip the renderer in that case — otherwise row.original\n // (the first child's data) gets rendered as expansion content under the header.\n let expandedRow;\n\n if (tableMeta.rowExpansion.isEnabled && row.getIsExpanded() && !row.getIsGrouped()) {\n attributes['data-row-expanded'] = true;\n expandedRow = tableMeta.rowExpansion.rowExpansionRenderer?.(row.original)?.();\n }\n\n const rowMeta = (row.original as TableRowWithMetaData<TType>)._meta;\n\n if (rowMeta?.layout) {\n attributes['data-row-meta-layout'] = rowMeta.layout;\n }\n\n const ref = React.useRef<HTMLTableRowElement>(null);\n const expansionRef = React.useRef<HTMLTableRowElement>(null);\n const expandedRowSize = useResizeObserver(expansionRef, !!expandedRow);\n\n React.useEffect(() => {\n const rowHeight = ref.current?.getBoundingClientRect().height ?? 0;\n const expansionHeight = expansionRef.current?.getBoundingClientRect().height ?? 0;\n\n measureRow(rowHeight + expansionHeight);\n }, [expansionRef.current, expandedRowSize?.height, ...remeasureDependencies]);\n\n const className = cn('group/row', otherAttributes.className, {\n 'hover:cursor-grab': tableMeta.rowDrag.isEnabled && typeof attributes.onClick !== 'function',\n 'hover:cursor-pointer': typeof attributes.onClick === 'function',\n });\n\n const isGrouped = row.getIsGrouped();\n\n const mergedRef = mergeRefs([ref, externalRef]);\n\n return (\n <>\n <tr {...attributes} className={className} ref={mergedRef}>\n {children}\n {row\n .getVisibleCells()\n // Filter out the row actions cell from rendering in Grouped Row\n .filter(cell => !(isGrouped && cell.column.id === '__actions'))\n .map((cell, cellIndex) => (\n <Cell key={cell.id} cell={cell} index={cellIndex} renderer={CellRenderer} />\n ))}\n </tr>\n {expandedRow ? (\n <tr data-row-parent-id={row.id} ref={expansionRef}>\n <td className=\"col-span-full\">{expandedRow}</td>\n </tr>\n ) : null}\n </>\n );\n })\n) as <TType = unknown>(props: Dis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IAAI,aAAa;AAEnC,UAAM,YAAY,UAAU,CAAC,KAAK,WAAW,CAAC;AAG1C,WAAAJ,+BAAA,cAAAA,eAAA,UAAA,MACKA,+BAAA,cAAA,MAAA,EAAI,GAAG,YAAY,WAAsB,KAAK,UAAA,GAC1C,UACA,IACI,gBAAgB,EAEhB,OAAO,CAAQ,SAAA,EAAE,aAAa,KAAK,OAAO,OAAO,YAAY,EAC7D,IAAI,CAAC,MAAM,cACRA,+BAAA,cAAC,QAAK,KAAK,KAAK,IAAI,MAAY,OAAO,WAAW,UAAU,aAAc,CAAA,CAC7E,CACT,GACC,cACGA,+BAAA,cAAC,QAAG,sBAAoB,IAAI,IAAI,KAAK,aACjC,GAAAA,+BAAA,cAAC,MAAG,EAAA,WAAU,gBAAiB,GAAA,WAAY,CAC/C,IACA,IACR;AAAA,EAEP,CAAA;AACL;"}
@@ -114,7 +114,7 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
114
114
  return /* @__PURE__ */ React.createElement(SkeletonRow.SkeletonRow, { key: skeletonKey, index: virtualRow.index, table });
115
115
  }
116
116
  const measureRow = (rowHeight) => {
117
- virtualiser.resizeItem(virtualRow, rowHeight);
117
+ virtualiser.resizeItem(virtualRow.index, rowHeight);
118
118
  };
119
119
  return /* @__PURE__ */ React.createElement(
120
120
  Row.Row,
@@ -1 +1 @@
1
- {"version":3,"file":"useTableRenderer.cjs","sources":["../../../../../src/primitives/Table/Core/features/useTableRenderer.tsx"],"sourcesContent":["import React, { CSSProperties } from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta, Row as ReactTableRow } from '@tanstack/react-table';\nimport {\n useVirtualizer,\n defaultRangeExtractor,\n ScrollToOptions as ReactVirtualScrollToOptions,\n Range,\n} from '@tanstack/react-virtual';\nimport sortBy from 'lodash/sortBy';\nimport without from 'lodash/without';\n\nimport { ROW_HEIGHT_ESTIMATES } from '../util/rows';\nimport { Row } from '../components/Row/Row';\nimport { useTableRenderers } from '../types';\nimport { TableRef } from '../../types';\nimport { SkeletonRow } from '../components/Row/BuiltIns/SkeletonRow';\n\n// scroll padding end is designed to always show half of the next row\nfunction getScrollPaddingEndOffset<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n let offset = 2;\n\n if (tableMeta.footer.isEnabled) {\n offset += 1;\n }\n\n if (table.getHeaderGroups().length > 1) {\n offset += table.getHeaderGroups().length - 1;\n }\n\n let height = ROW_HEIGHT_ESTIMATES.medium * offset;\n\n const bottomRows = table.getBottomRows();\n\n if (bottomRows.length) {\n // 1.4 offsets for half rows and also accounts for increased row heights (which is likely in pinned rows)\n height += ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] * 1.4 * bottomRows.length;\n }\n\n return height;\n}\n\n// scroll padding end is designed to always show half of the next row\nfunction getPaddingEndOffset<TType = unknown>(table: ReactTable<TType>) {\n const bottomRows = table.getBottomRows() ?? [];\n return ROW_HEIGHT_ESTIMATES.medium * 1 * bottomRows.length;\n}\n\n// A higher number ensure less scroll jumping for dynamic row heights, but too high can reduce performance. 8 worked well\nconst OVERSCAN_ROW_COUNT = 8;\n\nexport function useTableRenderer<TType = unknown>(\n renderers: useTableRenderers<TType>,\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n length: number,\n defaultRowActiveIndex?: number | undefined\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const isTableRowGrouped = !!table.getState().grouping?.length;\n const rows = table.getCenterRows() ?? [];\n\n // row groups\n const rangeExtractor = useRowGroupVirtualisation<TType>(table);\n\n // account for thead and tfoot in the scroll area - both are always medium row height\n const scrollPaddingStart = ROW_HEIGHT_ESTIMATES.medium;\n\n const count = tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2 ? length : rows.length;\n\n const virtualiser = useVirtualizer({\n count,\n estimateSize: () => {\n return tableMeta.rowHeight.height ? ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] : ROW_HEIGHT_ESTIMATES.medium;\n },\n getScrollElement: () => tableRef.current,\n overscan: tableMeta.printing.isPrinting ? count : OVERSCAN_ROW_COUNT,\n rangeExtractor,\n // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list\n scrollPaddingStart,\n scrollPaddingEnd: getScrollPaddingEndOffset(table),\n paddingEnd: getPaddingEndOffset(table),\n });\n\n const expandedState = table.getState().expanded;\n const previousExpandedStateRef = React.useRef(false);\n\n React.useEffect(() => {\n // only remeasure when transitioning between expand all and not expand all\n const isEmpty = JSON.stringify(expandedState) === '{}';\n\n if (expandedState === true || (isEmpty && previousExpandedStateRef.current === true)) {\n previousExpandedStateRef.current = expandedState === true;\n virtualiser.measure();\n }\n }, [expandedState]);\n\n const totalSize = virtualiser.getTotalSize();\n const virtualItems = virtualiser.getVirtualItems();\n\n const scrollToIndex = React.useCallback(\n (index: number, options: ReactVirtualScrollToOptions = { align: 'auto', behavior: 'smooth' }) => {\n const notSmooth: ReactVirtualScrollToOptions = { ...options, behavior: 'auto' };\n\n if (tableRef.current) {\n if (index === 0) {\n virtualiser.scrollToOffset(0, notSmooth);\n } else if (index === count - 1) {\n // sometimes the last row doesn't fully show, so we just force scroll to the bottom\n tableRef.current.scrollTop = tableRef.current.scrollHeight;\n } else {\n virtualiser.scrollToIndex(index, options);\n }\n }\n },\n [virtualItems.length, tableRef.current, totalSize, count]\n );\n\n // use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0\n const paddingStartIndex = isTableRowGrouped && count > 1 ? 1 : 0;\n\n const startValue = isTableRowGrouped\n ? (virtualItems[paddingStartIndex]?.start ?? 0) - (virtualItems[paddingStartIndex]?.size ?? 0)\n : virtualItems[paddingStartIndex]?.start;\n\n // styling for offsetting rows - this \"is\" the virtualisation\n const [paddingTop, paddingBottom] =\n virtualItems.length > 0\n ? [Math.max(0, startValue ?? 0), Math.max(0, totalSize - (virtualItems[virtualItems.length - 1]?.end ?? 0))]\n : [0, 0];\n\n // ensure default active rows are scrolled to\n React.useEffect(() => {\n if (defaultRowActiveIndex) {\n scrollToIndex(defaultRowActiveIndex, { align: 'center', behavior: 'auto' });\n }\n }, []);\n\n // rendered output\n let style: CSSProperties = {};\n let content: (JSX.Element | null)[] | null = null;\n\n // bottom rows aren't virtualised (they're sticky) but we need to set the height\n if (count || table.getBottomRows().length) {\n style = {\n height: totalSize,\n paddingBottom: Number.isNaN(paddingBottom) ? 0 : paddingBottom,\n paddingTop: Number.isNaN(paddingTop) ? 0 : paddingTop,\n };\n }\n\n // only render non sticky rows\n if (count) {\n content = virtualItems.map(virtualRow => {\n // there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here\n if (!virtualRow) {\n return null;\n }\n\n let row: ReactTableRow<TType> | undefined;\n\n if (tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2) {\n const currentPageIndex =\n (Math.floor(virtualRow.index / tableMeta.server.pageSize) * tableMeta.server.pageSize) /\n tableMeta.server.pageSize;\n const pagePosition = tableMeta.server.pages?.indexOf(currentPageIndex) ?? -1;\n\n if (pagePosition > -1) {\n // \"flatten\" row indexes down into the dataloader2 dataset size\n // for example, with a page size of 100...\n // row index 14267 is actually one of index 67, 167, 267 etc within the dataset (depending on number of pages stored)\n const fakeIndex = pagePosition * tableMeta.server.pageSize + (virtualRow.index % tableMeta.server.pageSize);\n row = rows[fakeIndex];\n }\n } else {\n row = rows[virtualRow.index];\n }\n\n if (!row?.original) {\n // Prefix skeleton keys to prevent collision with real data row keys\n const skeletonKey = `skeleton-${virtualRow.index}`;\n return <SkeletonRow key={skeletonKey} index={virtualRow.index} table={table} />;\n }\n\n const measureRow = (rowHeight: number) => {\n virtualiser.resizeItem(virtualRow, rowHeight);\n };\n\n return (\n <Row\n key={row.id}\n row={row}\n index={virtualRow.index}\n table={table}\n measureRow={measureRow}\n renderer={renderers.row}\n cellRenderer={renderers.cell}\n />\n );\n });\n }\n\n return {\n rows: content,\n style,\n scrollToIndex,\n };\n}\n\n// support virtualised row groups (where the row group headers are sticky)\nfunction useRowGroupVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const rows = table.getRowModel().rows;\n const isTableGrouped = !!table.getState().grouping.length;\n\n const rowGroupIndexes = React.useMemo(() => {\n const indexes: number[] = [];\n\n if (isTableGrouped) {\n rows.forEach((row, index) => {\n if (row.getIsGrouped()) {\n indexes.push(index);\n }\n });\n }\n\n return indexes;\n }, [rows]);\n\n // this is taken from the react-virtual docs/examples\n const rangeExtractor = React.useCallback(\n (range: Range) => {\n const activeRowGroupIndex =\n [...rowGroupIndexes].reverse().find(index => range.startIndex >= index) ?? rowGroupIndexes[0];\n\n return activeRowGroupIndex === undefined\n ? defaultRangeExtractor(range)\n : sortBy([activeRowGroupIndex, ...without(defaultRangeExtractor(range), activeRowGroupIndex)], a => a);\n },\n [rowGroupIndexes]\n );\n\n return isTableGrouped ? rangeExtractor : undefined;\n}\n"],"names":["ROW_HEIGHT_ESTIMATES","rows","useVirtualizer","_a","SkeletonRow","Row","defaultRangeExtractor"],"mappings":";;;;;;;;;AAkBA,SAAS,0BAA2C,OAA0B;AACpE,QAAA,YAAY,MAAM,QAAQ;AAChC,MAAI,SAAS;AAET,MAAA,UAAU,OAAO,WAAW;AAClB,cAAA;AAAA,EAAA;AAGd,MAAI,MAAM,kBAAkB,SAAS,GAAG;AAC1B,cAAA,MAAM,gBAAgB,EAAE,SAAS;AAAA,EAAA;AAG3C,MAAA,SAASA,0BAAqB,SAAS;AAErC,QAAA,aAAa,MAAM,cAAc;AAEvC,MAAI,WAAW,QAAQ;AAEnB,cAAUA,0BAAqB,UAAU,UAAU,MAAM,IAAI,MAAM,WAAW;AAAA,EAAA;AAG3E,SAAA;AACX;AAGA,SAAS,oBAAqC,OAA0B;AACpE,QAAM,aAAa,MAAM,cAAc,KAAK,CAAC;AACtC,SAAAA,0BAAqB,SAAS,IAAI,WAAW;AACxD;AAGA,MAAM,qBAAqB;AAEpB,SAAS,iBACZ,WACA,OACA,UACA,QACA,uBACF;;AACQ,QAAA,YAAY,MAAM,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AACd,YAAM,sBACF,CAAC,GAAG,eAAe,EAAE,QAAQ,EAAE,KAAK,CAAA,UAAS,MAAM,cAAc,KAAK,KAAK,gBAAgB,CAAC;AAEhG,aAAO,wBAAwB,SACzBK,aAAAA,sBAAsB,KAAK,IAC3B,OAAO,CAAC,qBAAqB,GAAG,QAAQA,aAAAA,sBAAsB,KAAK,GAAG,mBAAmB,CAAC,GAAG,OAAK,CAAC;AAAA,IAC7G;AAAA,IACA,CAAC,eAAe;AAAA,EACpB;AAEA,SAAO,iBAAiB,iBAAiB;AAC7C;;"}
1
+ {"version":3,"file":"useTableRenderer.cjs","sources":["../../../../../src/primitives/Table/Core/features/useTableRenderer.tsx"],"sourcesContent":["import React, { CSSProperties } from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta, Row as ReactTableRow } from '@tanstack/react-table';\nimport {\n useVirtualizer,\n defaultRangeExtractor,\n ScrollToOptions as ReactVirtualScrollToOptions,\n Range,\n} from '@tanstack/react-virtual';\nimport sortBy from 'lodash/sortBy';\nimport without from 'lodash/without';\n\nimport { ROW_HEIGHT_ESTIMATES } from '../util/rows';\nimport { Row } from '../components/Row/Row';\nimport { useTableRenderers } from '../types';\nimport { TableRef } from '../../types';\nimport { SkeletonRow } from '../components/Row/BuiltIns/SkeletonRow';\n\n// scroll padding end is designed to always show half of the next row\nfunction getScrollPaddingEndOffset<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n let offset = 2;\n\n if (tableMeta.footer.isEnabled) {\n offset += 1;\n }\n\n if (table.getHeaderGroups().length > 1) {\n offset += table.getHeaderGroups().length - 1;\n }\n\n let height = ROW_HEIGHT_ESTIMATES.medium * offset;\n\n const bottomRows = table.getBottomRows();\n\n if (bottomRows.length) {\n // 1.4 offsets for half rows and also accounts for increased row heights (which is likely in pinned rows)\n height += ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] * 1.4 * bottomRows.length;\n }\n\n return height;\n}\n\n// scroll padding end is designed to always show half of the next row\nfunction getPaddingEndOffset<TType = unknown>(table: ReactTable<TType>) {\n const bottomRows = table.getBottomRows() ?? [];\n return ROW_HEIGHT_ESTIMATES.medium * 1 * bottomRows.length;\n}\n\n// A higher number ensure less scroll jumping for dynamic row heights, but too high can reduce performance. 8 worked well\nconst OVERSCAN_ROW_COUNT = 8;\n\nexport function useTableRenderer<TType = unknown>(\n renderers: useTableRenderers<TType>,\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n length: number,\n defaultRowActiveIndex?: number | undefined\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const isTableRowGrouped = !!table.getState().grouping?.length;\n const rows = table.getCenterRows() ?? [];\n\n // row groups\n const rangeExtractor = useRowGroupVirtualisation<TType>(table);\n\n // account for thead and tfoot in the scroll area - both are always medium row height\n const scrollPaddingStart = ROW_HEIGHT_ESTIMATES.medium;\n\n const count = tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2 ? length : rows.length;\n\n const virtualiser = useVirtualizer({\n count,\n estimateSize: () => {\n return tableMeta.rowHeight.height ? ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] : ROW_HEIGHT_ESTIMATES.medium;\n },\n getScrollElement: () => tableRef.current,\n overscan: tableMeta.printing.isPrinting ? count : OVERSCAN_ROW_COUNT,\n rangeExtractor,\n // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list\n scrollPaddingStart,\n scrollPaddingEnd: getScrollPaddingEndOffset(table),\n paddingEnd: getPaddingEndOffset(table),\n });\n\n const expandedState = table.getState().expanded;\n const previousExpandedStateRef = React.useRef(false);\n\n React.useEffect(() => {\n // only remeasure when transitioning between expand all and not expand all\n const isEmpty = JSON.stringify(expandedState) === '{}';\n\n if (expandedState === true || (isEmpty && previousExpandedStateRef.current === true)) {\n previousExpandedStateRef.current = expandedState === true;\n virtualiser.measure();\n }\n }, [expandedState]);\n\n const totalSize = virtualiser.getTotalSize();\n const virtualItems = virtualiser.getVirtualItems();\n\n const scrollToIndex = React.useCallback(\n (index: number, options: ReactVirtualScrollToOptions = { align: 'auto', behavior: 'smooth' }) => {\n const notSmooth: ReactVirtualScrollToOptions = { ...options, behavior: 'auto' };\n\n if (tableRef.current) {\n if (index === 0) {\n virtualiser.scrollToOffset(0, notSmooth);\n } else if (index === count - 1) {\n // sometimes the last row doesn't fully show, so we just force scroll to the bottom\n tableRef.current.scrollTop = tableRef.current.scrollHeight;\n } else {\n virtualiser.scrollToIndex(index, options);\n }\n }\n },\n [virtualItems.length, tableRef.current, totalSize, count]\n );\n\n // use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0\n const paddingStartIndex = isTableRowGrouped && count > 1 ? 1 : 0;\n\n const startValue = isTableRowGrouped\n ? (virtualItems[paddingStartIndex]?.start ?? 0) - (virtualItems[paddingStartIndex]?.size ?? 0)\n : virtualItems[paddingStartIndex]?.start;\n\n // styling for offsetting rows - this \"is\" the virtualisation\n const [paddingTop, paddingBottom] =\n virtualItems.length > 0\n ? [Math.max(0, startValue ?? 0), Math.max(0, totalSize - (virtualItems[virtualItems.length - 1]?.end ?? 0))]\n : [0, 0];\n\n // ensure default active rows are scrolled to\n React.useEffect(() => {\n if (defaultRowActiveIndex) {\n scrollToIndex(defaultRowActiveIndex, { align: 'center', behavior: 'auto' });\n }\n }, []);\n\n // rendered output\n let style: CSSProperties = {};\n let content: (JSX.Element | null)[] | null = null;\n\n // bottom rows aren't virtualised (they're sticky) but we need to set the height\n if (count || table.getBottomRows().length) {\n style = {\n height: totalSize,\n paddingBottom: Number.isNaN(paddingBottom) ? 0 : paddingBottom,\n paddingTop: Number.isNaN(paddingTop) ? 0 : paddingTop,\n };\n }\n\n // only render non sticky rows\n if (count) {\n content = virtualItems.map(virtualRow => {\n // there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here\n if (!virtualRow) {\n return null;\n }\n\n let row: ReactTableRow<TType> | undefined;\n\n if (tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2) {\n const currentPageIndex =\n (Math.floor(virtualRow.index / tableMeta.server.pageSize) * tableMeta.server.pageSize) /\n tableMeta.server.pageSize;\n const pagePosition = tableMeta.server.pages?.indexOf(currentPageIndex) ?? -1;\n\n if (pagePosition > -1) {\n // \"flatten\" row indexes down into the dataloader2 dataset size\n // for example, with a page size of 100...\n // row index 14267 is actually one of index 67, 167, 267 etc within the dataset (depending on number of pages stored)\n const fakeIndex = pagePosition * tableMeta.server.pageSize + (virtualRow.index % tableMeta.server.pageSize);\n row = rows[fakeIndex];\n }\n } else {\n row = rows[virtualRow.index];\n }\n\n if (!row?.original) {\n // Prefix skeleton keys to prevent collision with real data row keys\n const skeletonKey = `skeleton-${virtualRow.index}`;\n return <SkeletonRow key={skeletonKey} index={virtualRow.index} table={table} />;\n }\n\n const measureRow = (rowHeight: number) => {\n virtualiser.resizeItem(virtualRow.index, rowHeight);\n };\n\n return (\n <Row\n key={row.id}\n row={row}\n index={virtualRow.index}\n table={table}\n measureRow={measureRow}\n renderer={renderers.row}\n cellRenderer={renderers.cell}\n />\n );\n });\n }\n\n return {\n rows: content,\n style,\n scrollToIndex,\n };\n}\n\n// support virtualised row groups (where the row group headers are sticky)\nfunction useRowGroupVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const rows = table.getRowModel().rows;\n const isTableGrouped = !!table.getState().grouping.length;\n\n const rowGroupIndexes = React.useMemo(() => {\n const indexes: number[] = [];\n\n if (isTableGrouped) {\n rows.forEach((row, index) => {\n if (row.getIsGrouped()) {\n indexes.push(index);\n }\n });\n }\n\n return indexes;\n }, [rows]);\n\n // this is taken from the react-virtual docs/examples\n const rangeExtractor = React.useCallback(\n (range: Range) => {\n const activeRowGroupIndex =\n [...rowGroupIndexes].reverse().find(index => range.startIndex >= index) ?? rowGroupIndexes[0];\n\n return activeRowGroupIndex === undefined\n ? defaultRangeExtractor(range)\n : sortBy([activeRowGroupIndex, ...without(defaultRangeExtractor(range), activeRowGroupIndex)], a => a);\n },\n [rowGroupIndexes]\n );\n\n return isTableGrouped ? rangeExtractor : undefined;\n}\n"],"names":["ROW_HEIGHT_ESTIMATES","rows","useVirtualizer","_a","SkeletonRow","Row","defaultRangeExtractor"],"mappings":";;;;;;;;;AAkBA,SAAS,0BAA2C,OAA0B;AACpE,QAAA,YAAY,MAAM,QAAQ;AAChC,MAAI,SAAS;AAET,MAAA,UAAU,OAAO,WAAW;AAClB,cAAA;AAAA,EAAA;AAGd,MAAI,MAAM,kBAAkB,SAAS,GAAG;AAC1B,cAAA,MAAM,gBAAgB,EAAE,SAAS;AAAA,EAAA;AAG3C,MAAA,SAASA,0BAAqB,SAAS;AAErC,QAAA,aAAa,MAAM,cAAc;AAEvC,MAAI,WAAW,QAAQ;AAEnB,cAAUA,0BAAqB,UAAU,UAAU,MAAM,IAAI,MAAM,WAAW;AAAA,EAAA;AAG3E,SAAA;AACX;AAGA,SAAS,oBAAqC,OAA0B;AACpE,QAAM,aAAa,MAAM,cAAc,KAAK,CAAC;AACtC,SAAAA,0BAAqB,SAAS,IAAI,WAAW;AACxD;AAGA,MAAM,qBAAqB;AAEpB,SAAS,iBACZ,WACA,OACA,UACA,QACA,uBACF;;AACQ,QAAA,YAAY,MAAM,QAAQ;AAChC,QAAM,oBAAoB,CAAC,GAAC,WAAM,WAAW,aAAjB,mBAA2B;AACvD,QAAMC,SAAO,MAAM,cAAc,KAAK,CAAC;AAGjC,QAAA,iBAAiB,0BAAiC,KAAK;AAG7D,QAAM,qBAAqBD,KAAAA,qBAAqB;AAE1C,QAAA,QAAQ,UAAU,OAAO,aAAa,UAAU,OAAO,2BAA2B,SAASC,OAAK;AAEtG,QAAM,cAAcC,aAAAA,eAAe;AAAA,IAC/B;AAAA,IACA,cAAc,MAAM;AACT,aAAA,UAAU,UAAU,SAASF,KAAA,qBAAqB,UAAU,UAAU,MAAM,IAAIA,KAAAA,qBAAqB;AAAA,IAChH;AAAA,IACA,kBAAkB,MAAM,SAAS;AAAA,IACjC,UAAU,UAAU,SAAS,a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;AAAA,MACtD;AAGI,aAAA,sBAAA;AAAA,QAACC,IAAA;AAAA,QAAA;AAAA,UACG,KAAK,IAAI;AAAA,UACT;AAAA,UACA,OAAO,WAAW;AAAA,UAClB;AAAA,UACA;AAAA,UACA,UAAU,UAAU;AAAA,UACpB,cAAc,UAAU;AAAA,QAAA;AAAA,MAC5B;AAAA,IAAA,CAEP;AAAA,EAAA;AAGE,SAAA;AAAA,IACH,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACJ;AACJ;AAGA,SAAS,0BAA2C,OAA0B;AACpE,QAAAJ,QAAO,MAAM,YAAA,EAAc;AACjC,QAAM,iBAAiB,CAAC,CAAC,MAAM,WAAW,SAAS;AAE7C,QAAA,kBAAkB,MAAM,QAAQ,MAAM;AACxC,UAAM,UAAoB,CAAC;AAE3B,QAAI,gBAAgB;AACX,MAAAA,MAAA,QAAQ,CAAC,KAAK,UAAU;AACrB,YAAA,IAAI,gBAAgB;AACpB,kBAAQ,KAAK,KAAK;AAAA,QAAA;AAAA,MACtB,CACH;AAAA,IAAA;AAGE,WAAA;AAAA,EAAA,GACR,CAACA,KAAI,CAAC;AAGT,QAAM,iBAAiB,MAAM;AAAA,IACzB,CAAC,UAAiB;AACd,YAAM,sBACF,CAAC,GAAG,eAAe,EAAE,QAAQ,EAAE,KAAK,CAAA,UAAS,MAAM,cAAc,KAAK,KAAK,gBAAgB,CAAC;AAEhG,aAAO,wBAAwB,SACzBK,aAAAA,sBAAsB,KAAK,IAC3B,OAAO,CAAC,qBAAqB,GAAG,QAAQA,aAAAA,sBAAsB,KAAK,GAAG,mBAAmB,CAAC,GAAG,OAAK,CAAC;AAAA,IAC7G;AAAA,IACA,CAAC,eAAe;AAAA,EACpB;AAEA,SAAO,iBAAiB,iBAAiB;AAC7C;;"}
@@ -112,7 +112,7 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
112
112
  return /* @__PURE__ */ React__default.createElement(SkeletonRow, { key: skeletonKey, index: virtualRow.index, table });
113
113
  }
114
114
  const measureRow = (rowHeight) => {
115
- virtualiser.resizeItem(virtualRow, rowHeight);
115
+ virtualiser.resizeItem(virtualRow.index, rowHeight);
116
116
  };
117
117
  return /* @__PURE__ */ React__default.createElement(
118
118
  Row,
@@ -1 +1 @@
1
- {"version":3,"file":"useTableRenderer.js","sources":["../../../../../src/primitives/Table/Core/features/useTableRenderer.tsx"],"sourcesContent":["import React, { CSSProperties } from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta, Row as ReactTableRow } from '@tanstack/react-table';\nimport {\n useVirtualizer,\n defaultRangeExtractor,\n ScrollToOptions as ReactVirtualScrollToOptions,\n Range,\n} from '@tanstack/react-virtual';\nimport sortBy from 'lodash/sortBy';\nimport without from 'lodash/without';\n\nimport { ROW_HEIGHT_ESTIMATES } from '../util/rows';\nimport { Row } from '../components/Row/Row';\nimport { useTableRenderers } from '../types';\nimport { TableRef } from '../../types';\nimport { SkeletonRow } from '../components/Row/BuiltIns/SkeletonRow';\n\n// scroll padding end is designed to always show half of the next row\nfunction getScrollPaddingEndOffset<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n let offset = 2;\n\n if (tableMeta.footer.isEnabled) {\n offset += 1;\n }\n\n if (table.getHeaderGroups().length > 1) {\n offset += table.getHeaderGroups().length - 1;\n }\n\n let height = ROW_HEIGHT_ESTIMATES.medium * offset;\n\n const bottomRows = table.getBottomRows();\n\n if (bottomRows.length) {\n // 1.4 offsets for half rows and also accounts for increased row heights (which is likely in pinned rows)\n height += ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] * 1.4 * bottomRows.length;\n }\n\n return height;\n}\n\n// scroll padding end is designed to always show half of the next row\nfunction getPaddingEndOffset<TType = unknown>(table: ReactTable<TType>) {\n const bottomRows = table.getBottomRows() ?? [];\n return ROW_HEIGHT_ESTIMATES.medium * 1 * bottomRows.length;\n}\n\n// A higher number ensure less scroll jumping for dynamic row heights, but too high can reduce performance. 8 worked well\nconst OVERSCAN_ROW_COUNT = 8;\n\nexport function useTableRenderer<TType = unknown>(\n renderers: useTableRenderers<TType>,\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n length: number,\n defaultRowActiveIndex?: number | undefined\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const isTableRowGrouped = !!table.getState().grouping?.length;\n const rows = table.getCenterRows() ?? [];\n\n // row groups\n const rangeExtractor = useRowGroupVirtualisation<TType>(table);\n\n // account for thead and tfoot in the scroll area - both are always medium row height\n const scrollPaddingStart = ROW_HEIGHT_ESTIMATES.medium;\n\n const count = tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2 ? length : rows.length;\n\n const virtualiser = useVirtualizer({\n count,\n estimateSize: () => {\n return tableMeta.rowHeight.height ? ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] : ROW_HEIGHT_ESTIMATES.medium;\n },\n getScrollElement: () => tableRef.current,\n overscan: tableMeta.printing.isPrinting ? count : OVERSCAN_ROW_COUNT,\n rangeExtractor,\n // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list\n scrollPaddingStart,\n scrollPaddingEnd: getScrollPaddingEndOffset(table),\n paddingEnd: getPaddingEndOffset(table),\n });\n\n const expandedState = table.getState().expanded;\n const previousExpandedStateRef = React.useRef(false);\n\n React.useEffect(() => {\n // only remeasure when transitioning between expand all and not expand all\n const isEmpty = JSON.stringify(expandedState) === '{}';\n\n if (expandedState === true || (isEmpty && previousExpandedStateRef.current === true)) {\n previousExpandedStateRef.current = expandedState === true;\n virtualiser.measure();\n }\n }, [expandedState]);\n\n const totalSize = virtualiser.getTotalSize();\n const virtualItems = virtualiser.getVirtualItems();\n\n const scrollToIndex = React.useCallback(\n (index: number, options: ReactVirtualScrollToOptions = { align: 'auto', behavior: 'smooth' }) => {\n const notSmooth: ReactVirtualScrollToOptions = { ...options, behavior: 'auto' };\n\n if (tableRef.current) {\n if (index === 0) {\n virtualiser.scrollToOffset(0, notSmooth);\n } else if (index === count - 1) {\n // sometimes the last row doesn't fully show, so we just force scroll to the bottom\n tableRef.current.scrollTop = tableRef.current.scrollHeight;\n } else {\n virtualiser.scrollToIndex(index, options);\n }\n }\n },\n [virtualItems.length, tableRef.current, totalSize, count]\n );\n\n // use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0\n const paddingStartIndex = isTableRowGrouped && count > 1 ? 1 : 0;\n\n const startValue = isTableRowGrouped\n ? (virtualItems[paddingStartIndex]?.start ?? 0) - (virtualItems[paddingStartIndex]?.size ?? 0)\n : virtualItems[paddingStartIndex]?.start;\n\n // styling for offsetting rows - this \"is\" the virtualisation\n const [paddingTop, paddingBottom] =\n virtualItems.length > 0\n ? [Math.max(0, startValue ?? 0), Math.max(0, totalSize - (virtualItems[virtualItems.length - 1]?.end ?? 0))]\n : [0, 0];\n\n // ensure default active rows are scrolled to\n React.useEffect(() => {\n if (defaultRowActiveIndex) {\n scrollToIndex(defaultRowActiveIndex, { align: 'center', behavior: 'auto' });\n }\n }, []);\n\n // rendered output\n let style: CSSProperties = {};\n let content: (JSX.Element | null)[] | null = null;\n\n // bottom rows aren't virtualised (they're sticky) but we need to set the height\n if (count || table.getBottomRows().length) {\n style = {\n height: totalSize,\n paddingBottom: Number.isNaN(paddingBottom) ? 0 : paddingBottom,\n paddingTop: Number.isNaN(paddingTop) ? 0 : paddingTop,\n };\n }\n\n // only render non sticky rows\n if (count) {\n content = virtualItems.map(virtualRow => {\n // there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here\n if (!virtualRow) {\n return null;\n }\n\n let row: ReactTableRow<TType> | undefined;\n\n if (tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2) {\n const currentPageIndex =\n (Math.floor(virtualRow.index / tableMeta.server.pageSize) * tableMeta.server.pageSize) /\n tableMeta.server.pageSize;\n const pagePosition = tableMeta.server.pages?.indexOf(currentPageIndex) ?? -1;\n\n if (pagePosition > -1) {\n // \"flatten\" row indexes down into the dataloader2 dataset size\n // for example, with a page size of 100...\n // row index 14267 is actually one of index 67, 167, 267 etc within the dataset (depending on number of pages stored)\n const fakeIndex = pagePosition * tableMeta.server.pageSize + (virtualRow.index % tableMeta.server.pageSize);\n row = rows[fakeIndex];\n }\n } else {\n row = rows[virtualRow.index];\n }\n\n if (!row?.original) {\n // Prefix skeleton keys to prevent collision with real data row keys\n const skeletonKey = `skeleton-${virtualRow.index}`;\n return <SkeletonRow key={skeletonKey} index={virtualRow.index} table={table} />;\n }\n\n const measureRow = (rowHeight: number) => {\n virtualiser.resizeItem(virtualRow, rowHeight);\n };\n\n return (\n <Row\n key={row.id}\n row={row}\n index={virtualRow.index}\n table={table}\n measureRow={measureRow}\n renderer={renderers.row}\n cellRenderer={renderers.cell}\n />\n );\n });\n }\n\n return {\n rows: content,\n style,\n scrollToIndex,\n };\n}\n\n// support virtualised row groups (where the row group headers are sticky)\nfunction useRowGroupVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const rows = table.getRowModel().rows;\n const isTableGrouped = !!table.getState().grouping.length;\n\n const rowGroupIndexes = React.useMemo(() => {\n const indexes: number[] = [];\n\n if (isTableGrouped) {\n rows.forEach((row, index) => {\n if (row.getIsGrouped()) {\n indexes.push(index);\n }\n });\n }\n\n return indexes;\n }, [rows]);\n\n // this is taken from the react-virtual docs/examples\n const rangeExtractor = React.useCallback(\n (range: Range) => {\n const activeRowGroupIndex =\n [...rowGroupIndexes].reverse().find(index => range.startIndex >= index) ?? rowGroupIndexes[0];\n\n return activeRowGroupIndex === undefined\n ? defaultRangeExtractor(range)\n : sortBy([activeRowGroupIndex, ...without(defaultRangeExtractor(range), activeRowGroupIndex)], a => a);\n },\n [rowGroupIndexes]\n );\n\n return isTableGrouped ? rangeExtractor : undefined;\n}\n"],"names":["React","_a"],"mappings":";;;;;;;AAkBA,SAAS,0BAA2C,OAA0B;AACpE,QAAA,YAAY,MAAM,QAAQ;AAChC,MAAI,SAAS;AAET,MAAA,UAAU,OAAO,WAAW;AAClB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A,EACJ;AACJ;AAGA,SAAS,0BAA2C,OAA0B;AACpE,QAAA,OAAO,MAAM,YAAA,EAAc;AACjC,QAAM,iBAAiB,CAAC,CAAC,MAAM,WAAW,SAAS;AAE7C,QAAA,kBAAkBA,eAAM,QAAQ,MAAM;AACxC,UAAM,UAAoB,CAAC;AAE3B,QAAI,gBAAgB;AACX,WAAA,QAAQ,CAAC,KAAK,UAAU;AACrB,YAAA,IAAI,gBAAgB;AACpB,kBAAQ,KAAK,KAAK;AAAA,QAAA;AAAA,MACtB,CACH;AAAA,IAAA;AAGE,WAAA;AAAA,EAAA,GACR,CAAC,IAAI,CAAC;AAGT,QAAM,iBAAiBA,eAAM;AAAA,IACzB,CAAC,UAAiB;AACd,YAAM,sBACF,CAAC,GAAG,eAAe,EAAE,QAAQ,EAAE,KAAK,CAAA,UAAS,MAAM,cAAc,KAAK,KAAK,gBAAgB,CAAC;AAEhG,aAAO,wBAAwB,SACzB,sBAAsB,KAAK,IAC3B,OAAO,CAAC,qBAAqB,GAAG,QAAQ,sBAAsB,KAAK,GAAG,mBAAmB,CAAC,GAAG,OAAK,CAAC;AAAA,IAC7G;AAAA,IACA,CAAC,eAAe;AAAA,EACpB;AAEA,SAAO,iBAAiB,iBAAiB;AAC7C;"}
1
+ {"version":3,"file":"useTableRenderer.js","sources":["../../../../../src/primitives/Table/Core/features/useTableRenderer.tsx"],"sourcesContent":["import React, { CSSProperties } from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta, Row as ReactTableRow } from '@tanstack/react-table';\nimport {\n useVirtualizer,\n defaultRangeExtractor,\n ScrollToOptions as ReactVirtualScrollToOptions,\n Range,\n} from '@tanstack/react-virtual';\nimport sortBy from 'lodash/sortBy';\nimport without from 'lodash/without';\n\nimport { ROW_HEIGHT_ESTIMATES } from '../util/rows';\nimport { Row } from '../components/Row/Row';\nimport { useTableRenderers } from '../types';\nimport { TableRef } from '../../types';\nimport { SkeletonRow } from '../components/Row/BuiltIns/SkeletonRow';\n\n// scroll padding end is designed to always show half of the next row\nfunction getScrollPaddingEndOffset<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n let offset = 2;\n\n if (tableMeta.footer.isEnabled) {\n offset += 1;\n }\n\n if (table.getHeaderGroups().length > 1) {\n offset += table.getHeaderGroups().length - 1;\n }\n\n let height = ROW_HEIGHT_ESTIMATES.medium * offset;\n\n const bottomRows = table.getBottomRows();\n\n if (bottomRows.length) {\n // 1.4 offsets for half rows and also accounts for increased row heights (which is likely in pinned rows)\n height += ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] * 1.4 * bottomRows.length;\n }\n\n return height;\n}\n\n// scroll padding end is designed to always show half of the next row\nfunction getPaddingEndOffset<TType = unknown>(table: ReactTable<TType>) {\n const bottomRows = table.getBottomRows() ?? [];\n return ROW_HEIGHT_ESTIMATES.medium * 1 * bottomRows.length;\n}\n\n// A higher number ensure less scroll jumping for dynamic row heights, but too high can reduce performance. 8 worked well\nconst OVERSCAN_ROW_COUNT = 8;\n\nexport function useTableRenderer<TType = unknown>(\n renderers: useTableRenderers<TType>,\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n length: number,\n defaultRowActiveIndex?: number | undefined\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const isTableRowGrouped = !!table.getState().grouping?.length;\n const rows = table.getCenterRows() ?? [];\n\n // row groups\n const rangeExtractor = useRowGroupVirtualisation<TType>(table);\n\n // account for thead and tfoot in the scroll area - both are always medium row height\n const scrollPaddingStart = ROW_HEIGHT_ESTIMATES.medium;\n\n const count = tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2 ? length : rows.length;\n\n const virtualiser = useVirtualizer({\n count,\n estimateSize: () => {\n return tableMeta.rowHeight.height ? ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] : ROW_HEIGHT_ESTIMATES.medium;\n },\n getScrollElement: () => tableRef.current,\n overscan: tableMeta.printing.isPrinting ? count : OVERSCAN_ROW_COUNT,\n rangeExtractor,\n // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list\n scrollPaddingStart,\n scrollPaddingEnd: getScrollPaddingEndOffset(table),\n paddingEnd: getPaddingEndOffset(table),\n });\n\n const expandedState = table.getState().expanded;\n const previousExpandedStateRef = React.useRef(false);\n\n React.useEffect(() => {\n // only remeasure when transitioning between expand all and not expand all\n const isEmpty = JSON.stringify(expandedState) === '{}';\n\n if (expandedState === true || (isEmpty && previousExpandedStateRef.current === true)) {\n previousExpandedStateRef.current = expandedState === true;\n virtualiser.measure();\n }\n }, [expandedState]);\n\n const totalSize = virtualiser.getTotalSize();\n const virtualItems = virtualiser.getVirtualItems();\n\n const scrollToIndex = React.useCallback(\n (index: number, options: ReactVirtualScrollToOptions = { align: 'auto', behavior: 'smooth' }) => {\n const notSmooth: ReactVirtualScrollToOptions = { ...options, behavior: 'auto' };\n\n if (tableRef.current) {\n if (index === 0) {\n virtualiser.scrollToOffset(0, notSmooth);\n } else if (index === count - 1) {\n // sometimes the last row doesn't fully show, so we just force scroll to the bottom\n tableRef.current.scrollTop = tableRef.current.scrollHeight;\n } else {\n virtualiser.scrollToIndex(index, options);\n }\n }\n },\n [virtualItems.length, tableRef.current, totalSize, count]\n );\n\n // use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0\n const paddingStartIndex = isTableRowGrouped && count > 1 ? 1 : 0;\n\n const startValue = isTableRowGrouped\n ? (virtualItems[paddingStartIndex]?.start ?? 0) - (virtualItems[paddingStartIndex]?.size ?? 0)\n : virtualItems[paddingStartIndex]?.start;\n\n // styling for offsetting rows - this \"is\" the virtualisation\n const [paddingTop, paddingBottom] =\n virtualItems.length > 0\n ? [Math.max(0, startValue ?? 0), Math.max(0, totalSize - (virtualItems[virtualItems.length - 1]?.end ?? 0))]\n : [0, 0];\n\n // ensure default active rows are scrolled to\n React.useEffect(() => {\n if (defaultRowActiveIndex) {\n scrollToIndex(defaultRowActiveIndex, { align: 'center', behavior: 'auto' });\n }\n }, []);\n\n // rendered output\n let style: CSSProperties = {};\n let content: (JSX.Element | null)[] | null = null;\n\n // bottom rows aren't virtualised (they're sticky) but we need to set the height\n if (count || table.getBottomRows().length) {\n style = {\n height: totalSize,\n paddingBottom: Number.isNaN(paddingBottom) ? 0 : paddingBottom,\n paddingTop: Number.isNaN(paddingTop) ? 0 : paddingTop,\n };\n }\n\n // only render non sticky rows\n if (count) {\n content = virtualItems.map(virtualRow => {\n // there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here\n if (!virtualRow) {\n return null;\n }\n\n let row: ReactTableRow<TType> | undefined;\n\n if (tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2) {\n const currentPageIndex =\n (Math.floor(virtualRow.index / tableMeta.server.pageSize) * tableMeta.server.pageSize) /\n tableMeta.server.pageSize;\n const pagePosition = tableMeta.server.pages?.indexOf(currentPageIndex) ?? -1;\n\n if (pagePosition > -1) {\n // \"flatten\" row indexes down into the dataloader2 dataset size\n // for example, with a page size of 100...\n // row index 14267 is actually one of index 67, 167, 267 etc within the dataset (depending on number of pages stored)\n const fakeIndex = pagePosition * tableMeta.server.pageSize + (virtualRow.index % tableMeta.server.pageSize);\n row = rows[fakeIndex];\n }\n } else {\n row = rows[virtualRow.index];\n }\n\n if (!row?.original) {\n // Prefix skeleton keys to prevent collision with real data row keys\n const skeletonKey = `skeleton-${virtualRow.index}`;\n return <SkeletonRow key={skeletonKey} index={virtualRow.index} table={table} />;\n }\n\n const measureRow = (rowHeight: number) => {\n virtualiser.resizeItem(virtualRow.index, rowHeight);\n };\n\n return (\n <Row\n key={row.id}\n row={row}\n index={virtualRow.index}\n table={table}\n measureRow={measureRow}\n renderer={renderers.row}\n cellRenderer={renderers.cell}\n />\n );\n });\n }\n\n return {\n rows: content,\n style,\n scrollToIndex,\n };\n}\n\n// support virtualised row groups (where the row group headers are sticky)\nfunction useRowGroupVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const rows = table.getRowModel().rows;\n const isTableGrouped = !!table.getState().grouping.length;\n\n const rowGroupIndexes = React.useMemo(() => {\n const indexes: number[] = [];\n\n if (isTableGrouped) {\n rows.forEach((row, index) => {\n if (row.getIsGrouped()) {\n indexes.push(index);\n }\n });\n }\n\n return indexes;\n }, [rows]);\n\n // this is taken from the react-virtual docs/examples\n const rangeExtractor = React.useCallback(\n (range: Range) => {\n const activeRowGroupIndex =\n [...rowGroupIndexes].reverse().find(index => range.startIndex >= index) ?? rowGroupIndexes[0];\n\n return activeRowGroupIndex === undefined\n ? defaultRangeExtractor(range)\n : sortBy([activeRowGroupIndex, ...without(defaultRangeExtractor(range), activeRowGroupIndex)], a => a);\n },\n [rowGroupIndexes]\n );\n\n return isTableGrouped ? rangeExtractor : undefined;\n}\n"],"names":["React","_a"],"mappings":";;;;;;;AAkBA,SAAS,0BAA2C,OAA0B;AACpE,QAAA,YAAY,MAAM,QAAQ;AAChC,MAAI,SAAS;AAET,MAAA,UAAU,OAAO,WAAW;AAClB,cAAA;AAAA,EAAA;AAGd,MAAI,MAAM,kBAAkB,SAAS,GAAG;AAC1B,cAAA,MAAM,gBAAgB,EAAE,SAAS;AAAA,EAAA;AAG3C,MAAA,SAAS,qBAAqB,SAAS;AAErC,QAAA,aAAa,MAAM,cAAc;AAEvC,MAAI,WAAW,QAAQ;AAEnB,cAAU,qBAAqB,UAAU,UAAU,MAAM,IAAI,MAAM,WAAW;AAAA,EAAA;AAG3E,SAAA;AACX;AAGA,SAAS,oBAAqC,OAA0B;AACpE,QAAM,aAAa,MAAM,cAAc,KAAK,CAAC;AACtC,SAAA,qBAAqB,SAAS,IAAI,WAAW;AACxD;AAGA,MAAM,qBAAqB;AAEpB,SAAS,iBACZ,WACA,OACA,UACA,QACA,uBACF;;AACQ,QAAA,YAAY,MAAM,QAAQ;AAChC,QAAM,oBAAoB,CAAC,GAAC,WAAM,WAAW,aAAjB,mBAA2B;AACvD,QAAM,OAAO,MAAM,cAAc,KAAK,CAAC;AAGjC,QAAA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AAO,CAAC,qBAAqB,GAAG,QAAQ,sBAAsB,KAAK,GAAG,mBAAmB,CAAC,GAAG,OAAK,CAAC;AAAA,IAC7G;AAAA,IACA,CAAC,eAAe;AAAA,EACpB;AAEA,SAAO,iBAAiB,iBAAiB;AAC7C;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@economic/taco",
3
- "version": "8.1.2-hanger-base-ui.4",
3
+ "version": "8.1.3-alpha.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -43,12 +43,13 @@
43
43
  "@dnd-kit/modifiers": "^7.0.0",
44
44
  "@dnd-kit/sortable": "^7.0.2",
45
45
  "@dnd-kit/utilities": "^3.2.2",
46
- "@economic/taco-tokens": "^2.2.4",
46
+ "@economic/taco-tokens": "^2.2.5-alpha.0",
47
+ "@radix-ui/react-popover": "1.0.2",
47
48
  "@radix-ui/react-scroll-area": "1.2.10",
48
49
  "@react-aria/focus": "^3.19.0",
49
50
  "@react-aria/interactions": "^3.12.0",
50
51
  "@tanstack/react-table": "^8.21.3",
51
- "@tanstack/react-virtual": "3.0.1",
52
+ "@tanstack/react-virtual": "3.13.23",
52
53
  "clsx": "^2.1.1",
53
54
  "date-fns": "^3.6.0",
54
55
  "framer-motion": "12.38.0",
@@ -70,13 +71,13 @@
70
71
  "tailwindcss": ">=3.4.19"
71
72
  },
72
73
  "devDependencies": {
73
- "@oxlint/plugins": "^1.67.0",
74
+ "@oxlint/plugins": "^1.69.0",
74
75
  "@svgr/cli": "^5.5.0",
75
76
  "@testing-library/jest-dom": "6.9.1",
76
77
  "@testing-library/react": "16.3.2",
77
78
  "@testing-library/user-event": "14.6.1",
78
79
  "@types/lodash": "^4.17.24",
79
- "@types/node": "^22.19.19",
80
+ "@types/node": "^22.19.21",
80
81
  "@types/react": "18.3.31",
81
82
  "@types/react-dom": "18.3.7",
82
83
  "@types/react-table": "^7.7.20",
@@ -86,7 +87,7 @@
86
87
  "jsdom": "^26.1.0",
87
88
  "resize-observer-polyfill": "^1.5.1",
88
89
  "rimraf": "^3.0.2",
89
- "stylelint": "^17.12.0",
90
+ "stylelint": "^17.13.0",
90
91
  "svgo": "^1.3.2",
91
92
  "tailwindcss": "^3.4.19",
92
93
  "typescript": "^5.9.3",
@@ -96,7 +97,7 @@
96
97
  "vitest": "^3.2.6"
97
98
  },
98
99
  "optionalDependencies": {
99
- "@rollup/rollup-linux-x64-gnu": "^4.60.4"
100
+ "@rollup/rollup-linux-x64-gnu": "^4.62.0"
100
101
  },
101
- "gitHead": "6a489b2d226b2d2bd8ab2ce067e3ef12db6427ac"
102
+ "gitHead": "e2b2169e5fbc9a76f671e2eac5b6532a2e68336a"
102
103
  }