@reportportal/ui-kit 0.0.1-alpha.174 → 0.0.1-alpha.176

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/tooltip.js CHANGED
@@ -1,102 +1,105 @@
1
- import { jsxs as p, Fragment as P, jsx as o } from "react/jsx-runtime";
2
- import { useState as R, useRef as d } from "react";
1
+ import { jsxs as p, Fragment as P, jsx as n } from "react/jsx-runtime";
2
+ import { useState as R, useRef as f } from "react";
3
3
  import { createPortal as G } from "react-dom";
4
4
  import { c as j } from "./bind-06a7ff84.js";
5
- import { useFloating as k, offset as $, flip as C, arrow as U, autoUpdate as Y, FloatingArrow as Z } from "@floating-ui/react";
6
- import { T as f, g as q, b as z, a as B } from "./floatingUi-41f8c7b5.js";
5
+ import { useFloating as k, offset as $, flip as B, arrow as C, autoUpdate as U, FloatingArrow as Y } from "@floating-ui/react";
6
+ import { T as u, g as Z, b as q, a as z } from "./floatingUi-41f8c7b5.js";
7
7
  const J = {
8
- "tooltip-wrapper": "_tooltip-wrapper_lwpn2_16",
9
- "tooltip-content": "_tooltip-content_lwpn2_23"
10
- }, n = j.bind(J), K = 300, Q = 100, st = ({
11
- content: u,
12
- wrapperClassName: h,
13
- tooltipClassName: w,
14
- contentClassName: x,
15
- dynamicWidth: g,
16
- width: T,
17
- minWidth: _ = 120,
18
- safeZone: A = 4,
19
- zIndex: E = 9,
20
- placement: N = "bottom",
21
- arrowColor: b = "rgba(34, 34, 34, 0.91)",
22
- dataAutomationId: I,
23
- mainAxis: O = !0,
24
- children: S,
25
- portalRoot: s,
26
- isFloating: W = !0
8
+ "tooltip-wrapper": "_tooltip-wrapper_1n6ya_16",
9
+ "tooltip-content": "_tooltip-content_1n6ya_26"
10
+ }, s = j.bind(J), K = 300, Q = 100, st = ({
11
+ content: h,
12
+ wrapperClassName: x,
13
+ tooltipClassName: g,
14
+ contentClassName: w,
15
+ dynamicWidth: T,
16
+ width: _,
17
+ minWidth: A = 120,
18
+ safeZone: E = 4,
19
+ zIndex: b = 9,
20
+ placement: y = "bottom",
21
+ arrowColor: I = "rgba(34, 34, 34, 0.91)",
22
+ dataAutomationId: N,
23
+ mainAxis: F = !0,
24
+ children: O,
25
+ portalRoot: i,
26
+ isFloating: S = !0
27
27
  }) => {
28
- const [i, l] = R(!1), a = d(null), t = d(), { refs: r, floatingStyles: v, context: y } = k({
29
- open: i,
30
- placement: N,
28
+ const [a, l] = R(!1), r = f(null), t = f(), { refs: c, floatingStyles: W, context: v } = k({
29
+ open: a,
30
+ placement: y,
31
31
  middleware: [
32
32
  $(({ rects: D, placement: H }) => ({
33
- mainAxis: A + f,
34
- alignmentAxis: q(D, H)
33
+ mainAxis: E + u,
34
+ alignmentAxis: Z(D, H)
35
35
  })),
36
- W && C({
37
- mainAxis: O,
36
+ S && B({
37
+ mainAxis: F,
38
38
  fallbackAxisSideDirection: "start",
39
- fallbackPlacements: z
39
+ fallbackPlacements: q
40
40
  }),
41
- U({
42
- element: a
41
+ C({
42
+ element: r
43
43
  })
44
44
  ],
45
- whileElementsMounted: Y
46
- }), e = g ? null : { width: `${T}px` }, F = document.documentElement.clientWidth, L = e || F - Q, c = () => {
45
+ whileElementsMounted: U
46
+ }), e = T ? null : { width: `${_}px` }, L = document.documentElement.clientWidth, M = e || L - Q, o = () => {
47
47
  t.current && clearTimeout(t.current), l(!1);
48
- }, M = () => {
48
+ }, m = () => {
49
49
  t.current = setTimeout(() => l(!0), K);
50
- }, m = () => /* @__PURE__ */ p(
50
+ }, d = () => /* @__PURE__ */ p(
51
51
  "div",
52
52
  {
53
- ref: r.setFloating,
53
+ ref: c.setFloating,
54
54
  style: {
55
- ...v,
55
+ ...W,
56
56
  ...e,
57
- minWidth: _,
58
- zIndex: E,
57
+ minWidth: A,
58
+ zIndex: b,
59
59
  pointerEvents: "none"
60
60
  },
61
- "data-automation-id": I,
62
- className: n(w),
61
+ "data-automation-id": N,
62
+ className: s(g),
63
63
  children: [
64
- /* @__PURE__ */ o(
65
- Z,
64
+ /* @__PURE__ */ n(
65
+ Y,
66
66
  {
67
- ref: a,
68
- context: y,
69
- width: B,
70
- height: f,
71
- fill: b
67
+ ref: r,
68
+ context: v,
69
+ width: z,
70
+ height: u,
71
+ fill: I
72
72
  }
73
73
  ),
74
- /* @__PURE__ */ o(
74
+ /* @__PURE__ */ n(
75
75
  "div",
76
76
  {
77
- className: n("tooltip-content", x),
77
+ className: s("tooltip-content", w),
78
78
  style: {
79
- maxWidth: `${L}px`
79
+ maxWidth: `${M}px`
80
80
  },
81
- children: u
81
+ children: h
82
82
  }
83
83
  )
84
84
  ]
85
85
  }
86
86
  );
87
87
  return /* @__PURE__ */ p(P, { children: [
88
- /* @__PURE__ */ o(
88
+ /* @__PURE__ */ n(
89
89
  "div",
90
90
  {
91
- ref: r.setReference,
92
- className: n("tooltip-wrapper", h),
93
- onMouseDown: c,
94
- onMouseEnter: M,
95
- onMouseLeave: c,
96
- children: S
91
+ ref: c.setReference,
92
+ className: s("tooltip-wrapper", x),
93
+ onMouseDown: o,
94
+ onMouseEnter: m,
95
+ onMouseLeave: o,
96
+ onFocus: m,
97
+ onBlur: o,
98
+ tabIndex: 0,
99
+ children: O
97
100
  }
98
101
  ),
99
- i && (s ? G(m(), s) : m())
102
+ a && (i ? G(d(), i) : d())
100
103
  ] });
101
104
  };
102
105
  export {
@@ -0,0 +1,184 @@
1
+ import { useRef as _, useState as N, useEffect as w, useCallback as b } from "react";
2
+ import { useDrag as Z, useDrop as A } from "react-dnd";
3
+ import { getEmptyImage as F } from "react-dnd-html5-backend";
4
+ import { DROP_POSITIONS as D, DROP_DETECTION_MODE as d, TREE_DROP_POSITIONS as h } from "./common.js";
5
+ const k = "SORTABLE_ITEM", y = (r) => {
6
+ if (!r)
7
+ return {
8
+ display: "none"
9
+ };
10
+ const { x: n, y: o } = r, i = `translate(${n}px, ${o}px)`;
11
+ return {
12
+ transform: i,
13
+ WebkitTransform: i
14
+ };
15
+ }, L = ({
16
+ fromIndex: r,
17
+ targetIndex: n,
18
+ isTopZone: o
19
+ }) => o ? r < n ? n - 1 : n : r > n ? n + 1 : n, $ = (r, n) => r / n < 0.5 ? D.TOP : D.BOTTOM, z = ({
20
+ id: r,
21
+ index: n,
22
+ type: o = k,
23
+ isDisabled: i = !1,
24
+ isLast: R = !1,
25
+ onDrop: g,
26
+ hideDefaultPreview: T = !1,
27
+ dropDetectionMode: u = d.INDEX_BASED
28
+ }) => {
29
+ const p = u === d.HOVER, v = _(null), O = _(null), [E, c] = N(null), [{ isDragging: B }, I, m] = Z(
30
+ () => ({
31
+ type: o,
32
+ item: { id: r, index: n, type: o },
33
+ collect: (t) => ({
34
+ isDragging: t.isDragging()
35
+ }),
36
+ canDrag: () => !i
37
+ }),
38
+ [r, n, o, i]
39
+ );
40
+ w(() => {
41
+ T && m(F(), { captureDraggingState: !0 });
42
+ }, [T, m]);
43
+ const [{ isOver: P, draggedItemIndex: S }, C] = A(
44
+ () => ({
45
+ accept: o,
46
+ collect: (t) => {
47
+ const e = t.getItem(), l = (e == null ? void 0 : e.id) !== r ? t.isOver() : !1;
48
+ return {
49
+ isOver: l,
50
+ draggedItemIndex: l ? (e == null ? void 0 : e.index) ?? null : null
51
+ };
52
+ },
53
+ hover: (t, e) => {
54
+ if (!p)
55
+ return;
56
+ if (t.id === r) {
57
+ c(null);
58
+ return;
59
+ }
60
+ const a = v.current;
61
+ if (!a) {
62
+ c(null);
63
+ return;
64
+ }
65
+ const l = a.getBoundingClientRect(), x = l.bottom - l.top, V = e.getClientOffset();
66
+ if (!V) {
67
+ c(null);
68
+ return;
69
+ }
70
+ const H = V.y - l.top, Y = $(H, x);
71
+ Y === null ? (c(null), O.current = null) : Y === D.TOP ? (c(D.TOP), O.current = D.TOP) : (c(D.BOTTOM), O.current = D.BOTTOM);
72
+ },
73
+ drop: (t) => {
74
+ if (!(t.id === r || !g))
75
+ if (p) {
76
+ const e = O.current;
77
+ if (!e)
78
+ return;
79
+ const a = e === D.TOP, l = L({
80
+ fromIndex: t.index,
81
+ targetIndex: n,
82
+ isTopZone: a
83
+ });
84
+ g(t.index, l);
85
+ } else
86
+ g(t.index, n);
87
+ }
88
+ }),
89
+ [r, n, o, g, R, p]
90
+ ), M = b(
91
+ (t) => (v.current = t, C(t)),
92
+ [C]
93
+ );
94
+ w(() => {
95
+ P || c(null);
96
+ }, [P]);
97
+ const f = p ? E : (() => S === null ? null : S > n ? D.TOP : D.BOTTOM)();
98
+ return {
99
+ isDragging: B,
100
+ isOver: P,
101
+ draggedItemIndex: S,
102
+ dropPosition: f,
103
+ dragRef: I,
104
+ dropRef: M,
105
+ previewRef: m
106
+ };
107
+ }, G = (r, n, o = !1) => {
108
+ if (!r || !n)
109
+ return null;
110
+ const { top: i, height: R } = n, T = r.y - i, u = 6;
111
+ return T >= 0 && T < u ? h.BEFORE : o && T >= R - u && T <= R ? h.AFTER : h.INSIDE;
112
+ }, J = ({
113
+ id: r,
114
+ index: n,
115
+ parentId: o = null,
116
+ type: i = k,
117
+ isDisabled: R = !1,
118
+ acceptDrop: g = !0,
119
+ isLast: T = !1,
120
+ canDropOn: u,
121
+ onDrop: p,
122
+ hideDefaultPreview: v = !1
123
+ }) => {
124
+ const O = _(null), E = _(null), [c, B] = N(null), [{ isDragging: I }, m, P] = Z(
125
+ () => ({
126
+ type: i,
127
+ item: { id: r, index: n, type: i, parentId: o },
128
+ collect: (s) => ({
129
+ isDragging: s.isDragging()
130
+ }),
131
+ canDrag: () => !R
132
+ }),
133
+ [r, n, i, o, R]
134
+ );
135
+ w(() => {
136
+ v && P(F(), { captureDraggingState: !0 });
137
+ }, [v, P]);
138
+ const [{ isOver: S }, C] = A(
139
+ () => ({
140
+ accept: i,
141
+ hover: (s, f) => {
142
+ if (O.current && s.id !== r && g)
143
+ if (!u || u(s, r)) {
144
+ const e = f.getClientOffset(), a = O.current.getBoundingClientRect();
145
+ if (e && a) {
146
+ const l = G(e, a, T);
147
+ l !== c && (B(l), E.current = l);
148
+ }
149
+ } else
150
+ c !== null && (B(null), E.current = null);
151
+ },
152
+ collect: (s) => {
153
+ const f = s.getItem(), t = (f == null ? void 0 : f.id) !== r && g, e = !u || !f || u(f, r), a = s.isOver({ shallow: !0 }), l = t && e;
154
+ return !a && c !== null && (B(null), E.current = null), {
155
+ isOver: a && l
156
+ };
157
+ },
158
+ drop: (s, f) => {
159
+ if (f.didDrop())
160
+ return;
161
+ const t = !u || u(s, r);
162
+ s.id !== r && g && t && p && E.current && p(s, r, E.current);
163
+ }
164
+ }),
165
+ [r, i, g, T, u, p, c]
166
+ );
167
+ return {
168
+ isDragging: I,
169
+ isOver: S,
170
+ dropPosition: c,
171
+ dragRef: m,
172
+ dropRef: (s) => {
173
+ O.current = s, C(s);
174
+ },
175
+ previewRef: P,
176
+ elementRef: O
177
+ };
178
+ };
179
+ export {
180
+ k as D,
181
+ J as a,
182
+ y as g,
183
+ z as u
184
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reportportal/ui-kit",
3
- "version": "0.0.1-alpha.174",
3
+ "version": "0.0.1-alpha.176",
4
4
  "description": "The UI-kit library for ReportPortal Design System.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,179 +0,0 @@
1
- import { useRef as C, useState as V, useEffect as d, useCallback as b } from "react";
2
- import { useDrag as F, useDrop as Y } from "react-dnd";
3
- import { getEmptyImage as k } from "react-dnd-html5-backend";
4
- import { DROP_POSITIONS as l, DROP_DETECTION_MODE as h, TREE_DROP_POSITIONS as Z } from "./common.js";
5
- const x = "SORTABLE_ITEM", z = (r) => {
6
- if (!r)
7
- return {
8
- display: "none"
9
- };
10
- const { x: n, y: t } = r, s = `translate(${n}px, ${t}px)`;
11
- return {
12
- transform: s,
13
- WebkitTransform: s
14
- };
15
- }, $ = ({
16
- fromIndex: r,
17
- targetIndex: n,
18
- isTopZone: t
19
- }) => t ? r < n ? n - 1 : n : r > n ? n + 1 : n, G = (r, n) => r / n < 0.5 ? l.TOP : l.BOTTOM, J = ({
20
- id: r,
21
- index: n,
22
- type: t = x,
23
- isDisabled: s = !1,
24
- isLast: a = !1,
25
- onDrop: g,
26
- hideDefaultPreview: O = !1,
27
- dropDetectionMode: E = h.INDEX_BASED
28
- }) => {
29
- const T = E === h.HOVER, p = C(null), i = C(null), [_, u] = V(null), [{ isDragging: P }, I, m] = F(
30
- () => ({
31
- type: t,
32
- item: { id: r, index: n, type: t },
33
- collect: (e) => ({
34
- isDragging: e.isDragging()
35
- }),
36
- canDrag: () => !s
37
- }),
38
- [r, n, t, s]
39
- );
40
- d(() => {
41
- O && m(k(), { captureDraggingState: !0 });
42
- }, [O, m]);
43
- const [{ isOver: v, draggedItemIndex: B }, o] = Y(
44
- () => ({
45
- accept: t,
46
- collect: (e) => {
47
- const c = e.getItem(), D = (c == null ? void 0 : c.id) !== r ? e.isOver() : !1;
48
- return {
49
- isOver: D,
50
- draggedItemIndex: D ? (c == null ? void 0 : c.index) ?? null : null
51
- };
52
- },
53
- hover: (e, c) => {
54
- if (!T)
55
- return;
56
- if (e.id === r) {
57
- u(null);
58
- return;
59
- }
60
- const R = p.current;
61
- if (!R) {
62
- u(null);
63
- return;
64
- }
65
- const D = R.getBoundingClientRect(), H = D.bottom - D.top, w = c.getClientOffset();
66
- if (!w) {
67
- u(null);
68
- return;
69
- }
70
- const L = w.y - D.top, N = G(L, H);
71
- N === null ? (u(null), i.current = null) : N === l.TOP ? (u(l.TOP), i.current = l.TOP) : (u(l.BOTTOM), i.current = l.BOTTOM);
72
- },
73
- drop: (e) => {
74
- if (!(e.id === r || !g))
75
- if (T) {
76
- const c = i.current;
77
- if (!c)
78
- return;
79
- const R = c === l.TOP, D = $({
80
- fromIndex: e.index,
81
- targetIndex: n,
82
- isTopZone: R
83
- });
84
- g(e.index, D);
85
- } else
86
- g(e.index, n);
87
- }
88
- }),
89
- [r, n, t, g, a, T]
90
- ), f = b(
91
- (e) => (p.current = e, o(e)),
92
- [o]
93
- );
94
- d(() => {
95
- v || u(null);
96
- }, [v]);
97
- const S = T ? _ : (() => B === null ? null : B > n ? l.TOP : l.BOTTOM)();
98
- return {
99
- isDragging: P,
100
- isOver: v,
101
- draggedItemIndex: B,
102
- dropPosition: S,
103
- dragRef: I,
104
- dropRef: f,
105
- previewRef: m
106
- };
107
- }, A = 2, U = (r, n) => {
108
- if (!r || !n)
109
- return null;
110
- const { top: t, height: s } = n, a = r.y - t;
111
- return a < A ? Z.BEFORE : a > s - A ? Z.AFTER : Z.INSIDE;
112
- }, K = ({
113
- id: r,
114
- index: n,
115
- parentId: t = null,
116
- type: s = x,
117
- isDisabled: a = !1,
118
- acceptDrop: g = !0,
119
- canDropOn: O,
120
- onDrop: E,
121
- hideDefaultPreview: T = !1
122
- }) => {
123
- const p = C(null), i = C(null), [{ isDragging: _ }, u, P] = F(
124
- () => ({
125
- type: s,
126
- item: { id: r, index: n, type: s, parentId: t },
127
- collect: (o) => ({
128
- isDragging: o.isDragging()
129
- }),
130
- canDrag: () => !a
131
- }),
132
- [r, n, s, t, a]
133
- );
134
- d(() => {
135
- T && P(k(), { captureDraggingState: !0 });
136
- }, [T, P]);
137
- const [{ isOver: I, dropPosition: m }, v] = Y(
138
- () => ({
139
- accept: s,
140
- collect: (o) => {
141
- const f = o.getItem(), S = (f == null ? void 0 : f.id) !== r && g && (!O || !f || O(f, r)) ? o.isOver({ shallow: !0 }) : !1;
142
- let e = null;
143
- if (S && p.current) {
144
- const c = o.getClientOffset(), R = p.current.getBoundingClientRect();
145
- e = U(c, R), i.current = e;
146
- } else
147
- i.current = null;
148
- return {
149
- isOver: S,
150
- dropPosition: e
151
- };
152
- },
153
- drop: (o, f) => {
154
- if (f.didDrop())
155
- return;
156
- const M = !O || O(o, r);
157
- o.id !== r && g && M && E && i.current && E(o, r, i.current);
158
- }
159
- }),
160
- [r, s, g, O, E]
161
- );
162
- return {
163
- isDragging: _,
164
- isOver: I,
165
- dropPosition: m,
166
- dragRef: u,
167
- dropRef: (o) => {
168
- p.current = o, v(o);
169
- },
170
- previewRef: P,
171
- elementRef: p
172
- };
173
- };
174
- export {
175
- x as D,
176
- K as a,
177
- z as g,
178
- J as u
179
- };