@visactor/react-vtable 1.12.1-alpha.1 → 1.13.1-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,5 +1,5 @@
1
1
  import type { IGroup } from '@visactor/vtable/es/vrender';
2
- import type { ReactElement, ReactNode } from 'react';
2
+ import type { CSSProperties, ReactElement, ReactNode } from 'react';
3
3
  import React from 'react';
4
4
  type Anchor = 'top' | 'tl' | 'tr' | 'bottom' | 'bl' | 'br' | 'left' | 'lt' | 'lb' | 'right' | 'rt' | 'rb';
5
5
  export interface PopoverProps {
@@ -8,6 +8,8 @@ export interface PopoverProps {
8
8
  popupVisible?: boolean;
9
9
  position?: Anchor;
10
10
  content?: ReactNode;
11
+ panelStyle?: CSSProperties;
12
+ arrowStyle?: CSSProperties;
11
13
  }
12
14
  export declare const Popover: React.ForwardRefExoticComponent<PopoverProps & React.RefAttributes<IGroup>>;
13
15
  export {};
@@ -32,7 +32,7 @@ Object.defineProperty(exports, "__esModule", {
32
32
  const vutils_1 = require("@visactor/vutils"), react_1 = __importStar(require("react")), table_components_1 = require("../../table-components"), defaultProps = {
33
33
  defaultPopupVisible: !1,
34
34
  position: "top"
35
- }, poptipPanalStyle = {
35
+ }, defaultPoptipPanelStyle = {
36
36
  backgroundColor: "rgb(255, 255, 255)",
37
37
  boxShadow: "0 4px 10px rgba(0, 0, 0, .1)",
38
38
  fontSize: "14px",
@@ -43,7 +43,7 @@ const vutils_1 = require("@visactor/vutils"), react_1 = __importStar(require("re
43
43
  border: "1px solid rgb(229, 230, 235)",
44
44
  padding: "12px 16px"
45
45
  }, Tooltip = props => {
46
- const arrowStyle = Object.assign({
46
+ const arrowStyle = Object.assign(Object.assign({
47
47
  content: "",
48
48
  height: "8px",
49
49
  width: "8px",
@@ -54,16 +54,16 @@ const vutils_1 = require("@visactor/vutils"), react_1 = __importStar(require("re
54
54
  transformOrigin: "50% 50% 0",
55
55
  backgroundColor: "rgb(255, 255, 255)",
56
56
  border: "1px solid rgb(229, 230, 235)"
57
- }, getArrowStyle(props.position));
57
+ }, getArrowStyle(props.position)), props.arrowStyle);
58
58
  return props.visible ? react_1.default.createElement(react_1.default.Fragment, null, react_1.default.createElement("div", {
59
- style: poptipPanalStyle
59
+ style: (0, vutils_1.merge)({}, defaultPoptipPanelStyle, props.panelStyle)
60
60
  }, props.content), react_1.default.createElement("div", {
61
61
  style: arrowStyle
62
62
  })) : react_1.default.createElement(react_1.default.Fragment, null);
63
63
  };
64
64
 
65
65
  function PopoverComponent(baseProps, ref) {
66
- const props = (0, vutils_1.merge)({}, defaultProps, baseProps), {content: content, position: position, popupVisible: popupVisible, defaultPopupVisible: defaultPopupVisible, children: children} = props;
66
+ const props = (0, vutils_1.merge)({}, defaultProps, baseProps), {content: content, position: position, popupVisible: popupVisible, defaultPopupVisible: defaultPopupVisible, panelStyle: panelStyle, arrowStyle: arrowStyle, children: children} = props;
67
67
  let popoverRef = react_1.default.useRef(null);
68
68
  popoverRef = ref || popoverRef;
69
69
  const [popupOpen, setPopupOpen] = (0, react_1.useState)(!1);
@@ -81,7 +81,9 @@ function PopoverComponent(baseProps, ref) {
81
81
  element: react_1.default.createElement(Tooltip, {
82
82
  visible: popupOpen,
83
83
  content: content,
84
- position: position
84
+ position: position,
85
+ panelStyle: panelStyle,
86
+ arrowStyle: arrowStyle
85
87
  }),
86
88
  container: null,
87
89
  visible: !0,
@@ -1 +1 @@
1
- {"version":3,"sources":["components/popover/popover.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,6CAAkD;AAElD,+CAAgE;AAChE,6DAA+C;AAe/C,MAAM,YAAY,GAAiB;IACjC,mBAAmB,EAAE,KAAK;IAG1B,QAAQ,EAAE,KAAK;CAChB,CAAC;AAEF,MAAM,gBAAgB,GAAkB;IACtC,eAAe,EAAE,oBAAoB;IACrC,SAAS,EAAE,8BAA8B;IACzC,QAAQ,EAAE,MAAM;IAChB,YAAY,EAAE,K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EAAE,iBAAiB;gBACtB,IAAI,EAAE,kBAAkB;gBACxB,UAAU,EAAE,MAAM;gBAClB,YAAY,EAAE,MAAM;aACrB,CAAC;QACJ,KAAK,IAAI;YACP,OAAO;gBACL,GAAG,EAAE,MAAM;gBACX,IAAI,EAAE,kBAAkB;gBACxB,UAAU,EAAE,MAAM;gBAClB,YAAY,EAAE,MAAM;aACrB,CAAC;QACJ,KAAK,IAAI;YACP,OAAO;gBACL,GAAG,EAAE,mBAAmB;gBACxB,IAAI,EAAE,kBAAkB;gBACxB,UAAU,EAAE,MAAM;gBAClB,YAAY,EAAE,MAAM;aACrB,CAAC;QACJ,KAAK,OAAO;YACV,OAAO;gBACL,GAAG,EAAE,iBAAiB;gBACtB,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,MAAM;gBACnB,SAAS,EAAE,MAAM;aAClB,CAAC;QACJ,KAAK,IAAI;YACP,OAAO;gBACL,GAAG,EAAE,MAAM;gBACX,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,MAAM;gBACnB,SAAS,EAAE,MAAM;aAClB,CAAC;QACJ,KAAK,IAAI;YACP,OAAO;gBACL,GAAG,EAAE,mBAAmB;gBACxB,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,MAAM;gBACnB,SAAS,EAAE,MAAM;aAClB,CAAC;KACL;AACH,CAAC;AAEY,QAAA,OAAO,GAAG,eAAK,CAAC,UAAU,CAAuB,gBAAgB,CAAC,CAAC;AAEhF,eAAO,CAAC,WAAW,GAAG,SAAS,CAAC","file":"popover.js","sourcesContent":["import type {\n BackgroundAttributes,\n Cursor,\n IGroup,\n IGroupGraphicAttribute,\n IRectGraphicAttribute,\n ITextGraphicAttribute,\n Padding,\n Tag,\n TagAttributes\n} from '@visactor/vtable/es/vrender';\nimport { Tag as VTag } from '../vrender-components/tag';\nimport type { BoundsAnchorType } from '@visactor/vutils';\nimport { isValid, merge } from '@visactor/vutils';\nimport type { CSSProperties, ReactElement, ReactNode } from 'react';\nimport React, { useCallback, useEffect, useState } from 'react';\nimport { Group } from '../../table-components';\n\ntype Anchor = 'top' | 'tl' | 'tr' | 'bottom' | 'bl' | 'br' | 'left' | 'lt' | 'lb' | 'right' | 'rt' | 'rb';\nexport interface PopoverProps {\n children?: ReactElement;\n defaultPopupVisible?: boolean;\n // disabled?: boolean;\n // popupHoverStay?: boolean;\n popupVisible?: boolean;\n // color?: string;\n position?: Anchor;\n content?: ReactNode;\n // onVisibleChange?: (visible: boolean) => void;\n}\n\nconst defaultProps: PopoverProps = {\n defaultPopupVisible: false,\n // popupHoverStay: true,\n // popupVisible: false,\n position: 'top'\n};\n\nconst poptipPanalStyle: CSSProperties = {\n backgroundColor: 'rgb(255, 255, 255)',\n boxShadow: '0 4px 10px rgba(0, 0, 0, .1)',\n fontSize: '14px',\n borderRadius: '4px',\n lineHeight: '1.5715',\n boxSizing: 'border-box',\n color: 'rgb(78, 89, 105)',\n border: '1px solid rgb(229, 230, 235)',\n padding: '12px 16px'\n};\n\nconst Tooltip = (props: { visible: boolean; content: ReactNode; position: Anchor }) => {\n const arrowStyle: CSSProperties = {\n content: '',\n height: '8px',\n width: '8px',\n position: 'absolute',\n display: 'block',\n boxSizing: 'border-box',\n transform: 'rotate(45deg)',\n transformOrigin: '50% 50% 0',\n backgroundColor: 'rgb(255, 255, 255)',\n border: '1px solid rgb(229, 230, 235)',\n ...getArrowStyle(props.position)\n };\n\n return props.visible ? (\n <>\n <div style={poptipPanalStyle}>{props.content}</div>\n <div style={arrowStyle}></div>\n </>\n ) : (\n <></>\n );\n};\n\nfunction PopoverComponent(baseProps: PopoverProps, ref: React.Ref<IGroup>) {\n const props: PopoverProps = merge({}, defaultProps, baseProps);\n const { content, position, popupVisible, defaultPopupVisible, children } = props;\n let popoverRef = React.useRef<IGroup>(null);\n popoverRef = ref ? (ref as React.RefObject<IGroup>) : popoverRef;\n\n const [popupOpen, setPopupOpen] = useState(false);\n\n useEffect(() => {\n if (popupVisible) {\n setPopupOpen(true);\n } else {\n setPopupOpen(false);\n }\n popoverRef.current.stage.renderNextFrame();\n }, [popupVisible]);\n\n useEffect(() => {\n setPopupOpen(popupVisible ?? defaultPopupVisible ?? false);\n }, []);\n\n const { transform, anchorType } = getTransform(position);\n const poptipContainerStyle: CSSProperties = {\n // display: popupOpen ? 'block' : 'none',\n transform: transform\n };\n\n const groupAttribute: IGroupGraphicAttribute = {\n react: {\n // width: 100,\n // height: 100,\n style: poptipContainerStyle,\n element: <Tooltip visible={popupOpen} content={content} position={position} />,\n container: null,\n visible: true,\n pointerEvents: false,\n anchorType: anchorType\n } as IGroupGraphicAttribute['react']\n };\n\n const groupMouseEnter = useCallback((event: any) => {\n if (isValid(popupVisible)) {\n return;\n }\n setPopupOpen(true);\n event.currentTarget.stage.renderNextFrame();\n }, []);\n\n const groupMouseLeave = useCallback((event: any) => {\n if (isValid(popupVisible)) {\n return;\n }\n setPopupOpen(false);\n event.currentTarget.stage.renderNextFrame();\n }, []);\n\n return (\n <Group ref={popoverRef} attribute={groupAttribute} onMouseEnter={groupMouseEnter} onMouseLeave={groupMouseLeave}>\n {children}\n </Group>\n );\n}\n\nfunction getTransform(position: Anchor): { transform: string; anchorType: BoundsAnchorType } {\n switch (position) {\n case 'top':\n return {\n anchorType: 'top',\n transform: 'translate(-50%, calc(-100% - 10px))'\n };\n case 'tl':\n return {\n anchorType: 'top-left',\n transform: 'translate(0, calc(-100% - 10px))'\n };\n case 'tr':\n return {\n anchorType: 'top-right',\n transform: 'translate(-100%, calc(-100% - 10px))'\n };\n case 'bottom':\n return {\n anchorType: 'bottom',\n transform: 'translate(-50%, 10px)'\n };\n case 'bl':\n return {\n anchorType: 'bottom-left',\n transform: 'translate(0, 10px)'\n };\n case 'br':\n return {\n anchorType: 'bottom-right',\n transform: 'translate(-100%, 10px)'\n };\n case 'left':\n return {\n anchorType: 'left',\n transform: 'translate(calc(-100% - 10px), -50%)'\n };\n case 'lt':\n return {\n anchorType: 'top-left',\n transform: 'translate(calc(-100% - 10px), 0)'\n };\n case 'lb':\n return {\n anchorType: 'bottom-left',\n transform: 'translate(calc(-100% - 10px), -100%)'\n };\n case 'right':\n return {\n anchorType: 'right',\n transform: 'translate(10px, -50%)'\n };\n case 'rt':\n return {\n anchorType: 'top-right',\n transform: 'translate(10px, 0)'\n };\n case 'rb':\n return {\n anchorType: 'bottom-right',\n transform: 'translate(10px, -100%)'\n };\n }\n}\n\nfunction getArrowStyle(position: Anchor): CSSProperties {\n switch (position) {\n case 'top':\n return {\n top: 'calc(100% - 5px)',\n left: 'calc(50% - 5px)',\n borderTop: 'none',\n borderLeft: 'none'\n };\n case 'tl':\n return {\n top: 'calc(100% - 4px)',\n left: '14px', // 4(1/2width) + 10(offset)\n borderTop: 'none',\n borderLeft: 'none'\n };\n case 'tr':\n return {\n top: 'calc(100% - 4px)',\n left: 'calc(100% - 24px)', // 10(offset) + 10(width) + 4(1/2width)\n borderTop: 'none',\n borderLeft: 'none'\n };\n case 'bottom':\n return {\n top: '-4px',\n left: 'calc(50% - 4px)',\n borderRight: 'none',\n borderBottom: 'none'\n };\n case 'bl':\n return {\n top: '-4px',\n left: '14px', // 4(1/2width) + 10(offset)\n borderRight: 'none',\n borderBottom: 'none'\n };\n case 'br':\n return {\n top: '-4px',\n left: 'calc(100% - 24px)', // 10(offset) + 10(width) + 4(1/2width)\n borderRight: 'none',\n borderBottom: 'none'\n };\n case 'left':\n return {\n top: 'calc(50% - 4px)',\n left: 'calc(100% - 5px)',\n borderLeft: 'none',\n borderBottom: 'none'\n };\n case 'lt':\n return {\n top: '14px', // 4(1/2width) + 10(offset)\n left: 'calc(100% - 5px)',\n borderLeft: 'none',\n borderBottom: 'none'\n };\n case 'lb':\n return {\n top: 'calc(100% - 24px)', // 10(offset) + 10(width) + 4(1/2width)\n left: 'calc(100% - 5px)',\n borderLeft: 'none',\n borderBottom: 'none'\n };\n case 'right':\n return {\n top: 'calc(50% - 4px)',\n left: '-4px',\n borderRight: 'none',\n borderTop: 'none'\n };\n case 'rt':\n return {\n top: '14px', // 4(1/2width) + 10(offset)\n left: '-4px',\n borderRight: 'none',\n borderTop: 'none'\n };\n case 'rb':\n return {\n top: 'calc(100% - 24px)', // 10(offset) + 10(width) + 4(1/2width)\n left: '-4px',\n borderRight: 'none',\n borderTop: 'none'\n };\n }\n}\n\nexport const Popover = React.forwardRef<IGroup, PopoverProps>(PopoverComponent);\n\nPopover.displayName = 'Popover';\n"]}
1
+ {"version":3,"sources":["components/popover/popover.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,6CAAkD;AAElD,+CAAgE;AAChE,6DAA+C;AAkB/C,MAAM,YAAY,GAAiB;IACjC,mBAAmB,EAAE,KAAK;IAG1B,QAAQ,EAAE,KAAK;CAChB,CAAC;AAEF,MAAM,uBAAuB,GAAkB;IAC7C,eAAe,EAAE,oBAAoB;IACrC,SAAS,EAAE,8BAA8B;IACzC,QAAQ,EAAE,MAAM;IAChB,YAAY,EAAE,KAAK;IACnB,UAAU,EAAE,QAAQ;IACpB,SAAS,EAAE,YAAY;IACvB,KAAK,EAAE,kBAAkB;IACzB,MAAM,EAAE,8BAA8B;IACtC,OAAO,EAAE,WAAW;CACrB,CAAC;AAEF,MAAM,OAAO,GAAG,CAAC,KAMhB,EAAE,EAAE;IACH,MAAM,UAAU,iCACd,OAAO,EAAE,EAAE,EACX,MAAM,EAAE,KAAK,EACb,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,YAAY,EACvB,SAAS,EAAE,eAAe,EAC1B,eAAe,EAAE,WAAW,EAC5B,eAAe,EAAE,oBAAoB,EACrC,MAAM,EAAE,8BAA8B,IACnC,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,GAE7B,KAAK,CAAC,UAAU,CACpB,CAAC;IAEF,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CACrB;QACE,uCAAK,KAAK,EAAE,IAAA,cAAK,EAAC,E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;gBACZ,WAAW,EAAE,MAAM;gBACnB,SAAS,EAAE,MAAM;aAClB,CAAC;QACJ,KAAK,IAAI;YACP,OAAO;gBACL,GAAG,EAAE,MAAM;gBACX,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,MAAM;gBACnB,SAAS,EAAE,MAAM;aAClB,CAAC;QACJ,KAAK,IAAI;YACP,OAAO;gBACL,GAAG,EAAE,mBAAmB;gBACxB,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,MAAM;gBACnB,SAAS,EAAE,MAAM;aAClB,CAAC;KACL;AACH,CAAC;AAEY,QAAA,OAAO,GAAG,eAAK,CAAC,UAAU,CAAuB,gBAAgB,CAAC,CAAC;AAEhF,eAAO,CAAC,WAAW,GAAG,SAAS,CAAC","file":"popover.js","sourcesContent":["import type {\n BackgroundAttributes,\n Cursor,\n IGroup,\n IGroupGraphicAttribute,\n IRectGraphicAttribute,\n ITextGraphicAttribute,\n Padding,\n Tag,\n TagAttributes\n} from '@visactor/vtable/es/vrender';\nimport { Tag as VTag } from '../vrender-components/tag';\nimport type { BoundsAnchorType } from '@visactor/vutils';\nimport { isValid, merge } from '@visactor/vutils';\nimport type { CSSProperties, ReactElement, ReactNode } from 'react';\nimport React, { useCallback, useEffect, useState } from 'react';\nimport { Group } from '../../table-components';\n\ntype Anchor = 'top' | 'tl' | 'tr' | 'bottom' | 'bl' | 'br' | 'left' | 'lt' | 'lb' | 'right' | 'rt' | 'rb';\nexport interface PopoverProps {\n children?: ReactElement;\n defaultPopupVisible?: boolean;\n // disabled?: boolean;\n // popupHoverStay?: boolean;\n popupVisible?: boolean;\n // color?: string;\n position?: Anchor;\n content?: ReactNode;\n // onVisibleChange?: (visible: boolean) => void;\n\n panelStyle?: CSSProperties;\n arrowStyle?: CSSProperties;\n}\n\nconst defaultProps: PopoverProps = {\n defaultPopupVisible: false,\n // popupHoverStay: true,\n // popupVisible: false,\n position: 'top'\n};\n\nconst defaultPoptipPanelStyle: CSSProperties = {\n backgroundColor: 'rgb(255, 255, 255)',\n boxShadow: '0 4px 10px rgba(0, 0, 0, .1)',\n fontSize: '14px',\n borderRadius: '4px',\n lineHeight: '1.5715',\n boxSizing: 'border-box',\n color: 'rgb(78, 89, 105)',\n border: '1px solid rgb(229, 230, 235)',\n padding: '12px 16px'\n};\n\nconst Tooltip = (props: {\n visible: boolean;\n content: ReactNode;\n position: Anchor;\n panelStyle?: CSSProperties;\n arrowStyle?: CSSProperties;\n}) => {\n const arrowStyle: CSSProperties = {\n content: '',\n height: '8px',\n width: '8px',\n position: 'absolute',\n display: 'block',\n boxSizing: 'border-box',\n transform: 'rotate(45deg)',\n transformOrigin: '50% 50% 0',\n backgroundColor: 'rgb(255, 255, 255)',\n border: '1px solid rgb(229, 230, 235)',\n ...getArrowStyle(props.position),\n\n ...props.arrowStyle\n };\n\n return props.visible ? (\n <>\n <div style={merge({}, defaultPoptipPanelStyle, props.panelStyle)}>{props.content}</div>\n <div style={arrowStyle}></div>\n </>\n ) : (\n <></>\n );\n};\n\nfunction PopoverComponent(baseProps: PopoverProps, ref: React.Ref<IGroup>) {\n const props: PopoverProps = merge({}, defaultProps, baseProps);\n const { content, position, popupVisible, defaultPopupVisible, panelStyle, arrowStyle, children } = props;\n let popoverRef = React.useRef<IGroup>(null);\n popoverRef = ref ? (ref as React.RefObject<IGroup>) : popoverRef;\n\n const [popupOpen, setPopupOpen] = useState(false);\n\n useEffect(() => {\n if (popupVisible) {\n setPopupOpen(true);\n } else {\n setPopupOpen(false);\n }\n popoverRef.current.stage.renderNextFrame();\n }, [popupVisible]);\n\n useEffect(() => {\n setPopupOpen(popupVisible ?? defaultPopupVisible ?? false);\n }, []);\n\n const { transform, anchorType } = getTransform(position);\n const poptipContainerStyle: CSSProperties = {\n // display: popupOpen ? 'block' : 'none',\n transform: transform\n };\n\n const groupAttribute: IGroupGraphicAttribute = {\n react: {\n // width: 100,\n // height: 100,\n style: poptipContainerStyle,\n element: (\n <Tooltip\n visible={popupOpen}\n content={content}\n position={position}\n panelStyle={panelStyle}\n arrowStyle={arrowStyle}\n />\n ),\n container: null,\n visible: true,\n pointerEvents: false,\n anchorType: anchorType\n } as IGroupGraphicAttribute['react']\n };\n\n const groupMouseEnter = useCallback((event: any) => {\n if (isValid(popupVisible)) {\n return;\n }\n setPopupOpen(true);\n event.currentTarget.stage.renderNextFrame();\n }, []);\n\n const groupMouseLeave = useCallback((event: any) => {\n if (isValid(popupVisible)) {\n return;\n }\n setPopupOpen(false);\n event.currentTarget.stage.renderNextFrame();\n }, []);\n\n return (\n <Group ref={popoverRef} attribute={groupAttribute} onMouseEnter={groupMouseEnter} onMouseLeave={groupMouseLeave}>\n {children}\n </Group>\n );\n}\n\nfunction getTransform(position: Anchor): { transform: string; anchorType: BoundsAnchorType } {\n switch (position) {\n case 'top':\n return {\n anchorType: 'top',\n transform: 'translate(-50%, calc(-100% - 10px))'\n };\n case 'tl':\n return {\n anchorType: 'top-left',\n transform: 'translate(0, calc(-100% - 10px))'\n };\n case 'tr':\n return {\n anchorType: 'top-right',\n transform: 'translate(-100%, calc(-100% - 10px))'\n };\n case 'bottom':\n return {\n anchorType: 'bottom',\n transform: 'translate(-50%, 10px)'\n };\n case 'bl':\n return {\n anchorType: 'bottom-left',\n transform: 'translate(0, 10px)'\n };\n case 'br':\n return {\n anchorType: 'bottom-right',\n transform: 'translate(-100%, 10px)'\n };\n case 'left':\n return {\n anchorType: 'left',\n transform: 'translate(calc(-100% - 10px), -50%)'\n };\n case 'lt':\n return {\n anchorType: 'top-left',\n transform: 'translate(calc(-100% - 10px), 0)'\n };\n case 'lb':\n return {\n anchorType: 'bottom-left',\n transform: 'translate(calc(-100% - 10px), -100%)'\n };\n case 'right':\n return {\n anchorType: 'right',\n transform: 'translate(10px, -50%)'\n };\n case 'rt':\n return {\n anchorType: 'top-right',\n transform: 'translate(10px, 0)'\n };\n case 'rb':\n return {\n anchorType: 'bottom-right',\n transform: 'translate(10px, -100%)'\n };\n }\n}\n\nfunction getArrowStyle(position: Anchor): CSSProperties {\n switch (position) {\n case 'top':\n return {\n top: 'calc(100% - 5px)',\n left: 'calc(50% - 5px)',\n borderTop: 'none',\n borderLeft: 'none'\n };\n case 'tl':\n return {\n top: 'calc(100% - 4px)',\n left: '14px', // 4(1/2width) + 10(offset)\n borderTop: 'none',\n borderLeft: 'none'\n };\n case 'tr':\n return {\n top: 'calc(100% - 4px)',\n left: 'calc(100% - 24px)', // 10(offset) + 10(width) + 4(1/2width)\n borderTop: 'none',\n borderLeft: 'none'\n };\n case 'bottom':\n return {\n top: '-4px',\n left: 'calc(50% - 4px)',\n borderRight: 'none',\n borderBottom: 'none'\n };\n case 'bl':\n return {\n top: '-4px',\n left: '14px', // 4(1/2width) + 10(offset)\n borderRight: 'none',\n borderBottom: 'none'\n };\n case 'br':\n return {\n top: '-4px',\n left: 'calc(100% - 24px)', // 10(offset) + 10(width) + 4(1/2width)\n borderRight: 'none',\n borderBottom: 'none'\n };\n case 'left':\n return {\n top: 'calc(50% - 4px)',\n left: 'calc(100% - 5px)',\n borderLeft: 'none',\n borderBottom: 'none'\n };\n case 'lt':\n return {\n top: '14px', // 4(1/2width) + 10(offset)\n left: 'calc(100% - 5px)',\n borderLeft: 'none',\n borderBottom: 'none'\n };\n case 'lb':\n return {\n top: 'calc(100% - 24px)', // 10(offset) + 10(width) + 4(1/2width)\n left: 'calc(100% - 5px)',\n borderLeft: 'none',\n borderBottom: 'none'\n };\n case 'right':\n return {\n top: 'calc(50% - 4px)',\n left: '-4px',\n borderRight: 'none',\n borderTop: 'none'\n };\n case 'rt':\n return {\n top: '14px', // 4(1/2width) + 10(offset)\n left: '-4px',\n borderRight: 'none',\n borderTop: 'none'\n };\n case 'rb':\n return {\n top: 'calc(100% - 24px)', // 10(offset) + 10(width) + 4(1/2width)\n left: '-4px',\n borderRight: 'none',\n borderTop: 'none'\n };\n }\n}\n\nexport const Popover = React.forwardRef<IGroup, PopoverProps>(PopoverComponent);\n\nPopover.displayName = 'Popover';\n"]}
package/cjs/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './tables';
2
2
  export * from './table-components';
3
3
  export * from './components';
4
- export declare const version = "1.12.1-alpha.1";
4
+ export declare const version = "1.13.1-alpha.0";
package/cjs/index.js CHANGED
@@ -18,5 +18,5 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
18
18
  Object.defineProperty(exports, "__esModule", {
19
19
  value: !0
20
20
  }), exports.version = void 0, __exportStar(require("./tables"), exports), __exportStar(require("./table-components"), exports),
21
- __exportStar(require("./components"), exports), exports.version = "1.12.1-alpha.1";
21
+ __exportStar(require("./components"), exports), exports.version = "1.13.1-alpha.0";
22
22
  //# sourceMappingURL=index.js.map
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,qDAAmC;AACnC,+CAA6B;AAEhB,QAAA,OAAO,GAAG,gBAAgB,CAAC","file":"index.js","sourcesContent":["export * from './tables';\nexport * from './table-components';\nexport * from './components';\n\nexport const version = \"1.12.1-alpha.1\";\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,qDAAmC;AACnC,+CAA6B;AAEhB,QAAA,OAAO,GAAG,gBAAgB,CAAC","file":"index.js","sourcesContent":["export * from './tables';\nexport * from './table-components';\nexport * from './components';\n\nexport const version = \"1.13.1-alpha.0\";\n"]}