@efolusi/meridian 1.7.0 → 1.9.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.
@@ -0,0 +1,148 @@
1
+ 'use client';
2
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
+ import React from 'react';
4
+ import { Icon } from "../icons/Icon.js";
5
+ import { Calendar } from "./Calendar.js";
6
+ import { useFieldProps } from "../forms/FormField.js";
7
+ import { Portal, useAnchoredStyle } from "../overlay/Portal.js";
8
+ const fmt = v => {
9
+ if (!v) return null;
10
+ const d = new Date(v + 'T00:00:00');
11
+ return d.toLocaleDateString('en-US', {
12
+ month: 'short',
13
+ day: 'numeric',
14
+ year: 'numeric'
15
+ });
16
+ };
17
+ const EMPTY = {
18
+ from: null,
19
+ to: null
20
+ };
21
+ export function DateRangePicker({
22
+ label,
23
+ hint,
24
+ value,
25
+ onChange,
26
+ min,
27
+ max,
28
+ placeholder = 'Pick a date range',
29
+ disabled,
30
+ style,
31
+ className,
32
+ ...rest
33
+ }) {
34
+ // Picks up id / aria wiring when nested in a FormField; standalone this is a no-op.
35
+ const field = useFieldProps({
36
+ id: rest.id,
37
+ 'aria-describedby': rest['aria-describedby']
38
+ });
39
+ const [inner, setInner] = React.useState(EMPTY);
40
+ const v = value != null ? value : inner;
41
+ const from = v && v.from ? v.from : null;
42
+ const to = v && v.to ? v.to : null;
43
+ const [open, setOpen] = React.useState(false);
44
+ const rootRef = React.useRef(null);
45
+ const wrapRef = React.useRef(null);
46
+ const btnRef = React.useRef(null);
47
+ const panelRef = React.useRef(null);
48
+ const {
49
+ style: anchored
50
+ } = useAnchoredStyle(wrapRef, panelRef, {
51
+ open,
52
+ placement: 'bottom',
53
+ align: 'start'
54
+ });
55
+ React.useEffect(() => {
56
+ if (!open) return;
57
+ // the calendar is portaled out of `rootRef`, so look for it in the panel
58
+ const day = panelRef.current && panelRef.current.querySelector('[role="gridcell"][tabindex="0"]');
59
+ if (day) day.focus();
60
+ const away = e => {
61
+ const inTrigger = rootRef.current && rootRef.current.contains(e.target);
62
+ const inPanel = panelRef.current && panelRef.current.contains(e.target);
63
+ if (!inTrigger && !inPanel) setOpen(false);
64
+ };
65
+ const key = e => {
66
+ if (e.key === 'Escape') {
67
+ setOpen(false);
68
+ if (btnRef.current) btnRef.current.focus();
69
+ }
70
+ };
71
+ document.addEventListener('mousedown', away);
72
+ document.addEventListener('keydown', key);
73
+ return () => {
74
+ document.removeEventListener('mousedown', away);
75
+ document.removeEventListener('keydown', key);
76
+ };
77
+ }, [open]);
78
+ const commit = r => {
79
+ if (value == null) setInner(r);
80
+ if (onChange) onChange(r);
81
+ };
82
+ // The Calendar itself has no bounds, so a pick outside [min, max] is dropped
83
+ // here: any change whose ends stray out of the window never commits.
84
+ const inBounds = d => !d || (!min || d >= min) && (!max || d <= max);
85
+ const handlePick = r => {
86
+ if (!inBounds(r.from) || !inBounds(r.to)) return;
87
+ commit(r);
88
+ if (r.from && r.to) {
89
+ setOpen(false);
90
+ if (btnRef.current) btnRef.current.focus();
91
+ }
92
+ };
93
+ const clear = () => {
94
+ commit(EMPTY);
95
+ if (btnRef.current) btnRef.current.focus();
96
+ };
97
+ const text = from || to ? `${fmt(from) || '…'} — ${fmt(to) || '…'}` : null;
98
+ return /*#__PURE__*/React.createElement("span", _extends({}, rest, {
99
+ ref: rootRef,
100
+ className: `ef-daterange${className ? ' ' + className : ''}`,
101
+ style: style
102
+ }), label ? /*#__PURE__*/React.createElement("span", {
103
+ className: "ef-daterange__label"
104
+ }, label) : null, /*#__PURE__*/React.createElement("span", {
105
+ ref: wrapRef,
106
+ className: "ef-daterange__wrap"
107
+ }, /*#__PURE__*/React.createElement("button", _extends({}, field.controlProps, {
108
+ type: "button",
109
+ ref: btnRef,
110
+ disabled: disabled,
111
+ "aria-haspopup": "dialog",
112
+ "aria-expanded": open,
113
+ className: `ef-daterange__btn${text ? '' : ' ef-daterange__btn--empty'}`,
114
+ onClick: () => setOpen(o => !o)
115
+ }), /*#__PURE__*/React.createElement(Icon, {
116
+ name: "calendar",
117
+ size: 15,
118
+ style: {
119
+ color: 'var(--text-muted)'
120
+ }
121
+ }), text || placeholder), text && !disabled ? /*#__PURE__*/React.createElement("button", {
122
+ type: "button",
123
+ className: "ef-daterange__clear",
124
+ "aria-label": "Clear date range",
125
+ onClick: clear
126
+ }, /*#__PURE__*/React.createElement(Icon, {
127
+ name: "x",
128
+ size: 13
129
+ })) : /*#__PURE__*/React.createElement("span", {
130
+ className: "ef-daterange__chevron"
131
+ }, /*#__PURE__*/React.createElement(Icon, {
132
+ name: "chevron-down",
133
+ size: 14
134
+ }))), hint ? /*#__PURE__*/React.createElement("span", {
135
+ className: "ef-daterange__hint"
136
+ }, hint) : null, open && /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement("div", {
137
+ ref: panelRef,
138
+ className: "ef-daterange__pop",
139
+ style: anchored
140
+ }, /*#__PURE__*/React.createElement(Calendar, {
141
+ range: true,
142
+ value: {
143
+ from,
144
+ to
145
+ },
146
+ onChange: handlePick
147
+ }))));
148
+ }
@@ -0,0 +1,25 @@
1
+ export interface TimePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
2
+ /** Field label rendered above the input */
3
+ label?: string;
4
+ /** Muted helper line rendered below */
5
+ hint?: string;
6
+ /** Controlled time as 24h 'HH:MM', or null when empty (always 24h, whatever `format24` shows) */
7
+ value?: string | null;
8
+ onChange?: (time: string | null) => void;
9
+ /** Minutes between listed slots @default 30 */
10
+ stepMinutes?: number;
11
+ /** First listed slot as 'HH:MM' @default '00:00' */
12
+ minTime?: string;
13
+ /** Slots stop at this 'HH:MM' @default '23:59' */
14
+ maxTime?: string;
15
+ /** 24h labels; false renders 12h with AM/PM (value stays 24h) @default true */
16
+ format24?: boolean;
17
+ /** @default 'Pick a time' */
18
+ placeholder?: string;
19
+ disabled?: boolean;
20
+ /** Danger border + aria-invalid */
21
+ invalid?: boolean;
22
+ style?: React.CSSProperties;
23
+ className?: string;
24
+ }
25
+ export declare function TimePicker(props: TimePickerProps): React.JSX.Element;
@@ -0,0 +1,205 @@
1
+ 'use client';
2
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
+ import React from 'react';
4
+ import { Icon } from "../icons/Icon.js";
5
+ import { useFieldProps } from "../forms/FormField.js";
6
+ import { Portal, useAnchoredStyle } from "../overlay/Portal.js";
7
+ const toMin = t => {
8
+ const p = t.split(':');
9
+ return Number(p[0]) * 60 + Number(p[1] || 0);
10
+ };
11
+ const toHM = n => String(Math.floor(n / 60)).padStart(2, '0') + ':' + String(n % 60).padStart(2, '0');
12
+ const label12 = t => {
13
+ const p = t.split(':').map(Number);
14
+ const ap = p[0] < 12 ? 'AM' : 'PM';
15
+ return (p[0] % 12 || 12) + ':' + String(p[1]).padStart(2, '0') + ' ' + ap;
16
+ };
17
+ // '9:5' -> '09:05', '14' -> '14:00', '9:05 pm' -> '21:05'; null when not a time.
18
+ const parseTyped = raw => {
19
+ const m = /^\s*(\d{1,2})(?::(\d{1,2}))?\s*(am|pm)?\s*$/i.exec(raw);
20
+ if (!m) return null;
21
+ let h = Number(m[1]);
22
+ const mm = Number(m[2] || 0);
23
+ const ap = m[3] ? m[3].toLowerCase() : null;
24
+ if (ap) {
25
+ if (h < 1 || h > 12) return null;
26
+ if (ap === 'pm' && h !== 12) h += 12;
27
+ if (ap === 'am' && h === 12) h = 0;
28
+ }
29
+ if (h > 23 || mm > 59) return null;
30
+ return toHM(h * 60 + mm);
31
+ };
32
+ export function TimePicker({
33
+ label,
34
+ hint,
35
+ value,
36
+ onChange,
37
+ stepMinutes = 30,
38
+ minTime,
39
+ maxTime,
40
+ format24 = true,
41
+ placeholder = 'Pick a time',
42
+ disabled,
43
+ invalid,
44
+ style,
45
+ className,
46
+ ...rest
47
+ }) {
48
+ // Picks up id / aria wiring when nested in a FormField; standalone this is a no-op.
49
+ const field = useFieldProps({
50
+ invalid,
51
+ id: rest.id,
52
+ 'aria-describedby': rest['aria-describedby']
53
+ });
54
+ const bad = field.invalid;
55
+ const [open, setOpen] = React.useState(false);
56
+ const [q, setQ] = React.useState(null); // null = not editing, input mirrors `value`
57
+ const [hi, setHi] = React.useState(0);
58
+ const listId = React.useId();
59
+ const ref = React.useRef(null);
60
+ const panelRef = React.useRef(null);
61
+ const {
62
+ style: anchored
63
+ } = useAnchoredStyle(ref, panelRef, {
64
+ open,
65
+ placement: 'bottom',
66
+ align: 'start',
67
+ matchWidth: true
68
+ });
69
+ const lo = toMin(minTime || '00:00');
70
+ const end = toMin(maxTime || '23:59');
71
+ const step = Math.max(1, stepMinutes);
72
+ const slots = [];
73
+ for (let t = lo; t <= end; t += step) slots.push(toHM(t));
74
+ const fmtSlot = t => format24 ? t : label12(t);
75
+ const query = q ? q.trim().toLowerCase() : '';
76
+ const shown = query ? slots.filter(s => fmtSlot(s).toLowerCase().includes(query) || s.includes(query)) : slots;
77
+ // Keep the highlighted option visible to sighted users the same way
78
+ // aria-activedescendant keeps it visible to screen readers.
79
+ React.useEffect(() => {
80
+ if (!open) return;
81
+ const el = document.getElementById(`${listId}-opt-${hi}`);
82
+ if (el && el.scrollIntoView) el.scrollIntoView({
83
+ block: 'nearest'
84
+ });
85
+ }, [open, hi, listId]);
86
+ React.useEffect(() => {
87
+ if (!open) return;
88
+ const away = e => {
89
+ const inControl = ref.current && ref.current.contains(e.target);
90
+ const inPanel = panelRef.current && panelRef.current.contains(e.target);
91
+ if (!inControl && !inPanel) setOpen(false);
92
+ };
93
+ document.addEventListener('mousedown', away);
94
+ return () => document.removeEventListener('mousedown', away);
95
+ }, [open]);
96
+ const openList = () => {
97
+ if (disabled) return;
98
+ setOpen(true);
99
+ const idx = value ? slots.indexOf(value) : -1;
100
+ setHi(idx >= 0 ? idx : 0);
101
+ };
102
+ const pick = t => {
103
+ if (onChange) onChange(t);
104
+ setQ(null);
105
+ setOpen(false);
106
+ };
107
+ // A typed valid time commits on blur even when it is not a listed slot,
108
+ // clamped into [minTime, maxTime]; an emptied input commits null.
109
+ const commitTyped = () => {
110
+ if (q == null) return;
111
+ if (q.trim() === '') {
112
+ if (onChange) onChange(null);
113
+ } else {
114
+ const t = parseTyped(q);
115
+ if (t) {
116
+ if (onChange) onChange(toHM(Math.min(Math.max(toMin(t), lo), end)));
117
+ }
118
+ }
119
+ setQ(null);
120
+ };
121
+ const onBlur = () => {
122
+ commitTyped();
123
+ setOpen(false);
124
+ };
125
+ const onKey = e => {
126
+ if (e.key === 'ArrowDown') {
127
+ e.preventDefault();
128
+ if (!open) openList();else setHi(h => Math.min(h + 1, shown.length - 1));
129
+ } else if (e.key === 'ArrowUp') {
130
+ e.preventDefault();
131
+ setHi(h => Math.max(h - 1, 0));
132
+ } else if (e.key === 'Enter' && open && shown[hi]) {
133
+ e.preventDefault();
134
+ pick(shown[hi]);
135
+ } else if (e.key === 'Escape') {
136
+ setOpen(false);
137
+ setQ(null);
138
+ }
139
+ };
140
+ const control = /*#__PURE__*/React.createElement("div", {
141
+ ref: ref,
142
+ className: `ef-timepicker${bad ? ' ef-timepicker--invalid' : ''}`
143
+ }, /*#__PURE__*/React.createElement("input", _extends({}, field.controlProps, {
144
+ className: "ef-timepicker__input",
145
+ role: "combobox",
146
+ "aria-expanded": open,
147
+ "aria-controls": listId,
148
+ "aria-autocomplete": "list",
149
+ "aria-invalid": bad || undefined,
150
+ "aria-activedescendant": open && shown.length ? `${listId}-opt-${hi}` : undefined,
151
+ placeholder: placeholder,
152
+ disabled: disabled,
153
+ value: q != null ? q : value ? fmtSlot(value) : '',
154
+ onChange: e => {
155
+ setQ(e.target.value);
156
+ setOpen(true);
157
+ setHi(0);
158
+ },
159
+ onClick: openList,
160
+ onFocus: openList,
161
+ onBlur: onBlur,
162
+ onKeyDown: onKey
163
+ })), /*#__PURE__*/React.createElement("span", {
164
+ className: "ef-timepicker__icon"
165
+ }, /*#__PURE__*/React.createElement(Icon, {
166
+ name: "clock",
167
+ size: 15
168
+ })), open && /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement("div", {
169
+ ref: panelRef,
170
+ className: "ef-timepicker__panel",
171
+ role: "listbox",
172
+ id: listId,
173
+ style: anchored,
174
+ onMouseDown: e => e.preventDefault()
175
+ }, shown.length === 0 && /*#__PURE__*/React.createElement("div", {
176
+ className: "ef-timepicker__empty"
177
+ }, "No matching time."), shown.map((t, i) => /*#__PURE__*/React.createElement("button", {
178
+ key: t,
179
+ type: "button",
180
+ role: "option",
181
+ id: `${listId}-opt-${i}`,
182
+ tabIndex: -1,
183
+ "aria-selected": t === value,
184
+ className: `ef-timepicker__opt${i === hi ? ' ef-timepicker__opt--hi' : ''}`,
185
+ onMouseEnter: () => setHi(i),
186
+ onClick: () => pick(t)
187
+ }, fmtSlot(t), t === value ? /*#__PURE__*/React.createElement("span", {
188
+ className: "ef-timepicker__opt__check"
189
+ }, /*#__PURE__*/React.createElement(Icon, {
190
+ name: "check",
191
+ size: 15
192
+ })) : null)))));
193
+ if (!label && !hint) return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
194
+ className: className,
195
+ style: style
196
+ }), control);
197
+ return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
198
+ className: `ef-field${className ? ' ' + className : ''}`,
199
+ style: style
200
+ }), label ? /*#__PURE__*/React.createElement("span", {
201
+ className: "ef-field__label"
202
+ }, label) : null, control, hint ? /*#__PURE__*/React.createElement("span", {
203
+ className: "ef-field__hint"
204
+ }, hint) : null);
205
+ }
@@ -11,6 +11,9 @@ export interface TreeListProps {
11
11
  nodes: TreeNode[];
12
12
  /** Controlled selected id */
13
13
  value?: string;
14
+ /** Fires with the clicked row's id and node */
15
+ onChange?: (id: string, node: TreeNode) => void;
16
+ /** @deprecated Use `onChange`. Alias kept for one major; `onChange` wins when both are passed. */
14
17
  onSelect?: (id: string, node: TreeNode) => void;
15
18
  /** Branch ids open initially (default: all top-level) */
16
19
  defaultOpen?: string[];
@@ -57,19 +57,22 @@ function Node({
57
57
  export function TreeList({
58
58
  nodes,
59
59
  value,
60
+ onChange,
60
61
  onSelect,
61
62
  defaultOpen,
62
63
  style,
63
64
  className,
64
65
  ...rest
65
66
  }) {
67
+ // onSelect is the deprecated alias; onChange (state-carrying selection) wins when both are passed.
68
+ const fire = onChange ?? onSelect;
66
69
  const [open, setOpen] = React.useState(defaultOpen || nodes.filter(n => n.children).map(n => n.id));
67
70
  const [innerSel, setInnerSel] = React.useState(null);
68
71
  const sel = value != null ? value : innerSel;
69
72
  const toggle = id => setOpen(o => o.includes(id) ? o.filter(x => x !== id) : [...o, id]);
70
73
  const select = (id, node) => {
71
74
  if (value == null) setInnerSel(id);
72
- if (onSelect) onSelect(id, node);
75
+ if (fire) fire(id, node);
73
76
  };
74
77
  return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
75
78
  role: "tree",
@@ -1,6 +1,8 @@
1
1
  export interface TooltipProps {
2
2
  label: React.ReactNode;
3
- /** Preferred side; flips automatically when there is no room. @default 'top' */
3
+ /** Preferred side; flips to the opposite side when there is no room. @default 'top' */
4
+ side?: 'top' | 'bottom' | 'left' | 'right';
5
+ /** @deprecated Use `side`. Alias kept for one major; `side` wins when both are passed. */
4
6
  position?: 'top' | 'bottom';
5
7
  /** Hover delay in ms before showing. Focus always shows immediately. @default 200 */
6
8
  delay?: number;
@@ -2,10 +2,12 @@
2
2
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
3
  import React from 'react';
4
4
  import { useIsoLayoutEffect } from "../forms/Button.js";
5
- import { Portal, useAnchoredStyle } from "../overlay/Portal.js";
5
+ import { Portal } from "../overlay/Portal.js";
6
+ const SIDES = ['top', 'bottom', 'left', 'right'];
6
7
  export function Tooltip({
7
8
  label,
8
- position = 'top',
9
+ side: sideProp,
10
+ position,
9
11
  delay = 200,
10
12
  children,
11
13
  style,
@@ -17,30 +19,96 @@ export function Tooltip({
17
19
  const ref = React.useRef(null);
18
20
  const bubbleRef = React.useRef(null);
19
21
  const timer = React.useRef(null);
22
+ // position is the deprecated alias; side (the house placement prop) wins when both are passed.
23
+ const asked = sideProp ?? position;
24
+ const want = SIDES.includes(asked) ? asked : 'top';
25
+
26
+ // Portal's useAnchoredStyle only resolves top/bottom, so the tooltip places
27
+ // itself: the same flip-then-clamp behaviour, extended to left/right. Hidden
28
+ // for the first frame so the measurement never flashes at the origin.
29
+ const [placed, setPlaced] = React.useState({
30
+ style: {
31
+ position: 'fixed',
32
+ top: 0,
33
+ left: 0,
34
+ visibility: 'hidden'
35
+ },
36
+ side: want
37
+ });
38
+ useIsoLayoutEffect(() => {
39
+ if (!open) {
40
+ setPlaced(s => s.style.visibility === 'hidden' ? s : {
41
+ ...s,
42
+ style: {
43
+ ...s.style,
44
+ visibility: 'hidden'
45
+ }
46
+ });
47
+ return;
48
+ }
49
+ const move = () => {
50
+ const anchor = ref.current;
51
+ const bubble = bubbleRef.current;
52
+ if (!anchor || !bubble) return;
53
+ const a = anchor.getBoundingClientRect();
54
+ const b = bubble.getBoundingClientRect();
55
+ const vw = document.documentElement.clientWidth;
56
+ const vh = document.documentElement.clientHeight;
57
+ const edge = 8;
58
+ const offset = 8;
59
+ let side = want;
60
+ if (want === 'left' || want === 'right') {
61
+ const roomLeft = a.left - offset;
62
+ const roomRight = vw - a.right - offset;
63
+ side = want === 'left' ? roomLeft >= b.width || roomLeft >= roomRight ? 'left' : 'right' : roomRight >= b.width || roomRight >= roomLeft ? 'right' : 'left';
64
+ } else {
65
+ const roomAbove = a.top - offset;
66
+ const roomBelow = vh - a.bottom - offset;
67
+ side = want === 'top' ? roomAbove >= b.height || roomAbove >= roomBelow ? 'top' : 'bottom' : roomBelow >= b.height || roomBelow >= roomAbove ? 'bottom' : 'top';
68
+ }
69
+ let top = side === 'top' ? a.top - offset - b.height : side === 'bottom' ? a.bottom + offset : a.top + a.height / 2 - b.height / 2;
70
+ let left = side === 'left' ? a.left - offset - b.width : side === 'right' ? a.right + offset : a.left + a.width / 2 - b.width / 2;
71
+ left = Math.max(edge, Math.min(left, vw - b.width - edge));
72
+ top = Math.max(edge, Math.min(top, vh - b.height - edge));
73
+ setPlaced({
74
+ style: {
75
+ position: 'fixed',
76
+ top: Math.round(top),
77
+ left: Math.round(left),
78
+ visibility: 'visible'
79
+ },
80
+ side
81
+ });
82
+ };
83
+ move();
84
+ // capture phase: any scrolling ancestor moves the anchor, not just the window
85
+ window.addEventListener('scroll', move, true);
86
+ window.addEventListener('resize', move);
87
+ return () => {
88
+ window.removeEventListener('scroll', move, true);
89
+ window.removeEventListener('resize', move);
90
+ };
91
+ }, [open, want]);
20
92
  const {
21
93
  style: anchored,
22
94
  side
23
- } = useAnchoredStyle(ref, bubbleRef, {
24
- open,
25
- placement: position === 'bottom' ? 'bottom' : 'top',
26
- align: 'center',
27
- offset: 8
28
- });
95
+ } = placed;
29
96
 
30
97
  // Keep the arrow over the trigger's centre even when the bubble has been
31
98
  // shifted to stay on screen, so it never points at empty space.
32
- const [arrowX, setArrowX] = React.useState(null);
99
+ const [arrow, setArrow] = React.useState(null);
33
100
  useIsoLayoutEffect(() => {
34
101
  if (!open || !ref.current || !bubbleRef.current) {
35
- setArrowX(null);
102
+ setArrow(null);
36
103
  return;
37
104
  }
38
105
  const a = ref.current.getBoundingClientRect();
39
106
  const b = bubbleRef.current.getBoundingClientRect();
40
107
  if (!b.width) return;
41
- const x = a.left + a.width / 2 - b.left;
42
- setArrowX(Math.max(8, Math.min(x, b.width - 8)));
43
- }, [open, anchored.left, anchored.top]);
108
+ const across = side === 'left' || side === 'right';
109
+ const v = across ? a.top + a.height / 2 - b.top : a.left + a.width / 2 - b.left;
110
+ setArrow(Math.max(8, Math.min(v, (across ? b.height : b.width) - 8)));
111
+ }, [open, side, anchored.left, anchored.top]);
44
112
  const show = immediate => {
45
113
  clearTimeout(timer.current);
46
114
  if (immediate) setOpen(true);else timer.current = setTimeout(() => setOpen(true), delay);
@@ -68,11 +136,11 @@ export function Tooltip({
68
136
  ref: bubbleRef,
69
137
  role: "tooltip",
70
138
  id: id,
71
- className: `ef-tooltip__bubble${side === 'bottom' ? ' ef-tooltip__bubble--bottom' : ''}`,
139
+ className: `ef-tooltip__bubble${side !== 'top' ? ' ef-tooltip__bubble--' + side : ''}`,
72
140
  style: {
73
141
  ...anchored,
74
- ...(arrowX == null ? null : {
75
- '--ef-tt-arrow': arrowX + 'px'
142
+ ...(arrow == null ? null : {
143
+ '--ef-tt-arrow': arrow + 'px'
76
144
  })
77
145
  }
78
146
  }, label)) : null);