qbs-react-grid 2.2.3 → 2.2.5

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 (100) hide show
  1. package/dist/css/qbs-react-grid.css +1 -1
  2. package/dist/css/qbs-react-grid.min.css +1 -1
  3. package/dist/css/qbs-react-grid.min.css.map +1 -1
  4. package/es/Cell.js +1 -2
  5. package/es/Pagination.d.ts +0 -3
  6. package/es/Pagination.js +3 -8
  7. package/es/Table.d.ts +0 -3
  8. package/es/Table.js +12 -18
  9. package/es/index.d.ts +1 -1
  10. package/es/less/pagination.less +9 -9
  11. package/es/less/qbs-table.less +73 -205
  12. package/es/qbsTable/CustomTableCell.js +2 -13
  13. package/es/qbsTable/QbsTable.js +46 -124
  14. package/es/qbsTable/TableCardList.js +39 -52
  15. package/es/qbsTable/Toolbar.js +13 -62
  16. package/es/qbsTable/commontypes.d.ts +2 -30
  17. package/es/qbsTable/utilities/CardComponent.d.ts +0 -2
  18. package/es/qbsTable/utilities/CardComponent.js +3 -7
  19. package/es/qbsTable/utilities/CardMenuDropdown.d.ts +0 -2
  20. package/es/qbsTable/utilities/CardMenuDropdown.js +7 -7
  21. package/es/qbsTable/utilities/ColumShowHide.d.ts +0 -4
  22. package/es/qbsTable/utilities/ColumShowHide.js +6 -9
  23. package/es/qbsTable/utilities/SearchInput.d.ts +0 -1
  24. package/es/qbsTable/utilities/SearchInput.js +1 -3
  25. package/es/qbsTable/utilities/ToolTip.d.ts +1 -8
  26. package/es/qbsTable/utilities/ToolTip.js +31 -107
  27. package/es/qbsTable/utilities/empty.js +1 -1
  28. package/es/qbsTable/utilities/icons.d.ts +0 -3
  29. package/es/qbsTable/utilities/icons.js +1 -65
  30. package/es/qbsTable/utilities/tablecalc.d.ts +1 -1
  31. package/es/qbsTable/utilities/tablecalc.js +2 -7
  32. package/es/utils/useCellDescriptor.js +1 -0
  33. package/es/utils/useScrollListener.d.ts +0 -1
  34. package/es/utils/useScrollListener.js +3 -5
  35. package/lib/Cell.js +1 -2
  36. package/lib/Pagination.d.ts +0 -3
  37. package/lib/Pagination.js +3 -8
  38. package/lib/Table.d.ts +0 -3
  39. package/lib/Table.js +12 -18
  40. package/lib/index.d.ts +1 -1
  41. package/lib/less/pagination.less +9 -9
  42. package/lib/less/qbs-table.less +73 -205
  43. package/lib/qbsTable/CustomTableCell.js +2 -13
  44. package/lib/qbsTable/QbsTable.js +46 -124
  45. package/lib/qbsTable/TableCardList.js +39 -52
  46. package/lib/qbsTable/Toolbar.js +12 -61
  47. package/lib/qbsTable/commontypes.d.ts +2 -30
  48. package/lib/qbsTable/utilities/CardComponent.d.ts +0 -2
  49. package/lib/qbsTable/utilities/CardComponent.js +3 -7
  50. package/lib/qbsTable/utilities/CardMenuDropdown.d.ts +0 -2
  51. package/lib/qbsTable/utilities/CardMenuDropdown.js +5 -6
  52. package/lib/qbsTable/utilities/ColumShowHide.d.ts +0 -4
  53. package/lib/qbsTable/utilities/ColumShowHide.js +6 -9
  54. package/lib/qbsTable/utilities/SearchInput.d.ts +0 -1
  55. package/lib/qbsTable/utilities/SearchInput.js +1 -3
  56. package/lib/qbsTable/utilities/ToolTip.d.ts +1 -8
  57. package/lib/qbsTable/utilities/ToolTip.js +30 -107
  58. package/lib/qbsTable/utilities/empty.js +1 -1
  59. package/lib/qbsTable/utilities/icons.d.ts +0 -3
  60. package/lib/qbsTable/utilities/icons.js +3 -70
  61. package/lib/qbsTable/utilities/tablecalc.d.ts +1 -1
  62. package/lib/qbsTable/utilities/tablecalc.js +2 -7
  63. package/lib/utils/useCellDescriptor.js +1 -0
  64. package/lib/utils/useScrollListener.d.ts +0 -1
  65. package/lib/utils/useScrollListener.js +3 -5
  66. package/package.json +2 -2
  67. package/src/Cell.tsx +1 -3
  68. package/src/HeaderCell.tsx +1 -0
  69. package/src/Pagination.tsx +3 -10
  70. package/src/Table.tsx +10 -23
  71. package/src/customSelect.tsx +88 -88
  72. package/src/index.ts +1 -1
  73. package/src/less/pagination.less +9 -9
  74. package/src/less/qbs-table.less +73 -205
  75. package/src/qbsTable/CustomTableCell.tsx +9 -31
  76. package/src/qbsTable/QbsTable.tsx +25 -101
  77. package/src/qbsTable/TableCardList.tsx +19 -35
  78. package/src/qbsTable/Toolbar.tsx +11 -53
  79. package/src/qbsTable/commontypes.ts +1 -32
  80. package/src/qbsTable/utilities/CardComponent.tsx +2 -7
  81. package/src/qbsTable/utilities/CardMenuDropdown.tsx +6 -11
  82. package/src/qbsTable/utilities/ColumShowHide.tsx +6 -33
  83. package/src/qbsTable/utilities/SearchInput.tsx +1 -3
  84. package/src/qbsTable/utilities/ToolTip.tsx +27 -138
  85. package/src/qbsTable/utilities/empty.tsx +2 -2
  86. package/src/qbsTable/utilities/icons.tsx +1 -78
  87. package/src/qbsTable/utilities/tablecalc.ts +2 -8
  88. package/src/utils/useCellDescriptor.ts +1 -0
  89. package/src/utils/useScrollListener.ts +3 -13
  90. package/src/utils/useTableRows.ts +1 -1
  91. package/es/qbsTable/labels.d.ts +0 -48
  92. package/es/qbsTable/labels.js +0 -34
  93. package/es/qbsTable/utilities/VerticalDropDownMenu.d.ts +0 -13
  94. package/es/qbsTable/utilities/VerticalDropDownMenu.js +0 -166
  95. package/lib/qbsTable/labels.d.ts +0 -48
  96. package/lib/qbsTable/labels.js +0 -42
  97. package/lib/qbsTable/utilities/VerticalDropDownMenu.d.ts +0 -13
  98. package/lib/qbsTable/utilities/VerticalDropDownMenu.js +0 -174
  99. package/src/qbsTable/labels.ts +0 -58
  100. package/src/qbsTable/utilities/VerticalDropDownMenu.tsx +0 -187
