@ktfth/stickjs 3.0.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/CHANGELOG.md +169 -0
- package/README.md +449 -0
- package/bin/registry.json +20 -0
- package/bin/stickjs.js +158 -0
- package/llms.txt +244 -0
- package/package.json +38 -0
- package/stick-ui/components/accordion.html +25 -0
- package/stick-ui/components/autocomplete.html +82 -0
- package/stick-ui/components/command-palette.html +28 -0
- package/stick-ui/components/copy-button.html +12 -0
- package/stick-ui/components/data-table.html +191 -0
- package/stick-ui/components/dialog.html +23 -0
- package/stick-ui/components/dropdown.html +16 -0
- package/stick-ui/components/notification.html +11 -0
- package/stick-ui/components/skeleton.html +11 -0
- package/stick-ui/components/stepper.html +102 -0
- package/stick-ui/components/tabs.html +26 -0
- package/stick-ui/components/toast.html +10 -0
- package/stick-ui/components/toggle-group.html +16 -0
- package/stick-ui/components/toggle.html +9 -0
- package/stick-ui/components/tooltip.html +12 -0
- package/stick-ui/plugins/autocomplete.js +422 -0
- package/stick-ui/plugins/command-palette.js +289 -0
- package/stick-ui/plugins/data-table.js +426 -0
- package/stick-ui/plugins/dropdown.js +70 -0
- package/stick-ui/plugins/stepper.js +155 -0
- package/stick-ui/plugins/toast.js +51 -0
- package/stick-ui/plugins/tooltip.js +67 -0
- package/stick-ui/stick-ui.css +825 -0
- package/stick.d.ts +105 -0
- package/stick.js +655 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Stick UI — Tooltip plugin
|
|
3
|
+
* Usage: data-stick="mouseenter:tooltip:Text" data-stick-2="mouseleave:tooltip-hide:"
|
|
4
|
+
* Position: data-stk-tooltip-pos="top|bottom|left|right" (default: top)
|
|
5
|
+
*/
|
|
6
|
+
(function (root) {
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
var active = null;
|
|
10
|
+
|
|
11
|
+
function position(tip, anchor) {
|
|
12
|
+
var rect = anchor.getBoundingClientRect();
|
|
13
|
+
var pos = anchor.dataset.stkTooltipPos || 'top';
|
|
14
|
+
var gap = 6;
|
|
15
|
+
tip.style.position = 'fixed';
|
|
16
|
+
tip.style.zIndex = '400';
|
|
17
|
+
// Reset
|
|
18
|
+
tip.style.transform = '';
|
|
19
|
+
tip.style.top = '';
|
|
20
|
+
tip.style.left = '';
|
|
21
|
+
|
|
22
|
+
switch (pos) {
|
|
23
|
+
case 'bottom':
|
|
24
|
+
tip.style.top = (rect.bottom + gap) + 'px';
|
|
25
|
+
tip.style.left = (rect.left + rect.width / 2) + 'px';
|
|
26
|
+
tip.style.transform = 'translateX(-50%)';
|
|
27
|
+
break;
|
|
28
|
+
case 'left':
|
|
29
|
+
tip.style.top = (rect.top + rect.height / 2) + 'px';
|
|
30
|
+
tip.style.left = (rect.left - gap) + 'px';
|
|
31
|
+
tip.style.transform = 'translate(-100%, -50%)';
|
|
32
|
+
break;
|
|
33
|
+
case 'right':
|
|
34
|
+
tip.style.top = (rect.top + rect.height / 2) + 'px';
|
|
35
|
+
tip.style.left = (rect.right + gap) + 'px';
|
|
36
|
+
tip.style.transform = 'translateY(-50%)';
|
|
37
|
+
break;
|
|
38
|
+
default: // top
|
|
39
|
+
tip.style.top = (rect.top - gap) + 'px';
|
|
40
|
+
tip.style.left = (rect.left + rect.width / 2) + 'px';
|
|
41
|
+
tip.style.transform = 'translate(-50%, -100%)';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var stkTooltip = {
|
|
46
|
+
install: function(stick) {
|
|
47
|
+
stick.add('tooltip', function(el, param) {
|
|
48
|
+
if (active) active.remove();
|
|
49
|
+
var tip = document.createElement('div');
|
|
50
|
+
tip.className = 'stk-tooltip';
|
|
51
|
+
tip.setAttribute('role', 'tooltip');
|
|
52
|
+
tip.textContent = param;
|
|
53
|
+
document.body.appendChild(tip);
|
|
54
|
+
position(tip, el);
|
|
55
|
+
active = tip;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
stick.add('tooltip-hide', function() {
|
|
59
|
+
if (active) { active.remove(); active = null; }
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
if (root.Stick) root.Stick.use(stkTooltip);
|
|
65
|
+
if (typeof module !== 'undefined' && module.exports) module.exports = stkTooltip;
|
|
66
|
+
root.stkTooltip = stkTooltip;
|
|
67
|
+
}(typeof window !== 'undefined' ? window : this));
|