@reportportal/ui-kit 0.0.1-alpha.135 → 0.0.1-alpha.137

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.
Files changed (33) hide show
  1. package/dist/adaptiveTagList.js +189 -0
  2. package/dist/common/constants/sortable.d.ts +1 -0
  3. package/dist/common/hooks/index.d.ts +1 -0
  4. package/dist/common/hooks/useSortable.d.ts +3 -0
  5. package/dist/common/types/index.d.ts +2 -0
  6. package/dist/common/types/sortableTypes.d.ts +69 -0
  7. package/dist/common/utils/testUtils.d.ts +3 -0
  8. package/dist/components/adaptiveTagList/adaptiveTagList.d.ts +11 -0
  9. package/dist/components/adaptiveTagList/constants.d.ts +6 -0
  10. package/dist/components/adaptiveTagList/index.d.ts +2 -0
  11. package/dist/components/autocompletes/multipleAutocomplete/selectedItems/selectedItems.d.ts +1 -1
  12. package/dist/components/dropdown/constants.d.ts +1 -0
  13. package/dist/components/dropdown/dropdown.d.ts +2 -0
  14. package/dist/components/index.d.ts +2 -0
  15. package/dist/components/sortable/dragLayer/dragLayer.d.ts +3 -0
  16. package/dist/components/sortable/dragLayer/index.d.ts +1 -0
  17. package/dist/components/sortable/helpers.d.ts +4 -0
  18. package/dist/components/sortable/index.d.ts +3 -0
  19. package/dist/components/sortable/sortableItem/index.d.ts +1 -0
  20. package/dist/components/sortable/sortableItem/sortableItem.d.ts +3 -0
  21. package/dist/components/sortable/sortableList/index.d.ts +1 -0
  22. package/dist/components/sortable/sortableList/sortableList.d.ts +5 -0
  23. package/dist/{datePicker-926c9cae.js → datePicker-341db7a5.js} +1 -1
  24. package/dist/datePicker.js +8 -4
  25. package/dist/dropdown-0a043606.js +586 -0
  26. package/dist/dropdown.js +7 -3
  27. package/dist/index.js +148 -140
  28. package/dist/modal.js +17 -13
  29. package/dist/sortable.js +160 -0
  30. package/dist/style.css +1 -1
  31. package/package.json +3 -1
  32. package/dist/dropdown-360803d5.js +0 -550
  33. /package/dist/common/{types.d.ts → types/commonTypes.d.ts} +0 -0
