@reportportal/ui-kit 0.0.1-alpha.169 → 0.0.1-alpha.170

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.
@@ -1,3 +1,5 @@
1
1
  export { useOnClickOutside } from './useOnClickOutside';
2
2
  export { useSortable } from './useSortable';
3
+ export { useTreeSortable } from './useTreeSortable';
4
+ export { useTreeDropValidation } from './useTreeDropValidation';
3
5
  export { useWindowResize } from './useWindowResize';
@@ -0,0 +1,5 @@
1
+ import { TreeDragItem, TreeItem, UseTreeDropValidationOptions } from '../types';
2
+
3
+ export declare const useTreeDropValidation: <T extends TreeItem<T>>({ items, childrenKey, }: UseTreeDropValidationOptions<T>) => {
4
+ canDropOn: (draggedItem: TreeDragItem, targetId: string | number) => boolean;
5
+ };
@@ -0,0 +1,3 @@
1
+ import { UseTreeSortableOptions, UseTreeSortableReturn } from '../types';
2
+
3
+ export declare const useTreeSortable: ({ id, index, parentId, type, isDisabled, acceptDrop, canDropOn, onDrop, hideDefaultPreview, }: UseTreeSortableOptions) => UseTreeSortableReturn;
@@ -0,0 +1,67 @@
1
+ import { u as w } from "../useOnClickOutside-8f7d68a1.js";
2
+ import { u as E, a as R } from "../useTreeSortable-70a9c8f5.js";
3
+ import { useCallback as x } from "react";
4
+ import { i as z } from "../isEmpty-ccacb5ff.js";
5
+ import { u as W } from "../useWindowResize-a7e1ac92.js";
6
+ import "react-dnd";
7
+ import "react-dnd-html5-backend";
8
+ import "../common.js";
9
+ /*!
10
+ * Copyright 2026 EPAM Systems
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+ const o = (r) => String(r), I = (r, e, f, n = "children") => {
25
+ const s = o(r), u = o(e), i = (c, a) => {
26
+ for (const t of a) {
27
+ if (o(t.id) === c)
28
+ return t;
29
+ const m = t[n] || [];
30
+ if (!z(m)) {
31
+ const p = i(c, m);
32
+ if (p)
33
+ return p;
34
+ }
35
+ }
36
+ return null;
37
+ }, d = i(s, f);
38
+ if (!d)
39
+ return !1;
40
+ const l = (c) => {
41
+ for (const a of c) {
42
+ if (o(a.id) === u)
43
+ return !0;
44
+ const t = a[n] || [];
45
+ if (!z(t) && l(t))
46
+ return !0;
47
+ }
48
+ return !1;
49
+ }, D = d[n] || [];
50
+ return l(D);
51
+ }, S = ({
52
+ items: r,
53
+ childrenKey: e = "children"
54
+ }) => ({ canDropOn: x(
55
+ (n, s) => {
56
+ const u = o(n.id), i = o(s);
57
+ return u === i ? !1 : !I(n.id, s, r, e);
58
+ },
59
+ [r, e]
60
+ ) });
61
+ export {
62
+ w as useOnClickOutside,
63
+ E as useSortable,
64
+ S as useTreeDropValidation,
65
+ R as useTreeSortable,
66
+ W as useWindowResize
67
+ };
@@ -13,7 +13,6 @@ export declare const DROP_POSITIONS: {
13
13
  readonly BOTTOM: "bottom";
14
14
  };
15
15
  export type DropPositionValue = (typeof DROP_POSITIONS)[keyof typeof DROP_POSITIONS];
16
- export type DropPosition = DropPositionValue | null;
17
16
  export declare const DROP_DETECTION_MODE: {
18
17
  readonly INDEX_BASED: "indexBased";
19
18
  readonly HOVER: "hover";
@@ -82,3 +81,88 @@ export interface DragLayerCollectedProps {
82
81
  clientOffset: XYCoord | null;
83
82
  isDragging: boolean;
84
83
  }
84
+ export type DropPosition = 'top' | 'bottom' | null;
85
+ export declare const TREE_DROP_POSITIONS: {
86
+ readonly BEFORE: "before";
87
+ readonly INSIDE: "inside";
88
+ readonly AFTER: "after";
89
+ };
90
+ export type TreeDropPositionValue = (typeof TREE_DROP_POSITIONS)[keyof typeof TREE_DROP_POSITIONS];
91
+ export type TreeDropPosition = TreeDropPositionValue | null;
92
+ export interface TreeDragItem extends DragItem {
93
+ parentId?: string | number | null;
94
+ depth?: number;
95
+ }
96
+ export type TreeDropHandler = (draggedItem: TreeDragItem, targetId: string | number, position: TreeDropPosition) => void;
97
+ export interface UseTreeSortableOptions {
98
+ id: string | number;
99
+ index: number;
100
+ parentId?: string | number | null;
101
+ type?: string;
102
+ isDisabled?: boolean;
103
+ acceptDrop?: boolean;
104
+ canDropOn?: (draggedItem: TreeDragItem, targetId: string | number) => boolean;
105
+ onDrop?: TreeDropHandler;
106
+ hideDefaultPreview?: boolean;
107
+ }
108
+ export interface TreeSortableState {
109
+ isDragging: boolean;
110
+ isOver: boolean;
111
+ dropPosition: TreeDropPosition;
112
+ dragRef: ConnectDragSource;
113
+ }
114
+ export interface UseTreeSortableReturn extends TreeSortableState {
115
+ dropRef: (node: HTMLElement | null) => void;
116
+ previewRef: ConnectDragPreview;
117
+ elementRef: React.RefObject<HTMLElement | null>;
118
+ }
119
+ export type TreeSortableItemRenderProps = TreeSortableState;
120
+ export interface TreeSortableItemProps {
121
+ id: string | number;
122
+ index: number;
123
+ parentId?: string | number | null;
124
+ type?: string;
125
+ isDisabled?: boolean;
126
+ acceptDrop?: boolean;
127
+ isLast?: boolean;
128
+ canDropOn?: (draggedItem: TreeDragItem, targetId: string | number) => boolean;
129
+ depth?: number;
130
+ className?: string;
131
+ draggingClassName?: string;
132
+ dropBeforeClassName?: string;
133
+ dropInsideClassName?: string;
134
+ dropAfterClassName?: string;
135
+ onDrop?: TreeDropHandler;
136
+ hideDefaultPreview?: boolean;
137
+ children: ReactNode | ((props: TreeSortableItemRenderProps) => ReactNode);
138
+ }
139
+ export interface TreeItem<T = unknown> {
140
+ id: string | number;
141
+ children?: T[];
142
+ folders?: T[];
143
+ }
144
+ export interface UseTreeDropValidationOptions<T extends TreeItem<T>> {
145
+ items: T[];
146
+ childrenKey?: 'children' | 'folders';
147
+ }
148
+ export declare const DROP_ACTIONS: {
149
+ readonly MOVE: "move";
150
+ readonly DUPLICATE: "duplicate";
151
+ readonly CANCEL: "cancel";
152
+ };
153
+ export type DropAction = (typeof DROP_ACTIONS)[keyof typeof DROP_ACTIONS];
154
+ export interface PendingDropInfo {
155
+ draggedItem: TreeDragItem;
156
+ targetId: string | number;
157
+ position: TreeDropPosition;
158
+ }
159
+ export type DropConfirmationLabels = Partial<Record<DropAction, string>>;
160
+ export interface TreeSortableContainerProps {
161
+ children: ReactNode;
162
+ showDropConfirmation?: boolean;
163
+ confirmationLabels?: DropConfirmationLabels;
164
+ portalTarget?: Element | null;
165
+ onMove?: TreeDropHandler;
166
+ onDuplicate?: TreeDropHandler;
167
+ onCancel?: () => void;
168
+ }
package/dist/common.js CHANGED
@@ -1,11 +1,21 @@
1
1
  const O = {
2
2
  TOP: "top",
3
3
  BOTTOM: "bottom"
4
- }, o = {
4
+ }, E = {
5
5
  INDEX_BASED: "indexBased",
6
6
  HOVER: "hover"
7
+ }, e = {
8
+ BEFORE: "before",
9
+ INSIDE: "inside",
10
+ AFTER: "after"
11
+ }, o = {
12
+ MOVE: "move",
13
+ DUPLICATE: "duplicate",
14
+ CANCEL: "cancel"
7
15
  };
8
16
  export {
9
- o as DROP_DETECTION_MODE,
10
- O as DROP_POSITIONS
17
+ o as DROP_ACTIONS,
18
+ E as DROP_DETECTION_MODE,
19
+ O as DROP_POSITIONS,
20
+ e as TREE_DROP_POSITIONS
11
21
  };
@@ -1,4 +1,5 @@
1
1
  import { ReactNode, ReactElement } from 'react';
2
+ import { Placement } from '@floating-ui/react';
2
3
 
3
4
  type DateRangeValue = [Date | null, Date | null];
4
5
  interface DatePickerBaseProps {
@@ -16,6 +17,7 @@ interface DatePickerBaseProps {
16
17
  yearsOptions?: number[];
17
18
  placeholder?: string;
18
19
  dateFormat?: string;
20
+ popperPlacement?: Placement;
19
21
  }
20
22
  interface DatePickerSingleProps extends DatePickerBaseProps {
21
23
  selectsRange?: false;
@@ -1,4 +1,4 @@
1
1
  import { Locale } from 'date-fns';
2
2
 
3
3
  export declare const registerDatePickerLocale: (language: string, locale: Locale) => void;
4
- export declare const getYearsFrom: (start: number, amountYearsToGenerate?: number) => number[];
4
+ export declare const getYearsFrom: (start: number, extraYear: number, amountYearsToGenerate?: number) => number[];
@@ -30,10 +30,11 @@ export { SpinLoader } from './spinLoader';
30
30
  export { SystemAlert } from './systemAlert';
31
31
  export { SystemMessage } from './systemMessage';
32
32
  export { SingleAutocomplete } from './autocompletes/singleAutocomplete';
33
- export { SortableItem, SortableList, DragLayer } from './sortable';
33
+ export { SortableItem, SortableList, DragLayer, TreeSortableItem, TreeSortableContainer, } from './sortable';
34
34
  export { Table } from './table';
35
35
  export { ThemeProvider } from './themeProvider';
36
36
  export { Toggle } from './toggle';
37
37
  export { Tooltip } from './tooltip';
38
38
  export { SidePanel } from './sidePanel';
39
+ export { useTreeDropValidation } from '../common/hooks';
39
40
  export * from './icons';
@@ -1,3 +1,5 @@
1
1
  export { SortableItem } from './sortableItem';
2
2
  export { SortableList } from './sortableList';
3
3
  export { DragLayer } from './dragLayer';
4
+ export { TreeSortableItem } from './treeSortableItem';
5
+ export { TreeSortableContainer } from './treeSortableContainer';
@@ -0,0 +1,11 @@
1
+ import { TreeDragItem, TreeDropPosition } from '../../../common/types';
2
+
3
+ export interface TreeSortableContextValue {
4
+ showDropConfirmation: boolean;
5
+ pendingDraggedItemId: string | number | null;
6
+ pendingTargetId: string | number | null;
7
+ pendingDropPosition: TreeDropPosition;
8
+ requestDrop: (draggedItem: TreeDragItem, targetId: string | number, position: TreeDropPosition, dropElement: HTMLElement) => void;
9
+ }
10
+ export declare const TreeSortableContext: import('react').Context<TreeSortableContextValue | null>;
11
+ export declare const useTreeSortableContext: () => TreeSortableContextValue | null;
@@ -0,0 +1,2 @@
1
+ export { TreeSortableContainer } from './treeSortableContainer';
2
+ export { useTreeSortableContext } from './TreeSortableContext';
@@ -0,0 +1,3 @@
1
+ import { TreeSortableContainerProps } from '../../../common/types';
2
+
3
+ export declare const TreeSortableContainer: ({ children, showDropConfirmation, confirmationLabels, portalTarget, onMove, onDuplicate, onCancel, }: TreeSortableContainerProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export { TreeSortableItem } from './treeSortableItem';
@@ -0,0 +1,3 @@
1
+ import { TreeSortableItemProps } from '../../../common/types';
2
+
3
+ export declare const TreeSortableItem: ({ id, index, parentId, type, isDisabled, acceptDrop, isLast, canDropOn, className, draggingClassName, dropBeforeClassName, dropInsideClassName, dropAfterClassName, onDrop, hideDefaultPreview, children, }: TreeSortableItemProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,213 @@
1
+ import { jsxs as F, Fragment as G, jsx as o } from "react/jsx-runtime";
2
+ import { useMemo as T, forwardRef as W, useRef as q } from "react";
3
+ import E from "react-datepicker/dist/es/index.js";
4
+ import { c as L } from "./bind-06a7ff84.js";
5
+ import { F as B } from "./fieldText-1749da7a.js";
6
+ import { D as x } from "./dropdown-7d024c49.js";
7
+ import { S as I } from "./calendarArrow-44c7e60e.js";
8
+ import { registerLocale as z } from "react-datepicker";
9
+ const De = (t, n) => {
10
+ z(t, n);
11
+ }, J = (t, n, d = 20) => {
12
+ const c = new Array(d).fill(void 0).map((f, m) => t - m), _ = t - d + 1;
13
+ return n > t ? [n, ...c] : n < _ ? [...c, n] : c;
14
+ }, K = "_header_1s3dn_1", Q = "_disabled_1s3dn_25", X = "_dropdown_1s3dn_8", Z = {
15
+ header: K,
16
+ "dropdowns-wrapper": "_dropdowns-wrapper_1s3dn_8",
17
+ "button-prev": "_button-prev_1s3dn_13",
18
+ "button-next": "_button-next_1s3dn_14",
19
+ disabled: Q,
20
+ dropdown: X,
21
+ "month-dropdown": "_month-dropdown_1s3dn_44",
22
+ "toggle-button": "_toggle-button_1s3dn_47"
23
+ }, l = L.bind(Z), ee = ({
24
+ date: t = /* @__PURE__ */ new Date(),
25
+ changeYear: n = () => {
26
+ },
27
+ changeMonth: d = () => {
28
+ },
29
+ decreaseMonth: c = () => {
30
+ },
31
+ increaseMonth: _ = () => {
32
+ },
33
+ prevMonthButtonDisabled: f = !1,
34
+ nextMonthButtonDisabled: m = !1,
35
+ headerNodes: h = null,
36
+ customClassName: v = "",
37
+ yearsOptions: b = [],
38
+ locale: D
39
+ }) => {
40
+ const i = t.getFullYear(), S = t.getMonth(), N = T(() => {
41
+ const e = Array(12).keys(), p = new Intl.DateTimeFormat(D, {
42
+ month: "long"
43
+ }), a = (w) => p.format(new Date(i, w));
44
+ return Array.from(e, a).reduce((w, R, C) => w.concat({
45
+ value: C,
46
+ label: R
47
+ }), []);
48
+ }, [D, i]), y = T(() => {
49
+ const e = (/* @__PURE__ */ new Date()).getFullYear();
50
+ return (b.length > 0 ? b : J(e, i)).reduce(
51
+ (a, s) => a.concat({ value: s, label: `${s}` }),
52
+ []
53
+ );
54
+ }, [b, i]), A = (e) => {
55
+ d(e);
56
+ }, r = (e) => {
57
+ n(e);
58
+ };
59
+ return /* @__PURE__ */ F(G, { children: [
60
+ h && /* @__PURE__ */ o("div", { className: l(v), children: h }),
61
+ /* @__PURE__ */ F("div", { className: l("header"), children: [
62
+ /* @__PURE__ */ o(
63
+ "button",
64
+ {
65
+ type: "button",
66
+ "aria-label": "Previous Months",
67
+ disabled: f,
68
+ onClick: (e) => {
69
+ e.stopPropagation(), c();
70
+ },
71
+ className: l("button-prev", { disabled: f }),
72
+ children: /* @__PURE__ */ o(I, {})
73
+ }
74
+ ),
75
+ /* @__PURE__ */ F("div", { className: l("dropdowns-wrapper"), children: [
76
+ /* @__PURE__ */ o(
77
+ x,
78
+ {
79
+ options: N,
80
+ value: S,
81
+ onChange: A,
82
+ transparentBackground: !0,
83
+ className: l("dropdown", "month-dropdown"),
84
+ toggleButtonClassName: l("toggle-button")
85
+ }
86
+ ),
87
+ /* @__PURE__ */ o(
88
+ x,
89
+ {
90
+ options: y,
91
+ value: i,
92
+ onChange: r,
93
+ transparentBackground: !0,
94
+ className: l("dropdown"),
95
+ toggleButtonClassName: l("toggle-button")
96
+ }
97
+ )
98
+ ] }),
99
+ /* @__PURE__ */ o(
100
+ "button",
101
+ {
102
+ type: "button",
103
+ "aria-label": "Next Months",
104
+ disabled: m,
105
+ onClick: (e) => {
106
+ e.stopPropagation(), _();
107
+ },
108
+ className: l("button-next", { disabled: m }),
109
+ children: /* @__PURE__ */ o(I, {})
110
+ }
111
+ )
112
+ ] })
113
+ ] });
114
+ }, te = "_calendar_evrpf_5", ne = "_date_evrpf_103", oe = "_disabled_evrpf_149", re = "_popper_evrpf_157", ae = "_input_evrpf_161", se = {
115
+ calendar: te,
116
+ "current-date": "_current-date_evrpf_102",
117
+ date: ne,
118
+ "end-date": "_end-date_evrpf_120",
119
+ "selected-range": "_selected-range_evrpf_130",
120
+ disabled: oe,
121
+ popper: re,
122
+ input: ae,
123
+ "input-range": "_input-range_evrpf_168"
124
+ }, u = L.bind(se), de = "en", ce = "MM-dd-yyyy", le = " to ", ie = W(({ value: t, ...n }, d) => {
125
+ const c = (t == null ? void 0 : t.replace(" - ", le)) ?? "";
126
+ return /* @__PURE__ */ o(B, { ...n, value: c, ref: d });
127
+ }), Ne = (t) => {
128
+ const {
129
+ onChange: n = () => {
130
+ },
131
+ disabled: d = !1,
132
+ onBlur: c = () => {
133
+ },
134
+ onFocus: _ = () => {
135
+ },
136
+ headerNodes: f = null,
137
+ customClassName: m = "",
138
+ customTimeInput: h = void 0,
139
+ shouldCloseOnSelect: v = !0,
140
+ popperClassName: b = "",
141
+ calendarClassName: D = "",
142
+ popperPlacement: i = "bottom-start",
143
+ fixedHeight: S = !0,
144
+ language: N = de,
145
+ yearsOptions: y = [],
146
+ dateFormat: A = ce,
147
+ value: r = null
148
+ } = t, e = "selectsRange" in t && t.selectsRange === !0, p = q(null), a = e ? (r == null ? void 0 : r[0]) ?? void 0 : void 0, s = e ? (r == null ? void 0 : r[1]) ?? void 0 : void 0, w = a == null ? void 0 : a.toDateString(), R = s == null ? void 0 : s.toDateString(), C = s && a && s > a, O = e ? "Select date range" : "Select date", Y = t.placeholder ?? O, $ = (g) => {
149
+ if (!e) {
150
+ const V = r == null ? void 0 : r.toDateString(), j = g.toDateString();
151
+ return u("date", {
152
+ "current-date": j === V,
153
+ disabled: d
154
+ });
155
+ }
156
+ const k = g.toDateString(), H = k === w, M = C && k === R, U = a && s && g > a && g < s;
157
+ return u("date", {
158
+ "current-date": H,
159
+ "selected-range": U && !M,
160
+ "end-date": M && C,
161
+ disabled: d
162
+ });
163
+ }, P = {
164
+ customInput: e ? /* @__PURE__ */ o(ie, { className: u("input", "input-range"), defaultWidth: !1, ref: p }) : /* @__PURE__ */ o(B, { className: u("input"), defaultWidth: !1, ref: p }),
165
+ placeholderText: Y,
166
+ disabled: d,
167
+ shouldCloseOnSelect: v,
168
+ fixedHeight: S,
169
+ locale: N,
170
+ showPopperArrow: !1,
171
+ dayClassName: $,
172
+ calendarClassName: u(D, "calendar"),
173
+ renderCustomHeader: (g) => /* @__PURE__ */ o(
174
+ ee,
175
+ {
176
+ ...g,
177
+ headerNodes: f,
178
+ customClassName: m,
179
+ yearsOptions: y,
180
+ locale: N
181
+ }
182
+ ),
183
+ onBlur: c,
184
+ onFocus: _,
185
+ customTimeInput: h,
186
+ showTimeInput: !!h,
187
+ popperClassName: u(b, "popper"),
188
+ dateFormat: A,
189
+ className: u("datepicker"),
190
+ popperPlacement: i
191
+ };
192
+ return e ? /* @__PURE__ */ o(
193
+ E,
194
+ {
195
+ ...P,
196
+ selectsRange: !0,
197
+ startDate: a,
198
+ endDate: s,
199
+ onChange: n
200
+ }
201
+ ) : /* @__PURE__ */ o(
202
+ E,
203
+ {
204
+ ...P,
205
+ selected: r,
206
+ onChange: n
207
+ }
208
+ );
209
+ };
210
+ export {
211
+ Ne as D,
212
+ De as r
213
+ };
@@ -1,9 +1,9 @@
1
- import { D as t } from "./datePicker-ad4a758c.js";
2
- import { r as A } from "./datePicker-ad4a758c.js";
1
+ import { D as t } from "./datePicker-412fb8e8.js";
2
+ import { r as A } from "./datePicker-412fb8e8.js";
3
3
  import "react/jsx-runtime";
4
+ import "react";
4
5
  import "react-datepicker/dist/es/index.js";
5
6
  import "./bind-06a7ff84.js";
6
- import "react";
7
7
  import "./fieldText-1749da7a.js";
8
8
  import "./clear-53660571.js";
9
9
  import "./openEye-950159cb.js";