@@ -1,149 +1,38 @@
1
- import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
2
- import ReactDOM from 'react-dom';
3
-
4
- type TooltipComponentProps = {
5
- title?: React.ReactNode;
6
- children: React.ReactNode;
7
- tableBodyRef?: React.RefObject<HTMLDivElement | null>;
8
- /** When false, renders children only (no tooltip). */
9
- enabled?: boolean;
10
- };
11
-
12
- const VIEWPORT_PADDING = 8;
13
- const TOOLTIP_GAP = 8;
14
-
15
- const TooltipComponent: React.FC<TooltipComponentProps> = ({
16
- title,
17
- children,
18
- tableBodyRef,
19
- enabled = true,
20
- }) => {
21
- const [visible, setVisible] = useState(false);
22
- const [positioned, setPositioned] = useState(false);
23
- const [placement, setPlacement] = useState<'up' | 'down'>('down');
24
- const [coords, setCoords] = useState({ top: 0, left: 0 });
25
- const [arrowOffset, setArrowOffset] = useState(0);
26
- const triggerRef = useRef<HTMLSpanElement>(null);
27
- const tooltipRef = useRef<HTMLSpanElement>(null);
28
-
29
- const updatePosition = useCallback(() => {
30
- const trigger = triggerRef.current;
31
- const tooltip = tooltipRef.current;
32
- if (!trigger || !tooltip) {
33
- return;
1
+ import React, { useRef, useState } from 'react';
2
+
3
+ const TooltipComponent: React.FC<any> = ({ title, children, tableBodyRef }) => {
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 && tableBodyRef?.current) {
9
+ const inputBoxRect = menuButtonRef.current?.getBoundingClientRect();
10
+ const tableRect = tableBodyRef.current.getBoundingClientRect();
11
+ // Calculate positions relative to the table
12
+ const spaceAbove = inputBoxRect.top - tableRect.top;
13
+ const spaceBelow = tableRect.bottom - inputBoxRect.bottom;
14
+
15
+ if (spaceAbove > spaceBelow) {
16
+ setDropdownPosition('top-position');
17
+ } else {
18
+ setDropdownPosition('bottom-position');
19
+ }
34
20
  }
35
-
36
- const triggerRect = trigger.getBoundingClientRect();
37
- const tooltipRect = tooltip.getBoundingClientRect();
38
- const boundaryRect =
39
- tableBodyRef?.current?.getBoundingClientRect() ??
40
- trigger.closest('.qbs-table')?.getBoundingClientRect();
41
-
42
- const spaceAbove = boundaryRect
43
- ? triggerRect.top - boundaryRect.top
44
- : triggerRect.top;
45
- const spaceBelow = boundaryRect
46
- ? boundaryRect.bottom - triggerRect.bottom
47
- : window.innerHeight - triggerRect.bottom;
48
-
49
- const nextPlacement =
50
- spaceBelow >= tooltipRect.height + TOOLTIP_GAP || spaceBelow >= spaceAbove ? 'down' : 'up';
51
-
52
- const triggerCenter = triggerRect.left + triggerRect.width / 2;
53
- let left = triggerCenter - tooltipRect.width / 2;
54
-
55
- if (left < VIEWPORT_PADDING) {
56
- left = VIEWPORT_PADDING;
57
- } else if (left + tooltipRect.width > window.innerWidth - VIEWPORT_PADDING) {
58
- left = window.innerWidth - VIEWPORT_PADDING - tooltipRect.width;
59
- }
60
-
61
- const top =
62
- nextPlacement === 'down'
63
- ? triggerRect.bottom + TOOLTIP_GAP
64
- : triggerRect.top - tooltipRect.height - TOOLTIP_GAP;
65
-
66
- setPlacement(nextPlacement);
67
- setCoords({ top, left });
68
- setArrowOffset(triggerCenter - left);
69
- setPositioned(true);
70
- }, [tableBodyRef]);
71
-
72
- const showTooltip = () => {
73
- setPositioned(false);
74
- setVisible(true);
75
- };
76
-
77
- const hideTooltip = () => {
78
- setVisible(false);
79
- setPositioned(false);
80
21
  };
81
22
 
82
- useLayoutEffect(() => {
83
- if (!visible) {
84
- return;
85
- }
86
-
87
- updatePosition();
88
- const frame = window.requestAnimationFrame(updatePosition);
89
- return () => window.cancelAnimationFrame(frame);
90
- }, [visible, title, updatePosition]);
91
-
92
- useEffect(() => {
93
- if (!visible) {
94
- return;
95
- }
96
-
97
- const handleReposition = () => updatePosition();
98
- window.addEventListener('resize', handleReposition);
99
- window.addEventListener('scroll', handleReposition, true);
100
- return () => {
101
- window.removeEventListener('resize', handleReposition);
102
- window.removeEventListener('scroll', handleReposition, true);
103
- };
104
- }, [visible, updatePosition]);
105
-
106
- if (!title || enabled === false) {
107
- return <>{children}</>;
108
- }
109
-
110
- const portalRoot = typeof document !== 'undefined' ? document.body : null;
111
-
112
23
  return (
113
- <>
24
+ <div className={`qbs-table-tooltip ${dropdownPosition == 'bottom-position' ? 'down' : 'up'} `}>
114
25
  <span
115
- ref={triggerRef}
116
- className="qbs-table-tooltip-trigger"
117
- style={{ display: 'inline-flex' }}
118
- onMouseEnter={showTooltip}
119
- onMouseLeave={hideTooltip}
120
- onFocus={showTooltip}
121
- onBlur={hideTooltip}
26
+ ref={menuButtonRef}
27
+ style={{ display: 'flex' }}
28
+ onMouseEnter={() => adjustDropdownPosition()}
122
29
  >
123
30
  {children}
124
31
  </span>
125
- {visible &&
126
- portalRoot &&
127
- ReactDOM.createPortal(
128
- <span
129
- ref={tooltipRef}
130
- role="tooltip"
131
- className={`qbs-table-tooltip-floating tooltiptext qbs-table-tooltip-floating--${placement} ${
132
- positioned ? 'is-positioned' : ''
133
- }`}
134
- style={
135
- {
136
- top: coords.top,
137
- left: coords.left,
138
- '--tooltip-arrow-offset': `${arrowOffset}px`,
139
- } as React.CSSProperties
140
- }
141
- >
142
- {title}
143
- </span>,
144
- portalRoot,
145
- )}
146
- </>
32
+ <span ref={dropRef} className={'tooltiptext'}>
33
+ {title}
34
+ </span>
35
+ </div>
147
36
  );
148
37
  };
149
38
 
@@ -18,7 +18,7 @@ const NoData: React.FC<props> = ({ title, subtitle }) => {
18
18
  }}
