@prokodo/ui 0.1.11 → 0.1.13
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/README.md +6 -1
- package/dist/components/RTE/RTE.client.js +46 -5
- package/dist/components/RTE/RTE.css +226 -6
- package/dist/components/RTE/RTE.module.css +226 -6
- package/dist/components/RTE/RTE.module.scss.js +3 -0
- package/dist/components/RTE/RTE.utils.js +23 -1
- package/dist/components/accordion/Accordion.css +46 -0
- package/dist/components/accordion/Accordion.module.css +46 -0
- package/dist/components/accordion/Accordion.module.scss.js +4 -0
- package/dist/components/accordion/Accordion.view.js +25 -5
- package/dist/components/autocomplete/Autocomplete.client.js +132 -0
- package/dist/components/autocomplete/Autocomplete.css +317 -0
- package/dist/components/autocomplete/Autocomplete.js +12 -0
- package/dist/components/autocomplete/Autocomplete.lazy.js +12 -0
- package/dist/components/autocomplete/Autocomplete.module.css +317 -0
- package/dist/components/autocomplete/Autocomplete.module.scss.js +21 -0
- package/dist/components/autocomplete/Autocomplete.server.js +11 -0
- package/dist/components/autocomplete/Autocomplete.view.js +142 -0
- package/dist/components/autocomplete/index.js +4 -0
- package/dist/components/button/Button.css +1 -0
- package/dist/components/button/Button.module.css +1 -0
- package/dist/components/card/Card.css +9 -0
- package/dist/components/card/Card.module.css +9 -0
- package/dist/components/card/Card.module.scss.js +1 -0
- package/dist/components/dynamic-list/DynamicList.view.js +1 -1
- package/dist/components/input/Input.css +23 -4
- package/dist/components/input/Input.module.css +23 -4
- package/dist/components/pagination/Pagination.client.js +14 -0
- package/dist/components/pagination/Pagination.css +191 -0
- package/dist/components/pagination/Pagination.js +12 -0
- package/dist/components/pagination/Pagination.lazy.js +12 -0
- package/dist/components/pagination/Pagination.module.css +191 -0
- package/dist/components/pagination/Pagination.module.scss.js +12 -0
- package/dist/components/pagination/Pagination.server.js +11 -0
- package/dist/components/pagination/Pagination.utils.js +55 -0
- package/dist/components/pagination/Pagination.view.js +98 -0
- package/dist/components/pagination/index.js +4 -0
- package/dist/components/rich-text/RichText.css +0 -1
- package/dist/components/rich-text/RichText.module.css +0 -1
- package/dist/components/select/Select.client.js +230 -8
- package/dist/components/select/Select.css +47 -16
- package/dist/components/select/Select.module.css +47 -16
- package/dist/components/select/Select.module.scss.js +2 -0
- package/dist/components/select/Select.view.js +20 -57
- package/dist/components/switch/Switch.css +1 -1
- package/dist/components/switch/Switch.module.css +1 -1
- package/dist/components/switch/Switch.view.js +3 -1
- package/dist/components/tabs/Tabs.client.js +182 -0
- package/dist/components/tabs/Tabs.css +330 -0
- package/dist/components/tabs/Tabs.js +13 -0
- package/dist/components/tabs/Tabs.lazy.js +15 -0
- package/dist/components/tabs/Tabs.module.css +330 -0
- package/dist/components/tabs/Tabs.module.scss.js +19 -0
- package/dist/components/tabs/Tabs.server.js +11 -0
- package/dist/components/tabs/Tabs.view.js +157 -0
- package/dist/components/tabs/index.js +4 -0
- package/dist/components/tooltip/Tooltip.client.js +382 -0
- package/dist/components/tooltip/Tooltip.css +242 -0
- package/dist/components/tooltip/Tooltip.js +16 -0
- package/dist/components/tooltip/Tooltip.module.css +242 -0
- package/dist/components/tooltip/Tooltip.module.scss.js +15 -0
- package/dist/components/tooltip/Tooltip.server.js +12 -0
- package/dist/components/tooltip/Tooltip.view.js +127 -0
- package/dist/components/tooltip/index.js +4 -0
- package/dist/constants/project.js +1 -1
- package/dist/index.js +8 -0
- package/dist/theme.css +640 -22
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/components/RTE/RTE.utils.d.ts +1 -0
- package/dist/types/components/accordion/Accordion.d.ts +3 -0
- package/dist/types/components/accordion/Accordion.lazy.d.ts +3 -0
- package/dist/types/components/accordion/Accordion.model.d.ts +3 -0
- package/dist/types/components/accordion/Accordion.view.d.ts +1 -1
- package/dist/types/components/autocomplete/Autocomplete.client.d.ts +5 -0
- package/dist/types/components/autocomplete/Autocomplete.d.ts +4 -0
- package/dist/types/components/autocomplete/Autocomplete.lazy.d.ts +5 -0
- package/dist/types/components/autocomplete/Autocomplete.model.d.ts +58 -0
- package/dist/types/components/autocomplete/Autocomplete.server.d.ts +3 -0
- package/dist/types/components/autocomplete/Autocomplete.view.d.ts +3 -0
- package/dist/types/components/autocomplete/index.d.ts +2 -0
- package/dist/types/components/card/Card.model.d.ts +1 -1
- package/dist/types/components/grid/Grid.model.d.ts +37 -7
- package/dist/types/components/pagination/Pagination.client.d.ts +5 -0
- package/dist/types/components/pagination/Pagination.d.ts +4 -0
- package/dist/types/components/pagination/Pagination.lazy.d.ts +5 -0
- package/dist/types/components/pagination/Pagination.model.d.ts +22 -0
- package/dist/types/components/pagination/Pagination.server.d.ts +3 -0
- package/dist/types/components/pagination/Pagination.utils.d.ts +13 -0
- package/dist/types/components/pagination/Pagination.view.d.ts +3 -0
- package/dist/types/components/pagination/index.d.ts +2 -0
- package/dist/types/components/select/Select.model.d.ts +16 -1
- package/dist/types/components/tabs/Tabs.client.d.ts +5 -0
- package/dist/types/components/tabs/Tabs.d.ts +4 -0
- package/dist/types/components/tabs/Tabs.lazy.d.ts +5 -0
- package/dist/types/components/tabs/Tabs.model.d.ts +43 -0
- package/dist/types/components/tabs/Tabs.server.d.ts +3 -0
- package/dist/types/components/tabs/Tabs.view.d.ts +3 -0
- package/dist/types/components/tabs/index.d.ts +2 -0
- package/dist/types/components/tooltip/Tooltip.client.d.ts +5 -0
- package/dist/types/components/tooltip/Tooltip.d.ts +4 -0
- package/dist/types/components/tooltip/Tooltip.lazy.d.ts +5 -0
- package/dist/types/components/tooltip/Tooltip.model.d.ts +47 -0
- package/dist/types/components/tooltip/Tooltip.server.d.ts +3 -0
- package/dist/types/components/tooltip/Tooltip.view.d.ts +3 -0
- package/dist/types/components/tooltip/index.d.ts +2 -0
- package/dist/types/index.d.ts +4 -0
- package/package.json +23 -2
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
5
|
+
import { memo, useState, useRef, useCallback, useMemo, useLayoutEffect } from "react";
|
|
6
|
+
import { createPortal } from "react-dom";
|
|
7
|
+
import { create } from "../../helpers/bem.js";
|
|
8
|
+
import styles from "./Tooltip.module.scss.js";
|
|
9
|
+
import { TooltipView } from "./Tooltip.view.js";
|
|
10
|
+
const bem = create(styles, "Tooltip");
|
|
11
|
+
function clamp(n, min, max) {
|
|
12
|
+
return Math.max(min, Math.min(max, n));
|
|
13
|
+
}
|
|
14
|
+
__name(clamp, "clamp");
|
|
15
|
+
function getOverlayRoot(id, zIndex) {
|
|
16
|
+
let el = document.getElementById(id);
|
|
17
|
+
if (!el) {
|
|
18
|
+
el = document.createElement("div");
|
|
19
|
+
el.id = id;
|
|
20
|
+
document.body.appendChild(el);
|
|
21
|
+
}
|
|
22
|
+
el.style.position = "fixed";
|
|
23
|
+
el.style.left = "0";
|
|
24
|
+
el.style.top = "0";
|
|
25
|
+
el.style.width = "0";
|
|
26
|
+
el.style.height = "0";
|
|
27
|
+
el.style.pointerEvents = "none";
|
|
28
|
+
el.style.zIndex = String(zIndex);
|
|
29
|
+
return el;
|
|
30
|
+
}
|
|
31
|
+
__name(getOverlayRoot, "getOverlayRoot");
|
|
32
|
+
function opposite(p) {
|
|
33
|
+
if (p === "top") return "bottom";
|
|
34
|
+
if (p === "bottom") return "top";
|
|
35
|
+
if (p === "left") return "right";
|
|
36
|
+
return "left";
|
|
37
|
+
}
|
|
38
|
+
__name(opposite, "opposite");
|
|
39
|
+
function perpendicular(p) {
|
|
40
|
+
if (p === "top" || p === "bottom") return ["right", "left"];
|
|
41
|
+
return ["top", "bottom"];
|
|
42
|
+
}
|
|
43
|
+
__name(perpendicular, "perpendicular");
|
|
44
|
+
function fitsPlacement(args) {
|
|
45
|
+
const {
|
|
46
|
+
placement,
|
|
47
|
+
anchorX,
|
|
48
|
+
anchorY,
|
|
49
|
+
triggerRect,
|
|
50
|
+
bubbleSize,
|
|
51
|
+
gutter,
|
|
52
|
+
offset,
|
|
53
|
+
arrowSize
|
|
54
|
+
} = args;
|
|
55
|
+
const vw = window.innerWidth;
|
|
56
|
+
const vh = window.innerHeight;
|
|
57
|
+
const need = offset + arrowSize;
|
|
58
|
+
let left = 0;
|
|
59
|
+
let top = 0;
|
|
60
|
+
if (placement === "top") {
|
|
61
|
+
left = anchorX - bubbleSize.w / 2;
|
|
62
|
+
top = triggerRect.top - need - bubbleSize.h;
|
|
63
|
+
} else if (placement === "bottom") {
|
|
64
|
+
left = anchorX - bubbleSize.w / 2;
|
|
65
|
+
top = triggerRect.bottom + need;
|
|
66
|
+
} else if (placement === "left") {
|
|
67
|
+
left = triggerRect.left - need - bubbleSize.w;
|
|
68
|
+
top = anchorY - bubbleSize.h / 2;
|
|
69
|
+
} else {
|
|
70
|
+
left = triggerRect.right + need;
|
|
71
|
+
top = anchorY - bubbleSize.h / 2;
|
|
72
|
+
}
|
|
73
|
+
const right = left + bubbleSize.w;
|
|
74
|
+
const bottom = top + bubbleSize.h;
|
|
75
|
+
return left >= gutter && right <= vw - gutter && top >= gutter && bottom <= vh - gutter;
|
|
76
|
+
}
|
|
77
|
+
__name(fitsPlacement, "fitsPlacement");
|
|
78
|
+
function choosePlacement(args) {
|
|
79
|
+
const { preferred, preventOverflow } = args;
|
|
80
|
+
if (!preventOverflow) return preferred;
|
|
81
|
+
const tryOrder = [
|
|
82
|
+
preferred,
|
|
83
|
+
opposite(preferred),
|
|
84
|
+
...perpendicular(preferred)
|
|
85
|
+
];
|
|
86
|
+
for (const p of tryOrder) {
|
|
87
|
+
if (fitsPlacement({ ...args, placement: p })) return p;
|
|
88
|
+
}
|
|
89
|
+
return preferred;
|
|
90
|
+
}
|
|
91
|
+
__name(choosePlacement, "choosePlacement");
|
|
92
|
+
function computeFixedPosition(args) {
|
|
93
|
+
const { placement, anchorX, anchorY, bubbleSize, gutter, offset, arrowSize } = args;
|
|
94
|
+
const vw = window.innerWidth;
|
|
95
|
+
const vh = window.innerHeight;
|
|
96
|
+
const need = offset + arrowSize;
|
|
97
|
+
let x = 0;
|
|
98
|
+
let y = 0;
|
|
99
|
+
if (placement === "top") {
|
|
100
|
+
x = anchorX - bubbleSize.w / 2;
|
|
101
|
+
y = anchorY - need - bubbleSize.h;
|
|
102
|
+
} else if (placement === "bottom") {
|
|
103
|
+
x = anchorX - bubbleSize.w / 2;
|
|
104
|
+
y = anchorY + need;
|
|
105
|
+
} else if (placement === "left") {
|
|
106
|
+
x = anchorX - need - bubbleSize.w;
|
|
107
|
+
y = anchorY - bubbleSize.h / 2;
|
|
108
|
+
} else {
|
|
109
|
+
x = anchorX + need;
|
|
110
|
+
y = anchorY - bubbleSize.h / 2;
|
|
111
|
+
}
|
|
112
|
+
const clampedX = clamp(x, gutter, vw - gutter - bubbleSize.w);
|
|
113
|
+
const clampedY = clamp(y, gutter, vh - gutter - bubbleSize.h);
|
|
114
|
+
const pad = 12;
|
|
115
|
+
if (placement === "top" || placement === "bottom") {
|
|
116
|
+
const rawArrowX = anchorX - clampedX;
|
|
117
|
+
const arrowX = clamp(
|
|
118
|
+
rawArrowX,
|
|
119
|
+
arrowSize + pad,
|
|
120
|
+
bubbleSize.w - arrowSize - pad
|
|
121
|
+
);
|
|
122
|
+
return { x: clampedX, y: clampedY, arrowX };
|
|
123
|
+
}
|
|
124
|
+
const rawArrowY = anchorY - clampedY;
|
|
125
|
+
const arrowY = clamp(
|
|
126
|
+
rawArrowY,
|
|
127
|
+
arrowSize + pad,
|
|
128
|
+
bubbleSize.h - arrowSize - pad
|
|
129
|
+
);
|
|
130
|
+
return { x: clampedX, y: clampedY, arrowY };
|
|
131
|
+
}
|
|
132
|
+
__name(computeFixedPosition, "computeFixedPosition");
|
|
133
|
+
function TooltipClient(props) {
|
|
134
|
+
const {
|
|
135
|
+
anchor = "element",
|
|
136
|
+
content,
|
|
137
|
+
preventOverflow = true,
|
|
138
|
+
// Portal defaults.
|
|
139
|
+
portal = true,
|
|
140
|
+
overlayRootId = "pk-overlays",
|
|
141
|
+
zIndex = 2147483647,
|
|
142
|
+
offset = 6,
|
|
143
|
+
mobileBreakpoint = 960,
|
|
144
|
+
// Open logic.
|
|
145
|
+
open: controlledOpen,
|
|
146
|
+
defaultOpen,
|
|
147
|
+
onOpenChange,
|
|
148
|
+
delay = 120,
|
|
149
|
+
closeDelay = 80,
|
|
150
|
+
openOnHover = true,
|
|
151
|
+
openOnFocus = true,
|
|
152
|
+
disabled,
|
|
153
|
+
// View.
|
|
154
|
+
triggerProps,
|
|
155
|
+
placement = "top",
|
|
156
|
+
tooltipClassName,
|
|
157
|
+
...rest
|
|
158
|
+
} = props;
|
|
159
|
+
const isControlled = controlledOpen !== void 0;
|
|
160
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(
|
|
161
|
+
Boolean(defaultOpen)
|
|
162
|
+
);
|
|
163
|
+
const open = isControlled ? Boolean(controlledOpen) : uncontrolledOpen;
|
|
164
|
+
const lastPointer = useRef(null);
|
|
165
|
+
const triggerRef = useRef(null);
|
|
166
|
+
const bubbleRef = useRef(null);
|
|
167
|
+
const [bubbleStyle, setBubbleStyle] = useState(
|
|
168
|
+
void 0
|
|
169
|
+
);
|
|
170
|
+
const [effectivePlacement, setEffectivePlacement] = useState(placement);
|
|
171
|
+
const openTimer = useRef(null);
|
|
172
|
+
const closeTimer = useRef(null);
|
|
173
|
+
const clearTimers = useCallback(() => {
|
|
174
|
+
if (openTimer.current != null) window.clearTimeout(openTimer.current);
|
|
175
|
+
if (closeTimer.current != null) window.clearTimeout(closeTimer.current);
|
|
176
|
+
openTimer.current = null;
|
|
177
|
+
closeTimer.current = null;
|
|
178
|
+
}, []);
|
|
179
|
+
const setOpen = useCallback(
|
|
180
|
+
(next) => {
|
|
181
|
+
if (disabled) return;
|
|
182
|
+
if (!isControlled) setUncontrolledOpen(next);
|
|
183
|
+
onOpenChange == null ? void 0 : onOpenChange(next);
|
|
184
|
+
},
|
|
185
|
+
[disabled, isControlled, onOpenChange]
|
|
186
|
+
);
|
|
187
|
+
const scheduleOpen = useCallback(() => {
|
|
188
|
+
if (disabled) return;
|
|
189
|
+
clearTimers();
|
|
190
|
+
if (delay <= 0) return setOpen(true);
|
|
191
|
+
openTimer.current = window.setTimeout(() => setOpen(true), delay);
|
|
192
|
+
}, [clearTimers, delay, disabled, setOpen]);
|
|
193
|
+
const scheduleClose = useCallback(() => {
|
|
194
|
+
clearTimers();
|
|
195
|
+
if (closeDelay <= 0) return setOpen(false);
|
|
196
|
+
closeTimer.current = window.setTimeout(() => setOpen(false), closeDelay);
|
|
197
|
+
}, [clearTimers, closeDelay, setOpen]);
|
|
198
|
+
const mergedTriggerProps = useMemo(
|
|
199
|
+
() => ({
|
|
200
|
+
...triggerProps,
|
|
201
|
+
onMouseEnter: openOnHover ? (e) => {
|
|
202
|
+
var _a;
|
|
203
|
+
(_a = triggerProps == null ? void 0 : triggerProps.onMouseEnter) == null ? void 0 : _a.call(triggerProps, e);
|
|
204
|
+
if (anchor === "pointer")
|
|
205
|
+
lastPointer.current = { x: e.clientX, y: e.clientY };
|
|
206
|
+
scheduleOpen();
|
|
207
|
+
} : triggerProps == null ? void 0 : triggerProps.onMouseEnter,
|
|
208
|
+
onMouseLeave: openOnHover ? (e) => {
|
|
209
|
+
var _a, _b;
|
|
210
|
+
(_a = triggerProps == null ? void 0 : triggerProps.onMouseLeave) == null ? void 0 : _a.call(triggerProps, e);
|
|
211
|
+
const nextTarget = e.relatedTarget;
|
|
212
|
+
if (nextTarget && ((_b = bubbleRef.current) == null ? void 0 : _b.contains(nextTarget))) return;
|
|
213
|
+
if (anchor === "pointer") lastPointer.current = null;
|
|
214
|
+
scheduleClose();
|
|
215
|
+
} : triggerProps == null ? void 0 : triggerProps.onMouseLeave,
|
|
216
|
+
onMouseMove: anchor === "pointer" ? (e) => {
|
|
217
|
+
var _a;
|
|
218
|
+
(_a = triggerProps == null ? void 0 : triggerProps.onMouseMove) == null ? void 0 : _a.call(triggerProps, e);
|
|
219
|
+
lastPointer.current = { x: e.clientX, y: e.clientY };
|
|
220
|
+
} : triggerProps == null ? void 0 : triggerProps.onMouseMove,
|
|
221
|
+
onFocus: openOnFocus ? (e) => {
|
|
222
|
+
var _a;
|
|
223
|
+
(_a = triggerProps == null ? void 0 : triggerProps.onFocus) == null ? void 0 : _a.call(triggerProps, e);
|
|
224
|
+
scheduleOpen();
|
|
225
|
+
} : triggerProps == null ? void 0 : triggerProps.onFocus,
|
|
226
|
+
onBlur: openOnFocus ? (e) => {
|
|
227
|
+
var _a;
|
|
228
|
+
(_a = triggerProps == null ? void 0 : triggerProps.onBlur) == null ? void 0 : _a.call(triggerProps, e);
|
|
229
|
+
scheduleClose();
|
|
230
|
+
} : triggerProps == null ? void 0 : triggerProps.onBlur,
|
|
231
|
+
onKeyDown: /* @__PURE__ */ __name((e) => {
|
|
232
|
+
var _a, _b, _c;
|
|
233
|
+
(_a = triggerProps == null ? void 0 : triggerProps.onKeyDown) == null ? void 0 : _a.call(triggerProps, e);
|
|
234
|
+
if (e.key === "Escape") {
|
|
235
|
+
clearTimers();
|
|
236
|
+
setOpen(false);
|
|
237
|
+
(_c = (_b = e.currentTarget) == null ? void 0 : _b.blur) == null ? void 0 : _c.call(_b);
|
|
238
|
+
}
|
|
239
|
+
}, "onKeyDown")
|
|
240
|
+
}),
|
|
241
|
+
[
|
|
242
|
+
triggerProps,
|
|
243
|
+
openOnHover,
|
|
244
|
+
openOnFocus,
|
|
245
|
+
scheduleOpen,
|
|
246
|
+
scheduleClose,
|
|
247
|
+
clearTimers,
|
|
248
|
+
setOpen,
|
|
249
|
+
anchor
|
|
250
|
+
]
|
|
251
|
+
);
|
|
252
|
+
const portalBubbleClassBase = useMemo(
|
|
253
|
+
() => bem("bubble", void 0, tooltipClassName),
|
|
254
|
+
[tooltipClassName]
|
|
255
|
+
);
|
|
256
|
+
const portalBubbleClassFinal = useMemo(
|
|
257
|
+
() => bem(
|
|
258
|
+
"bubble",
|
|
259
|
+
{ open: Boolean(open && bubbleStyle), [effectivePlacement]: true },
|
|
260
|
+
tooltipClassName
|
|
261
|
+
),
|
|
262
|
+
[open, bubbleStyle, effectivePlacement, tooltipClassName]
|
|
263
|
+
);
|
|
264
|
+
const compute = useCallback(() => {
|
|
265
|
+
if (!portal || !open || disabled) return;
|
|
266
|
+
const triggerEl = triggerRef.current;
|
|
267
|
+
const bubbleEl = bubbleRef.current;
|
|
268
|
+
if (!triggerEl || !bubbleEl) return;
|
|
269
|
+
const anchorEl = triggerEl.querySelector("[data-tooltip-anchor]") ?? triggerEl;
|
|
270
|
+
const gutter = 8;
|
|
271
|
+
const arrowSize = 8;
|
|
272
|
+
const triggerRect = anchorEl.getBoundingClientRect();
|
|
273
|
+
const bubbleSize = {
|
|
274
|
+
w: bubbleEl.offsetWidth,
|
|
275
|
+
h: bubbleEl.offsetHeight
|
|
276
|
+
};
|
|
277
|
+
if (!bubbleSize.w || !bubbleSize.h) return;
|
|
278
|
+
const isMobile = window.innerWidth < mobileBreakpoint;
|
|
279
|
+
const preferred = isMobile && (placement === "left" || placement === "right") ? "top" : placement;
|
|
280
|
+
const ar = anchorEl.getBoundingClientRect();
|
|
281
|
+
const anchorX = ar.left + ar.width / 2;
|
|
282
|
+
const anchorY = ar.top + ar.height / 2;
|
|
283
|
+
const chosen = choosePlacement({
|
|
284
|
+
preferred,
|
|
285
|
+
anchorX,
|
|
286
|
+
anchorY,
|
|
287
|
+
triggerRect,
|
|
288
|
+
bubbleSize,
|
|
289
|
+
gutter,
|
|
290
|
+
offset,
|
|
291
|
+
arrowSize,
|
|
292
|
+
preventOverflow
|
|
293
|
+
});
|
|
294
|
+
const { x, y, arrowX, arrowY } = computeFixedPosition({
|
|
295
|
+
placement: chosen,
|
|
296
|
+
anchorX,
|
|
297
|
+
anchorY,
|
|
298
|
+
bubbleSize,
|
|
299
|
+
gutter,
|
|
300
|
+
offset,
|
|
301
|
+
arrowSize
|
|
302
|
+
});
|
|
303
|
+
setEffectivePlacement(chosen);
|
|
304
|
+
setBubbleStyle({
|
|
305
|
+
["--pk-tt-x"]: `${x}px`,
|
|
306
|
+
["--pk-tt-y"]: `${y}px`,
|
|
307
|
+
["--pk-tt-arrow-x"]: arrowX != null ? `${arrowX}px` : void 0,
|
|
308
|
+
["--pk-tt-arrow-y"]: arrowY != null ? `${arrowY}px` : void 0,
|
|
309
|
+
["--pk-tt-z"]: String(zIndex)
|
|
310
|
+
});
|
|
311
|
+
}, [
|
|
312
|
+
portal,
|
|
313
|
+
open,
|
|
314
|
+
disabled,
|
|
315
|
+
placement,
|
|
316
|
+
preventOverflow,
|
|
317
|
+
offset,
|
|
318
|
+
zIndex,
|
|
319
|
+
mobileBreakpoint
|
|
320
|
+
]);
|
|
321
|
+
useLayoutEffect(() => {
|
|
322
|
+
if (!portal || !open) return;
|
|
323
|
+
setBubbleStyle(void 0);
|
|
324
|
+
const raf1 = requestAnimationFrame(() => {
|
|
325
|
+
requestAnimationFrame(() => compute());
|
|
326
|
+
});
|
|
327
|
+
const onResize = /* @__PURE__ */ __name(() => compute(), "onResize");
|
|
328
|
+
const onScroll = /* @__PURE__ */ __name(() => compute(), "onScroll");
|
|
329
|
+
window.addEventListener("resize", onResize);
|
|
330
|
+
window.addEventListener("scroll", onScroll, true);
|
|
331
|
+
return () => {
|
|
332
|
+
cancelAnimationFrame(raf1);
|
|
333
|
+
window.removeEventListener("resize", onResize);
|
|
334
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
335
|
+
};
|
|
336
|
+
}, [portal, open, compute]);
|
|
337
|
+
const overlayRoot = typeof document !== "undefined" && portal ? getOverlayRoot(overlayRootId, zIndex) : null;
|
|
338
|
+
const portalOpen = open && Boolean(bubbleStyle);
|
|
339
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
340
|
+
/* @__PURE__ */ jsx(
|
|
341
|
+
TooltipView,
|
|
342
|
+
{
|
|
343
|
+
...rest,
|
|
344
|
+
__open: portal ? portalOpen : open,
|
|
345
|
+
__placement: portal ? effectivePlacement : placement,
|
|
346
|
+
__renderVisualBubble: !portal,
|
|
347
|
+
__triggerRef: triggerRef,
|
|
348
|
+
content,
|
|
349
|
+
disabled,
|
|
350
|
+
placement,
|
|
351
|
+
tooltipClassName,
|
|
352
|
+
triggerProps: mergedTriggerProps
|
|
353
|
+
}
|
|
354
|
+
),
|
|
355
|
+
portal && !disabled && overlayRoot ? createPortal(
|
|
356
|
+
/* @__PURE__ */ jsx(
|
|
357
|
+
"span",
|
|
358
|
+
{
|
|
359
|
+
ref: bubbleRef,
|
|
360
|
+
"aria-hidden": open === void 0 ? void 0 : !open,
|
|
361
|
+
role: "tooltip",
|
|
362
|
+
style: bubbleStyle,
|
|
363
|
+
className: bubbleStyle ? portalBubbleClassFinal : portalBubbleClassBase,
|
|
364
|
+
onMouseEnter: openOnHover ? () => {
|
|
365
|
+
clearTimers();
|
|
366
|
+
setOpen(true);
|
|
367
|
+
} : void 0,
|
|
368
|
+
onMouseLeave: openOnHover ? () => {
|
|
369
|
+
scheduleClose();
|
|
370
|
+
} : void 0,
|
|
371
|
+
children: content
|
|
372
|
+
}
|
|
373
|
+
),
|
|
374
|
+
overlayRoot
|
|
375
|
+
) : null
|
|
376
|
+
] });
|
|
377
|
+
}
|
|
378
|
+
__name(TooltipClient, "TooltipClient");
|
|
379
|
+
const Tooltip_client = memo(TooltipClient);
|
|
380
|
+
export {
|
|
381
|
+
Tooltip_client as default
|
|
382
|
+
};
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/* stylelint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Calculates a rem-based value by a given pixel size.
|
|
4
|
+
*/
|
|
5
|
+
/* stylelint-disable */
|
|
6
|
+
/**
|
|
7
|
+
* Applies flex-column and gap.
|
|
8
|
+
*/
|
|
9
|
+
/*
|
|
10
|
+
As example (light, primary)
|
|
11
|
+
See defined modes in designsystem/config/gradients
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Mixin that renders a media query that target screens that are larger than the
|
|
15
|
+
* given size.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Mixin that renders a media query that target screens that are smaller than the
|
|
19
|
+
* given size.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Mixin that renders a media query that target screens in between the given range.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Mixin that renders a media query that target screens that have height larger than the
|
|
26
|
+
* given size.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Mixin that renders a media query that target screens that have height smaller than the
|
|
30
|
+
* given size.
|
|
31
|
+
*/
|
|
32
|
+
/* stylelint-disable */
|
|
33
|
+
/* M3/Elevation Light/1 */
|
|
34
|
+
/* M3/Elevation Light/2 */
|
|
35
|
+
/* M3/Elevation/5 */
|
|
36
|
+
/* M3/Elevation/1 Text */
|
|
37
|
+
/* Inner elevations */
|
|
38
|
+
/* stylelint-disable */
|
|
39
|
+
/**
|
|
40
|
+
* Visually hides an element but not removes them for screen readers.
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* The inverse of the `hidden` helper to reset a previously hidden element to be
|
|
44
|
+
* visible for users.
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* Creates a selector for :hover effects depending on the current user input
|
|
48
|
+
* device. If the input device is a mouse, this hover effect will appear.
|
|
49
|
+
* Keyboard and touch inputs are ignored.
|
|
50
|
+
*
|
|
51
|
+
* Example usage:
|
|
52
|
+
* .link {
|
|
53
|
+
* color: blue;
|
|
54
|
+
*
|
|
55
|
+
* @include when-hovered() {
|
|
56
|
+
* color: green;
|
|
57
|
+
* }
|
|
58
|
+
* }
|
|
59
|
+
*/
|
|
60
|
+
/**
|
|
61
|
+
* Creates a selector for :active effects depending on the current user input
|
|
62
|
+
* device. The state applies when the input device is a mouse or keyboard. Touch
|
|
63
|
+
* devices will not show a pressed state.
|
|
64
|
+
*
|
|
65
|
+
* Example usage:
|
|
66
|
+
* .link {
|
|
67
|
+
* box-shadow: none;
|
|
68
|
+
*
|
|
69
|
+
* @include when-pressed() {
|
|
70
|
+
* box-shadow: inset 0 2px 4px grey;
|
|
71
|
+
* }
|
|
72
|
+
* }
|
|
73
|
+
*/
|
|
74
|
+
/**
|
|
75
|
+
* Creates a selector for :focus effects depending on the current user input
|
|
76
|
+
* device. When the user navigates using a keyboard, the focus effect defined in
|
|
77
|
+
* here is applied. For other input devices they don't show up.
|
|
78
|
+
*
|
|
79
|
+
* Example usage:
|
|
80
|
+
* .link {
|
|
81
|
+
* text-decoration: none;
|
|
82
|
+
*
|
|
83
|
+
* @include when-focused() {
|
|
84
|
+
* text-decoration: underline;
|
|
85
|
+
* }
|
|
86
|
+
* }
|
|
87
|
+
*/
|
|
88
|
+
/**
|
|
89
|
+
* Creates a selector for :focus-within effects depending on the current user
|
|
90
|
+
* input device. When the user navigates using a keyboard, the focus effect
|
|
91
|
+
* defined in here is applied. For other input devices they don't show up.
|
|
92
|
+
*
|
|
93
|
+
* Example usage:
|
|
94
|
+
* .link {
|
|
95
|
+
* img {
|
|
96
|
+
* opacity: 0.75;
|
|
97
|
+
*
|
|
98
|
+
* @include when-focused-within() {
|
|
99
|
+
* opacity: 1;
|
|
100
|
+
* }
|
|
101
|
+
* }
|
|
102
|
+
* }
|
|
103
|
+
*/
|
|
104
|
+
/**
|
|
105
|
+
* Wrapper for media query "prefers-reduced-motion".
|
|
106
|
+
*/
|
|
107
|
+
/**
|
|
108
|
+
* This helper hides the outline but still makes it visible for
|
|
109
|
+
* Windows high-contrast users. Use this instead of `outline: 0;`.
|
|
110
|
+
*/
|
|
111
|
+
/**
|
|
112
|
+
* This helper hides the outline but still makes it visible for
|
|
113
|
+
* Windows high-contrast users. Use this instead of `outline: 0;`.
|
|
114
|
+
*/
|
|
115
|
+
/**
|
|
116
|
+
* Renders an alternative, but application consistent focus-ring.
|
|
117
|
+
*/
|
|
118
|
+
/**
|
|
119
|
+
* Specifies the outer layout for all contents across breakpoints. Apply this
|
|
120
|
+
* mixin to the container element, to center the contents on the screen within
|
|
121
|
+
* the layout offsets.
|
|
122
|
+
*/
|
|
123
|
+
/**
|
|
124
|
+
* This mixin specifies basic text-styles for components that render a richtext
|
|
125
|
+
* content.
|
|
126
|
+
*/
|
|
127
|
+
.prokodo-Tooltip {
|
|
128
|
+
position: relative;
|
|
129
|
+
display: inline-flex;
|
|
130
|
+
align-items: center;
|
|
131
|
+
/* Visually hidden described-by node (portal a11y). */
|
|
132
|
+
/* CSS-only fallback (only works for inline mode). */
|
|
133
|
+
}
|
|
134
|
+
.prokodo-Tooltip--disabled {
|
|
135
|
+
pointer-events: none;
|
|
136
|
+
}
|
|
137
|
+
.prokodo-Tooltip__sr {
|
|
138
|
+
position: absolute;
|
|
139
|
+
width: 1px;
|
|
140
|
+
height: 1px;
|
|
141
|
+
padding: 0;
|
|
142
|
+
margin: -1px;
|
|
143
|
+
overflow: hidden;
|
|
144
|
+
clip: rect(0, 0, 0, 0);
|
|
145
|
+
border: 0;
|
|
146
|
+
white-space: nowrap;
|
|
147
|
+
}
|
|
148
|
+
.prokodo-Tooltip__trigger {
|
|
149
|
+
width: -moz-max-content !important;
|
|
150
|
+
width: max-content !important;
|
|
151
|
+
flex: 0 0 auto !important;
|
|
152
|
+
}
|
|
153
|
+
.prokodo-Tooltip__bubble {
|
|
154
|
+
/* Make sizing measurable and stable. */
|
|
155
|
+
display: block;
|
|
156
|
+
position: fixed;
|
|
157
|
+
left: 0;
|
|
158
|
+
top: 0;
|
|
159
|
+
/* Position via CSS vars, but NO animated transform/scale */
|
|
160
|
+
transform: translate3d(var(--pk-tt-x, 0px), var(--pk-tt-y, 0px), 0);
|
|
161
|
+
/* Only opacity changes for animation */
|
|
162
|
+
will-change: opacity;
|
|
163
|
+
z-index: var(--pk-tt-z, 2147483647);
|
|
164
|
+
max-width: min(360px, 100vw - 16px);
|
|
165
|
+
white-space: normal;
|
|
166
|
+
overflow-wrap: anywhere;
|
|
167
|
+
padding: 0.25rem 0.5rem;
|
|
168
|
+
border-radius: 10px;
|
|
169
|
+
box-shadow: var(--elevation-2);
|
|
170
|
+
background: var(--color-grey-900);
|
|
171
|
+
color: var(--color-white);
|
|
172
|
+
opacity: 0;
|
|
173
|
+
visibility: hidden;
|
|
174
|
+
pointer-events: none;
|
|
175
|
+
/* fade only */
|
|
176
|
+
transition: opacity 120ms ease, visibility 120ms ease;
|
|
177
|
+
font-weight: 400;
|
|
178
|
+
font-size: 1rem;
|
|
179
|
+
font-family: var(--font-secondary), -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
180
|
+
font-style: normal;
|
|
181
|
+
line-height: 1.45;
|
|
182
|
+
letter-spacing: 0.03em;
|
|
183
|
+
text-transform: none;
|
|
184
|
+
text-align: left;
|
|
185
|
+
text-decoration: none;
|
|
186
|
+
}
|
|
187
|
+
@media screen and (min-width: 480px) {
|
|
188
|
+
.prokodo-Tooltip__bubble {
|
|
189
|
+
font-size: 0.875rem;
|
|
190
|
+
line-height: 1.4;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
@media screen and (min-width: 960px) {
|
|
194
|
+
.prokodo-Tooltip__bubble {
|
|
195
|
+
font-size: 0.875rem;
|
|
196
|
+
line-height: 1.4;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
.prokodo-Tooltip__bubble--open {
|
|
200
|
+
opacity: 1;
|
|
201
|
+
visibility: visible;
|
|
202
|
+
pointer-events: auto;
|
|
203
|
+
}
|
|
204
|
+
.prokodo-Tooltip__bubble::after {
|
|
205
|
+
content: "";
|
|
206
|
+
position: absolute;
|
|
207
|
+
width: 0;
|
|
208
|
+
height: 0;
|
|
209
|
+
border-style: solid;
|
|
210
|
+
}
|
|
211
|
+
.prokodo-Tooltip__bubble--top::after {
|
|
212
|
+
left: var(--pk-tt-arrow-x, 50%);
|
|
213
|
+
top: 100%;
|
|
214
|
+
transform: translateX(-50%);
|
|
215
|
+
border-width: 8px 8px 0 8px;
|
|
216
|
+
border-color: var(--color-grey-900) transparent transparent transparent;
|
|
217
|
+
}
|
|
218
|
+
.prokodo-Tooltip__bubble--bottom::after {
|
|
219
|
+
left: var(--pk-tt-arrow-x, 50%);
|
|
220
|
+
bottom: 100%;
|
|
221
|
+
transform: translateX(-50%);
|
|
222
|
+
border-width: 0 8px 8px 8px;
|
|
223
|
+
border-color: transparent transparent var(--color-grey-900) transparent;
|
|
224
|
+
}
|
|
225
|
+
.prokodo-Tooltip__bubble--left::after {
|
|
226
|
+
top: var(--pk-tt-arrow-y, 50%);
|
|
227
|
+
left: 100%;
|
|
228
|
+
transform: translateY(-50%);
|
|
229
|
+
border-width: 8px 0 8px 8px;
|
|
230
|
+
border-color: transparent transparent transparent var(--color-grey-900);
|
|
231
|
+
}
|
|
232
|
+
.prokodo-Tooltip__bubble--right::after {
|
|
233
|
+
top: var(--pk-tt-arrow-y, 50%);
|
|
234
|
+
right: 100%;
|
|
235
|
+
transform: translateY(-50%);
|
|
236
|
+
border-width: 8px 8px 8px 0;
|
|
237
|
+
border-color: transparent var(--color-grey-900) transparent transparent;
|
|
238
|
+
}
|
|
239
|
+
.prokodo-Tooltip:hover .prokodo-Tooltip__bubble, .prokodo-Tooltip:focus-within .prokodo-Tooltip__bubble {
|
|
240
|
+
opacity: 1;
|
|
241
|
+
visibility: visible;
|
|
242
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { createIsland } from "../../helpers/createIsland.js";
|
|
4
|
+
import TooltipServer from "./Tooltip.server.js";
|
|
5
|
+
const Tooltip = createIsland({
|
|
6
|
+
name: "Tooltip",
|
|
7
|
+
Server: TooltipServer,
|
|
8
|
+
loadLazy: /* @__PURE__ */ __name(() => import("./Tooltip.client.js"), "loadLazy"),
|
|
9
|
+
// Hydrate only when you actually need JS timing/controlled state/etc.
|
|
10
|
+
isInteractive: /* @__PURE__ */ __name((p) => Boolean(
|
|
11
|
+
(p.portal ?? true) || p.preventOverflow || p.open !== void 0 || p.defaultOpen !== void 0 || typeof p.onOpenChange === "function" || typeof p.delay === "number" || typeof p.closeDelay === "number"
|
|
12
|
+
), "isInteractive")
|
|
13
|
+
});
|
|
14
|
+
export {
|
|
15
|
+
Tooltip
|
|
16
|
+
};
|