@elcrm/tooltip 0.1.2 → 0.1.3
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/index.es.js +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +6 -35
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import k, { useId as K, useRef as w, useState as T, useCallback as A, useLayoutEffect as G, useEffect as Q } from "react";
|
|
2
2
|
import { createPortal as U } from "react-dom";
|
|
3
|
-
import './index.css';const tt = "0.1.
|
|
3
|
+
import './index.css';const tt = "0.1.3", et = {
|
|
4
4
|
version: tt
|
|
5
5
|
}, nt = "ttr", rt = "ttt", ot = "ttv", it = "ttl", lt = "ttm", st = "ttx", ct = "tta", ut = "ttb", ft = "ttc", at = "ttd", i = {
|
|
6
6
|
r: nt,
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
(function(i,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],n):(i=typeof globalThis<"u"?globalThis:i||self,n((i.elCRM=i.elCRM||{},i.elCRM.tooltip={}),i.React,i.ReactDOM))})(this,function(i,n,N){"use strict";var z=document.createElement("style");z.textContent=`@layer elcrm-tooltip{.ttr{display:inline-flex;vertical-align:middle;max-width:100%}.ttt{position:fixed;box-sizing:border-box;max-width:var(--tooltip-max-width, 280px);padding:var(--tooltip-padding-block, 6px) var(--tooltip-padding-inline, 12px);border-radius:var(--tooltip-radius, 8px);background:var(--tooltip-bg, #1e1f24);color:var(--tooltip-fg, #eaeaea);font-size:var(--tooltip-font-size, 13px);line-height:1.35;font-weight:500;box-shadow:var(--tooltip-shadow, 0 8px 24px rgba(0, 0, 0, .28));pointer-events:none;opacity:0;transition:opacity .12s ease;white-space:normal;word-break:break-word}.ttv{opacity:1}.ttl{text-align:left}.ttm{text-align:center}.ttx{text-align:right}.ttt:before{content:"";position:absolute;width:0;height:0;pointer-events:none;border-style:solid;border-width:6px}.tta:before{top:100%;left:var(--tooltip-arrow-offset);margin-left:-6px;border-color:var(--tooltip-bg, #1e1f24) transparent transparent transparent}.ttb:before{bottom:100%;left:var(--tooltip-arrow-offset);margin-left:-6px;border-color:transparent transparent var(--tooltip-bg, #1e1f24) transparent}.ttc:before{left:100%;top:var(--tooltip-arrow-offset);margin-top:-6px;border-color:transparent transparent transparent var(--tooltip-bg, #1e1f24)}.ttd:before{right:100%;top:var(--tooltip-arrow-offset);margin-top:-6px;border-color:transparent var(--tooltip-bg, #1e1f24) transparent transparent}}
|
|
2
|
-
/*$vite$:1*/`,document.head.appendChild(z);const X={version:"0.1.
|
|
2
|
+
/*$vite$:1*/`,document.head.appendChild(z);const X={version:"0.1.3"},s={r:"ttr",t:"ttt",v:"ttv",l:"ttl",m:"ttm",x:"ttx",a:"tta",b:"ttb",c:"ttc",d:"ttd"},a=10,c=8,O=10;function C(t,e){return Math.min(Math.max(c,t),window.innerWidth-e-c)}function S(t,e){return Math.min(Math.max(c,t),window.innerHeight-e-c)}function v(t,e){return Math.min(Math.max(O,t),e-O)}function Y(t,e,T){const f=t.left+t.width/2,p=t.top+t.height/2;switch(T){case"top":{let r=t.top-e.height-a,o=C(f-e.width/2,e.width),l="top";return r<c&&(r=t.bottom+a,l="bottom"),{top:r,left:o,side:l,arrow:v(f-o,e.width)}}case"bottom":{let r=t.bottom+a,o=C(f-e.width/2,e.width),l="bottom";return r+e.height>window.innerHeight-c&&(r=t.top-e.height-a,l="top"),{top:r,left:o,side:l,arrow:v(f-o,e.width)}}case"left":{let r=S(p-e.height/2,e.height),o=t.left-e.width-a,l="left";return o<c&&(o=t.right+a,l="right"),{top:r,left:o,side:l,arrow:v(p-r,e.height)}}case"right":{let r=S(p-e.height/2,e.height),o=t.right+a,l="right";return o+e.width>window.innerWidth-c&&(o=t.left-e.width-a,l="left"),{top:r,left:o,side:l,arrow:v(p-r,e.height)}}}}const Z=1e3,H=10;function x(){const t=globalThis;return t.elcrm||(t.elcrm={}),t.elcrm.overlayZ||(t.elcrm.overlayZ={seq:0,active:new Set}),t.elcrm.overlayZ}function k(){const t=x();t.seq+=1;const e=Z+t.seq*H;return t.active.add(e),e}function y(t){const e=x();e.active.delete(t),e.active.size===0&&(e.seq=0)}function V(){const t=x();return t.active.size===0?Z:Math.max(...t.active)}const F={top:s.a,bottom:s.b,left:s.c,right:s.d};function J(t){return t==="left"?s.l:t==="right"?s.x:s.m}function K({content:t,children:e,placement:T,orientation:f,textAlign:p="center",delay:r=180,delayHide:o=60,className:l,disabled:q=!1,open:I}){const L=T??f??"top",_=n.useId(),$=n.useRef(null),P=n.useRef(null),g=n.useRef(null),b=n.useRef(null),u=n.useRef(null),[U,j]=n.useState(!1),[d,B]=n.useState(null),[A,D]=n.useState(null),M=()=>{g.current!=null&&(window.clearTimeout(g.current),g.current=null),b.current!=null&&(window.clearTimeout(b.current),b.current=null)},G=n.useCallback(()=>{q||t==null||t===""||(M(),g.current=window.setTimeout(()=>{j(!0)},r))},[t,r,q]),R=n.useCallback(()=>{I||(M(),b.current=window.setTimeout(()=>{j(!1),B(null)},o))},[o,I]),h=I||U;n.useLayoutEffect(()=>{if(h){if(u.current==null){const m=k();u.current=m,D(m)}return}u.current!=null&&(y(u.current),u.current=null,D(null))},[h]),n.useEffect(()=>()=>{M(),u.current!=null&&(y(u.current),u.current=null)},[]),n.useLayoutEffect(()=>{if(!h)return;const m=$.current,W=P.current;if(!m||!W)return;const w=()=>{const rt=m.getBoundingClientRect(),ot=W.getBoundingClientRect();B(Y(rt,ot,L))};return w(),window.addEventListener("resize",w),window.addEventListener("scroll",w,!0),()=>{window.removeEventListener("resize",w),window.removeEventListener("scroll",w,!0)}},[h,L,t]);const tt=d?{top:d.top,left:d.left,zIndex:A??1e3,"--tooltip-arrow-offset":`${d.arrow}px`}:{top:-9999,left:-9999,zIndex:A??1e3,visibility:"hidden"},et=[s.t,d?F[d.side]:"",J(p),d?s.v:""].filter(Boolean).join(" "),nt=h&&typeof document<"u"?N.createPortal(n.createElement("div",{ref:P,id:_,role:"tooltip",className:et,style:tt},t),document.body):null;return n.createElement("span",{ref:$,className:l?`${s.r} ${l}`:s.r,onMouseEnter:G,onMouseLeave:R,onFocus:G,onBlur:R,"aria-describedby":h?_:void 0},e,nt)}const Q=()=>null;function E(){return typeof globalThis<"u"?globalThis:{}}E().elcrm||(E().elcrm={}),Object.assign(E().elcrm,{tooltip:X.version}),i.Item=Q,i.Tooltip=K,i.acquireOverlayZIndex=k,i.peekOverlayZIndex=V,i.releaseOverlayZIndex=y,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elcrm/tooltip",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "React-подсказки для elCRM: portal, общий overlayZ-стек, hover/focus, CSS-переменные.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "MaSkal <dev@elcrm.online>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "
|
|
10
|
+
"url": "https://elgit.ru/lib/elCRM.tooltip.git"
|
|
11
11
|
},
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://elgit.ru/lib/elCRM.tooltip/issues"
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=18"
|
|
21
21
|
},
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"**/*.css",
|
|
24
|
+
"**/*.module.css"
|
|
25
|
+
],
|
|
22
26
|
"files": [
|
|
23
27
|
"dist"
|
|
24
28
|
],
|
|
@@ -29,10 +33,6 @@
|
|
|
29
33
|
"overlay",
|
|
30
34
|
"portal"
|
|
31
35
|
],
|
|
32
|
-
"sideEffects": [
|
|
33
|
-
"**/*.css",
|
|
34
|
-
"**/*.module.css"
|
|
35
|
-
],
|
|
36
36
|
"main": "./dist/index.umd.js",
|
|
37
37
|
"module": "./dist/index.es.js",
|
|
38
38
|
"types": "./dist/index.d.ts",
|
|
@@ -54,16 +54,6 @@
|
|
|
54
54
|
},
|
|
55
55
|
"./package.json": "./package.json"
|
|
56
56
|
},
|
|
57
|
-
"scripts": {
|
|
58
|
-
"dev": "vite --port 3001",
|
|
59
|
-
"build": "vite build && node scripts/postbuild.mjs",
|
|
60
|
-
"check:css": "bun scripts/check-css-scoped.mjs",
|
|
61
|
-
"check:tokens": "bun scripts/check-tokens.mjs",
|
|
62
|
-
"test": "vitest run",
|
|
63
|
-
"test:watch": "vitest",
|
|
64
|
-
"prepublishOnly": "bun run check:css && bun run check:tokens && bun run test && bun run build",
|
|
65
|
-
"pack:check": "npm pack --dry-run"
|
|
66
|
-
},
|
|
67
57
|
"peerDependencies": {
|
|
68
58
|
"@types/react": ">=18.0.0",
|
|
69
59
|
"react": ">=18.0.0",
|
|
@@ -73,24 +63,5 @@
|
|
|
73
63
|
"@types/react": {
|
|
74
64
|
"optional": true
|
|
75
65
|
}
|
|
76
|
-
},
|
|
77
|
-
"devDependencies": {
|
|
78
|
-
"@elcrm/storybook": "^0.0.3",
|
|
79
|
-
"@testing-library/jest-dom": "^6.6.3",
|
|
80
|
-
"@testing-library/react": "^16.2.0",
|
|
81
|
-
"@testing-library/user-event": "^14.6.1",
|
|
82
|
-
"@types/node": "^22.13.10",
|
|
83
|
-
"@types/react": "^18.2.66",
|
|
84
|
-
"@types/react-dom": "^18.2.22",
|
|
85
|
-
"@vitejs/plugin-react": "^4.3.1",
|
|
86
|
-
"elcrm": "file:../elCRM.cli",
|
|
87
|
-
"jsdom": "^26.0.0",
|
|
88
|
-
"react": "^18.2.0",
|
|
89
|
-
"react-dom": "^18.2.0",
|
|
90
|
-
"typescript": "^5.8.2",
|
|
91
|
-
"vite": "^5.4.2",
|
|
92
|
-
"vite-plugin-dts": "^4.0.3",
|
|
93
|
-
"vite-plugin-lib-inject-css": "^2.1.1",
|
|
94
|
-
"vitest": "^3.0.8"
|
|
95
66
|
}
|
|
96
67
|
}
|