19
19
  >
20
20
  <div style={{ width: 145, marginBottom: 20 }} className="nodata-img">
21
- <svg
21
+ <svg
22
22
  xmlns="http://www.w3.org/2000/svg"
23
23
  width="148"
24
24
  height="132"
@@ -71,7 +71,7 @@ const NoData: React.FC<props> = ({ title, subtitle }) => {
71
71
  fill="#797979"
72
72
  d="M47.365 57.417a.926.926 0 00.926-.927v-1.777a.926.926 0 10-1.852 0v1.777c0 .512.415.927.926.927zM104.183 57.417a.926.926 0 00.926-.927v-1.777a.926.926 0 00-1.852 0v1.777c0 .512.414.927.926.927zM47.365 52.974a.926.926 0 00.926-.927V50.27a.926.926 0 00-1.852 0v1.777c0 .512.415.927.926.927zM104.183 52.974a.926.926 0 00.926-.927V50.27a.926.926 0 00-1.852 0v1.777c0 .512.414.927.926.927zM47.365 44.088a.926.926 0 00.926-.927v-1.777a.926.926 0 10-1.852 0v1.777c0 .512.415.927.926.927zM104.183 44.088a.926.926 0 00.926-.927v-1.777a.926.926 0 00-1.852 0v1.777c0 .512.414.927.926.927zM47.365 39.645a.926.926 0 00.926-.927v-1.777a.926.926 0 10-1.852 0v1.777c0 .512.415.927.926.927zM104.183 39.645a.926.926 0 00.926-.927v-1.777a.926.926 0 00-1.852 0v1.777c0 .512.414.927.926.927zM47.365 35.202a.926.926 0 00.926-.927v-1.777a.926.926 0 10-1.852 0v1.777c0 .512.415.927.926.927zM104.183 35.202a.926.926 0 00.926-.927v-1.777a.926.926 0 00-1.852 0v1.777c0 .512.414.927.926.927zM47.365 30.758a.926.926 0 00.926-.926v-.888c0-.248.02-.49.057-.726a.926.926 0 00-1.83-.288c-.052.33-.08.67-.08 1.014v.888c0 .512.416.926.927.926zM104.183 30.758a.926.926 0 00.926-.926v-.888c0-.345-.027-.683-.079-1.014a.926.926 0 10-1.83.288c.037.236.057.478.057.726v.888c0 .512.414.926.926.926zM47.881 26.426a.926.926 0 001.294-.204c.286-.394.633-.74 1.026-1.026a.926.926 0 00-1.09-1.498c-.55.4-1.034.884-1.434 1.434a.926.926 0 00.204 1.294zM103.667 26.426a.926.926 0 00.204-1.294 6.509 6.509 0 00-1.434-1.434.926.926 0 00-1.09 1.498c.393.286.74.632 1.026 1.026a.926.926 0 001.294.204zM51.138 23.597c.08.506.554.851 1.059.772a4.67 4.67 0 01.726-.057h.914a.926.926 0 000-1.852h-.914c-.344 0-.683.026-1.014.078a.926.926 0 00-.77 1.06zM100.41 23.597a.927.927 0 00-.771-1.059 6.522 6.522 0 00-1.014-.078h-.914a.926.926 0 100 1.852h.914c.248 0 .49.02.726.057a.926.926 0 001.059-.772zM55.653 23.386c0 .511.415.926.926.926h1.828a.926.926 0 000-1.852H56.58a.926.926 0 00-.926.926zM60.223 23.386c0 .511.415.926.926.926h1.828a.926.926 0 000-1.852H61.15a.926.926 0 00-.926.926zM64.793 23.386c0 .511.415.926.926.926h1.829a.926.926 0 000-1.852h-1.829a.926.926 0 00-.926.926zM69.364 23.386c0 .511.414.926.926.926h1.828a.926.926 0 000-1.852H70.29a.926.926 0 00-.927.926zM73.934 23.386c0 .511.414.926.926.926h1.828a.926.926 0 000-1.852H74.86a.926.926 0 00-.926.926zM78.504 23.386c0 .511.415.926.926.926h1.828a.926.926 0 000-1.852H79.43a.926.926 0 00-.926.926zM83.074 23.386c0 .511.415.926.927.926h1.828a.926.926 0 000-1.852H84a.926.926 0 00-.927.926zM87.644 23.386c0 .511.415.926.927.926h1.828a.926.926 0 000-1.852H88.57a.926.926 0 00-.927.926zM92.215 23.386c0 .511.414.926.926.926h1.828a.926.926 0 000-1.852h-1.828a.926.926 0 00-.926.926zM72.178 36.453a1.39 1.39 0 10-1.965 1.965l3.797 3.797-3.797 3.798a1.39 1.39 0 001.965 1.965l3.797-3.798 3.798 3.798a1.39 1.39 0 001.965-1.965l-3.798-3.798 3.798-3.797a1.39 1.39 0 10-1.965-1.965l-3.798 3.797-3.797-3.797z"
73
73
  ></path>
74
- </svg>{' '}
74
+ </svg> {' '}
75
75
  </div>
76
76
  <p className="text-center text-common font-bold text-blackAlt nodata-title">{title}</p>
77
77
  <span className="text-xxs font-medium text-grey-medium nodata-sub-title">{subtitle}</span>
@@ -5,7 +5,7 @@ export const ThreeDotIcon: React.FC<any> = () => {
5
5
  <svg width="4" height="16" viewBox="0 0 4 16" fill="none" xmlns="http://www.w3.org/2000/svg">
6
6
  <path
7
7
  d="M2 2.16665L2 2.17498M2 7.99998L2 8.00831M2 13.8333L2 13.8416M2 2.99998C1.53976 2.99998 1.16667 2.62688 1.16667 2.16665C1.16667 1.70641 1.53976 1.33331 2 1.33331C2.46024 1.33331 2.83333 1.70641 2.83333 2.16665C2.83333 2.62688 2.46024 2.99998 2 2.99998ZM2 8.83331C1.53976 8.83331 1.16667 8.46022 1.16667 7.99998C1.16667 7.53974 1.53976 7.16665 2 7.16665C2.46024 7.16665 2.83333 7.53974 2.83333 7.99998C2.83333 8.46022 2.46024 8.83331 2 8.83331ZM2 14.6666C1.53976 14.6666 1.16666 14.2935 1.16666 13.8333C1.16666 13.3731 1.53976 13 2 13C2.46024 13 2.83333 13.3731 2.83333 13.8333C2.83333 14.2935 2.46024 14.6666 2 14.6666Z"
8
- stroke="currentColor"
8
+ stroke="#313131"
9
9
  strokeWidth="1.5"
10
10
  strokeLinecap="round"
11
11
  strokeLinejoin="round"
@@ -134,80 +134,3 @@ export const TableView: React.FC<any> = ({ className }) => {
134
134
  </svg>
135
135
  );
136
136
  };
137
-
138
- export const ExpandIcon: React.FC<any> = ({ className }) => {
139
- return (
140
- <svg
141
- width="16"
142
- height="16"
143
- className={className}
144
- viewBox="0 0 16 16"
145
- fill="none"
146
- xmlns="http://www.w3.org/2000/svg"
147
- >
148
- <path
149
- d="M2.66797 5.33073V2.66406M2.66797 2.66406H5.33464M2.66797 2.66406L6.0013 5.9974M13.3346 5.33073V2.66406M13.3346 2.66406H10.668M13.3346 2.66406L10.0013 5.9974M2.66797 10.6641V13.3307M2.66797 13.3307H5.33464M2.66797 13.3307L6.0013 9.9974M13.3346 13.3307L10.0013 9.9974M13.3346 13.3307V10.6641M13.3346 13.3307H10.668"
150
- stroke="#585858"
151
- strokeWidth="1.5"
152
- strokeLinecap="round"
153
- strokeLinejoin="round"
154
- />
155
- </svg>
156
- );
157
- };
158
- export const ContentView: React.FC<any> = ({ className }) => {
159
- return (
160
- <svg
161
- width="16"
162
- height="17"
163
- className={className}
164
- viewBox="0 0 16 17"
165
- fill="none"
166
- xmlns="http://www.w3.org/2000/svg"
167
- >
168
- <path
169
- d="M4.00344 9.48438C3.24485 9.48438 2.94141 9.80804 2.94141 10.6122V12.6553C2.94141 13.4594 3.24485 13.7831 4.00344 13.7831H11.994C12.7526 13.7831 13.056 13.4594 13.056 12.6553V10.6122C13.056 9.80804 12.7526 9.48438 11.994 9.48438H4.00344Z"
170
- stroke="#585858"
171
- strokeLinecap="round"
172
- strokeLinejoin="round"
173
- />
174
- <path
175
- d="M4.00344 3.66406C3.24485 3.66406 2.94141 3.98773 2.94141 4.79184V6.835C2.94141 7.63911 3.24485 7.96278 4.00344 7.96278H11.994C12.7526 7.96278 13.056 7.63911 13.056 6.835V4.79184C13.056 3.98773 12.7526 3.66406 11.994 3.66406H4.00344Z"
176
- stroke="#585858"
177
- strokeLinecap="round"
178
- strokeLinejoin="round"
179
- />
180
- </svg>
181
- );
182
- };
183
- export const DefaultView: React.FC<any> = ({ className }) => {
184
- return (
185
- <svg
186
- width="16"
187
- height="17"
188
- className={className}
189
- viewBox="0 0 16 17"
190
- fill="none"
191
- xmlns="http://www.w3.org/2000/svg"
192
- >
193
- <path
194
- fillRule="evenodd"
195
- clipRule="evenodd"
196
- d="M2.39844 4.72969C2.39844 4.28786 2.75661 3.92969 3.19844 3.92969H12.7984C13.2403 3.92969 13.5984 4.28786 13.5984 4.72969C13.5984 5.17152 13.2403 5.52969 12.7984 5.52969H3.19844C2.75661 5.52969 2.39844 5.17152 2.39844 4.72969Z"
197
- fill="#585858"
198
- />
199
- <path
200
- fillRule="evenodd"
201
- clipRule="evenodd"
202
- d="M2.39844 8.72969C2.39844 8.28786 2.75661 7.92969 3.19844 7.92969H12.7984C13.2403 7.92969 13.5984 8.28786 13.5984 8.72969C13.5984 9.17152 13.2403 9.52969 12.7984 9.52969H3.19844C2.75661 9.52969 2.39844 9.17152 2.39844 8.72969Z"
203
- fill="#585858"
204
- />
205
- <path
206
- fillRule="evenodd"
207
- clipRule="evenodd"
208
- d="M2.39844 12.7297C2.39844 12.2879 2.75661 11.9297 3.19844 11.9297H12.7984C13.2403 11.9297 13.5984 12.2879 13.5984 12.7297C13.5984 13.1715 13.2403 13.5297 12.7984 13.5297H3.19844C2.75661 13.5297 2.39844 13.1715 2.39844 12.7297Z"
209
- fill="#585858"
210
- />
211
- </svg>
212
- );
213
- };
@@ -1,12 +1,6 @@
1
- export function getRowDisplayRange(
2
- totalRows: number,
3
- rowsPerPage: number,
4
- pageNumber: number,
5
- formatRange: (start: number, end: number, total: number) => string = (start, end, total) =>
6
- `Showing ${start} to ${end} of ${total}`
7
- ) {
1
+ export function getRowDisplayRange(totalRows: number, rowsPerPage: number, pageNumber: number) {
8
2
  const start = (pageNumber - 1) * rowsPerPage + 1;
9
3
  const end = Math.min(pageNumber * rowsPerPage, totalRows);
10
4
 
11
- return formatRange(start ?? 0, end ?? 0, totalRows ?? 0);
5
+ return `Showing ${start ?? 0} to ${end ?? 0} of ${totalRows ?? 0}`;
12
6
  }
@@ -205,6 +205,7 @@ const useCellDescriptor = <Row extends RowDataType>(
205
205
  if (treeCol) {
206
206
  hasCustomTreeCol = true;
207
207
  }
208
+ console.log(columns);
208
209
 
209
210
  if (columnChildren?.length !== 2) {
210
211
  throw new Error(`Component <HeaderCell> and <Cell> is required, column index: ${index} `);
@@ -4,7 +4,6 @@ import scrollLeft from 'dom-lib/scrollLeft';
4
4
  import scrollTop from 'dom-lib/scrollTop';
5
5
  import WheelHandler from 'dom-lib/WheelHandler';
6
6
  import React, { useCallback, useEffect, useRef, useState } from 'react';
7
-
8
7
  import type { ListenerCallback, RowDataType } from '../@types/common';
9
8
  import { BEZIER, SCROLLBAR_WIDTH, TRANSITION_DURATION } from '../constants';
10
9
  import type { ScrollbarInstance } from '../Scrollbar';
@@ -51,7 +50,6 @@ interface ScrollListenerProps {
51
50
  onTouchStart?: (event: React.TouchEvent) => void;
52
51
  onTouchMove?: (event: React.TouchEvent) => void;
53
52
  onTouchEnd?: (event: React.TouchEvent) => void;
54
- handleInfiniteScroll?: (value: number) => void;
55
53
  }
56
54
 
57
55
  /**
@@ -108,8 +106,7 @@ const useScrollListener = (props: ScrollListenerProps) => {
108
106
  contentHeight,
109
107
  headerHeight,
110
108
  rtl,
111
- tableKey,
112
- handleInfiniteScroll
109
+ tableKey
113
110
  } = props;
114
111
 
115
112
  const wheelListener = useRef<ListenerCallback>(null);
@@ -190,15 +187,6 @@ const useScrollListener = (props: ScrollListenerProps) => {
190
187
  setScrollX(x);
191
188
  setScrollY(y);
192
189
 
193
- if (
194
- typeof handleInfiniteScroll === 'function' &&
195
- deltaY !== 0 &&
196
- !loading &&
197
- Math.abs(y) + getTableHeight() >= contentHeight.current - 12
198
- ) {
199
- handleInfiniteScroll(scrollY.current);
200
- }
201
-
202
190
  onScroll?.(Math.abs(x), Math.abs(y));
203
191
 
204
192
  if (virtualized) {
@@ -309,6 +297,7 @@ const useScrollListener = (props: ScrollListenerProps) => {
309
297
  if (!isTouching.current) {
310
298
  return;
311
299
  }
300
+ console.log('handleTouchMove');
312
301
 
313
302
  const { pageX, pageY } = event.touches[0];
314
303
  const deltaX = touchX.current - pageX;
@@ -349,6 +338,7 @@ const useScrollListener = (props: ScrollListenerProps) => {
349
338
  if (!isTouching.current) {
350
339
  return;
351
340
  }
341
+ console.log('handleTouchEnd');
352
342
  isTouching.current = false;
353
343
  const touchDuration = new Date().getTime() - momentumStartTime.current;
354
344
  const absDeltaY = Math.abs(scrollY.current - momentumStartY.current);
@@ -8,7 +8,7 @@ import defer from './defer';
8
8
 
9
9
  interface TableRowsProps<Row, Key> {
10
10
  prefix: (str: string) => string;
11
- wordWrap?: boolean | 'break-all' | 'break-word' | 'keep-all' | 'fit-content';
11
+ wordWrap?: boolean | 'break-all' | 'break-word' | 'keep-all'| 'fit-content';
12
12
  data: readonly Row[];
13
13
  expandedRowKeys: readonly Key[];
14
14
  }
@@ -1,48 +0,0 @@
1
- export interface QbsTableLabels {
2
- search?: string;
3
- searchAriaLabel?: string;
4
- clear?: string;
5
- selectedItems?: string;
6
- switchToDefaultView?: string;
7
- switchToRelaxedView?: string;
8
- switchToFullScreen?: string;
9
- switchToTableView?: string;
10
- switchToCardView?: string;
11
- noDataFound?: string;
12
- showingRange?: (start: number, end: number, total: number) => string;
13
- itemsPerPage?: string;
14
- fixedColumns?: string;
15
- visibleColumns?: string;
16
- availableColumns?: string;
17
- resetToDefault?: string;
18
- save?: string;
19
- viewMore?: string;
20
- viewLess?: string;
21
- actions?: string;
22
- }
23
- export declare const DEFAULT_QBS_TABLE_LABELS: Required<Omit<QbsTableLabels, 'showingRange'>> & {
24
- showingRange: (start: number, end: number, total: number) => string;
25
- };
26
- export declare const mergeLabels: (labels?: QbsTableLabels) => {
27
- showingRange: (start: number, end: number, total: number) => string;
28
- search: string;
29
- searchAriaLabel: string;
30
- clear: string;
31
- selectedItems: string;
32
- switchToDefaultView: string;
33
- switchToRelaxedView: string;
34
- switchToFullScreen: string;
35
- switchToTableView: string;
36
- switchToCardView: string;
37
- noDataFound: string;
38
- itemsPerPage: string;
39
- fixedColumns: string;
40
- visibleColumns: string;
41
- availableColumns: string;
42
- resetToDefault: string;
43
- save: string;
44
- viewMore: string;
45
- viewLess: string;
46
- actions: string;
47
- };
48
- export declare const formatSelectedItems: (selectedItemsLabel: string, count: number) => string;
@@ -1,34 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- export var DEFAULT_QBS_TABLE_LABELS = {
3
- search: 'Search',
4
- searchAriaLabel: 'Search',
5
- clear: 'Clear',
6
- selectedItems: 'Selected Items',
7
- switchToDefaultView: 'Switch to Default View',
8
- switchToRelaxedView: 'Switch to Relaxed View',
9
- switchToFullScreen: 'Switch to Full Screen',
10
- switchToTableView: 'Switch to Table View',
11
- switchToCardView: 'Switch to Card View',
12
- noDataFound: 'No Data Found',
13
- showingRange: function showingRange(start, end, total) {
14
- return "Showing " + start + " to " + end + " of " + total;
15
- },
16
- itemsPerPage: 'Items per page',
17
- fixedColumns: 'FIXED COLUMNS',
18
- visibleColumns: 'VISIBLE COLUMNS',
19
- availableColumns: 'AVAILABLE COLUMNS',
20
- resetToDefault: 'Reset to default',
21
- save: 'Save',
22
- viewMore: 'View More',
23
- viewLess: 'View Less',
24
- actions: 'Actions'
25
- };
26
- export var mergeLabels = function mergeLabels(labels) {
27
- var _labels$showingRange;
28
- return _extends({}, DEFAULT_QBS_TABLE_LABELS, labels, {
29
- showingRange: (_labels$showingRange = labels === null || labels === void 0 ? void 0 : labels.showingRange) != null ? _labels$showingRange : DEFAULT_QBS_TABLE_LABELS.showingRange
30
- });
31
- };
32
- export var formatSelectedItems = function formatSelectedItems(selectedItemsLabel, count) {
33
- return selectedItemsLabel + "(" + count + ") ";
34
- };
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import { ActionProps } from '../commontypes';
3
- type Props = {
4
- actionDropDown: ActionProps[];
5
- handleMenuActions?: (slug: ActionProps, rowData?: any) => void;
6
- rowData?: any;
7
- dataTheme?: string;
8
- tableBodyRef: React.RefObject<HTMLDivElement>;
9
- rowIndex?: number;
10
- wheelWrapperRef?: React.RefObject<HTMLDivElement>;
11
- };
12
- declare const VerticalMenuDropdown: React.FC<Props>;
13
- export default VerticalMenuDropdown;
@@ -1,166 +0,0 @@
1
- function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
2
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
- import React, { useEffect, useRef, useState } from 'react';
5
- import ReactDOM from 'react-dom';
6
- import { ThreeDotIcon } from './icons';
7
- import TooltipComponent from './ToolTip';
8
- var VerticalMenuDropdown = function VerticalMenuDropdown(_ref) {
9
- var actionDropDown = _ref.actionDropDown,
10
- handleMenuActions = _ref.handleMenuActions,
11
- rowData = _ref.rowData,
12
- tableBodyRef = _ref.tableBodyRef,
13
- rowIndex = _ref.rowIndex;
14
- var _useState = useState(false),
15
- openMenu = _useState[0],
16
- setOpenMenu = _useState[1];
17
- var _useState2 = useState({
18
- top: 0,
19
- left: 0
20
- }),
21
- position = _useState2[0],
22
- setPosition = _useState2[1];
23
- var menuButtonRef = useRef(null);
24
- var menuRef = useRef(null);
25
- useEffect(function () {
26
- var handleClickOutside = function handleClickOutside(event) {
27
- if (menuRef.current && !menuRef.current.contains(event.target)) {
28
- setOpenMenu(false);
29
- }
30
- };
31
- var handleScroll = function handleScroll() {
32
- setOpenMenu(false);
33
- };
34
- document.addEventListener('click', handleClickOutside);
35
- window.addEventListener('scroll', handleScroll, true);
36
- // Use capture phase to catch all scrolls
37
-
38
- return function () {
39
- document.removeEventListener('click', handleClickOutside);
40
- window.removeEventListener('scroll', handleScroll, true);
41
- };
42
- }, []);
43
- useEffect(function () {
44
- var handleStyleChange = function handleStyleChange() {
45
- setOpenMenu(false); // Close the dropdown
46
- };
47
- var scrollbarHandle = document.querySelector('.rs-table-scrollbar-handle');
48
- if (!scrollbarHandle) return;
49
- var observer = new MutationObserver(function (mutations) {
50
- for (var _iterator = _createForOfIteratorHelperLoose(mutations), _step; !(_step = _iterator()).done;) {
51
- var mutation = _step.value;
52
- if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
53
- handleStyleChange();
54
- }
55
- }
56
- });
57
- observer.observe(scrollbarHandle, {
58
- attributes: true,
59
- attributeFilter: ['style']
60
- });
61
- return function () {
62
- observer.disconnect();
63
- };
64
- }, [openMenu]);
65
- var handleMenuItemClick = function handleMenuItemClick(slug) {
66
- var _slug$action;
67
- handleMenuActions === null || handleMenuActions === void 0 ? void 0 : handleMenuActions(slug, rowData);
68
- (_slug$action = slug.action) === null || _slug$action === void 0 ? void 0 : _slug$action.call(slug, rowData);
69
- setOpenMenu(false);
70
- };
71
- var handleShowHideMenu = function handleShowHideMenu() {
72
- var _actionDropDown$filte, _actionDropDown$filte2;
73
- return (_actionDropDown$filte = actionDropDown === null || actionDropDown === void 0 ? void 0 : (_actionDropDown$filte2 = actionDropDown.filter(function (item) {
74
- var _item$hide;
75
- return !item.hidden && !(item !== null && item !== void 0 && (_item$hide = item.hide) !== null && _item$hide !== void 0 && _item$hide.call(item, rowData, rowIndex));
76
- })) === null || _actionDropDown$filte2 === void 0 ? void 0 : _actionDropDown$filte2.length) != null ? _actionDropDown$filte : 0;
77
- };
78
- var toggleMenu = function toggleMenu() {
79
- if (!openMenu && menuButtonRef.current) {
80
- var _tableBodyRef$current;
81
- var rect = menuButtonRef.current.getBoundingClientRect();
82
- var windowHeight = window.innerHeight;
83
- var menuHeight = (actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.filter(function (item) {
84
- var _item$hide2;
85
- return !item.hidden && !(item !== null && item !== void 0 && (_item$hide2 = item.hide) !== null && _item$hide2 !== void 0 && _item$hide2.call(item, rowData, rowIndex));
86
- }).length) * 40; // 40px per menu item
87
-
88
- // Get table boundaries for RTL positioning
89
- var tableRect = (_tableBodyRef$current = tableBodyRef.current) === null || _tableBodyRef$current === void 0 ? void 0 : _tableBodyRef$current.getBoundingClientRect();
90
- var dropdownWidth = 200;
91
-
92
- // Check if there's enough space below
93
- var spaceBelow = windowHeight - rect.bottom;
94
- var leftPosition = rect.left - dropdownWidth;
95
-
96
- // For RTL, adjust positioning to stay within table bounds
97
- if (document.documentElement.dir === 'rtl' && tableRect) {
98
- // Calculate the right edge position for RTL
99
- var rightEdge = rect.right;
100
- leftPosition = Math.min(rightEdge, tableRect.right - dropdownWidth);
101
- // Ensure it doesn't go beyond the left edge of the table
102
- leftPosition = Math.max(leftPosition, tableRect.left);
103
- }
104
- if (spaceBelow >= menuHeight) {
105
- // Open below
106
- setPosition({
107
- top: rect.bottom + window.scrollY - rect.height,
108
- left: leftPosition
109
- });
110
- } else {
111
- // Open above
112
- setPosition({
113
- top: rect.top + window.scrollY - menuHeight,
114
- left: leftPosition
115
- });
116
- }
117
- }
118
- setTimeout(function () {
119
- setOpenMenu(function (prev) {
120
- return !prev;
121
- });
122
- }, 200);
123
- };
124
- var portalTarget = document.getElementById('portal-root');
125
- var dropdownContent = /*#__PURE__*/React.createElement("div", {
126
- className: "absolute z-[60] min-w-48 rounded-md vertical-menu-dropdown-content",
127
- ref: menuRef,
128
- style: {
129
- width: 200,
130
- top: position.top,
131
- left: position.left,
132
- position: 'absolute'
133
- }
134
- }, /*#__PURE__*/React.createElement("div", {
135
- className: "py-1"
136
- }, actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.map(function (item) {
137
- var _item$hide3;
138
- return !(item !== null && item !== void 0 && item.hidden) && !(item !== null && item !== void 0 && (_item$hide3 = item.hide) !== null && _item$hide3 !== void 0 && _item$hide3.call(item, rowData, rowIndex)) ? /*#__PURE__*/React.createElement("div", {
139
- key: item.title,
140
- className: "vertical-menu-item px-4 py-2 text-sm text-base-black hover:bg-gray-light-1 cursor-pointer flex items-center gap-2 transition-colors",
141
- onClick: function onClick(e) {
142
- var _item$action;
143
- e.preventDefault();
144
- (_item$action = item.action) === null || _item$action === void 0 ? void 0 : _item$action.call(item, item);
145
- handleMenuItemClick(item);
146
- }
147
- }, /*#__PURE__*/React.createElement(TooltipComponent, {
148
- title: item.toolTip,
149
- tableBodyRef: tableBodyRef
150
- }, /*#__PURE__*/React.createElement("div", {
151
- className: "vertical-menu-icon-title flex items-center gap-2"
152
- }, (item === null || item === void 0 ? void 0 : item.icon) && /*#__PURE__*/React.createElement("span", {
153
- className: "vertical-menu-icon"
154
- }, item.icon), /*#__PURE__*/React.createElement("span", {
155
- className: "vertical-menu-title"
156
- }, item.title)))) : null;
157
- })));
158
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
159
- className: "inline-block vertical-menu-dropdown-wrapper"
160
- }, handleShowHideMenu() > 0 && /*#__PURE__*/React.createElement("button", {
161
- className: "vertical-menu-trigger-button p-2 rounded text-base-gray hover:bg-gray-light-1 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",
162
- onClick: toggleMenu,
163
- ref: menuButtonRef
164
- }, /*#__PURE__*/React.createElement(ThreeDotIcon, null))), openMenu && portalTarget && /*#__PURE__*/ReactDOM.createPortal(dropdownContent, portalTarget));
165
- };
166
- export default VerticalMenuDropdown;