@economic/taco 1.1.12-alpha.0 → 1.1.12

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,14 +1,12 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
1
  import { forwardRef, createElement } from 'react';
3
2
  import cn from 'classnames';
4
3
 
5
- var _excluded = ["as"];
6
- var Group = /*#__PURE__*/forwardRef(function Group(props, ref) {
7
- var _props$as = props.as,
8
- Tag = _props$as === void 0 ? 'span' : _props$as,
9
- otherProps = _objectWithoutPropertiesLoose(props, _excluded);
10
-
11
- var className = cn('flex ', props.className);
4
+ const Group = /*#__PURE__*/forwardRef(function Group(props, ref) {
5
+ const {
6
+ as: Tag = 'span',
7
+ ...otherProps
8
+ } = props;
9
+ const className = cn('flex ', props.className);
12
10
  return createElement(Tag, Object.assign({}, otherProps, {
13
11
  className: className,
14
12
  "data-taco": "group",
@@ -1 +1 @@
1
- {"version":3,"file":"Group.js","sources":["../../../../src/components/Group/Group.tsx"],"sourcesContent":["import * as React from 'react';\r\nimport cn from 'classnames';\r\nimport './Group.css';\r\n\r\nexport type GroupProps = React.HTMLAttributes<HTMLElement> & {\r\n /**\r\n * Change what html tag element will render.\r\n * Default value is `span`\r\n */\r\n as?: 'div' | 'span' | 'nav';\r\n /** Content should be composed of other Taco elements */\r\n children: React.ReactNode;\r\n};\r\n\r\nexport const Group = React.forwardRef(function Group(props: GroupProps, ref: React.Ref<HTMLDivElement>) {\r\n const { as: Tag = 'span', ...otherProps } = props;\r\n const className = cn('flex ', props.className);\r\n return <Tag {...otherProps} className={className} data-taco=\"group\" ref={ref} />;\r\n});\r\n"],"names":["Group","React","props","ref","as","Tag","otherProps","className","cn"],"mappings":";;;;;IAcaA,KAAK,gBAAGC,UAAA,CAAiB,SAASD,KAAT,CAAeE,KAAf,EAAkCC,GAAlC;EAClC,gBAA4CD,KAA5C,CAAQE,EAAR;MAAYC,GAAZ,0BAAkB,MAAlB;MAA6BC,UAA7B,iCAA4CJ,KAA5C;;EACA,IAAMK,SAAS,GAAGC,EAAE,CAAC,OAAD,EAAUN,KAAK,CAACK,SAAhB,CAApB;EACA,OAAON,aAAA,CAACI,GAAD,oBAASC;IAAYC,SAAS,EAAEA;iBAAqB;IAAQJ,GAAG,EAAEA;IAAlE,CAAP;AACH,CAJoB;;;;"}
1
+ {"version":3,"file":"Group.js","sources":["../../../../src/components/Group/Group.tsx"],"sourcesContent":["import * as React from 'react';\r\nimport cn from 'classnames';\r\nimport './Group.css';\r\n\r\nexport type GroupProps = React.HTMLAttributes<HTMLElement> & {\r\n /**\r\n * Change what html tag element will render.\r\n * Default value is `span`\r\n */\r\n as?: 'div' | 'span' | 'nav';\r\n /** Content should be composed of other Taco elements */\r\n children: React.ReactNode;\r\n};\r\n\r\nexport const Group = React.forwardRef(function Group(props: GroupProps, ref: React.Ref<HTMLDivElement>) {\r\n const { as: Tag = 'span', ...otherProps } = props;\r\n const className = cn('flex ', props.className);\r\n return <Tag {...otherProps} className={className} data-taco=\"group\" ref={ref} />;\r\n});\r\n"],"names":["Group","React","props","ref","as","Tag","otherProps","className","cn"],"mappings":";;;MAcaA,KAAK,gBAAGC,UAAA,CAAiB,SAASD,KAAT,CAAeE,KAAf,EAAkCC,GAAlC;EAClC,MAAM;IAAEC,EAAE,EAAEC,GAAG,GAAG,MAAZ;IAAoB,GAAGC;MAAeJ,KAA5C;EACA,MAAMK,SAAS,GAAGC,EAAE,CAAC,OAAD,EAAUN,KAAK,CAACK,SAAhB,CAApB;EACA,OAAON,aAAA,CAACI,GAAD,oBAASC;IAAYC,SAAS,EAAEA;iBAAqB;IAAQJ,GAAG,EAAEA;IAAlE,CAAP;AACH,CAJoB;;;;"}
@@ -1,3 +1,4 @@
1
+ import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../_virtual/_rollupPluginBabelHelpers.js';
1
2
  import { forwardRef, createElement, useMemo, useState, useEffect, createContext, useContext, isValidElement } from 'react';
2
3
  import cn from 'classnames';
3
4
  import { IconButton } from '../IconButton/IconButton.js';
@@ -6,18 +7,19 @@ import { Root, Anchor as Anchor$1, Close } from '@radix-ui/react-popover';
6
7
  import { UnstyledContent, UnstyledArrow } from '../Popover/Primitives.js';
7
8
  import { mergeRefs } from '../../utils/mergeRefs.js';
8
9
 
9
- const HangerContext = /*#__PURE__*/createContext({
10
+ var _excluded = ["anchor", "children", "defaultOpen"];
11
+ var HangerContext = /*#__PURE__*/createContext({
10
12
  props: {},
11
13
  ref: null
12
14
  });
13
- const Anchor = /*#__PURE__*/forwardRef(function HangerAnchor(props, ref) {
15
+ var Anchor = /*#__PURE__*/forwardRef(function HangerAnchor(props, ref) {
14
16
  var _props$children;
15
17
 
16
- const context = useContext(HangerContext);
17
- let children = props.children;
18
+ var context = useContext(HangerContext);
19
+ var children = props.children;
18
20
 
19
21
  if (isValidElement(props.children) && typeof ((_props$children = props.children) === null || _props$children === void 0 ? void 0 : _props$children.type) === 'function') {
20
- console.warn(`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
+ console.warn("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");
21
23
  children = createElement("span", null, props.children);
22
24
  }
23
25
 
@@ -27,21 +29,22 @@ const Anchor = /*#__PURE__*/forwardRef(function HangerAnchor(props, ref) {
27
29
  asChild: true
28
30
  }));
29
31
  });
30
- const Title = /*#__PURE__*/forwardRef(function DialogTitle(props, ref) {
31
- const className = cn('mb-1 text-base font-bold flex w-full', props.className);
32
+ var Title = /*#__PURE__*/forwardRef(function DialogTitle(props, ref) {
33
+ var className = cn('mb-1 text-base font-bold flex w-full', props.className);
32
34
  return createElement("span", Object.assign({}, props, {
33
35
  className: className,
34
36
  ref: ref
35
37
  }));
36
38
  });
37
- const Content = /*#__PURE__*/forwardRef(function HangerContent(props, ref) {
38
- const context = useContext(HangerContext);
39
- const {
40
- texts
41
- } = useLocalization();
42
- const className = cn('wcag-blue border border-transparent rounded p-3 pr-12 yt-shadow z-[996] focus:border-transparent max-w-sm', props.className);
39
+ var Content = /*#__PURE__*/forwardRef(function HangerContent(props, ref) {
40
+ var context = useContext(HangerContext);
43
41
 
44
- const handleInteractOutside = event => {
42
+ var _useLocalization = useLocalization(),
43
+ texts = _useLocalization.texts;
44
+
45
+ var className = cn('wcag-blue border border-transparent rounded p-3 pr-12 yt-shadow z-[996] focus:border-transparent max-w-sm', props.className);
46
+
47
+ var handleInteractOutside = function handleInteractOutside(event) {
45
48
  event.preventDefault();
46
49
  };
47
50
 
@@ -63,20 +66,25 @@ const Content = /*#__PURE__*/forwardRef(function HangerContent(props, ref) {
63
66
  onClick: context.props.onClose
64
67
  })));
65
68
  });
66
- const Hanger = /*#__PURE__*/forwardRef(function Hanger(props, ref) {
67
- const {
68
- anchor,
69
- children,
70
- defaultOpen = true,
71
- ...otherProps
72
- } = props;
73
- const context = useMemo(() => ({
74
- props: otherProps,
75
- ref
76
- }), [otherProps]); // we do this to ensure hangers are mounted after their containers, e.g. if the container is another portal
69
+ var Hanger = /*#__PURE__*/forwardRef(function Hanger(props, ref) {
70
+ var anchor = props.anchor,
71
+ children = props.children,
72
+ _props$defaultOpen = props.defaultOpen,
73
+ defaultOpen = _props$defaultOpen === void 0 ? true : _props$defaultOpen,
74
+ otherProps = _objectWithoutPropertiesLoose(props, _excluded);
75
+
76
+ var context = useMemo(function () {
77
+ return {
78
+ props: otherProps,
79
+ ref: ref
80
+ };
81
+ }, [otherProps]); // we do this to ensure hangers are mounted after their containers, e.g. if the container is another portal
82
+
83
+ var _React$useState = useState(false),
84
+ open = _React$useState[0],
85
+ setOpen = _React$useState[1];
77
86
 
78
- const [open, setOpen] = useState(false);
79
- useEffect(() => {
87
+ useEffect(function () {
80
88
  if (defaultOpen) {
81
89
  setOpen(defaultOpen);
82
90
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Hanger.js","sources":["../../../../src/components/Hanger/Hanger.tsx"],"sourcesContent":["import * as React from 'react';\r\nimport cn from 'classnames';\r\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\r\nimport { IconButton } from '../IconButton/IconButton';\r\nimport { Placement } from '../..';\r\nimport { UnstyledArrow, UnstyledContent } from '../Popover/Primitives';\r\nimport { useLocalization } from '../Provider/Provider';\r\nimport './Hanger.css';\r\nimport { mergeRefs } from '../../utils/mergeRefs';\r\n\r\ntype HangerContextValue = {\r\n props: any;\r\n ref: React.Ref<HTMLElement>;\r\n};\r\nconst HangerContext = React.createContext<HangerContextValue>({\r\n props: {},\r\n ref: null,\r\n});\r\n\r\nexport type HangerTexts = {\r\n /** Aria-label for the close icon button of hanger */\r\n close: string;\r\n};\r\n\r\nexport type HangerAnchorProps = React.HTMLAttributes<HTMLDivElement>;\r\nconst Anchor = React.forwardRef(function HangerAnchor(props: HangerAnchorProps, ref: React.Ref<HTMLDivElement>) {\r\n const context = React.useContext(HangerContext);\r\n let children = props.children;\r\n\r\n if (React.isValidElement(props.children) && typeof props.children?.type === 'function') {\r\n console.warn(\r\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`\r\n );\r\n children = <span>{props.children}</span>;\r\n }\r\n\r\n return (\r\n <PopoverPrimitive.Anchor {...context.props} {...props} children={children} ref={mergeRefs([context.ref, ref])} asChild />\r\n );\r\n});\r\n\r\nexport type HangerTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\r\nexport const Title = React.forwardRef(function DialogTitle(props: HangerTitleProps, ref: React.Ref<HTMLHeadingElement>) {\r\n const className = cn('mb-1 text-base font-bold flex w-full', props.className);\r\n return <span {...props} className={className} ref={ref} />;\r\n});\r\n\r\nexport type HangerContentProps = React.HTMLAttributes<HTMLDivElement> & {\r\n /** Set the position of the Hanger relative to its achor. Default value is `bottom` */\r\n placement?: Placement;\r\n};\r\n\r\nconst Content = React.forwardRef(function HangerContent(props: HangerContentProps, ref: React.Ref<HTMLDivElement>) {\r\n const context = React.useContext(HangerContext);\r\n const { texts } = useLocalization();\r\n const className = cn(\r\n 'wcag-blue border border-transparent rounded p-3 pr-12 yt-shadow z-[996] focus:border-transparent max-w-sm',\r\n props.className\r\n );\r\n const handleInteractOutside = (event: CustomEvent): void => {\r\n event.preventDefault();\r\n };\r\n\r\n return (\r\n <UnstyledContent\r\n className={className}\r\n data-taco=\"hanger\"\r\n onInteractOutside={handleInteractOutside}\r\n placement={props.placement}\r\n ref={ref}\r\n >\r\n {props.children}\r\n <UnstyledArrow className=\"text-blue\" />\r\n <PopoverPrimitive.Close asChild>\r\n <IconButton\r\n appearance=\"primary\"\r\n aria-label={texts.hanger.close}\r\n className=\"absolute top-0 right-0 ml-2 mr-2 mt-2 text-white\"\r\n icon=\"close\"\r\n onClick={context.props.onClose}\r\n />\r\n </PopoverPrimitive.Close>\r\n </UnstyledContent>\r\n );\r\n});\r\n\r\nexport type HangerProps = React.PropsWithChildren<{\r\n /** An anchor to be used for the hanger, should not be set if `children` already contains an anchor */\r\n anchor?: JSX.Element;\r\n /**\r\n * Shows or hides hanger depending on the value\r\n * @defaultValue true\r\n */\r\n defaultOpen?: boolean;\r\n /** Handler called when user closes the hanger */\r\n onClose?: () => void;\r\n}>;\r\n\r\nexport type ForwardedHangerWithStatics = React.ForwardRefExoticComponent<HangerProps & React.RefAttributes<HTMLElement>> & {\r\n Anchor: React.ForwardRefExoticComponent<HangerAnchorProps>;\r\n Content: React.ForwardRefExoticComponent<HangerContentProps>;\r\n Title: React.ForwardRefExoticComponent<HangerTitleProps>;\r\n};\r\n\r\nexport const Hanger = React.forwardRef(function Hanger(props: HangerProps, ref: React.Ref<HTMLElement>) {\r\n const { anchor, children, defaultOpen = true, ...otherProps } = props;\r\n const context = React.useMemo(() => ({ props: otherProps, ref }), [otherProps]);\r\n\r\n // we do this to ensure hangers are mounted after their containers, e.g. if the container is another portal\r\n const [open, setOpen] = React.useState(false);\r\n React.useEffect(() => {\r\n if (defaultOpen) {\r\n setOpen(defaultOpen);\r\n }\r\n }, []);\r\n\r\n return (\r\n <HangerContext.Provider value={context}>\r\n <PopoverPrimitive.Root key={String(open)} defaultOpen={open}>\r\n {anchor && <Anchor>{anchor}</Anchor>}\r\n {children}\r\n </PopoverPrimitive.Root>\r\n </HangerContext.Provider>\r\n );\r\n}) as ForwardedHangerWithStatics;\r\nHanger.Anchor = Anchor;\r\nHanger.Content = Content;\r\nHanger.Title = Title;\r\n"],"names":["HangerContext","React","props","ref","Anchor","HangerAnchor","context","children","type","console","warn","name","PopoverPrimitive","mergeRefs","asChild","Title","DialogTitle","className","cn","Content","HangerContent","texts","useLocalization","handleInteractOutside","event","preventDefault","UnstyledContent","onInteractOutside","placement","UnstyledArrow","IconButton","appearance","hanger","close","icon","onClick","onClose","Hanger","anchor","defaultOpen","otherProps","open","setOpen","Provider","value","key","String"],"mappings":";;;;;;;;AAcA,MAAMA,aAAa,gBAAGC,aAAA,CAAwC;EAC1DC,KAAK,EAAE,EADmD;EAE1DC,GAAG,EAAE;AAFqD,CAAxC,CAAtB;AAWA,MAAMC,MAAM,gBAAGH,UAAA,CAAiB,SAASI,YAAT,CAAsBH,KAAtB,EAAgDC,GAAhD;;;EAC5B,MAAMG,OAAO,GAAGL,UAAA,CAAiBD,aAAjB,CAAhB;EACA,IAAIO,QAAQ,GAAGL,KAAK,CAACK,QAArB;;EAEA,IAAIN,cAAA,CAAqBC,KAAK,CAACK,QAA3B,KAAwC,2BAAOL,KAAK,CAACK,QAAb,oDAAO,gBAAgBC,IAAvB,MAAgC,UAA5E,EAAwF;IACpFC,OAAO,CAACC,IAAR,mHACsHR,KA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O;GAA/B,EACIb,aAAA,CAAC6B,UAAD;IACIC,UAAU,EAAC;kBACCV,KAAK,CAACW,MAAN,CAAaC;IACzBhB,SAAS,EAAC;IACViB,IAAI,EAAC;IACLC,OAAO,EAAE7B,OAAO,CAACJ,KAAR,CAAckC;GAL3B,CADJ,CATJ,CADJ;AAqBH,CAhCe,CAAhB;MAoDaC,MAAM,gBAAGpC,UAAA,CAAiB,SAASoC,MAAT,CAAgBnC,KAAhB,EAAoCC,GAApC;EACnC,MAAM;IAAEmC,MAAF;IAAU/B,QAAV;IAAoBgC,WAAW,GAAG,IAAlC;IAAwC,GAAGC;MAAetC,KAAhE;EACA,MAAMI,OAAO,GAAGL,OAAA,CAAc,OAAO;IAAEC,KAAK,EAAEsC,UAAT;IAAqBrC;GAA5B,CAAd,EAAkD,CAACqC,UAAD,CAAlD,CAAhB;;EAGA,MAAM,CAACC,IAAD,EAAOC,OAAP,IAAkBzC,QAAA,CAAe,KAAf,CAAxB;EACAA,SAAA,CAAgB;IACZ,IAAIsC,WAAJ,EAAiB;MACbG,OAAO,CAACH,WAAD,CAAP;;GAFR,EAIG,EAJH;EAMA,OACItC,aAAA,CAACD,aAAa,CAAC2C,QAAf;IAAwBC,KAAK,EAAEtC;GAA/B,EACIL,aAAA,CAACW,IAAD;IAAuBiC,GAAG,EAAEC,MAAM,CAACL,IAAD;IAAQF,WAAW,EAAEE;GAAvD,EACKH,MAAM,IAAIrC,aAAA,CAACG,MAAD,MAAA,EAASkC,MAAT,CADf,EAEK/B,QAFL,CADJ,CADJ;AAQH,CApBqB;AAqBtB8B,MAAM,CAACjC,MAAP,GAAgBA,MAAhB;AACAiC,MAAM,CAAClB,OAAP,GAAiBA,OAAjB;AACAkB,MAAM,CAACtB,KAAP,GAAeA,KAAf;;;;"}
1
+ {"version":3,"file":"Hanger.js","sources":["../../../../src/components/Hanger/Hanger.tsx"],"sourcesContent":["import * as React from 'react';\r\nimport cn from 'classnames';\r\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\r\nimport { IconButton } from '../IconButton/IconButton';\r\nimport { Placement } from '../..';\r\nimport { UnstyledArrow, UnstyledContent } from '../Popover/Primitives';\r\nimport { useLocalization } from '../Provider/Provider';\r\nimport './Hanger.css';\r\nimport { mergeRefs } from '../../utils/mergeRefs';\r\n\r\ntype HangerContextValue = {\r\n props: any;\r\n ref: React.Ref<HTMLElement>;\r\n};\r\nconst HangerContext = React.createContext<HangerContextValue>({\r\n props: {},\r\n ref: null,\r\n});\r\n\r\nexport type HangerTexts = {\r\n /** Aria-label for the close icon button of hanger */\r\n close: string;\r\n};\r\n\r\nexport type HangerAnchorProps = React.HTMLAttributes<HTMLDivElement>;\r\nconst Anchor = React.forwardRef(function HangerAnchor(props: HangerAnchorProps, ref: React.Ref<HTMLDivElement>) {\r\n const context = React.useContext(HangerContext);\r\n let children = props.children;\r\n\r\n if (React.isValidElement(props.children) && typeof props.children?.type === 'function') {\r\n console.warn(\r\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`\r\n );\r\n children = <span>{props.children}</span>;\r\n }\r\n\r\n return (\r\n <PopoverPrimitive.Anchor {...context.props} {...props} children={children} ref={mergeRefs([context.ref, ref])} asChild />\r\n );\r\n});\r\n\r\nexport type HangerTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\r\nexport const Title = React.forwardRef(function DialogTitle(props: HangerTitleProps, ref: React.Ref<HTMLHeadingElement>) {\r\n const className = cn('mb-1 text-base font-bold flex w-full', props.className);\r\n return <span {...props} className={className} ref={ref} />;\r\n});\r\n\r\nexport type HangerContentProps = React.HTMLAttributes<HTMLDivElement> & {\r\n /** Set the position of the Hanger relative to its achor. Default value is `bottom` */\r\n placement?: Placement;\r\n};\r\n\r\nconst Content = React.forwardRef(function HangerContent(props: HangerContentProps, ref: React.Ref<HTMLDivElement>) {\r\n const context = React.useContext(HangerContext);\r\n const { texts } = useLocalization();\r\n const className = cn(\r\n 'wcag-blue border border-transparent rounded p-3 pr-12 yt-shadow z-[996] focus:border-transparent max-w-sm',\r\n props.className\r\n );\r\n const handleInteractOutside = (event: CustomEvent): void => {\r\n event.preventDefault();\r\n };\r\n\r\n return (\r\n <UnstyledContent\r\n className={className}\r\n data-taco=\"hanger\"\r\n onInteractOutside={handleInteractOutside}\r\n placement={props.placement}\r\n ref={ref}\r\n >\r\n {props.children}\r\n <UnstyledArrow className=\"text-blue\" />\r\n <PopoverPrimitive.Close asChild>\r\n <IconButton\r\n appearance=\"primary\"\r\n aria-label={texts.hanger.close}\r\n className=\"absolute top-0 right-0 ml-2 mr-2 mt-2 text-white\"\r\n icon=\"close\"\r\n onClick={context.props.onClose}\r\n />\r\n </PopoverPrimitive.Close>\r\n </UnstyledContent>\r\n );\r\n});\r\n\r\nexport type HangerProps = React.PropsWithChildren<{\r\n /** An anchor to be used for the hanger, should not be set if `children` already contains an anchor */\r\n anchor?: JSX.Element;\r\n /**\r\n * Shows or hides hanger depending on the value\r\n * @defaultValue true\r\n */\r\n defaultOpen?: boolean;\r\n /** Handler called when user closes the hanger */\r\n onClose?: () => void;\r\n}>;\r\n\r\nexport type ForwardedHangerWithStatics = React.ForwardRefExoticComponent<HangerProps & React.RefAttributes<HTMLElement>> & {\r\n Anchor: React.ForwardRefExoticComponent<HangerAnchorProps>;\r\n Content: React.ForwardRefExoticComponent<HangerContentProps>;\r\n Title: React.ForwardRefExoticComponent<HangerTitleProps>;\r\n};\r\n\r\nexport const Hanger = React.forwardRef(function Hanger(props: HangerProps, ref: React.Ref<HTMLElement>) {\r\n const { anchor, children, defaultOpen = true, ...otherProps } = props;\r\n const context = React.useMemo(() => ({ props: otherProps, ref }), [otherProps]);\r\n\r\n // we do this to ensure hangers are mounted after their containers, e.g. if the container is another portal\r\n const [open, setOpen] = React.useState(false);\r\n React.useEffect(() => {\r\n if (defaultOpen) {\r\n setOpen(defaultOpen);\r\n }\r\n }, []);\r\n\r\n return (\r\n <HangerContext.Provider value={context}>\r\n <PopoverPrimitive.Root key={String(open)} defaultOpen={open}>\r\n {anchor && <Anchor>{anchor}</Anchor>}\r\n {children}\r\n </PopoverPrimitive.Root>\r\n </HangerContext.Provider>\r\n );\r\n}) as ForwardedHangerWithStatics;\r\nHanger.Anchor = Anchor;\r\nHanger.Content = Content;\r\nHanger.Title = Title;\r\n"],"names":["HangerContext","React","props","ref","Anchor","HangerAnchor","context","children","type","console","warn","name","PopoverPrimitive","mergeRefs","asChild","Title","DialogTitle","className","cn","Content","HangerContent","useLocalization","texts","handleInteractOutside","event","preventDefault","UnstyledContent","onInteractOutside","placement","UnstyledArrow","IconButton","appearance","hanger","close","icon","onClick","onClose","Hanger","anchor","defaultOpen","otherProps","open","setOpen","Provider","value","key","String"],"mappings":";;;;;;;;;;AAcA,IAAMA,aAAa,gBAAGC,aAAA,CAAwC;EAC1DC,KAAK,EAAE,EADmD;EAE1DC,GAAG,EAAE;AAFqD,CAAxC,CAAtB;AAWA,IAAMC,MAAM,gBAAGH,UAAA,CAAiB,SAASI,YAAT,CAAsBH,KAAtB,EAAgDC,GAAhD;;;EAC5B,IAAMG,OAAO,GAAGL,UAAA,CAAiBD,aAAjB,CAAhB;EACA,IAAIO,QAAQ,GAAGL,KAAK,CAACK,QAArB;;EAEA,IAAIN,cAAA,CAAqBC,KAAK,CAACK,QAA3B,KAAwC,2BAAOL,KAAK,CAACK,QAAb,oDAAO,gBAAgBC,IAAvB,MAAgC,UAA5E,EAAwF;IACpFC,OAAO,CAACC,IAAR,qHACsHR,KAAK,CAACK,QAAN,CAAeC,IAAf,CAAoBG,IAD1I,mDAC4LT,KAAK,CAACK,QAAN,CAAeC,IAAf,CAAoBG,IADhN;IAGAJ,QAAQ,GAAGN,aAAA,OAAA,MAAA,EAAOC,KAAK,CAACK,QAAb,CAAX;;;EAGJ,OACIN,aAAA,CAACW,QAAD,oBAA6BN,OAAO,CAACJ,OAAWA;IAAOK,QA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AqBH,CAhCe,CAAhB;IAoDaC,MAAM,gBAAGpC,UAAA,CAAiB,SAASoC,MAAT,CAAgBnC,KAAhB,EAAoCC,GAApC;EACnC,IAAQmC,MAAR,GAAgEpC,KAAhE,CAAQoC,MAAR;MAAgB/B,QAAhB,GAAgEL,KAAhE,CAAgBK,QAAhB;2BAAgEL,KAAhE,CAA0BqC,WAA1B;MAA0BA,WAA1B,mCAAwC,IAAxC;MAAiDC,UAAjD,iCAAgEtC,KAAhE;;EACA,IAAMI,OAAO,GAAGL,OAAA,CAAc;IAAA,OAAO;MAAEC,KAAK,EAAEsC,UAAT;MAAqBrC,GAAG,EAAHA;KAA5B;GAAd,EAAkD,CAACqC,UAAD,CAAlD,CAAhB;;EAGA,sBAAwBvC,QAAA,CAAe,KAAf,CAAxB;MAAOwC,IAAP;MAAaC,OAAb;;EACAzC,SAAA,CAAgB;IACZ,IAAIsC,WAAJ,EAAiB;MACbG,OAAO,CAACH,WAAD,CAAP;;GAFR,EAIG,EAJH;EAMA,OACItC,aAAA,CAACD,aAAa,CAAC2C,QAAf;IAAwBC,KAAK,EAAEtC;GAA/B,EACIL,aAAA,CAACW,IAAD;IAAuBiC,GAAG,EAAEC,MAAM,CAACL,IAAD;IAAQF,WAAW,EAAEE;GAAvD,EACKH,MAAM,IAAIrC,aAAA,CAACG,MAAD,MAAA,EAASkC,MAAT,CADf,EAEK/B,QAFL,CADJ,CADJ;AAQH,CApBqB;AAqBtB8B,MAAM,CAACjC,MAAP,GAAgBA,MAAhB;AACAiC,MAAM,CAAClB,OAAP,GAAiBA,OAAjB;AACAkB,MAAM,CAACtB,KAAP,GAAeA,KAAf;;;;"}
package/dist/index.d.ts CHANGED
@@ -41,9 +41,9 @@ export * from './components/VisuallyHidden/VisuallyHidden';
41
41
  export * from './utils/date';
42
42
  export * from './utils/mergeRefs';
43
43
  export * from './utils/hooks/useBoundingClientRectListener';
44
+ export * from './utils/hooks/useDropTarget';
44
45
  export * from './utils/hooks/useListKeyboardNavigation';
45
- export * from './utils/hooks/useOnClickOutside';
46
46
  export * from './utils/hooks/useListScrollTo';
47
+ export * from './utils/hooks/useOnClickOutside';
47
48
  export * from './utils/hooks/useProxiedRef';
48
- export * from './utils/hooks/useDropTarget';
49
49
  export * from './types';
@@ -5911,12 +5911,13 @@ var Field = /*#__PURE__*/React.forwardRef(function Field(props, ref) {
5911
5911
  }, message));
5912
5912
  });
5913
5913
 
5914
- const Form = /*#__PURE__*/React.forwardRef(function Form(props, ref) {
5915
- const {
5916
- horizontal = false,
5917
- ...otherProps
5918
- } = props;
5919
- const className = cn('yt-form', {
5914
+ var _excluded$9 = ["horizontal"];
5915
+ var Form = /*#__PURE__*/React.forwardRef(function Form(props, ref) {
5916
+ var _props$horizontal = props.horizontal,
5917
+ horizontal = _props$horizontal === void 0 ? false : _props$horizontal,
5918
+ otherProps = _objectWithoutPropertiesLoose(props, _excluded$9);
5919
+
5920
+ var className = cn('yt-form', {
5920
5921
  'yt-form--horizontal flex flex-wrap': horizontal
5921
5922
  }, props.className);
5922
5923
  return React.createElement("form", Object.assign({}, otherProps, {
@@ -5926,11 +5927,11 @@ const Form = /*#__PURE__*/React.forwardRef(function Form(props, ref) {
5926
5927
  }));
5927
5928
  });
5928
5929
 
5929
- var _excluded$9 = ["as"];
5930
+ var _excluded$a = ["as"];
5930
5931
  var Group = /*#__PURE__*/React.forwardRef(function Group(props, ref) {
5931
5932
  var _props$as = props.as,
5932
5933
  Tag = _props$as === void 0 ? 'span' : _props$as,
5933
- otherProps = _objectWithoutPropertiesLoose(props, _excluded$9);
5934
+ otherProps = _objectWithoutPropertiesLoose(props, _excluded$a);
5934
5935
 
5935
5936
  var className = cn('flex ', props.className);
5936
5937
  return React.createElement(Tag, Object.assign({}, otherProps, {
@@ -5940,18 +5941,19 @@ var Group = /*#__PURE__*/React.forwardRef(function Group(props, ref) {
5940
5941
  }));
5941
5942
  });
5942
5943
 
5943
- const HangerContext = /*#__PURE__*/React.createContext({
5944
+ var _excluded$b = ["anchor", "children", "defaultOpen"];
5945
+ var HangerContext = /*#__PURE__*/React.createContext({
5944
5946
  props: {},
5945
5947
  ref: null
5946
5948
  });
5947
- const Anchor = /*#__PURE__*/React.forwardRef(function HangerAnchor(props, ref) {
5949
+ var Anchor = /*#__PURE__*/React.forwardRef(function HangerAnchor(props, ref) {
5948
5950
  var _props$children;
5949
5951
 
5950
- const context = React.useContext(HangerContext);
5951
- let children = props.children;
5952
+ var context = React.useContext(HangerContext);
5953
+ var children = props.children;
5952
5954
 
5953
5955
  if (React.isValidElement(props.children) && typeof ((_props$children = props.children) === null || _props$children === void 0 ? void 0 : _props$children.type) === 'function') {
5954
- console.warn(`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`);
5956
+ console.warn("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");
5955
5957
  children = React.createElement("span", null, props.children);
5956
5958
  }
5957
5959
 
@@ -5961,21 +5963,22 @@ const Anchor = /*#__PURE__*/React.forwardRef(function HangerAnchor(props, ref) {
5961
5963
  asChild: true
5962
5964
  }));
5963
5965
  });
5964
- const Title$1 = /*#__PURE__*/React.forwardRef(function DialogTitle(props, ref) {
5965
- const className = cn('mb-1 text-base font-bold flex w-full', props.className);
5966
+ var Title$1 = /*#__PURE__*/React.forwardRef(function DialogTitle(props, ref) {
5967
+ var className = cn('mb-1 text-base font-bold flex w-full', props.className);
5966
5968
  return React.createElement("span", Object.assign({}, props, {
5967
5969
  className: className,
5968
5970
  ref: ref
5969
5971
  }));
5970
5972
  });
5971
- const Content$3 = /*#__PURE__*/React.forwardRef(function HangerContent(props, ref) {
5972
- const context = React.useContext(HangerContext);
5973
- const {
5974
- texts
5975
- } = useLocalization();
5976
- const className = cn('wcag-blue border border-transparent rounded p-3 pr-12 yt-shadow z-[996] focus:border-transparent max-w-sm', props.className);
5973
+ var Content$3 = /*#__PURE__*/React.forwardRef(function HangerContent(props, ref) {
5974
+ var context = React.useContext(HangerContext);
5975
+
5976
+ var _useLocalization = useLocalization(),
5977
+ texts = _useLocalization.texts;
5978
+
5979
+ var className = cn('wcag-blue border border-transparent rounded p-3 pr-12 yt-shadow z-[996] focus:border-transparent max-w-sm', props.className);
5977
5980
 
5978
- const handleInteractOutside = event => {
5981
+ var handleInteractOutside = function handleInteractOutside(event) {
5979
5982
  event.preventDefault();
5980
5983
  };
5981
5984
 
@@ -5997,20 +6000,25 @@ const Content$3 = /*#__PURE__*/React.forwardRef(function HangerContent(props, re
5997
6000
  onClick: context.props.onClose
5998
6001
  })));
5999
6002
  });
6000
- const Hanger = /*#__PURE__*/React.forwardRef(function Hanger(props, ref) {
6001
- const {
6002
- anchor,
6003
- children,
6004
- defaultOpen = true,
6005
- ...otherProps
6006
- } = props;
6007
- const context = React.useMemo(() => ({
6008
- props: otherProps,
6009
- ref
6010
- }), [otherProps]); // we do this to ensure hangers are mounted after their containers, e.g. if the container is another portal
6003
+ var Hanger = /*#__PURE__*/React.forwardRef(function Hanger(props, ref) {
6004
+ var anchor = props.anchor,
6005
+ children = props.children,
6006
+ _props$defaultOpen = props.defaultOpen,
6007
+ defaultOpen = _props$defaultOpen === void 0 ? true : _props$defaultOpen,
6008
+ otherProps = _objectWithoutPropertiesLoose(props, _excluded$b);
6011
6009
 
6012
- const [open, setOpen] = React.useState(false);
6013
- React.useEffect(() => {
6010
+ var context = React.useMemo(function () {
6011
+ return {
6012
+ props: otherProps,
6013
+ ref: ref
6014
+ };
6015
+ }, [otherProps]); // we do this to ensure hangers are mounted after their containers, e.g. if the container is another portal
6016
+
6017
+ var _React$useState = React.useState(false),
6018
+ open = _React$useState[0],
6019
+ setOpen = _React$useState[1];
6020
+
6021
+ React.useEffect(function () {
6014
6022
  if (defaultOpen) {
6015
6023
  setOpen(defaultOpen);
6016
6024
  }
@@ -9469,10 +9477,10 @@ var useOnClickOutside = function useOnClickOutside(ref, callback) {
9469
9477
  }, [ref, callback]);
9470
9478
  };
9471
9479
 
9472
- var _excluded$a = ["noPadding"];
9480
+ var _excluded$c = ["noPadding"];
9473
9481
  var Content$6 = /*#__PURE__*/React.forwardRef(function CardContent(externalProps, ref) {
9474
9482
  var noPadding = externalProps.noPadding,
9475
- props = _objectWithoutPropertiesLoose(externalProps, _excluded$a);
9483
+ props = _objectWithoutPropertiesLoose(externalProps, _excluded$c);
9476
9484
 
9477
9485
  var className = cn('flex-grow overflow-auto', {
9478
9486
  'mx-4 mb-4': !noPadding