@@ -0,0 +1,189 @@
1
+ import { jsx as l, jsxs as g, Fragment as M } from "react/jsx-runtime";
2
+ import { useRef as Z, useState as v, useCallback as m, useMemo as h, useEffect as S } from "react";
3
+ import { c as A } from "./bind-06a7ff84.js";
4
+ import { B as P } from "./button-97d9e587.js";
5
+ import { S as V } from "./close-4d480ef7.js";
6
+ import { i as tt } from "./isEmpty-ccacb5ff.js";
7
+ const et = 3, st = 22, nt = 8, it = 0, at = 100, ot = 20, lt = {
8
+ "tag-list-wrapper": "_tag-list-wrapper_1yg21_16",
9
+ "tag-list-wrapper--show-all-view": "_tag-list-wrapper--show-all-view_1yg21_19",
10
+ "tag-list": "_tag-list_1yg21_16",
11
+ "tag-list--full-width": "_tag-list--full-width_1yg21_31",
12
+ "tag-list--show-all-view": "_tag-list--show-all-view_1yg21_34",
13
+ "tag-list--expanded": "_tag-list--expanded_1yg21_40",
14
+ "tag-list--no-tags": "_tag-list--no-tags_1yg21_45",
15
+ "tag-list__item": "_tag-list__item_1yg21_49",
16
+ "tag-list__item-title": "_tag-list__item-title_1yg21_78",
17
+ "tag-list__item--is-editable": "_tag-list__item--is-editable_1yg21_93",
18
+ "tag-list__item-remove": "_tag-list__item-remove_1yg21_99",
19
+ "tag-list__item--count": "_tag-list__item--count_1yg21_123",
20
+ "tag-list__item--button-show-all-view": "_tag-list__item--button-show-all-view_1yg21_137",
21
+ "tag-list__item--button-wrapper": "_tag-list__item--button-wrapper_1yg21_141",
22
+ "no-tags-message": "_no-tags-message_1yg21_158"
23
+ }, a = A.bind(lt), pt = ({
24
+ tags: C,
25
+ isShowAllView: e = !1,
26
+ defaultVisibleLines: s = et,
27
+ onRemoveTag: c,
28
+ noTagsMessage: R = "No tags added",
29
+ showAllText: I = "Show all",
30
+ hideAllText: H = "Hide all",
31
+ showLessText: O = "Show less"
32
+ }) => {
33
+ const d = Z(null), [E, b] = v(0), [o, $] = v(!1), [j, w] = v(/* @__PURE__ */ new Set()), [B, Y] = v(!1), U = m(
34
+ (t, n) => {
35
+ t.stopPropagation(), c == null || c(n);
36
+ },
37
+ [c]
38
+ ), k = m(() => {
39
+ const t = d.current, n = /* @__PURE__ */ new Set();
40
+ if (!t)
41
+ return;
42
+ const i = [...t.children].filter(
43
+ (r) => !r.classList.contains("tag-list__item--button")
44
+ );
45
+ if (i.length === 0)
46
+ return;
47
+ const p = i[0].offsetTop, x = t.getBoundingClientRect().right;
48
+ let u = 0;
49
+ i.forEach((r, f) => {
50
+ const T = r.getBoundingClientRect(), Q = r.offsetTop !== p, X = T.right > x;
51
+ (Q || X) && (n.add(f), u += 1);
52
+ }), w(n), b(u);
53
+ }, []), D = m(() => {
54
+ const t = d.current, n = /* @__PURE__ */ new Set();
55
+ if (!t || !s)
56
+ return;
57
+ const i = [...t.children].filter(
58
+ (f) => !f.classList.contains("tag-list__item--button")
59
+ );
60
+ if (i.length === 0)
61
+ return;
62
+ const p = i[0].offsetTop, _ = i[0].offsetHeight, x = p + _ * (s - 1);
63
+ let u = 0, r = !1;
64
+ i.forEach((f, T) => {
65
+ f.offsetTop > x + ot && (n.add(T), u += 1, r = !0);
66
+ }), w(n), b(u), Y(r);
67
+ }, [s]), q = h(() => e && s && !o ? {
68
+ maxHeight: `${st * s + nt * (s - 1)}px`,
69
+ overflow: "hidden"
70
+ } : {}, [e, s, o]);
71
+ S(() => {
72
+ if (!d.current)
73
+ return;
74
+ const i = setTimeout(() => {
75
+ e && s ? D() : k();
76
+ }, e && s ? it : at);
77
+ return () => clearTimeout(i);
78
+ }, [
79
+ d,
80
+ e,
81
+ s,
82
+ k,
83
+ D,
84
+ E
85
+ ]);
86
+ const N = m(() => {
87
+ $((t) => !t);
88
+ }, []), z = (t) => {
89
+ t.stopPropagation(), N();
90
+ }, y = m(
91
+ (t) => {
92
+ t.stopPropagation(), N();
93
+ },
94
+ [N]
95
+ ), J = h(() => E > 0 && !o, [E, o]), F = h(
96
+ () => e && s && B && !o,
97
+ [e, s, B, o]
98
+ ), G = h(() => /* @__PURE__ */ l("div", { className: a("tag-list__item--button-wrapper"), children: /* @__PURE__ */ l(
99
+ P,
100
+ {
101
+ className: a("tag-list__item--button", "tag-list__item--button-show-all-view"),
102
+ onClick: y,
103
+ variant: "text",
104
+ children: I
105
+ }
106
+ ) }), [y, I]), W = h(() => /* @__PURE__ */ l("div", { className: a({ "tag-list__item--button-wrapper": e }), children: /* @__PURE__ */ l(
107
+ P,
108
+ {
109
+ className: a("tag-list__item--button", {
110
+ "tag-list__item--button-show-all-view": e && s
111
+ }),
112
+ onClick: y,
113
+ variant: "text",
114
+ children: e && s ? H : O
115
+ }
116
+ ) }), [y, e, s, H, O]), K = m((t, n) => {
117
+ t && (t.scrollWidth > t.clientWidth ? t.setAttribute("title", n) : t.removeAttribute("title"));
118
+ }, []);
119
+ return tt(C) ? /* @__PURE__ */ l("div", { className: a("tag-list-wrapper"), children: /* @__PURE__ */ l("div", { className: a("tag-list", "tag-list--no-tags", "tag-list--full-width"), children: /* @__PURE__ */ l("div", { className: a("no-tags-message"), children: R }) }) }) : /* @__PURE__ */ g("div", { className: a("tag-list-wrapper", { "tag-list-wrapper--show-all-view": e }), children: [
120
+ /* @__PURE__ */ g(
121
+ "div",
122
+ {
123
+ className: a("tag-list", "tag-list--full-width", {
124
+ "tag-list--expanded": o,
125
+ "tag-list--show-all-view": e && !o
126
+ }),
127
+ style: q,
128
+ ref: d,
129
+ children: [
130
+ C.map((t, n) => {
131
+ const i = !o && j.has(n), p = !e && i;
132
+ return /* @__PURE__ */ g(
133
+ "div",
134
+ {
135
+ className: a("tag-list__item", { "tag-list__item--is-editable": !!c }),
136
+ style: {
137
+ display: p ? "none" : "flex"
138
+ },
139
+ children: [
140
+ /* @__PURE__ */ l(
141
+ "div",
142
+ {
143
+ className: a("tag-list__item-title"),
144
+ ref: (_) => K(_, t),
145
+ children: t
146
+ }
147
+ ),
148
+ c && /* @__PURE__ */ l(
149
+ "button",
150
+ {
151
+ type: "button",
152
+ className: a("tag-list__item-remove"),
153
+ onClick: (_) => U(_, t),
154
+ children: /* @__PURE__ */ l(V, {})
155
+ }
156
+ )
157
+ ]
158
+ },
159
+ `${n}-${t}`
160
+ );
161
+ }),
162
+ !e && /* @__PURE__ */ g(M, { children: [
163
+ o && W,
164
+ F && G
165
+ ] })
166
+ ]
167
+ }
168
+ ),
169
+ e && /* @__PURE__ */ g(M, { children: [
170
+ o && W,
171
+ F && G
172
+ ] }),
173
+ J && !e ? /* @__PURE__ */ g(
174
+ "button",
175
+ {
176
+ type: "button",
177
+ className: a("tag-list__item", "tag-list__item--count"),
178
+ onClick: z,
179
+ children: [
180
+ "+",
181
+ E
182
+ ]
183
+ }
184
+ ) : null
185
+ ] });
186
+ };
187
+ export {
188
+ pt as AdaptiveTagList
189
+ };
@@ -0,0 +1 @@
1
+ export declare const DEFAULT_SORTABLE_TYPE = "SORTABLE_ITEM";
@@ -1,2 +1,3 @@
1
1
  export { useOnClickOutside } from './useOnClickOutside';
