@economic/taco 8.1.4-hanger-base-ui-migration.2 → 8.1.4-test-docs.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts/components/Legend.cjs +16 -9
- package/dist/charts/components/Legend.cjs.map +1 -1
- package/dist/charts/components/Legend.js +16 -9
- package/dist/charts/components/Legend.js.map +1 -1
- package/dist/components/Hanger/Arrow.cjs +3 -2
- package/dist/components/Hanger/Arrow.cjs.map +1 -1
- package/dist/components/Hanger/Arrow.js +2 -2
- package/dist/components/Hanger/Arrow.js.map +1 -1
- package/dist/components/Hanger/Hanger.cjs +39 -39
- package/dist/components/Hanger/Hanger.cjs.map +1 -1
- package/dist/components/Hanger/Hanger.d.ts +1 -1
- package/dist/components/Hanger/Hanger.js +38 -39
- package/dist/components/Hanger/Hanger.js.map +1 -1
- package/dist/components/Layout/components/Sidebar.cjs +1 -1
- package/dist/components/Layout/components/Sidebar.cjs.map +1 -1
- package/dist/components/Layout/components/Sidebar.js +1 -1
- package/dist/components/Layout/components/Sidebar.js.map +1 -1
- package/dist/components/Navigation2/components/Content.cjs +1 -1
- package/dist/components/Navigation2/components/Content.cjs.map +1 -1
- package/dist/components/Navigation2/components/Content.js +1 -1
- package/dist/components/Navigation2/components/Content.js.map +1 -1
- package/dist/components/Navigation2/components/Link.cjs +1 -1
- package/dist/components/Navigation2/components/Link.cjs.map +1 -1
- package/dist/components/Navigation2/components/Link.js +1 -1
- package/dist/components/Navigation2/components/Link.js.map +1 -1
- package/dist/components/Navigation2/components/Section.cjs +1 -1
- package/dist/components/Navigation2/components/Section.cjs.map +1 -1
- package/dist/components/Navigation2/components/Section.js +1 -1
- package/dist/components/Navigation2/components/Section.js.map +1 -1
- package/dist/components/Navigation2/components/util.cjs +3 -3
- package/dist/components/Navigation2/components/util.cjs.map +1 -1
- package/dist/components/Navigation2/components/util.js +3 -3
- package/dist/components/Navigation2/components/util.js.map +1 -1
- package/dist/components/Select/useSelect.cjs.map +1 -1
- package/dist/components/Select/useSelect.d.ts +2 -2
- package/dist/components/Select/useSelect.js.map +1 -1
- package/dist/taco.css +5 -0
- package/dist/utils/tailwind.cjs +1 -1
- package/dist/utils/tailwind.cjs.map +1 -1
- package/dist/utils/tailwind.js +1 -1
- package/dist/utils/tailwind.js.map +1 -1
- package/package.json +4 -3
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
|
-
const cn = require("clsx");
|
|
5
4
|
const Button = require("../../components/Button/Button.cjs");
|
|
6
5
|
const Icon = require("../../components/Icon/Icon.cjs");
|
|
7
6
|
const OverflowGroup = require("../../components/OverflowGroup/OverflowGroup.cjs");
|
|
7
|
+
const color = require("../utils/color.cjs");
|
|
8
|
+
function getDarkerThemeColor(color$1) {
|
|
9
|
+
const colorName = Object.keys(color.colors).find((name) => color.colors[name] === color$1);
|
|
10
|
+
if (!colorName) {
|
|
11
|
+
return void 0;
|
|
12
|
+
}
|
|
13
|
+
return color.getThemeColor(colorName.replace(/-\d+$/, "-300"));
|
|
14
|
+
}
|
|
8
15
|
function Legend(props) {
|
|
9
|
-
const {
|
|
16
|
+
const { items, onHover: handleHover, onToggle: handleToggle } = props;
|
|
10
17
|
const handleMouseEnter = (item, index) => {
|
|
11
18
|
if (item.isHidden) {
|
|
12
19
|
return;
|
|
@@ -22,18 +29,18 @@ function Legend(props) {
|
|
|
22
29
|
};
|
|
23
30
|
const moreButton = (moreButtonText) => /* @__PURE__ */ React.createElement(Button.Button, { appearance: "transparent", className: "!h-5 !min-h-[1.25rem] !px-1.5 text-xs text-gray-700" }, moreButtonText);
|
|
24
31
|
return /* @__PURE__ */ React.createElement(OverflowGroup.OverflowGroup, { className: "mt-3 w-full gap-x-1", moreButton }, items.map((item, index) => {
|
|
25
|
-
const className =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
let style;
|
|
32
|
+
const className = "mr-1 flex h-3.5 w-3.5 rounded-sm border";
|
|
33
|
+
const style = {};
|
|
34
|
+
const darkerThemeColor = getDarkerThemeColor(item.color);
|
|
29
35
|
if (!item.isHidden) {
|
|
30
|
-
style =
|
|
36
|
+
style.backgroundColor = item.color;
|
|
37
|
+
style.borderColor = darkerThemeColor;
|
|
31
38
|
}
|
|
32
39
|
return /* @__PURE__ */ React.createElement(
|
|
33
40
|
"button",
|
|
34
41
|
{
|
|
35
42
|
key: `${item.label}_${index}`,
|
|
36
|
-
className: "focus-visible:yt-focus flex items-center rounded px-1 !text-xs hover:bg-gray-
|
|
43
|
+
className: "focus-visible:yt-focus flex items-center rounded px-1 !text-xs hover:bg-gray-100",
|
|
37
44
|
onClick: (event) => {
|
|
38
45
|
event == null ? void 0 : event.preventDefault();
|
|
39
46
|
handleClick(item);
|
|
@@ -41,7 +48,7 @@ function Legend(props) {
|
|
|
41
48
|
onMouseEnter: () => handleMouseEnter(item, index),
|
|
42
49
|
onMouseLeave: () => handleMouseLeave()
|
|
43
50
|
},
|
|
44
|
-
/* @__PURE__ */ React.createElement("span", { className, style },
|
|
51
|
+
/* @__PURE__ */ React.createElement("span", { className, style }, !item.isHidden ? /* @__PURE__ */ React.createElement(Icon.Icon, { name: "tick-bold", className: "!h-full !w-full text-white" }) : null),
|
|
45
52
|
item.label
|
|
46
53
|
);
|
|
47
54
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Legend.cjs","sources":["../../../src/charts/components/Legend.tsx"],"sourcesContent":["import React from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"Legend.cjs","sources":["../../../src/charts/components/Legend.tsx"],"sourcesContent":["import React from 'react';\nimport { Button } from '../../components/Button/Button';\nimport { Icon } from '../../components/Icon/Icon';\nimport { OverflowGroup } from '../../components/OverflowGroup/OverflowGroup';\nimport { ChartChildProps } from './types';\nimport { colors, getThemeColor } from '../utils/color';\n\nexport interface LegendProps<TData extends object> {\n items: ChartChildProps<TData>[];\n hoverIndex: number | undefined;\n onHover: (index: number | undefined) => void;\n onToggle: (name: keyof TData) => void;\n}\n\nfunction getDarkerThemeColor(color: string | undefined) {\n const colorName = Object.keys(colors).find(name => colors[name] === color);\n\n if (!colorName) {\n return undefined;\n }\n\n return getThemeColor(colorName.replace(/-\\d+$/, '-300'));\n}\n\nexport function Legend<TData extends object>(props: LegendProps<TData>) {\n const { items, onHover: handleHover, onToggle: handleToggle } = props;\n\n const handleMouseEnter = (item: ChartChildProps<TData>, index: number) => {\n if (item.isHidden) {\n return;\n }\n\n handleHover(index);\n };\n const handleMouseLeave = () => handleHover(undefined);\n\n const handleClick = (item: ChartChildProps<TData>) => {\n // remove hover if hiding the item\n if (!item.isHidden) {\n handleHover(undefined);\n }\n\n handleToggle(item.dataKey);\n };\n\n const moreButton = (moreButtonText: string) => (\n <Button appearance=\"transparent\" className=\"!h-5 !min-h-[1.25rem] !px-1.5 text-xs text-gray-700\">\n {moreButtonText}\n </Button>\n );\n\n return (\n <OverflowGroup className=\"mt-3 w-full gap-x-1\" moreButton={moreButton}>\n {items.map((item, index) => {\n const className = 'mr-1 flex h-3.5 w-3.5 rounded-sm border';\n const style: React.CSSProperties = {};\n const darkerThemeColor = getDarkerThemeColor(item.color);\n\n if (!item.isHidden) {\n style.backgroundColor = item.color;\n style.borderColor = darkerThemeColor;\n }\n\n return (\n <button\n key={`${item.label}_${index}`}\n className=\"focus-visible:yt-focus flex items-center rounded px-1 !text-xs hover:bg-gray-100\"\n onClick={event => {\n event?.preventDefault();\n handleClick(item);\n }}\n onMouseEnter={() => handleMouseEnter(item, index)}\n onMouseLeave={() => handleMouseLeave()}>\n <span className={className} style={style}>\n {!item.isHidden ? <Icon name=\"tick-bold\" className=\"!h-full !w-full text-white\" /> : null}\n </span>\n {item.label}\n </button>\n );\n })}\n </OverflowGroup>\n );\n}\n"],"names":["color","colors","getThemeColor","Button","OverflowGroup","Icon"],"mappings":";;;;;;;AAcA,SAAS,oBAAoBA,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A,EAAK,WAAsB,MAAA,GACvB,CAAC,KAAK,WAAY,sBAAA,cAAAC,KAAAA,MAAA,EAAK,MAAK,aAAY,WAAU,6BAAA,CAA6B,IAAK,IACzF;AAAA,MACC,KAAK;AAAA,IACV;AAAA,EAAA,CAEP,CACL;AAER;;"}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import React__default from "react";
|
|
2
|
-
import { clsx } from "clsx";
|
|
3
2
|
import { Button } from "../../components/Button/Button.js";
|
|
4
3
|
import { Icon } from "../../components/Icon/Icon.js";
|
|
5
4
|
import { OverflowGroup } from "../../components/OverflowGroup/OverflowGroup.js";
|
|
5
|
+
import { colors, getThemeColor } from "../utils/color.js";
|
|
6
|
+
function getDarkerThemeColor(color) {
|
|
7
|
+
const colorName = Object.keys(colors).find((name) => colors[name] === color);
|
|
8
|
+
if (!colorName) {
|
|
9
|
+
return void 0;
|
|
10
|
+
}
|
|
11
|
+
return getThemeColor(colorName.replace(/-\d+$/, "-300"));
|
|
12
|
+
}
|
|
6
13
|
function Legend(props) {
|
|
7
|
-
const {
|
|
14
|
+
const { items, onHover: handleHover, onToggle: handleToggle } = props;
|
|
8
15
|
const handleMouseEnter = (item, index) => {
|
|
9
16
|
if (item.isHidden) {
|
|
10
17
|
return;
|
|
@@ -20,18 +27,18 @@ function Legend(props) {
|
|
|
20
27
|
};
|
|
21
28
|
const moreButton = (moreButtonText) => /* @__PURE__ */ React__default.createElement(Button, { appearance: "transparent", className: "!h-5 !min-h-[1.25rem] !px-1.5 text-xs text-gray-700" }, moreButtonText);
|
|
22
29
|
return /* @__PURE__ */ React__default.createElement(OverflowGroup, { className: "mt-3 w-full gap-x-1", moreButton }, items.map((item, index) => {
|
|
23
|
-
const className =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
let style;
|
|
30
|
+
const className = "mr-1 flex h-3.5 w-3.5 rounded-sm border";
|
|
31
|
+
const style = {};
|
|
32
|
+
const darkerThemeColor = getDarkerThemeColor(item.color);
|
|
27
33
|
if (!item.isHidden) {
|
|
28
|
-
style =
|
|
34
|
+
style.backgroundColor = item.color;
|
|
35
|
+
style.borderColor = darkerThemeColor;
|
|
29
36
|
}
|
|
30
37
|
return /* @__PURE__ */ React__default.createElement(
|
|
31
38
|
"button",
|
|
32
39
|
{
|
|
33
40
|
key: `${item.label}_${index}`,
|
|
34
|
-
className: "focus-visible:yt-focus flex items-center rounded px-1 !text-xs hover:bg-gray-
|
|
41
|
+
className: "focus-visible:yt-focus flex items-center rounded px-1 !text-xs hover:bg-gray-100",
|
|
35
42
|
onClick: (event) => {
|
|
36
43
|
event == null ? void 0 : event.preventDefault();
|
|
37
44
|
handleClick(item);
|
|
@@ -39,7 +46,7 @@ function Legend(props) {
|
|
|
39
46
|
onMouseEnter: () => handleMouseEnter(item, index),
|
|
40
47
|
onMouseLeave: () => handleMouseLeave()
|
|
41
48
|
},
|
|
42
|
-
/* @__PURE__ */ React__default.createElement("span", { className, style },
|
|
49
|
+
/* @__PURE__ */ React__default.createElement("span", { className, style }, !item.isHidden ? /* @__PURE__ */ React__default.createElement(Icon, { name: "tick-bold", className: "!h-full !w-full text-white" }) : null),
|
|
43
50
|
item.label
|
|
44
51
|
);
|
|
45
52
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Legend.js","sources":["../../../src/charts/components/Legend.tsx"],"sourcesContent":["import React from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"Legend.js","sources":["../../../src/charts/components/Legend.tsx"],"sourcesContent":["import React from 'react';\nimport { Button } from '../../components/Button/Button';\nimport { Icon } from '../../components/Icon/Icon';\nimport { OverflowGroup } from '../../components/OverflowGroup/OverflowGroup';\nimport { ChartChildProps } from './types';\nimport { colors, getThemeColor } from '../utils/color';\n\nexport interface LegendProps<TData extends object> {\n items: ChartChildProps<TData>[];\n hoverIndex: number | undefined;\n onHover: (index: number | undefined) => void;\n onToggle: (name: keyof TData) => void;\n}\n\nfunction getDarkerThemeColor(color: string | undefined) {\n const colorName = Object.keys(colors).find(name => colors[name] === color);\n\n if (!colorName) {\n return undefined;\n }\n\n return getThemeColor(colorName.replace(/-\\d+$/, '-300'));\n}\n\nexport function Legend<TData extends object>(props: LegendProps<TData>) {\n const { items, onHover: handleHover, onToggle: handleToggle } = props;\n\n const handleMouseEnter = (item: ChartChildProps<TData>, index: number) => {\n if (item.isHidden) {\n return;\n }\n\n handleHover(index);\n };\n const handleMouseLeave = () => handleHover(undefined);\n\n const handleClick = (item: ChartChildProps<TData>) => {\n // remove hover if hiding the item\n if (!item.isHidden) {\n handleHover(undefined);\n }\n\n handleToggle(item.dataKey);\n };\n\n const moreButton = (moreButtonText: string) => (\n <Button appearance=\"transparent\" className=\"!h-5 !min-h-[1.25rem] !px-1.5 text-xs text-gray-700\">\n {moreButtonText}\n </Button>\n );\n\n return (\n <OverflowGroup className=\"mt-3 w-full gap-x-1\" moreButton={moreButton}>\n {items.map((item, index) => {\n const className = 'mr-1 flex h-3.5 w-3.5 rounded-sm border';\n const style: React.CSSProperties = {};\n const darkerThemeColor = getDarkerThemeColor(item.color);\n\n if (!item.isHidden) {\n style.backgroundColor = item.color;\n style.borderColor = darkerThemeColor;\n }\n\n return (\n <button\n key={`${item.label}_${index}`}\n className=\"focus-visible:yt-focus flex items-center rounded px-1 !text-xs hover:bg-gray-100\"\n onClick={event => {\n event?.preventDefault();\n handleClick(item);\n }}\n onMouseEnter={() => handleMouseEnter(item, index)}\n onMouseLeave={() => handleMouseLeave()}>\n <span className={className} style={style}>\n {!item.isHidden ? <Icon name=\"tick-bold\" className=\"!h-full !w-full text-white\" /> : null}\n </span>\n {item.label}\n </button>\n );\n })}\n </OverflowGroup>\n );\n}\n"],"names":["React"],"mappings":";;;;;AAcA,SAAS,oBAAoB,OAA2B;AAC9C,QAAA,YAAY,OAAO,KAAK,MAAM,EAAE,KAAK,CAAQ,SAAA,OAAO,IAAI,MAAM,KAAK;AAEzE,MAAI,CAAC,WAAW;AACL,WAAA;AAAA,EAAA;AAGX,SAA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"}
|
|
@@ -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
|
|
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(
|
|
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
|
|
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
|
|
2
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
3
3
|
const UnstyledArrow = React.forwardRef(function PopoverArrow(props, ref) {
|
|
4
|
-
return /* @__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
|
|
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
|
|
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,75 +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
|
-
|
|
30
|
-
|
|
30
|
+
onClose: void 0,
|
|
31
|
+
props: {},
|
|
32
|
+
ref: null
|
|
31
33
|
});
|
|
32
|
-
const Anchor = React__namespace.forwardRef(function HangerAnchor(props,
|
|
33
|
-
|
|
34
|
-
|
|
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);
|
|
35
44
|
}
|
|
36
|
-
|
|
37
|
-
return React__namespace.cloneElement(child, {
|
|
38
|
-
ref: child.ref ? mergeRefs.mergeRefs([ref, child.ref]) : ref
|
|
39
|
-
});
|
|
45
|
+
return /* @__PURE__ */ React__namespace.createElement(PopoverPrimitive__namespace.Anchor, { ...parentProps, ...props, ref: refCallback, asChild: true }, children);
|
|
40
46
|
});
|
|
41
47
|
const Title = React__namespace.forwardRef(function DialogTitle(props, ref) {
|
|
42
48
|
const className = cn("mb-1 text-base font-bold flex w-full", props.className);
|
|
43
49
|
return /* @__PURE__ */ React__namespace.createElement("span", { ...props, className, ref });
|
|
44
50
|
});
|
|
45
51
|
const Content = React__namespace.forwardRef(function HangerContent(props, ref) {
|
|
46
|
-
const { placement: side, hideWhenDetached = false, container
|
|
52
|
+
const { placement: side, hideWhenDetached = false, container } = props;
|
|
47
53
|
const context = React__namespace.useContext(HangerContext);
|
|
48
54
|
const { texts } = Localization.useLocalization();
|
|
49
55
|
const className = cn(
|
|
50
56
|
"wcag-blue-500 border border-transparent rounded p-3 pr-12 yt-shadow focus:border-transparent max-w-sm print:hidden",
|
|
51
57
|
props.className
|
|
52
58
|
);
|
|
53
|
-
|
|
54
|
-
|
|
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,
|
|
55
64
|
{
|
|
56
|
-
|
|
57
|
-
|
|
65
|
+
className,
|
|
66
|
+
"data-taco": "hanger",
|
|
67
|
+
onInteractOutside: handleInteractOutside,
|
|
58
68
|
side,
|
|
59
|
-
sideOffset:
|
|
69
|
+
sideOffset: 1,
|
|
70
|
+
ref,
|
|
71
|
+
hideWhenDetached
|
|
60
72
|
},
|
|
61
|
-
|
|
62
|
-
|
|
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,
|
|
63
77
|
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
className: "absolute right-0 top-0 mx-2 mt-2 text-white",
|
|
70
|
-
icon: "close",
|
|
71
|
-
onClick: context.onClose
|
|
72
|
-
}
|
|
73
|
-
)
|
|
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
|
|
74
83
|
}
|
|
75
84
|
))
|
|
76
85
|
));
|
|
77
86
|
});
|
|
78
87
|
const Hanger = React__namespace.forwardRef(function Hanger2(props, ref) {
|
|
79
88
|
const { anchor, children, defaultOpen = true, onClose, ...otherProps } = props;
|
|
80
|
-
const
|
|
81
|
-
const combinedRef = mergeRefs.mergeRefs([anchorRef, ref]);
|
|
82
|
-
const context = React__namespace.useMemo(() => ({ anchorRef, onClose }), [onClose]);
|
|
89
|
+
const context = React__namespace.useMemo(() => ({ onClose, props: otherProps, ref }), [onClose, otherProps]);
|
|
83
90
|
const [open, setOpen] = React__namespace.useState(false);
|
|
84
91
|
React__namespace.useEffect(() => {
|
|
85
92
|
if (defaultOpen) {
|
|
86
93
|
setOpen(defaultOpen);
|
|
87
94
|
}
|
|
88
95
|
}, []);
|
|
89
|
-
|
|
90
|
-
if (!nextOpen && (eventDetails.reason === "outside-press" || eventDetails.reason === "focus-out")) {
|
|
91
|
-
eventDetails.cancel();
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
setOpen(nextOpen);
|
|
95
|
-
};
|
|
96
|
-
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));
|
|
97
97
|
});
|
|
98
98
|
Hanger.Anchor = Anchor;
|
|
99
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
|
|
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,gBA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
|
};
|
|
7
|
-
export type HangerAnchorProps = React.HTMLAttributes<
|
|
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,80 +1,79 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import cn from "clsx";
|
|
3
|
-
import
|
|
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
|
-
|
|
11
|
-
|
|
10
|
+
onClose: void 0,
|
|
11
|
+
props: {},
|
|
12
|
+
ref: null
|
|
12
13
|
});
|
|
13
|
-
const Anchor = React.forwardRef(function HangerAnchor(props,
|
|
14
|
-
|
|
15
|
-
|
|
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);
|
|
16
24
|
}
|
|
17
|
-
|
|
18
|
-
return React.cloneElement(child, {
|
|
19
|
-
ref: child.ref ? mergeRefs([ref, child.ref]) : ref
|
|
20
|
-
});
|
|
25
|
+
return /* @__PURE__ */ React.createElement(PopoverPrimitive.Anchor, { ...parentProps, ...props, ref: refCallback, asChild: true }, children);
|
|
21
26
|
});
|
|
22
27
|
const Title = React.forwardRef(function DialogTitle(props, ref) {
|
|
23
28
|
const className = cn("mb-1 text-base font-bold flex w-full", props.className);
|
|
24
29
|
return /* @__PURE__ */ React.createElement("span", { ...props, className, ref });
|
|
25
30
|
});
|
|
26
31
|
const Content = React.forwardRef(function HangerContent(props, ref) {
|
|
27
|
-
const { placement: side, hideWhenDetached = false, container
|
|
32
|
+
const { placement: side, hideWhenDetached = false, container } = props;
|
|
28
33
|
const context = React.useContext(HangerContext);
|
|
29
34
|
const { texts } = useLocalization();
|
|
30
35
|
const className = cn(
|
|
31
36
|
"wcag-blue-500 border border-transparent rounded p-3 pr-12 yt-shadow focus:border-transparent max-w-sm print:hidden",
|
|
32
37
|
props.className
|
|
33
38
|
);
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
const handleInteractOutside = (event) => {
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
};
|
|
42
|
+
return /* @__PURE__ */ React.createElement(PopoverPrimitive.Portal, { container }, /* @__PURE__ */ React.createElement(
|
|
43
|
+
PopoverPrimitive.Content,
|
|
36
44
|
{
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
className,
|
|
46
|
+
"data-taco": "hanger",
|
|
47
|
+
onInteractOutside: handleInteractOutside,
|
|
39
48
|
side,
|
|
40
|
-
sideOffset:
|
|
49
|
+
sideOffset: 1,
|
|
50
|
+
ref,
|
|
51
|
+
hideWhenDetached
|
|
41
52
|
},
|
|
42
|
-
|
|
43
|
-
|
|
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,
|
|
44
57
|
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
className: "absolute right-0 top-0 mx-2 mt-2 text-white",
|
|
51
|
-
icon: "close",
|
|
52
|
-
onClick: context.onClose
|
|
53
|
-
}
|
|
54
|
-
)
|
|
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
|
|
55
63
|
}
|
|
56
64
|
))
|
|
57
65
|
));
|
|
58
66
|
});
|
|
59
67
|
const Hanger = React.forwardRef(function Hanger2(props, ref) {
|
|
60
68
|
const { anchor, children, defaultOpen = true, onClose, ...otherProps } = props;
|
|
61
|
-
const
|
|
62
|
-
const combinedRef = mergeRefs([anchorRef, ref]);
|
|
63
|
-
const context = React.useMemo(() => ({ anchorRef, onClose }), [onClose]);
|
|
69
|
+
const context = React.useMemo(() => ({ onClose, props: otherProps, ref }), [onClose, otherProps]);
|
|
64
70
|
const [open, setOpen] = React.useState(false);
|
|
65
71
|
React.useEffect(() => {
|
|
66
72
|
if (defaultOpen) {
|
|
67
73
|
setOpen(defaultOpen);
|
|
68
74
|
}
|
|
69
75
|
}, []);
|
|
70
|
-
|
|
71
|
-
if (!nextOpen && (eventDetails.reason === "outside-press" || eventDetails.reason === "focus-out")) {
|
|
72
|
-
eventDetails.cancel();
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
setOpen(nextOpen);
|
|
76
|
-
};
|
|
77
|
-
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));
|
|
78
77
|
});
|
|
79
78
|
Hanger.Anchor = Anchor;
|
|
80
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
|
|
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,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AAER,CAAC;AAoBM,MAAM,SAAS,MAAM,WAAqC,SAASA,QAAO,OAAO,KAAK;AACnF,QAAA,EAAE,QAAQ,UAAU,cAAc,MAAM,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;"}
|
|
@@ -39,7 +39,7 @@ const Sidebar = React.forwardRef(function LayoutSidebar(props, ref) {
|
|
|
39
39
|
// this prevents awkward animation in the edge case (resizing the browser, instead of starting at a given size)
|
|
40
40
|
invisible: isSmallScreen && !ready,
|
|
41
41
|
"transition-[transform] duration-300 visible": isSmallScreen && ready,
|
|
42
|
-
"border-r-2 border-
|
|
42
|
+
"border-r-2 border-gray-100 ": !showBackdrop
|
|
43
43
|
},
|
|
44
44
|
props.className
|
|
45
45
|
);
|