ekm-ui 0.4.7 → 0.4.9
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/.turbo/turbo-build.log +11 -11
- package/CHANGELOG.md +6 -0
- package/dist/card-payment-block.js +2 -2
- package/dist/{chunk-3MJK7ZTP.js → chunk-3JMXJ65S.js} +3 -3
- package/dist/{chunk-3MJK7ZTP.js.map → chunk-3JMXJ65S.js.map} +1 -1
- package/dist/chunk-PKDFSF3I.js +11 -0
- package/dist/chunk-PKDFSF3I.js.map +1 -0
- package/dist/country-picker/country-modal.js +2 -2
- package/dist/drag-and-drop.js +2 -2
- package/dist/file-picker/file-picker.js +2 -2
- package/dist/index.js +2 -2
- package/dist/layout/layout.js +2 -2
- package/dist/product-picker/product-modal.js +2 -2
- package/dist/stacked-list-item.js +2 -2
- package/dist/table-header/table-header.js +2 -2
- package/dist/table-result-block.js +2 -2
- package/dist/tooltip/tooltip.d.ts +19 -2
- package/dist/tooltip/tooltip.js +2 -1
- package/package.json +1 -1
- package/src/table-header/table-header.tsx +2 -2
- package/src/tooltip/tooltip.tsx +19 -5
- package/dist/chunk-E62SCYLR.js +0 -9
- package/dist/chunk-E62SCYLR.js.map +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { a } from './chunk-6LHL364H.js';
|
|
2
|
+
import { e } from './chunk-Z4LPO673.js';
|
|
3
|
+
import x from 'clsx';
|
|
4
|
+
import { useRef, useEffect } from 'react';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var r=e(a(),1);function h({children:l,content:p,tooltipPos:s,width:o,additionalClasses:n}){let a=useRef(),f=useRef(),i=()=>{if(f.current&&a.current){let t=f.current.getBoundingClientRect(),e=a.current.getBoundingClientRect();["top","right","bottom","left"].find(b=>{switch(b){case"top":return t.top>=e.height;case"right":return window.innerWidth-t.right>=e.width;case"bottom":return window.innerHeight-t.bottom>=e.height;case"left":return t.left>=e.width;default:return !1}});}};return useEffect(()=>(i(),window.addEventListener("resize",i),()=>{window.removeEventListener("resize",i);}),[]),jsxs("div",{className:`group relative block w-fit ${n||""}`,ref:f,children:[l,jsx("div",{className:x("absolute z-50 w-fit whitespace-normal break-words rounded-md bg-black px-3 py-1 text-xs text-white opacity-0 after:absolute after:h-0 after:w-0 after:border-solid group-hover:visible group-hover:opacity-100 dark:bg-gray-700",{top:"bottom-full left-1/2 -translate-x-1/2 after:-bottom-[4px] after:left-1/2 after:-translate-x-1/2 after:border-b-0 after:border-l-[5px] after:border-r-[5px] after:border-t-[5px] after:border-transparent after:border-t-black dark:after:border-t-gray-700",right:"left-full top-1/2 -translate-y-1/2 after:-left-[4px] after:top-1/2 after:-translate-y-1/2 after:border-b-[5px] after:border-l-[0px] after:border-r-[5px] after:border-t-[5px] after:border-transparent after:border-r-black dark:after:border-r-gray-700",bottom:"left-1/2 top-full -translate-x-1/2 after:-top-[4px] after:left-1/2 after:-translate-x-1/2 after:border-b-[5px] after:border-l-[5px] after:border-r-[5px] after:border-t-[0px] after:border-transparent after:border-b-black dark:after:border-b-gray-700",left:"right-full top-1/2 -translate-y-1/2 after:-right-[4px] after:top-1/2 after:-translate-y-1/2 after:border-b-[5px] after:border-l-[5px] after:border-r-[0px] after:border-t-[5px] after:border-transparent after:border-l-black dark:after:border-l-gray-700"}[s]),ref:a,style:Number.isInteger(o)&&o>0?{width:`${o}px`}:{},children:p})]})}h.propTypes={children:r.default.node.isRequired,content:r.default.node.isRequired,tooltipPos:r.default.oneOf(["top","right","bottom","left"]).isRequired,width:r.default.number,additionalClasses:r.default.string};
|
|
8
|
+
|
|
9
|
+
export { h as a };
|
|
10
|
+
//# sourceMappingURL=out.js.map
|
|
11
|
+
//# sourceMappingURL=chunk-PKDFSF3I.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tooltip/tooltip.tsx"],"names":["import_prop_types","clsx","useEffect","useRef","jsx","jsxs","ToolTip","children","content","tooltipPos","width","additionalClasses","tooltipRef","childRef","updateTooltipPosition","childRect","tooltipRect","newPosition","pos","PropTypes"],"mappings":"gFAGA,IAAAA,EAAsB,SAFtB,OAAOC,MAAU,OACjB,OAAS,aAAAC,EAAW,UAAAC,MAAc,QAyC9B,OAEE,OAAAC,EAFF,QAAAC,MAAA,oBAtCG,SAASC,EAAQ,CAAE,SAAAC,EAAU,QAAAC,EAAS,WAAAC,EAAY,MAAAC,EAAO,kBAAAC,CAAkB,EAAG,CACnF,IAAMC,EAAaT,EAAO,EACpBU,EAAWV,EAAO,EAElBW,EAAwB,IAAM,CAClC,GAAID,EAAS,SAAWD,EAAW,QAAS,CAC1C,IAAMG,EAAYF,EAAS,QAAQ,sBAAsB,EACnDG,EAAcJ,EAAW,QAAQ,sBAAsB,EAIvDK,EAHY,CAAC,MAAO,QAAS,SAAU,MAAM,EAGrB,KAAMC,GAAQ,CAC1C,OAAQA,EAAK,CACX,IAAK,MACH,OAAOH,EAAU,KAAOC,EAAY,OACtC,IAAK,QACH,OAAO,OAAO,WAAaD,EAAU,OAASC,EAAY,MAC5D,IAAK,SACH,OAAO,OAAO,YAAcD,EAAU,QAAUC,EAAY,OAC9D,IAAK,OACH,OAAOD,EAAU,MAAQC,EAAY,MACvC,QACE,MAAO,EACX,CACF,CAAC,EAEL,EAEA,OAAAd,EAAU,KACRY,EAAsB,EACtB,OAAO,iBAAiB,SAAUA,CAAqB,EAEhD,IAAM,CACX,OAAO,oBAAoB,SAAUA,CAAqB,CAC5D,GACC,CAAC,CAAC,EAGHT,EAAC,OAAI,UAAW,8BAA8BM,GAAwC,KAAM,IAAKE,EAC9F,UAAAN,EACDH,EAAC,OACC,UAAWH,EACT,kOACA,CACE,IAAK,6PACL,MACE,2PACF,OACE,2PACF,KAAM,4PACR,EAAEQ,CAAU,CAEd,EACA,IAAKG,EACL,MAAO,OAAO,UAAUF,CAAK,GAAKA,EAAQ,EAAK,CAAE,MAAO,GAAGA,KAAU,EAAI,CAAC,EAEzE,SAAAF,EACH,GACF,CAEJ,CAEAF,EAAQ,UAAY,CAElB,SAAU,EAAAa,QAAU,KAAK,WAEzB,QAAS,EAAAA,QAAU,KAAK,WAExB,WAAY,EAAAA,QAAU,MAAM,CAAC,MAAO,QAAS,SAAU,MAAM,CAAC,EAAE,WAEhE,MAAO,EAAAA,QAAU,OAEjB,kBAAmB,EAAAA,QAAU,MAC/B","sourcesContent":["//@ts-nocheck\nimport clsx from \"clsx\";\nimport { useEffect, useRef } from \"react\";\nimport PropTypes from \"prop-types\";\n\nexport function ToolTip({ children, content, tooltipPos, width, additionalClasses }) {\n const tooltipRef = useRef();\n const childRef = useRef();\n\n const updateTooltipPosition = () => {\n if (childRef.current && tooltipRef.current) {\n const childRect = childRef.current.getBoundingClientRect();\n const tooltipRect = tooltipRef.current.getBoundingClientRect();\n const positions = [\"top\", \"right\", \"bottom\", \"left\"];\n\n // Find a position where the tooltip fits\n const newPosition = positions.find((pos) => {\n switch (pos) {\n case \"top\":\n return childRect.top >= tooltipRect.height;\n case \"right\":\n return window.innerWidth - childRect.right >= tooltipRect.width;\n case \"bottom\":\n return window.innerHeight - childRect.bottom >= tooltipRect.height;\n case \"left\":\n return childRect.left >= tooltipRect.width;\n default:\n return false;\n }\n });\n }\n };\n\n useEffect(() => {\n updateTooltipPosition();\n window.addEventListener(\"resize\", updateTooltipPosition);\n\n return () => {\n window.removeEventListener(\"resize\", updateTooltipPosition);\n };\n }, []);\n\n return (\n <div className={`group relative block w-fit ${additionalClasses ? additionalClasses : ''}`} ref={childRef}>\n {children}\n <div\n className={clsx(\n \"absolute z-50 w-fit whitespace-normal break-words rounded-md bg-black px-3 py-1 text-xs text-white opacity-0 after:absolute after:h-0 after:w-0 after:border-solid group-hover:visible group-hover:opacity-100 dark:bg-gray-700\",\n {\n top: \"bottom-full left-1/2 -translate-x-1/2 after:-bottom-[4px] after:left-1/2 after:-translate-x-1/2 after:border-b-0 after:border-l-[5px] after:border-r-[5px] after:border-t-[5px] after:border-transparent after:border-t-black dark:after:border-t-gray-700\",\n right:\n \"left-full top-1/2 -translate-y-1/2 after:-left-[4px] after:top-1/2 after:-translate-y-1/2 after:border-b-[5px] after:border-l-[0px] after:border-r-[5px] after:border-t-[5px] after:border-transparent after:border-r-black dark:after:border-r-gray-700\",\n bottom:\n \"left-1/2 top-full -translate-x-1/2 after:-top-[4px] after:left-1/2 after:-translate-x-1/2 after:border-b-[5px] after:border-l-[5px] after:border-r-[5px] after:border-t-[0px] after:border-transparent after:border-b-black dark:after:border-b-gray-700\",\n left: \"right-full top-1/2 -translate-y-1/2 after:-right-[4px] after:top-1/2 after:-translate-y-1/2 after:border-b-[5px] after:border-l-[5px] after:border-r-[0px] after:border-t-[5px] after:border-transparent after:border-l-black dark:after:border-l-gray-700\",\n }[tooltipPos]\n // takes the tooltip Positon and adds the relevant classes to the tooltip box to adjust the position of the box to the child element.\n )}\n ref={tooltipRef}\n style={Number.isInteger(width) && width > 0 ? { width: `${width}px` } : {}}\n >\n {content}\n </div>\n </div>\n );\n}\n\nToolTip.propTypes = {\n /** Target element of the tooltip */\n children: PropTypes.node.isRequired,\n /** Content to display in the tooltip */\n content: PropTypes.node.isRequired,\n /** String to determine the size of the badge. \"xs, sm\" */\n tooltipPos: PropTypes.oneOf([\"top\", \"right\", \"bottom\", \"left\"]).isRequired,\n /** width of tooltip in pixels. Otherwise w-fit is used. */\n width: PropTypes.number,\n /** Additional classes to add to div that surrounds children */\n additionalClasses: PropTypes.string,\n};\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { g as CountryPicker } from '../chunk-R4Z7MITT.js';
|
|
2
2
|
import '../chunk-52VBZOHL.js';
|
|
3
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-3JMXJ65S.js';
|
|
4
4
|
import '../chunk-YZ2YZSNQ.js';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-PKDFSF3I.js';
|
|
6
6
|
import '../chunk-7Q6OMA2A.js';
|
|
7
7
|
import '../chunk-KRMPO53Y.js';
|
|
8
8
|
import '../chunk-UFMUMALD.js';
|
package/dist/drag-and-drop.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { c as DragAndDrop } from './chunk-R4Z7MITT.js';
|
|
2
2
|
import './chunk-52VBZOHL.js';
|
|
3
|
-
import './chunk-
|
|
3
|
+
import './chunk-3JMXJ65S.js';
|
|
4
4
|
import './chunk-YZ2YZSNQ.js';
|
|
5
|
-
import './chunk-
|
|
5
|
+
import './chunk-PKDFSF3I.js';
|
|
6
6
|
import './chunk-7Q6OMA2A.js';
|
|
7
7
|
import './chunk-KRMPO53Y.js';
|
|
8
8
|
import './chunk-UFMUMALD.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { d as FilePicker } from '../chunk-R4Z7MITT.js';
|
|
2
2
|
import '../chunk-52VBZOHL.js';
|
|
3
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-3JMXJ65S.js';
|
|
4
4
|
import '../chunk-YZ2YZSNQ.js';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-PKDFSF3I.js';
|
|
6
6
|
import '../chunk-7Q6OMA2A.js';
|
|
7
7
|
import '../chunk-KRMPO53Y.js';
|
|
8
8
|
import '../chunk-UFMUMALD.js';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { h as CardPaymentBlock, g as CountryPicker, c as DragAndDrop, d as FilePicker, b as Layout, f as ProductPicker, a as StackedListItem, e as TableResultBlock } from './chunk-R4Z7MITT.js';
|
|
2
2
|
export { a as Sort } from './chunk-52VBZOHL.js';
|
|
3
|
-
export { a as TableHeader } from './chunk-
|
|
3
|
+
export { a as TableHeader } from './chunk-3JMXJ65S.js';
|
|
4
4
|
export { b as ToastProvider, c as useToast } from './chunk-YZ2YZSNQ.js';
|
|
5
|
-
export { a as ToolTip } from './chunk-
|
|
5
|
+
export { a as ToolTip } from './chunk-PKDFSF3I.js';
|
|
6
6
|
export { a as NBUI_Container } from './chunk-7Q6OMA2A.js';
|
|
7
7
|
export { a as Pagination } from './chunk-KRMPO53Y.js';
|
|
8
8
|
import './chunk-UFMUMALD.js';
|
package/dist/layout/layout.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { b as Layout } from '../chunk-R4Z7MITT.js';
|
|
2
2
|
import '../chunk-52VBZOHL.js';
|
|
3
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-3JMXJ65S.js';
|
|
4
4
|
import '../chunk-YZ2YZSNQ.js';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-PKDFSF3I.js';
|
|
6
6
|
import '../chunk-7Q6OMA2A.js';
|
|
7
7
|
import '../chunk-KRMPO53Y.js';
|
|
8
8
|
import '../chunk-UFMUMALD.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { f as ProductPicker } from '../chunk-R4Z7MITT.js';
|
|
2
2
|
import '../chunk-52VBZOHL.js';
|
|
3
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-3JMXJ65S.js';
|
|
4
4
|
import '../chunk-YZ2YZSNQ.js';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-PKDFSF3I.js';
|
|
6
6
|
import '../chunk-7Q6OMA2A.js';
|
|
7
7
|
import '../chunk-KRMPO53Y.js';
|
|
8
8
|
import '../chunk-UFMUMALD.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { a as StackedListItem } from './chunk-R4Z7MITT.js';
|
|
2
2
|
import './chunk-52VBZOHL.js';
|
|
3
|
-
import './chunk-
|
|
3
|
+
import './chunk-3JMXJ65S.js';
|
|
4
4
|
import './chunk-YZ2YZSNQ.js';
|
|
5
|
-
import './chunk-
|
|
5
|
+
import './chunk-PKDFSF3I.js';
|
|
6
6
|
import './chunk-7Q6OMA2A.js';
|
|
7
7
|
import './chunk-KRMPO53Y.js';
|
|
8
8
|
import './chunk-UFMUMALD.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { a as TableHeader } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { a as TableHeader } from '../chunk-3JMXJ65S.js';
|
|
2
|
+
import '../chunk-PKDFSF3I.js';
|
|
3
3
|
import '../chunk-6CVHAPIS.js';
|
|
4
4
|
import '../chunk-TJMI4DH2.js';
|
|
5
5
|
import '../chunk-6LHL364H.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { e as TableResultBlock } from './chunk-R4Z7MITT.js';
|
|
2
2
|
import './chunk-52VBZOHL.js';
|
|
3
|
-
import './chunk-
|
|
3
|
+
import './chunk-3JMXJ65S.js';
|
|
4
4
|
import './chunk-YZ2YZSNQ.js';
|
|
5
|
-
import './chunk-
|
|
5
|
+
import './chunk-PKDFSF3I.js';
|
|
6
6
|
import './chunk-7Q6OMA2A.js';
|
|
7
7
|
import './chunk-KRMPO53Y.js';
|
|
8
8
|
import './chunk-UFMUMALD.js';
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
|
|
3
|
+
declare function ToolTip({ children, content, tooltipPos, width, additionalClasses }: {
|
|
2
4
|
children: any;
|
|
3
5
|
content: any;
|
|
4
|
-
|
|
6
|
+
tooltipPos: any;
|
|
5
7
|
width: any;
|
|
8
|
+
additionalClasses: any;
|
|
6
9
|
}): JSX.Element;
|
|
10
|
+
declare namespace ToolTip {
|
|
11
|
+
var propTypes: {
|
|
12
|
+
/** Target element of the tooltip */
|
|
13
|
+
children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
|
14
|
+
/** Content to display in the tooltip */
|
|
15
|
+
content: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
|
16
|
+
/** String to determine the size of the badge. "xs, sm" */
|
|
17
|
+
tooltipPos: PropTypes.Validator<string>;
|
|
18
|
+
/** width of tooltip in pixels. Otherwise w-fit is used. */
|
|
19
|
+
width: PropTypes.Requireable<number>;
|
|
20
|
+
/** Additional classes to add to div that surrounds children */
|
|
21
|
+
additionalClasses: PropTypes.Requireable<string>;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
7
24
|
|
|
8
25
|
export { ToolTip };
|
package/dist/tooltip/tooltip.js
CHANGED
package/package.json
CHANGED
|
@@ -129,7 +129,7 @@ function TableHeaderItem({ ...props }) {
|
|
|
129
129
|
return (
|
|
130
130
|
<div
|
|
131
131
|
className={`${layout} ${sortable ? "cursor-pointer" : ""} ${
|
|
132
|
-
tooltip != null ? "
|
|
132
|
+
tooltip != null ? " flex align-items-center float-left" : ""
|
|
133
133
|
} `}
|
|
134
134
|
>
|
|
135
135
|
<span
|
|
@@ -143,7 +143,7 @@ function TableHeaderItem({ ...props }) {
|
|
|
143
143
|
<div className="ml-2 mt-1">
|
|
144
144
|
<ToolTip
|
|
145
145
|
key={`tooltipName-${title}`}
|
|
146
|
-
|
|
146
|
+
tooltipPos="bottom"
|
|
147
147
|
content={tooltip}
|
|
148
148
|
>
|
|
149
149
|
<HiExclamationCircle fontSize="20px" color="#555555" />
|
package/src/tooltip/tooltip.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
//@ts-nocheck
|
|
2
2
|
import clsx from "clsx";
|
|
3
3
|
import { useEffect, useRef } from "react";
|
|
4
|
+
import PropTypes from "prop-types";
|
|
4
5
|
|
|
5
|
-
export function ToolTip({ children, content,
|
|
6
|
+
export function ToolTip({ children, content, tooltipPos, width, additionalClasses }) {
|
|
6
7
|
const tooltipRef = useRef();
|
|
7
8
|
const childRef = useRef();
|
|
8
9
|
|
|
@@ -40,11 +41,11 @@ export function ToolTip({ children, content, tooltopPos, width }) {
|
|
|
40
41
|
}, []);
|
|
41
42
|
|
|
42
43
|
return (
|
|
43
|
-
<div className=
|
|
44
|
+
<div className={`group relative block w-fit ${additionalClasses ? additionalClasses : ''}`} ref={childRef}>
|
|
44
45
|
{children}
|
|
45
46
|
<div
|
|
46
47
|
className={clsx(
|
|
47
|
-
"
|
|
48
|
+
"absolute z-50 w-fit whitespace-normal break-words rounded-md bg-black px-3 py-1 text-xs text-white opacity-0 after:absolute after:h-0 after:w-0 after:border-solid group-hover:visible group-hover:opacity-100 dark:bg-gray-700",
|
|
48
49
|
{
|
|
49
50
|
top: "bottom-full left-1/2 -translate-x-1/2 after:-bottom-[4px] after:left-1/2 after:-translate-x-1/2 after:border-b-0 after:border-l-[5px] after:border-r-[5px] after:border-t-[5px] after:border-transparent after:border-t-black dark:after:border-t-gray-700",
|
|
50
51
|
right:
|
|
@@ -52,14 +53,27 @@ export function ToolTip({ children, content, tooltopPos, width }) {
|
|
|
52
53
|
bottom:
|
|
53
54
|
"left-1/2 top-full -translate-x-1/2 after:-top-[4px] after:left-1/2 after:-translate-x-1/2 after:border-b-[5px] after:border-l-[5px] after:border-r-[5px] after:border-t-[0px] after:border-transparent after:border-b-black dark:after:border-b-gray-700",
|
|
54
55
|
left: "right-full top-1/2 -translate-y-1/2 after:-right-[4px] after:top-1/2 after:-translate-y-1/2 after:border-b-[5px] after:border-l-[5px] after:border-r-[0px] after:border-t-[5px] after:border-transparent after:border-l-black dark:after:border-l-gray-700",
|
|
55
|
-
}[
|
|
56
|
+
}[tooltipPos]
|
|
56
57
|
// takes the tooltip Positon and adds the relevant classes to the tooltip box to adjust the position of the box to the child element.
|
|
57
58
|
)}
|
|
58
59
|
ref={tooltipRef}
|
|
59
|
-
style={{ width: `${width}px` }}
|
|
60
|
+
style={Number.isInteger(width) && width > 0 ? { width: `${width}px` } : {}}
|
|
60
61
|
>
|
|
61
62
|
{content}
|
|
62
63
|
</div>
|
|
63
64
|
</div>
|
|
64
65
|
);
|
|
65
66
|
}
|
|
67
|
+
|
|
68
|
+
ToolTip.propTypes = {
|
|
69
|
+
/** Target element of the tooltip */
|
|
70
|
+
children: PropTypes.node.isRequired,
|
|
71
|
+
/** Content to display in the tooltip */
|
|
72
|
+
content: PropTypes.node.isRequired,
|
|
73
|
+
/** String to determine the size of the badge. "xs, sm" */
|
|
74
|
+
tooltipPos: PropTypes.oneOf(["top", "right", "bottom", "left"]).isRequired,
|
|
75
|
+
/** width of tooltip in pixels. Otherwise w-fit is used. */
|
|
76
|
+
width: PropTypes.number,
|
|
77
|
+
/** Additional classes to add to div that surrounds children */
|
|
78
|
+
additionalClasses: PropTypes.string,
|
|
79
|
+
};
|
package/dist/chunk-E62SCYLR.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import p from 'clsx';
|
|
2
|
-
import { useRef, useEffect } from 'react';
|
|
3
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
-
|
|
5
|
-
function m({children:i,content:n,tooltopPos:l,width:d}){let e=useRef(),a=useRef(),o=()=>{if(a.current&&e.current){let r=a.current.getBoundingClientRect(),t=e.current.getBoundingClientRect();["top","right","bottom","left"].find(b=>{switch(b){case"top":return r.top>=t.height;case"right":return window.innerWidth-r.right>=t.width;case"bottom":return window.innerHeight-r.bottom>=t.height;case"left":return r.left>=t.width;default:return !1}});}};return useEffect(()=>(o(),window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o);}),[]),jsxs("div",{className:"group relative block w-fit p-2",ref:a,children:[i,jsx("div",{className:p("invisible absolute z-50 w-full whitespace-normal break-words rounded-md bg-black px-3 py-1 text-xs text-white opacity-0 after:absolute after:h-0 after:w-0 after:border-solid group-hover:visible group-hover:opacity-100 dark:bg-gray-700",{top:"bottom-full left-1/2 -translate-x-1/2 after:-bottom-[4px] after:left-1/2 after:-translate-x-1/2 after:border-b-0 after:border-l-[5px] after:border-r-[5px] after:border-t-[5px] after:border-transparent after:border-t-black dark:after:border-t-gray-700",right:"left-full top-1/2 -translate-y-1/2 after:-left-[4px] after:top-1/2 after:-translate-y-1/2 after:border-b-[5px] after:border-l-[0px] after:border-r-[5px] after:border-t-[5px] after:border-transparent after:border-r-black dark:after:border-r-gray-700",bottom:"left-1/2 top-full -translate-x-1/2 after:-top-[4px] after:left-1/2 after:-translate-x-1/2 after:border-b-[5px] after:border-l-[5px] after:border-r-[5px] after:border-t-[0px] after:border-transparent after:border-b-black dark:after:border-b-gray-700",left:"right-full top-1/2 -translate-y-1/2 after:-right-[4px] after:top-1/2 after:-translate-y-1/2 after:border-b-[5px] after:border-l-[5px] after:border-r-[0px] after:border-t-[5px] after:border-transparent after:border-l-black dark:after:border-l-gray-700"}[l]),ref:e,style:{width:`${d}px`},children:n})]})}
|
|
6
|
-
|
|
7
|
-
export { m as a };
|
|
8
|
-
//# sourceMappingURL=out.js.map
|
|
9
|
-
//# sourceMappingURL=chunk-E62SCYLR.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tooltip/tooltip.tsx"],"names":["clsx","useEffect","useRef","jsx","jsxs","ToolTip","children","content","tooltopPos","width","tooltipRef","childRef","updateTooltipPosition","childRect","tooltipRect","newPosition","pos"],"mappings":"AACA,OAAOA,MAAU,OACjB,OAAS,aAAAC,EAAW,UAAAC,MAAc,QAwC9B,OAEE,OAAAC,EAFF,QAAAC,MAAA,oBAtCG,SAASC,EAAQ,CAAE,SAAAC,EAAU,QAAAC,EAAS,WAAAC,EAAY,MAAAC,CAAM,EAAG,CAChE,IAAMC,EAAaR,EAAO,EACpBS,EAAWT,EAAO,EAElBU,EAAwB,IAAM,CAClC,GAAID,EAAS,SAAWD,EAAW,QAAS,CAC1C,IAAMG,EAAYF,EAAS,QAAQ,sBAAsB,EACnDG,EAAcJ,EAAW,QAAQ,sBAAsB,EAIvDK,EAHY,CAAC,MAAO,QAAS,SAAU,MAAM,EAGrB,KAAMC,GAAQ,CAC1C,OAAQA,EAAK,CACX,IAAK,MACH,OAAOH,EAAU,KAAOC,EAAY,OACtC,IAAK,QACH,OAAO,OAAO,WAAaD,EAAU,OAASC,EAAY,MAC5D,IAAK,SACH,OAAO,OAAO,YAAcD,EAAU,QAAUC,EAAY,OAC9D,IAAK,OACH,OAAOD,EAAU,MAAQC,EAAY,MACvC,QACE,MAAO,EACX,CACF,CAAC,EAEL,EAEA,OAAAb,EAAU,KACRW,EAAsB,EACtB,OAAO,iBAAiB,SAAUA,CAAqB,EAEhD,IAAM,CACX,OAAO,oBAAoB,SAAUA,CAAqB,CAC5D,GACC,CAAC,CAAC,EAGHR,EAAC,OAAI,UAAU,iCAAiC,IAAKO,EAClD,UAAAL,EACDH,EAAC,OACC,UAAWH,EACT,6OACA,CACE,IAAK,6PACL,MACE,2PACF,OACE,2PACF,KAAM,4PACR,EAAEQ,CAAU,CAEd,EACA,IAAKE,EACL,MAAO,CAAE,MAAO,GAAGD,KAAU,EAE5B,SAAAF,EACH,GACF,CAEJ","sourcesContent":["//@ts-nocheck\nimport clsx from \"clsx\";\nimport { useEffect, useRef } from \"react\";\n\nexport function ToolTip({ children, content, tooltopPos, width }) {\n const tooltipRef = useRef();\n const childRef = useRef();\n\n const updateTooltipPosition = () => {\n if (childRef.current && tooltipRef.current) {\n const childRect = childRef.current.getBoundingClientRect();\n const tooltipRect = tooltipRef.current.getBoundingClientRect();\n const positions = [\"top\", \"right\", \"bottom\", \"left\"];\n\n // Find a position where the tooltip fits\n const newPosition = positions.find((pos) => {\n switch (pos) {\n case \"top\":\n return childRect.top >= tooltipRect.height;\n case \"right\":\n return window.innerWidth - childRect.right >= tooltipRect.width;\n case \"bottom\":\n return window.innerHeight - childRect.bottom >= tooltipRect.height;\n case \"left\":\n return childRect.left >= tooltipRect.width;\n default:\n return false;\n }\n });\n }\n };\n\n useEffect(() => {\n updateTooltipPosition();\n window.addEventListener(\"resize\", updateTooltipPosition);\n\n return () => {\n window.removeEventListener(\"resize\", updateTooltipPosition);\n };\n }, []);\n\n return (\n <div className=\"group relative block w-fit p-2\" ref={childRef}>\n {children}\n <div\n className={clsx(\n \"invisible absolute z-50 w-full whitespace-normal break-words rounded-md bg-black px-3 py-1 text-xs text-white opacity-0 after:absolute after:h-0 after:w-0 after:border-solid group-hover:visible group-hover:opacity-100 dark:bg-gray-700\",\n {\n top: \"bottom-full left-1/2 -translate-x-1/2 after:-bottom-[4px] after:left-1/2 after:-translate-x-1/2 after:border-b-0 after:border-l-[5px] after:border-r-[5px] after:border-t-[5px] after:border-transparent after:border-t-black dark:after:border-t-gray-700\",\n right:\n \"left-full top-1/2 -translate-y-1/2 after:-left-[4px] after:top-1/2 after:-translate-y-1/2 after:border-b-[5px] after:border-l-[0px] after:border-r-[5px] after:border-t-[5px] after:border-transparent after:border-r-black dark:after:border-r-gray-700\",\n bottom:\n \"left-1/2 top-full -translate-x-1/2 after:-top-[4px] after:left-1/2 after:-translate-x-1/2 after:border-b-[5px] after:border-l-[5px] after:border-r-[5px] after:border-t-[0px] after:border-transparent after:border-b-black dark:after:border-b-gray-700\",\n left: \"right-full top-1/2 -translate-y-1/2 after:-right-[4px] after:top-1/2 after:-translate-y-1/2 after:border-b-[5px] after:border-l-[5px] after:border-r-[0px] after:border-t-[5px] after:border-transparent after:border-l-black dark:after:border-l-gray-700\",\n }[tooltopPos]\n // takes the tooltip Positon and adds the relevant classes to the tooltip box to adjust the position of the box to the child element.\n )}\n ref={tooltipRef}\n style={{ width: `${width}px` }}\n >\n {content}\n </div>\n </div>\n );\n}\n"]}
|