2
+ export { useSortable } from './useSortable';
2
3
  export { useWindowResize } from './useWindowResize';
@@ -0,0 +1,3 @@
1
+ import { UseSortableOptions, UseSortableReturn } from '../types';
2
+
3
+ export declare const useSortable: ({ id, index, type, isDisabled, onDrop, hideDefaultPreview, }: UseSortableOptions) => UseSortableReturn;
@@ -0,0 +1,2 @@
1
+ export * from './commonTypes';
2
+ export * from './sortableTypes';
@@ -0,0 +1,69 @@
1
+ import { ReactNode, Ref } from 'react';
2
+ import { XYCoord, ConnectDragSource, ConnectDropTarget, ConnectDragPreview } from 'react-dnd';
3
+
4
+ export interface SortableItemData {
5
+ id: string | number;
6
+ index: number;
7
+ }
8
+ export interface DragItem extends SortableItemData {
9
+ type: string;
10
+ }
11
+ export interface UseSortableOptions {
12
+ id: string | number;
13
+ index: number;
14
+ type?: string;
15
+ isDisabled?: boolean;
16
+ onDrop?: (fromIndex: number, toIndex: number) => void;
17
+ hideDefaultPreview?: boolean;
18
+ }
19
+ export interface UseSortableReturn {
20
+ isDragging: boolean;
21
+ isOver: boolean;
22
+ draggedItemIndex: number | null;
23
+ dropPosition: 'top' | 'bottom' | null;
24
+ dragRef: ConnectDragSource;
25
+ dropRef: ConnectDropTarget;
26
+ previewRef: ConnectDragPreview;
27
+ }
28
+ export interface SortableItemRenderProps {
29
+ isDragging: boolean;
30
+ isOver: boolean;
31
+ dragRef: Ref<HTMLElement>;
32
+ }
33
+ export interface SortableItemProps {
34
+ id: string | number;
35
+ index: number;
36
+ type?: string;
37
+ isDisabled?: boolean;
38
+ className?: string;
39
+ draggingClassName?: string;
40
+ dropTargetClassName?: string;
41
+ onDrop?: (fromIndex: number, toIndex: number) => void;
42
+ hideDefaultPreview?: boolean;
43
+ children: ReactNode | ((props: SortableItemRenderProps) => ReactNode);
44
+ }
45
+ export interface SortableListProps<T extends {
46
+ id: string | number;
47
+ }> {
48
+ items: T[];
49
+ type?: string;
50
+ isDisabled?: boolean;
51
+ className?: string;
52
+ itemClassName?: string;
53
+ onReorder: (reorderedItems: T[]) => void;
54
+ renderItem: (item: T, index: number, dragRef: Ref<HTMLElement>, isDragging: boolean) => ReactNode;
55
+ keyExtractor?: (item: T) => string | number;
56
+ }
57
+ export interface DragLayerProps {
58
+ type: string;
59
+ renderPreview: (item: DragItem) => ReactNode;
60
+ className?: string;
61
+ previewClassName?: string;
62
+ portalTarget?: Element | null;
63
+ }
64
+ export interface DragLayerCollectedProps {
65
+ item: DragItem | null;
66
+ itemType: string | symbol | null;
67
+ clientOffset: XYCoord | null;
68
+ isDragging: boolean;
69
+ }
@@ -0,0 +1,3 @@
1
+ import { ReactElement } from 'react';
2
+
3
+ export declare const renderWithDnd: (ui: ReactElement) => import('@testing-library/react').RenderResult<typeof import("@testing-library/dom/types/queries"), HTMLElement, HTMLElement>;
@@ -0,0 +1,11 @@
1
+ export interface AdaptiveTagListProps {
2
+ tags: string[];
3
+ isShowAllView?: boolean;
4
+ defaultVisibleLines?: number;
5
+ onRemoveTag?: (tag: string) => void;
6
+ noTagsMessage?: string;
7
+ showAllText?: string;
8
+ hideAllText?: string;
9
+ showLessText?: string;
10
+ }
11
+ export declare const AdaptiveTagList: ({ tags, isShowAllView, defaultVisibleLines, onRemoveTag, noTagsMessage, showAllText, hideAllText, showLessText, }: AdaptiveTagListProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ export declare const DEFAULT_VISIBLE_LINES = 3;
2
+ export declare const TAG_LINE_HEIGHT = 22;
3
+ export declare const TAG_GAP_HEIGHT = 8;
4
+ export declare const IMMEDIATE_DELAY = 0;
5
+ export declare const FONT_LOADING_DELAY = 100;
6
+ export declare const OFFSET_TOLERANCE = 20;
@@ -0,0 +1,2 @@
1
+ export { AdaptiveTagList } from './adaptiveTagList';
2
+ export type { AdaptiveTagListProps } from './adaptiveTagList';
@@ -37,5 +37,5 @@ type SelectedItemsProps<T> = Omit<SelectedItemProps<T>, 'item' | 'editItem'> & {
37
37
  selectedItemClassName?: string;
38
38
  selectedItemTextClassName?: string;
39
39
  };
40
- export declare const SelectedItems: <T>({ items, parseValueToString, getItemValidationErrorType, storedItemsMap, highlightUnStoredItem, renderCustomSelectedItem, selectedItemSingleLine, selectedItemClassName, selectedItemTextClassName, ...props }: SelectedItemsProps<T>) => (string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | null | undefined)[];
40
+ export declare const SelectedItems: <T>({ items, parseValueToString, getItemValidationErrorType, storedItemsMap, highlightUnStoredItem, renderCustomSelectedItem, selectedItemSingleLine, selectedItemClassName, selectedItemTextClassName, ...props }: SelectedItemsProps<T>) => (string | number | boolean | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined)[];
41
41
  export {};
@@ -8,3 +8,4 @@ export declare enum EventName {
8
8
  }
9
9
  export declare const SCROLLBARS_AUTO_HEIGHT_MAX = 216;
10
10
  export declare const DROPDOWN_PORTAL_MENU_ATTR = "data-dropdown-portal-menu";
11
+ export declare const DEFAULT_VISIBLE_TAG_LINES = 10;
@@ -51,5 +51,7 @@ export interface DropdownProps {
51
51
  * @example menuPortalRoot={document.body}
52
52
  */
53
53
  menuPortalRoot?: Element;
54
+ /** Whether to render selected values as tags using AdaptiveTagList (only for multiSelect mode) */
55
+ isMultiSelectWithTags?: boolean;
54
56
  }
55
57
  export declare const Dropdown: FC<DropdownProps>;
@@ -1,3 +1,4 @@
1
+ export { AdaptiveTagList } from './adaptiveTagList';
1
2
  export { AttachedFile } from './attachedFile';
2
3
  export { BaseIconButton } from './baseIconButton';
3
4
  export { Breadcrumbs } from './breadcrumbs';
@@ -22,6 +23,7 @@ export { SpinLoader } from './spinLoader';
22
23
  export { SystemAlert } from './systemAlert';
23
24
  export { SystemMessage } from './systemMessage';
24
25
  export { SingleAutocomplete } from './autocompletes/singleAutocomplete';
26
+ export { SortableItem, SortableList, DragLayer } from './sortable';
25
27
  export { Table } from './table';
26
28
  export { ThemeProvider } from './themeProvider';
27
29
  export { Toggle } from './toggle';
@@ -0,0 +1,3 @@
1
+ import { DragLayerProps } from '../../../common/types';
2
+
3
+ export declare const DragLayer: ({ type, renderPreview, className, previewClassName, portalTarget, }: DragLayerProps) => import('react').ReactPortal | null;
@@ -0,0 +1 @@
1
+ export { DragLayer } from './dragLayer';
@@ -0,0 +1,4 @@
1
+ import { CSSProperties } from 'react';
2
+ import { XYCoord } from 'react-dnd';
3
+
4
+ export declare const getPreviewStyles: (clientOffset: XYCoord | null) => CSSProperties;
@@ -0,0 +1,3 @@
1
+ export { SortableItem } from './sortableItem';
2
+ export { SortableList } from './sortableList';
3
+ export { DragLayer } from './dragLayer';
@@ -0,0 +1 @@
1
+ export { SortableItem } from './sortableItem';
@@ -0,0 +1,3 @@
1
+ import { SortableItemProps } from '../../../common/types';
2
+
3
+ export declare const SortableItem: ({ id, index, type, isDisabled, className, draggingClassName, dropTargetClassName, onDrop, hideDefaultPreview, children, }: SortableItemProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export { SortableList } from './sortableList';
@@ -0,0 +1,5 @@
1
+ import { SortableListProps } from '../../../common/types';
2
+
3
+ export declare const SortableList: <T extends {
4
+ id: string | number;
5
+ }>({ items, type, isDisabled, className, itemClassName, onReorder, renderItem, keyExtractor, }: SortableListProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -3,7 +3,7 @@ import B from "react-datepicker/dist/es/index.js";
3
3
  import { c as R } from "./bind-06a7ff84.js";
4
4
  import { useMemo as P, useRef as D } from "react";
5
5
  import { F as I } from "./fieldText-1749da7a.js";
6
- import { D as E } from "./dropdown-360803d5.js";
6
+ import { D as E } from "./dropdown-0a043606.js";
7
7
  import { S as T } from "./calendarArrow-44c7e60e.js";
8
8
  import { registerLocale as j } from "react-datepicker";
9
9
  const ie = (n, s) => {
@@ -1,5 +1,5 @@
1
- import { D as t } from "./datePicker-926c9cae.js";
2
- import { r as z } from "./datePicker-926c9cae.js";
1
+ import { D as t } from "./datePicker-341db7a5.js";
2
+ import { r as E } from "./datePicker-341db7a5.js";
3
3
  import "react/jsx-runtime";
4
4
  import "react-datepicker/dist/es/index.js";
5
5
  import "./bind-06a7ff84.js";
@@ -11,7 +11,7 @@ import "./baseIconButton-251479f7.js";
11
11
  import "./spinLoader-c4a53718.js";
12
12
  import "./maxValueDisplay-9be01a75.js";
13
13
  import "./fieldLabel.js";
14
- import "./dropdown-360803d5.js";
14
+ import "./dropdown-0a043606.js";
15
15
  import "react-dom";
16
16
  import "@floating-ui/react-dom";
17
17
  import "downshift";
@@ -21,11 +21,15 @@ import "./dropdown-0260bb66.js";
21
21
  import "./tooltip.js";
22
22
  import "@floating-ui/react";
23
23
  import "./floatingUi-41f8c7b5.js";
24
+ import "./adaptiveTagList.js";
25
+ import "./button-97d9e587.js";
26
+ import "./close-4d480ef7.js";
27
+ import "./isEmpty-ccacb5ff.js";
24
28
  import "./checkbox-ed6cc375.js";
25
29
  import "./calendarArrow-44c7e60e.js";
26
30
  import "react-datepicker";
27
31
  export {
28
32
  t as DatePicker,
29
33
  t as default,
30
- z as registerDatePickerLocale
34
+ E as registerDatePickerLocale
31
35
  };