react-core-ts 1.0.25 → 1.0.26

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,54 +0,0 @@
1
- export function deepEqual(value1: any, value2: any): boolean {
2
- // Check for strict equality first
3
- if (value1 === value2) {
4
- return true;
5
- }
6
-
7
- // If either is null (but not both), they're not equal
8
- if (value1 === null || value2 === null) {
9
- return false;
10
- }
11
-
12
- // If types differ, they're not equal
13
- if (typeof value1 !== typeof value2) {
14
- return false;
15
- }
16
-
17
- // Check objects (including arrays)
18
- if (typeof value1 === 'object' && typeof value2 === 'object') {
19
- // Different constructors means they are different objects
20
- if (value1.constructor !== value2.constructor) {
21
- return false;
22
- }
23
-
24
- if (Array.isArray(value1)) {
25
- // Array length comparison
26
- if (value1.length !== value2.length) {
27
- return false;
28
- }
29
- // Deep compare each element
30
- for (let i = 0; i < value1.length; i++) {
31
- if (!deepEqual(value1[i], value2[i])) {
32
- return false;
33
- }
34
- }
35
- return true;
36
- } else {
37
- // Compare object keys and values
38
- const keys1 = Object.keys(value1);
39
- const keys2 = new Set(Object.keys(value2));
40
- if (keys1.length !== keys2.size) {
41
- return false;
42
- }
43
- for (const key of keys1) {
44
- if (!keys2.has(key) || !deepEqual(value1[key], value2[key])) {
45
- return false;
46
- }
47
- }
48
- return true;
49
- }
50
- }
51
-
52
- // If none of the above, they're not equal
53
- return false;
54
- }
@@ -1,147 +0,0 @@
1
- import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
2
- import ReactDOM from 'react-dom';
3
-
4
- const ExpandableToolTip: React.FC<any> = ({ title, children, enabled }) => {
5
- const [dropdownPosition, setDropdownPosition] = useState('bottom-position');
6
- const dropRef = useRef(null);
7
- const menuButtonRef = useRef<HTMLDivElement>(null);
8
- const [visible, setVisible] = useState(false);
9
- const [tooltipStyle, setTooltipStyle] = useState({
10
- top: 0,
11
- left: 0,
12
- width: 0,
13
- });
14
- const adjustDropdownPosition = (): string => {
15
- if (menuButtonRef.current) {
16
- const inputBoxRect = menuButtonRef.current?.getBoundingClientRect();
17
- const viewportHeight = window.innerHeight;
18
-
19
- const spaceAbove = inputBoxRect.top;
20
- const spaceBelow = viewportHeight - inputBoxRect.bottom;
21
- if (spaceAbove > spaceBelow) {
22
- if (spaceAbove > 90 && spaceBelow < 120) {
23
- return 'top-position';
24
- } else {
25
- return 'bottom-position';
26
- }
27
- } else {
28
- const diff: number = spaceBelow - spaceAbove;
29
- if (spaceAbove > 90 && spaceBelow > 90 && diff < 90) {
30
- return 'top-position';
31
- } else {
32
- return 'bottom-position';
33
- }
34
- }
35
- }
36
- };
37
-
38
- const handleMouseEnter = (e: React.MouseEvent) => {
39
- if (menuButtonRef.current) {
40
- const dropPosition = adjustDropdownPosition();
41
- setDropdownPosition(dropPosition);
42
- const rect = (e.target as HTMLElement).getBoundingClientRect();
43
- let top = rect.bottom + window.scrollY;
44
- let left = rect.left + window.scrollX;
45
- const height = rect.height;
46
- const width = dropRef?.current?.offsetWidth;
47
- if (dropPosition === 'bottom-position') {
48
- top = top + height / 2 - 5;
49
- } else {
50
- top = top - height * 2 + 15;
51
- }
52
-
53
- setTooltipStyle({
54
- top: top,
55
- left: left,
56
- width: width,
57
- });
58
- setVisible(true);
59
- }
60
- };
61
-
62
- const handleMouseLeave = () => {
63
- setVisible(false);
64
- };
65
-
66
- useLayoutEffect(() => {
67
- const updateTooltipPosition = () => {
68
- if (dropRef.current && visible && tooltipStyle) {
69
- const tooltipHeight = dropRef.current.offsetHeight;
70
- const tooltipWidth = dropRef.current.offsetWidth;
71
- const boxWidth = menuButtonRef.current.offsetWidth;
72
- setTooltipStyle((prevStyle) => ({
73
- ...prevStyle,
74
- left:
75
- prevStyle.left + boxWidth / 2 - tooltipWidth / 2 < 0
76
- ? 20
77
- : prevStyle.left + boxWidth / 2 - tooltipWidth / 2,
78
- width: tooltipWidth,
79
- top:
80
- dropdownPosition === 'bottom-position'
81
- ? prevStyle.top
82
- : prevStyle.top - tooltipHeight,
83
- }));
84
- }
85
- };
86
-
87
- if (visible) {
88
- updateTooltipPosition();
89
- }
90
-
91
- window.addEventListener('resize', updateTooltipPosition);
92
-
93
- return () => {
94
- window.removeEventListener('resize', updateTooltipPosition);
95
- };
96
- }, [visible, dropdownPosition]);
97
-
98
- useEffect(() => {
99
- const handleClickOutside = (event: MouseEvent) => {
100
- if (dropRef.current && !dropRef.current.contains(event.target as Node)) {
101
- setVisible(false);
102
- }
103
- };
104
-
105
- document.addEventListener('mousedown', handleClickOutside);
106
- return () => {
107
- document.removeEventListener('mousedown', handleClickOutside);
108
- };
109
- }, []);
110
-
111
- return (
112
- <div
113
- onMouseEnter={handleMouseEnter}
114
- onMouseLeave={handleMouseLeave}
115
- ref={menuButtonRef}
116
- style={{ display: 'flex' }}
117
- >
118
- {children}
119
-
120
- {visible &&
121
- enabled &&
122
- tooltipStyle &&
123
- ReactDOM.createPortal(
124
- <span
125
- ref={(node) => (dropRef.current = node)}
126
- className={`tooltiptext ${
127
- dropdownPosition == 'bottom-position' ? 'down' : 'up'
128
- }`}
129
- style={{
130
- top: tooltipStyle.top,
131
- left: tooltipStyle.left,
132
- opacity: 1,
133
- width: tooltipStyle.width,
134
- minWidth: '60px',
135
- maxWidth: '200px',
136
- visibility: 'visible',
137
- }}
138
- >
139
- {title}
140
- </span>,
141
- document.body
142
- )}
143
- </div>
144
- );
145
- };
146
-
147
- export default ExpandableToolTip;
@@ -1,48 +0,0 @@
1
- interface Item {
2
- [key: string]: string;
3
- }
4
-
5
- export const filterSuggestions = (
6
- data: Item[],
7
- query: string,
8
- type: string,
9
- desc: string,
10
- inputValue?: string,
11
- async?: boolean,
12
- isTreeDropdown?: boolean
13
- ): Item[] => {
14
- if (
15
- (type === 'custom_search_select' ||
16
- type === 'auto_complete' ||
17
- type === 'auto_suggestion') &&
18
- !async &&
19
- query &&
20
- !isTreeDropdown
21
- ) {
22
- return data?.filter((item) =>
23
- item[desc].toLowerCase().includes(query.toLowerCase())
24
- );
25
- }
26
- return isTreeDropdown ? data : sortedArrayData(data, inputValue, desc);
27
- };
28
-
29
- const sortedArrayData = (
30
- filteredData: any[],
31
- selectedItems: any[] | string,
32
- desc: any
33
- ) => {
34
- return [...filteredData].sort((a, b) => {
35
- let aIsSelected: boolean;
36
- let bIsSelected: boolean;
37
-
38
- if (Array.isArray(selectedItems)) {
39
- aIsSelected = selectedItems.some((item) => item[desc] === a[desc]);
40
- bIsSelected = selectedItems.some((item) => item[desc] === b[desc]);
41
- } else {
42
- aIsSelected = a[desc] === selectedItems;
43
- bIsSelected = b[desc] === selectedItems;
44
- }
45
-
46
- return (bIsSelected ? 1 : 0) - (aIsSelected ? 1 : 0);
47
- });
48
- };
@@ -1,86 +0,0 @@
1
- import React from 'react';
2
-
3
- export const DropArrow: React.FC<any> = ({ className = '', stroke = 1.5 }) => {
4
- return (
5
- <svg
6
- xmlns="http://www.w3.org/2000/svg"
7
- fill="none"
8
- viewBox="0 0 24 24"
9
- strokeWidth="1.5"
10
- stroke="currentColor"
11
- style={{ width: 15 }}
12
- className={className}
13
- name="toggle"
14
- >
15
- <path
16
- strokeLinecap="round"
17
- strokeLinejoin="round"
18
- d="M19.5 8.25l-7.5 7.5-7.5-7.5"
19
- />
20
- </svg>
21
- );
22
- };
23
-
24
- export const Close: React.FC<any> = ({ className = '', stroke = 1.5 }) => {
25
- return (
26
- <svg
27
- xmlns="http://www.w3.org/2000/svg"
28
- fill="none"
29
- viewBox="0 0 24 24"
30
- strokeWidth="1.5"
31
- stroke="currentColor"
32
- style={{ width: 15 }}
33
- >
34
- <path
35
- strokeLinecap="round"
36
- strokeLinejoin="round"
37
- d="M6 18L18 6M6 6l12 12"
38
- />
39
- </svg>
40
- );
41
- };
42
-
43
- export const Spinner: React.FC<any> = ({ className = '', stroke = 1.5 }) => {
44
- return (
45
- <div role="status">
46
- <svg
47
- aria-hidden="true"
48
- className="custom-spinner "
49
- viewBox="0 0 100 101"
50
- fill="none"
51
- xmlns="http://www.w3.org/2000/svg"
52
- >
53
- <path
54
- d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
55
- fill="currentColor"
56
- />
57
- <path
58
- d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
59
- fill="currentFill"
60
- />
61
- </svg>
62
- </div>
63
- );
64
- };
65
-
66
- export const Search: React.FC<any> = ({ className = '', stroke = 1.5 }) => {
67
- return (
68
- <div role="status">
69
- <svg
70
- width="16"
71
- height="16"
72
- viewBox="0 0 16 16"
73
- fill="none"
74
- xmlns="http://www.w3.org/2000/svg"
75
- >
76
- <path
77
- d="M14 14.0027L10 10.0027M11.3333 6.66935C11.3333 9.24668 9.244 11.336 6.66667 11.336C4.08934 11.336 2 9.24668 2 6.66935C2 4.09202 4.08934 2.00269 6.66667 2.00269C9.244 2.00269 11.3333 4.09202 11.3333 6.66935Z"
78
- stroke="#999696"
79
- strokeWidth="1.5"
80
- strokeLinecap="round"
81
- strokeLinejoin="round"
82
- />
83
- </svg>
84
- </div>
85
- );
86
- };
@@ -1,52 +0,0 @@
1
- import React, { useRef, useState } from 'react';
2
-
3
- const ToolTip: React.FC<any> = ({ title, children }) => {
4
- const [dropdownPosition, setDropdownPosition] = useState('bottom-position');
5
- const dropRef = useRef(null);
6
- const menuButtonRef = useRef<HTMLElement>(null);
7
- const adjustDropdownPosition = () => {
8
- if (menuButtonRef.current && dropRef.current) {
9
- const inputBoxRect = menuButtonRef.current?.getBoundingClientRect();
10
- const viewportHeight = window.innerHeight;
11
-
12
- const spaceAbove = inputBoxRect.top;
13
- const spaceBelow = viewportHeight - inputBoxRect.bottom;
14
- console.log(spaceAbove, spaceBelow);
15
- if (spaceAbove > spaceBelow) {
16
- if (spaceAbove > 90 && spaceBelow < 120) {
17
- setDropdownPosition('top-position');
18
- } else {
19
- setDropdownPosition('bottom-position');
20
- }
21
- } else {
22
- const diff: number = spaceBelow - spaceAbove;
23
- if (spaceAbove > 90 && spaceBelow > 90 && diff < 90) {
24
- setDropdownPosition('top-position');
25
- } else {
26
- setDropdownPosition('bottom-position');
27
- }
28
- }
29
- }
30
- };
31
-
32
- return (
33
- <div
34
- className={`qbs-table-tooltip ${
35
- dropdownPosition == 'bottom-position' ? 'down' : 'up'
36
- } `}
37
- >
38
- <span
39
- ref={menuButtonRef}
40
- style={{ display: 'flex' }}
41
- onMouseEnter={() => adjustDropdownPosition()}
42
- >
43
- {children}
44
- </span>
45
- <span ref={dropRef} className={`tooltiptext `}>
46
- {title}
47
- </span>
48
- </div>
49
- );
50
- };
51
-
52
- export default ToolTip;