linear-react-components-ui 2.2.0-beta.1 → 2.2.0-beta.10
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/lib/assets/styles/datepicker2.css +81 -11
- package/lib/hooks/useScrollEndReached/index.d.ts +1 -1
- package/lib/hooks/useScrollEndReached/index.js +48 -82
- package/lib/hooks/useScrollEndReached/index.js.map +1 -1
- package/lib/hooks/useScrollEndReached/types.d.ts +1 -0
- package/lib/inputs/select/Dropdown.js +11 -1
- package/lib/inputs/select/Dropdown.js.map +1 -1
- package/lib/inputs/select/multiple/index.js +5 -2
- package/lib/inputs/select/multiple/index.js.map +1 -1
- package/lib/inputs/select/simple/index.js +5 -2
- package/lib/inputs/select/simple/index.js.map +1 -1
- package/lib/inputs/select/types.d.ts +3 -2
- package/lib/inputs/types.d.ts +2 -1
- package/lib/inputs2/date/calendarbox.d.ts +23 -0
- package/lib/inputs2/date/calendarbox.js +254 -0
- package/lib/inputs2/date/calendarbox.js.map +1 -0
- package/lib/inputs2/date/datefield/base.js +691 -214
- package/lib/inputs2/date/datefield/base.js.map +1 -1
- package/lib/inputs2/date/datefield/triggers.js +4 -4
- package/lib/inputs2/date/datefield/triggers.js.map +1 -1
- package/lib/inputs2/date/datefield/types.d.ts +5 -12
- package/lib/inputs2/date/dateperiodfield/base.js +694 -809
- package/lib/inputs2/date/dateperiodfield/base.js.map +1 -1
- package/lib/inputs2/date/dateperiodfield/triggers.js +21 -9
- package/lib/inputs2/date/dateperiodfield/triggers.js.map +1 -1
- package/lib/inputs2/date/dateperiodfield/types.d.ts +13 -23
- package/lib/inputs2/date/helpers.d.ts +44 -4
- package/lib/inputs2/date/helpers.js +200 -4
- package/lib/inputs2/date/helpers.js.map +1 -1
- package/lib/inputs2/date/{base/constants.d.ts → hooks/useCalendarPosition.d.ts} +1 -1
- package/lib/inputs2/date/hooks/useCalendarPosition.js +93 -0
- package/lib/inputs2/date/hooks/useCalendarPosition.js.map +1 -0
- package/lib/inputs2/date/hooks/useDateCalendarState.d.ts +14 -0
- package/lib/inputs2/date/hooks/useDateCalendarState.js +250 -0
- package/lib/inputs2/date/hooks/useDateCalendarState.js.map +1 -0
- package/lib/inputs2/date/hooks/useDateMask.d.ts +22 -0
- package/lib/inputs2/date/hooks/useDateMask.js +143 -0
- package/lib/inputs2/date/hooks/useDateMask.js.map +1 -0
- package/lib/inputs2/date/timeselector.d.ts +17 -0
- package/lib/inputs2/date/timeselector.js +226 -0
- package/lib/inputs2/date/timeselector.js.map +1 -0
- package/lib/inputs2/date/types.d.ts +22 -1
- package/lib/inputs2/date/types.js.map +1 -1
- package/lib/inputs2/selectfield/base.js +2 -1
- package/lib/inputs2/selectfield/base.js.map +1 -1
- package/lib/inputs2/selectfield/listbox.js +3 -1
- package/lib/inputs2/selectfield/listbox.js.map +1 -1
- package/lib/node_modules/moment/dist/locale/pt-br.js +54 -0
- package/lib/node_modules/moment/dist/locale/pt-br.js.map +1 -0
- package/lib/panel/Content.js +18 -15
- package/lib/panel/Content.js.map +1 -1
- package/lib/panel/Default.d.ts +1 -1
- package/lib/panel/Default.js +60 -54
- package/lib/panel/Default.js.map +1 -1
- package/package.json +1 -1
- package/lib/inputs2/date/base/constants.js +0 -69
- package/lib/inputs2/date/base/constants.js.map +0 -1
- package/lib/inputs2/date/datefield/calendarbox.d.ts +0 -6
- package/lib/inputs2/date/datefield/calendarbox.js +0 -228
- package/lib/inputs2/date/datefield/calendarbox.js.map +0 -1
- package/lib/inputs2/date/dateperiodfield/calendarbox.d.ts +0 -6
- package/lib/inputs2/date/dateperiodfield/calendarbox.js +0 -282
- package/lib/inputs2/date/dateperiodfield/calendarbox.js.map +0 -1
|
@@ -741,7 +741,7 @@
|
|
|
741
741
|
background-position: -135% 0%;
|
|
742
742
|
}
|
|
743
743
|
}
|
|
744
|
-
.date-calendar-box[aria-expanded=true], .date-field-root .container .input {
|
|
744
|
+
.date-calendar-box[aria-expanded=true] .date-calendar-box-time-selector .time-column .time-column-options, .date-calendar-box[aria-expanded=true], .date-field-root .container .input {
|
|
745
745
|
color: #666;
|
|
746
746
|
font-size: 16px;
|
|
747
747
|
font-family: Roboto;
|
|
@@ -892,8 +892,11 @@ input::-webkit-inner-spin-button {
|
|
|
892
892
|
border: 1px solid transparent;
|
|
893
893
|
background-color: transparent;
|
|
894
894
|
}
|
|
895
|
-
.date-field-root .container:has(input
|
|
896
|
-
|
|
895
|
+
.date-field-root .container:has(input:disabled) {
|
|
896
|
+
color: #cacaca !important;
|
|
897
|
+
transition: color 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms;
|
|
898
|
+
background-color: #f5f5f5;
|
|
899
|
+
cursor: not-allowed;
|
|
897
900
|
}
|
|
898
901
|
.date-field-root .container:has(input[data-state-read-only=true]) {
|
|
899
902
|
cursor: default;
|
|
@@ -903,11 +906,8 @@ input::-webkit-inner-spin-button {
|
|
|
903
906
|
box-shadow: 0 3px 0 #a10d0d;
|
|
904
907
|
transition: box-shadow 250ms cubic-bezier(0.19, 0.62, 0.58, 0.98) 100ms;
|
|
905
908
|
}
|
|
906
|
-
.date-field-root .container:has(input:
|
|
907
|
-
color: #
|
|
908
|
-
transition: color 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms;
|
|
909
|
-
background-color: #f5f5f5;
|
|
910
|
-
cursor: not-allowed;
|
|
909
|
+
.date-field-root .container:has(input[data-state-error=true]):has(input[data-state-skeletonize=false]) {
|
|
910
|
+
border-color: #f48181;
|
|
911
911
|
}
|
|
912
912
|
.date-field-root .container .separator {
|
|
913
913
|
display: flex;
|
|
@@ -1029,9 +1029,10 @@ input::-webkit-inner-spin-button {
|
|
|
1029
1029
|
margin: 5px 0;
|
|
1030
1030
|
font-size: 87.5%;
|
|
1031
1031
|
z-index: auto;
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1032
|
+
display: grid;
|
|
1033
|
+
grid-template-columns: minmax(280px, 1fr) auto;
|
|
1034
|
+
grid-template-areas: "header time" "weekdays time" "grid time";
|
|
1035
|
+
min-width: min-content;
|
|
1035
1036
|
overflow: hidden;
|
|
1036
1037
|
border: 1px solid #dae1e8;
|
|
1037
1038
|
background-color: #fff;
|
|
@@ -1039,6 +1040,7 @@ input::-webkit-inner-spin-button {
|
|
|
1039
1040
|
box-shadow: -6px 6px 50px -12px rgba(51, 51, 51, 0.4);
|
|
1040
1041
|
}
|
|
1041
1042
|
.date-calendar-box[aria-expanded=true] .date-calendar-box-header {
|
|
1043
|
+
grid-area: header;
|
|
1042
1044
|
width: auto;
|
|
1043
1045
|
height: auto;
|
|
1044
1046
|
display: flex;
|
|
@@ -1070,6 +1072,7 @@ input::-webkit-inner-spin-button {
|
|
|
1070
1072
|
font-size: 87.5%;
|
|
1071
1073
|
}
|
|
1072
1074
|
.date-calendar-box[aria-expanded=true] .date-calendar-box-days-of-week {
|
|
1075
|
+
grid-area: weekdays;
|
|
1073
1076
|
height: 28px;
|
|
1074
1077
|
display: flex;
|
|
1075
1078
|
flex-flow: nowrap;
|
|
@@ -1086,11 +1089,13 @@ input::-webkit-inner-spin-button {
|
|
|
1086
1089
|
vertical-align: middle;
|
|
1087
1090
|
}
|
|
1088
1091
|
.date-calendar-box[aria-expanded=true] .date-calendar-box-grid-of-days {
|
|
1092
|
+
grid-area: grid;
|
|
1089
1093
|
padding: 3px;
|
|
1090
1094
|
}
|
|
1091
1095
|
.date-calendar-box[aria-expanded=true] .date-calendar-box-grid-of-days table {
|
|
1092
1096
|
width: 100%;
|
|
1093
1097
|
height: 100%;
|
|
1098
|
+
min-height: 252px;
|
|
1094
1099
|
}
|
|
1095
1100
|
.date-calendar-box[aria-expanded=true] .date-calendar-box-grid-of-days table td[role=gridcell] {
|
|
1096
1101
|
text-align: center;
|
|
@@ -1127,6 +1132,13 @@ input::-webkit-inner-spin-button {
|
|
|
1127
1132
|
border-color: #d1d3d4;
|
|
1128
1133
|
border-style: dashed;
|
|
1129
1134
|
}
|
|
1135
|
+
.date-calendar-box[aria-expanded=true] .date-calendar-box-grid-of-days table .day-button[data-state-out-of-bounds=true] {
|
|
1136
|
+
color: #cacaca !important;
|
|
1137
|
+
cursor: not-allowed;
|
|
1138
|
+
}
|
|
1139
|
+
.date-calendar-box[aria-expanded=true] .date-calendar-box-grid-of-days table .day-button[data-state-out-of-bounds=true]:hover {
|
|
1140
|
+
background-color: transparent;
|
|
1141
|
+
}
|
|
1130
1142
|
.date-calendar-box[aria-expanded=true] .date-calendar-box-grid-of-days table .day-button[data-state-is-today=true] {
|
|
1131
1143
|
position: relative;
|
|
1132
1144
|
}
|
|
@@ -1144,4 +1156,62 @@ input::-webkit-inner-spin-button {
|
|
|
1144
1156
|
}
|
|
1145
1157
|
.date-calendar-box[aria-expanded=true] .date-calendar-box-grid-of-days table .day-button[data-state-is-today=true][aria-selected=true]::after {
|
|
1146
1158
|
background-color: #fff;
|
|
1159
|
+
}
|
|
1160
|
+
.date-calendar-box[aria-expanded=true] .date-calendar-box-time-selector {
|
|
1161
|
+
grid-area: time;
|
|
1162
|
+
display: flex;
|
|
1163
|
+
flex-direction: row;
|
|
1164
|
+
height: 0;
|
|
1165
|
+
min-height: 100%;
|
|
1166
|
+
}
|
|
1167
|
+
.date-calendar-box[aria-expanded=true] .date-calendar-box-time-selector .time-column {
|
|
1168
|
+
display: flex;
|
|
1169
|
+
flex-direction: column;
|
|
1170
|
+
min-height: 0;
|
|
1171
|
+
width: 52px;
|
|
1172
|
+
border-left: 1px solid #dae1e8;
|
|
1173
|
+
}
|
|
1174
|
+
.date-calendar-box[aria-expanded=true] .date-calendar-box-time-selector .time-column .time-column-label {
|
|
1175
|
+
padding: 6px 0;
|
|
1176
|
+
font-size: 87.5%;
|
|
1177
|
+
text-align: center;
|
|
1178
|
+
white-space: nowrap;
|
|
1179
|
+
background-color: #f0f0f0;
|
|
1180
|
+
border-bottom: 1px solid #e1e1e1;
|
|
1181
|
+
}
|
|
1182
|
+
.date-calendar-box[aria-expanded=true] .date-calendar-box-time-selector .time-column .time-column-options {
|
|
1183
|
+
flex: 1 1 auto;
|
|
1184
|
+
min-height: 0;
|
|
1185
|
+
font-size: 87.5%;
|
|
1186
|
+
overflow: hidden auto;
|
|
1187
|
+
scrollbar-width: thin;
|
|
1188
|
+
}
|
|
1189
|
+
.date-calendar-box[aria-expanded=true] .date-calendar-box-time-selector .time-unit-button {
|
|
1190
|
+
width: 100%;
|
|
1191
|
+
padding: 6px 0;
|
|
1192
|
+
border: none;
|
|
1193
|
+
cursor: pointer;
|
|
1194
|
+
text-align: center;
|
|
1195
|
+
background-color: transparent;
|
|
1196
|
+
}
|
|
1197
|
+
.date-calendar-box[aria-expanded=true] .date-calendar-box-time-selector .time-unit-button:hover {
|
|
1198
|
+
background-color: #dae1e8;
|
|
1199
|
+
}
|
|
1200
|
+
.date-calendar-box[aria-expanded=true] .date-calendar-box-time-selector .time-unit-button[aria-selected=true], .date-calendar-box[aria-expanded=true] .date-calendar-box-time-selector .time-unit-button[aria-selected=true]:hover {
|
|
1201
|
+
color: #fff;
|
|
1202
|
+
background-color: #6C757D;
|
|
1203
|
+
}
|
|
1204
|
+
.date-calendar-box[aria-expanded=true] .date-calendar-box-time-selector .time-unit-button[data-state-out-of-bounds=true] {
|
|
1205
|
+
color: #cacaca !important;
|
|
1206
|
+
cursor: not-allowed;
|
|
1207
|
+
}
|
|
1208
|
+
.date-calendar-box[aria-expanded=true] .date-calendar-box-time-selector .time-unit-button[data-state-out-of-bounds=true]:hover {
|
|
1209
|
+
background-color: transparent;
|
|
1210
|
+
}
|
|
1211
|
+
.date-calendar-box[aria-expanded=true] .date-calendar-box-time-selector[data-state-disabled=true] .time-unit-button {
|
|
1212
|
+
color: #cacaca !important;
|
|
1213
|
+
cursor: not-allowed;
|
|
1214
|
+
}
|
|
1215
|
+
.date-calendar-box[aria-expanded=true] .date-calendar-box-time-selector[data-state-disabled=true] .time-unit-button:hover {
|
|
1216
|
+
background-color: transparent;
|
|
1147
1217
|
}
|
|
@@ -5,4 +5,4 @@ export interface ScrollEndReachedParams extends UseScrollEndReachedParams {
|
|
|
5
5
|
onEndReachedThreshold?: number;
|
|
6
6
|
}
|
|
7
7
|
export declare function getCurrentThreshold(scrollableElement: HTMLElement, scrollThreshold: number): number;
|
|
8
|
-
export declare function useScrollEndReached({ elementRef, onEndReached, onEndReachedThreshold, }: ScrollEndReachedParams): void;
|
|
8
|
+
export declare function useScrollEndReached({ elementRef, onEndReached, onEndReachedThreshold, itemsCount, }: ScrollEndReachedParams): void;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { c as compilerRuntimeExports } from "../../_virtual/compiler-runtime.js";
|
|
2
1
|
import { useRef, useEffect } from "react";
|
|
3
2
|
function getCurrentThreshold(scrollableElement, scrollThreshold) {
|
|
4
3
|
const MIN_THRESHOLD = 0;
|
|
@@ -9,92 +8,59 @@ function getCurrentThreshold(scrollableElement, scrollThreshold) {
|
|
|
9
8
|
scrollHeight,
|
|
10
9
|
clientHeight
|
|
11
10
|
} = scrollableElement;
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
return Math.min(calculatedScrollThreshold, maxScrollThreshold);
|
|
11
|
+
const scrollableHeight = Math.max(scrollHeight - clientHeight, 0);
|
|
12
|
+
const thresholdBase = Math.min(clientHeight, scrollableHeight);
|
|
13
|
+
return Math.round(thresholdBase * scrollThreshold);
|
|
16
14
|
}
|
|
17
|
-
function useScrollEndReached(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const onEndReachedThreshold = t1 === void 0 ? 0.1 : t1;
|
|
25
|
-
const lastScrollHeight = useRef(0);
|
|
15
|
+
function useScrollEndReached({
|
|
16
|
+
elementRef,
|
|
17
|
+
onEndReached,
|
|
18
|
+
onEndReachedThreshold = 0.25,
|
|
19
|
+
itemsCount
|
|
20
|
+
}) {
|
|
21
|
+
const lastScrollTop = useRef(null);
|
|
26
22
|
const enableOnEndReached = useRef(true);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
23
|
+
const lastItemsCount = useRef(itemsCount);
|
|
24
|
+
const waitingForItems = useRef(false);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (itemsCount !== void 0 && lastItemsCount.current !== itemsCount) {
|
|
27
|
+
lastItemsCount.current = itemsCount;
|
|
28
|
+
waitingForItems.current = false;
|
|
29
|
+
enableOnEndReached.current = true;
|
|
30
|
+
}
|
|
31
|
+
}, [itemsCount]);
|
|
32
|
+
const onScrollEndReached = async () => {
|
|
33
|
+
const element = elementRef.current;
|
|
34
|
+
if (element && onEndReached) {
|
|
35
|
+
const {
|
|
36
|
+
scrollTop,
|
|
37
|
+
scrollHeight,
|
|
38
|
+
clientHeight
|
|
39
|
+
} = element;
|
|
40
|
+
const isScrollingDown = lastScrollTop.current === null || scrollTop > lastScrollTop.current;
|
|
41
|
+
lastScrollTop.current = scrollTop;
|
|
42
|
+
const scrollOffset = scrollHeight - clientHeight - scrollTop - 1;
|
|
43
|
+
const threshold = getCurrentThreshold(element, onEndReachedThreshold);
|
|
44
|
+
if (scrollOffset <= threshold && isScrollingDown && enableOnEndReached.current && !waitingForItems.current) {
|
|
45
|
+
enableOnEndReached.current = false;
|
|
46
|
+
waitingForItems.current = itemsCount !== void 0;
|
|
47
|
+
try {
|
|
48
|
+
await onEndReached();
|
|
49
|
+
} finally {
|
|
50
|
+
enableOnEndReached.current = itemsCount === void 0;
|
|
46
51
|
}
|
|
47
52
|
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
const element_0 = elementRef.current;
|
|
57
|
+
if (element_0 && onEndReached) {
|
|
58
|
+
element_0.addEventListener("scroll", onScrollEndReached);
|
|
59
|
+
}
|
|
60
|
+
return () => {
|
|
61
|
+
element_0?.removeEventListener("scroll", onScrollEndReached);
|
|
48
62
|
};
|
|
49
|
-
|
|
50
|
-
$[1] = onEndReached;
|
|
51
|
-
$[2] = onEndReachedThreshold;
|
|
52
|
-
$[3] = t2;
|
|
53
|
-
} else {
|
|
54
|
-
t2 = $[3];
|
|
55
|
-
}
|
|
56
|
-
const onScrollEndReached = t2;
|
|
57
|
-
let t3;
|
|
58
|
-
if ($[4] !== elementRef || $[5] !== onEndReached || $[6] !== onScrollEndReached) {
|
|
59
|
-
t3 = () => {
|
|
60
|
-
let observer;
|
|
61
|
-
const element_0 = elementRef.current;
|
|
62
|
-
if (element_0 && onEndReached) {
|
|
63
|
-
observer = new ResizeObserver(() => {
|
|
64
|
-
const currentElement = elementRef.current;
|
|
65
|
-
if (currentElement) {
|
|
66
|
-
const {
|
|
67
|
-
scrollHeight: scrollHeight_0
|
|
68
|
-
} = currentElement;
|
|
69
|
-
if (scrollHeight_0 && scrollHeight_0 !== lastScrollHeight.current) {
|
|
70
|
-
enableOnEndReached.current = true;
|
|
71
|
-
observer?.disconnect();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
observer.observe(element_0);
|
|
76
|
-
element_0.addEventListener("scroll", onScrollEndReached);
|
|
77
|
-
}
|
|
78
|
-
return () => {
|
|
79
|
-
element_0?.removeEventListener("scroll", onScrollEndReached);
|
|
80
|
-
observer?.disconnect();
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
$[4] = elementRef;
|
|
84
|
-
$[5] = onEndReached;
|
|
85
|
-
$[6] = onScrollEndReached;
|
|
86
|
-
$[7] = t3;
|
|
87
|
-
} else {
|
|
88
|
-
t3 = $[7];
|
|
89
|
-
}
|
|
90
|
-
let t4;
|
|
91
|
-
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
92
|
-
t4 = [];
|
|
93
|
-
$[8] = t4;
|
|
94
|
-
} else {
|
|
95
|
-
t4 = $[8];
|
|
96
|
-
}
|
|
97
|
-
useEffect(t3, t4);
|
|
63
|
+
}, [onEndReached, onEndReachedThreshold]);
|
|
98
64
|
}
|
|
99
65
|
export {
|
|
100
66
|
getCurrentThreshold,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/lib/hooks/useScrollEndReached/index.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { AsyncFunc, Func, UseScrollEndReachedParams } from \"./types\";\n\nexport interface ScrollEndReachedParams extends UseScrollEndReachedParams {\n elementRef: React.RefObject<HTMLElement | null>;\n onEndReached?: Func | AsyncFunc;\n onEndReachedThreshold?: number;\n}\n\nexport function getCurrentThreshold(\n scrollableElement: HTMLElement,\n scrollThreshold: number,\n): number {\n const MIN_THRESHOLD = 0;\n const MAX_THRESHOLD = 1;\n if (scrollThreshold < MIN_THRESHOLD) return MIN_THRESHOLD;\n if (scrollThreshold > MAX_THRESHOLD) return MAX_THRESHOLD;\n const { scrollHeight, clientHeight } = scrollableElement;\n const
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/lib/hooks/useScrollEndReached/index.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { AsyncFunc, Func, UseScrollEndReachedParams } from \"./types\";\n\nexport interface ScrollEndReachedParams extends UseScrollEndReachedParams {\n elementRef: React.RefObject<HTMLElement | null>;\n onEndReached?: Func | AsyncFunc;\n onEndReachedThreshold?: number;\n}\n\nexport function getCurrentThreshold(\n scrollableElement: HTMLElement,\n scrollThreshold: number,\n): number {\n const MIN_THRESHOLD = 0;\n const MAX_THRESHOLD = 1;\n if (scrollThreshold < MIN_THRESHOLD) return MIN_THRESHOLD;\n if (scrollThreshold > MAX_THRESHOLD) return MAX_THRESHOLD;\n const { scrollHeight, clientHeight } = scrollableElement;\n const scrollableHeight = Math.max(scrollHeight - clientHeight, 0);\n const thresholdBase = Math.min(clientHeight, scrollableHeight);\n\n return Math.round(thresholdBase * scrollThreshold);\n}\n\nexport function useScrollEndReached({\n elementRef,\n onEndReached,\n onEndReachedThreshold = 0.25,\n itemsCount,\n}: ScrollEndReachedParams) {\n const lastScrollTop = useRef<number | null>(null);\n const enableOnEndReached = useRef(true);\n const lastItemsCount = useRef<number | undefined>(itemsCount);\n const waitingForItems = useRef(false);\n\n useEffect(() => {\n if (itemsCount !== undefined && lastItemsCount.current !== itemsCount) {\n lastItemsCount.current = itemsCount;\n waitingForItems.current = false;\n enableOnEndReached.current = true;\n }\n }, [itemsCount]);\n\n const onScrollEndReached = async () => {\n const element = elementRef.current;\n\n if (element && onEndReached) {\n const { scrollTop, scrollHeight, clientHeight } = element;\n const isScrollingDown =\n lastScrollTop.current === null || scrollTop > lastScrollTop.current;\n lastScrollTop.current = scrollTop;\n const scrollOffset = scrollHeight - clientHeight - scrollTop - 1;\n const threshold = getCurrentThreshold(element, onEndReachedThreshold);\n\n if (\n scrollOffset <= threshold &&\n isScrollingDown &&\n enableOnEndReached.current &&\n !waitingForItems.current\n ) {\n enableOnEndReached.current = false;\n waitingForItems.current = itemsCount !== undefined;\n try {\n await onEndReached();\n } finally {\n enableOnEndReached.current = itemsCount === undefined;\n }\n }\n }\n };\n\n useEffect(() => {\n const element = elementRef.current;\n if (element && onEndReached) {\n element.addEventListener('scroll', onScrollEndReached);\n }\n\n return () => {\n element?.removeEventListener('scroll', onScrollEndReached);\n };\n }, [onEndReached, onEndReachedThreshold]);\n}\n"],"names":["getCurrentThreshold","scrollableElement","scrollThreshold","MIN_THRESHOLD","MAX_THRESHOLD","scrollHeight","clientHeight","scrollableHeight","Math","max","thresholdBase","min","round","useScrollEndReached","elementRef","onEndReached","onEndReachedThreshold","itemsCount","lastScrollTop","useRef","enableOnEndReached","lastItemsCount","waitingForItems","useEffect","undefined","current","onScrollEndReached","element","scrollTop","isScrollingDown","scrollOffset","threshold","addEventListener","removeEventListener"],"mappings":";AASO,SAASA,oBACdC,mBACAC,i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,YAAI;AACF,gBAAMT,aAAAA;AAAAA,QACR,UAAA;AACEK,6BAAmBK,UAAUR,eAAeO;AAAAA,QAC9C;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEAD,YAAU,MAAM;AACd,UAAMI,YAAUb,WAAWW;AAC3B,QAAIE,aAAWZ,cAAc;AAC3BY,gBAAQK,iBAAiB,UAAUN,kBAAkB;AAAA,IACvD;AAEA,WAAO,MAAM;AACXC,iBAASM,oBAAoB,UAAUP,kBAAkB;AAAA,IAC3D;AAAA,EACF,GAAG,CAACX,cAAcC,qBAAqB,CAAC;AAC1C;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useEffect } from "react";
|
|
3
|
+
import { useScrollEndReached } from "../../hooks/useScrollEndReached/index.js";
|
|
3
4
|
import Icon from "../../icons/index.js";
|
|
4
5
|
import Avatar from "../../avatar/index.js";
|
|
5
6
|
import { returnDropdownDynamicStyles, getDropdownItemCssClass } from "./helper.js";
|
|
@@ -25,7 +26,10 @@ const Dropdown = (props) => {
|
|
|
25
26
|
handleOnKeydown,
|
|
26
27
|
searchNotFoundText,
|
|
27
28
|
idKey,
|
|
28
|
-
selectFieldRef
|
|
29
|
+
selectFieldRef,
|
|
30
|
+
onEndReached,
|
|
31
|
+
onEndReachedThreshold,
|
|
32
|
+
itemsCount
|
|
29
33
|
} = props;
|
|
30
34
|
const [dropdownDynamicStyles, setDropdownDynamicStyles] = useState(returnDropdownDynamicStyles({
|
|
31
35
|
...props
|
|
@@ -37,6 +41,12 @@ const Dropdown = (props) => {
|
|
|
37
41
|
}));
|
|
38
42
|
}
|
|
39
43
|
}, [dropdownRef.current, dataCombo]);
|
|
44
|
+
useScrollEndReached({
|
|
45
|
+
elementRef: dropdownRef,
|
|
46
|
+
onEndReached,
|
|
47
|
+
onEndReachedThreshold,
|
|
48
|
+
itemsCount: itemsCount ?? dataCombo.length
|
|
49
|
+
});
|
|
40
50
|
return /* @__PURE__ */ jsx(DropdownPopup, { align: "left", leftPosition: dropdownDynamicStyles.left, topPosition: dropdownDynamicStyles.top, targetRef: selectFieldRef?.current, children: /* @__PURE__ */ jsxs("div", { className: "select-dropdown", ref: dropdownRef, style: {
|
|
41
51
|
width: dropdownWidth,
|
|
42
52
|
marginLeft: gridWrapperStyle ? gridWrapperStyle.paddingLeft : "0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.js","sources":["../../../src/lib/inputs/select/Dropdown.tsx"],"sourcesContent":["import { ChangeEvent, KeyboardEvent, useEffect, useState } from 'react';\nimport Icon from '../../icons';\nimport Avatar from '../../avatar';\nimport * as helper from './helper';\nimport DropdownPopup from '../../dropdown/Popup';\nimport { IDropdownSelectProps } from '../types';\nimport { DataCombo } from '../../@types/DataCombo';\n\nconst Dropdown = (props: IDropdownSelectProps) => {\n const {\n imageAlign = 'left', striped = false, dataCombo, descriptionKey, imgSrcKey, dropdownRef,\n currents = [], dropdownWidth, gridWrapperStyle, handleOnSelect, inputValue,\n handleOnFocus, opened, handleOnFilter, selected = null, searchOnDropdown, handleOnKeydown,\n searchNotFoundText, idKey, selectFieldRef,\n } = props;\n const [dropdownDynamicStyles, setDropdownDynamicStyles] =\n useState(helper.returnDropdownDynamicStyles({ ...props }));\n\n useEffect(() => {\n if (dropdownRef.current) {\n setDropdownDynamicStyles(helper.returnDropdownDynamicStyles({ ...props }));\n }\n }, [dropdownRef.current, dataCombo]);\n\n return (\n <DropdownPopup\n align=\"left\"\n leftPosition={dropdownDynamicStyles.left}\n topPosition={dropdownDynamicStyles.top}\n targetRef={selectFieldRef?.current}>\n <div\n className=\"select-dropdown\"\n ref={dropdownRef}\n style={{\n width: dropdownWidth,\n marginLeft: gridWrapperStyle ? gridWrapperStyle.paddingLeft : '0',\n maxHeight: dropdownDynamicStyles.maxHeight,\n }}>\n {searchOnDropdown &&\n <div className=\"filtercontainer\">\n <input\n className=\"filterinput\"\n type=\"text\"\n value={inputValue}\n onFocus={() => { handleOnFocus(); }}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n handleOnFilter(e.target.value);\n }}\n onKeyDown={(e: KeyboardEvent<Element>) => { handleOnKeydown(e); }}\n autoFocus={opened} />\n <Icon name=\"search\" viewBox=\"0 0 32 32\" />\n </div>\n }\n {dataCombo.map((item: DataCombo) => {\n const disabled = (currents && currents.length > 0 ?\n currents.some(s => s[idKey] === item[idKey])\n : false);\n const itemSelected = Boolean(selected && selected[idKey] === item[idKey]);\n return (\n <div\n key={`dropdowmIten ${item[idKey]}}`}\n className={helper.getDropdownItemCssClass(itemSelected, disabled, striped)} >\n <button\n className=\"menubutton\"\n tabIndex={-1}\n onClick={() => { if (!disabled) { handleOnSelect(item); } }}>\n {item.iconName &&\n <Icon\n name={item.iconName}\n customClass=\"menuicon\"\n style={{ order: imageAlign === 'left' ? 0 : 1 }} />\n }\n {imgSrcKey && item.imgSrcKey &&\n <Avatar\n src={item.imgSrcKey}\n customClass=\"menuicon\"\n style={{ order: imageAlign === 'left' ? 0 : 1 }} />\n }\n <span className=\"label\">{typeof descriptionKey === 'string' ? item[descriptionKey] : descriptionKey(item)}</span>\n </button>\n </div>\n );\n })}\n {dataCombo && dataCombo.length === 0 &&\n <div className=\"notfound\">{searchNotFoundText}</div>\n }\n </div>\n </DropdownPopup>\n );\n};\n\nexport default Dropdown;\n"],"names":["Dropdown","props","imageAlign","striped","dataCombo","descriptionKey","imgSrcKey","dropdownRef","currents","dropdownWidth","gridWrapperStyle","handleOnSelect","inputValue","handleOnFocus","opened","handleOnFilter","selected","searchOnDropdown","handleOnKeydown","searchNotFoundText","idKey","selectFieldRef","dropdownDynamicStyles","setDropdownDynamicStyles","useState","helper","useEffect","current","left","top","width","marginLeft","paddingLeft","maxHeight","e","target","value","map","item","disabled","
|
|
1
|
+
{"version":3,"file":"Dropdown.js","sources":["../../../src/lib/inputs/select/Dropdown.tsx"],"sourcesContent":["import { ChangeEvent, KeyboardEvent, useEffect, useState } from 'react';\nimport { useScrollEndReached } from '../../hooks/useScrollEndReached';\nimport Icon from '../../icons';\nimport Avatar from '../../avatar';\nimport * as helper from './helper';\nimport DropdownPopup from '../../dropdown/Popup';\nimport { IDropdownSelectProps } from '../types';\nimport { DataCombo } from '../../@types/DataCombo';\n\nconst Dropdown = (props: IDropdownSelectProps) => {\n const {\n imageAlign = 'left', striped = false, dataCombo, descriptionKey, imgSrcKey, dropdownRef,\n currents = [], dropdownWidth, gridWrapperStyle, handleOnSelect, inputValue,\n handleOnFocus, opened, handleOnFilter, selected = null, searchOnDropdown, handleOnKeydown,\n searchNotFoundText, idKey, selectFieldRef, onEndReached, onEndReachedThreshold, itemsCount,\n } = props;\n const [dropdownDynamicStyles, setDropdownDynamicStyles] =\n useState(helper.returnDropdownDynamicStyles({ ...props }));\n\n useEffect(() => {\n if (dropdownRef.current) {\n setDropdownDynamicStyles(helper.returnDropdownDynamicStyles({ ...props }));\n }\n }, [dropdownRef.current, dataCombo]);\n\n useScrollEndReached({\n elementRef: dropdownRef,\n onEndReached,\n onEndReachedThreshold,\n itemsCount: itemsCount ?? dataCombo.length,\n });\n\n return (\n <DropdownPopup\n align=\"left\"\n leftPosition={dropdownDynamicStyles.left}\n topPosition={dropdownDynamicStyles.top}\n targetRef={selectFieldRef?.current}>\n <div\n className=\"select-dropdown\"\n ref={dropdownRef}\n style={{\n width: dropdownWidth,\n marginLeft: gridWrapperStyle ? gridWrapperStyle.paddingLeft : '0',\n maxHeight: dropdownDynamicStyles.maxHeight,\n }}>\n {searchOnDropdown &&\n <div className=\"filtercontainer\">\n <input\n className=\"filterinput\"\n type=\"text\"\n value={inputValue}\n onFocus={() => { handleOnFocus(); }}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n handleOnFilter(e.target.value);\n }}\n onKeyDown={(e: KeyboardEvent<Element>) => { handleOnKeydown(e); }}\n autoFocus={opened} />\n <Icon name=\"search\" viewBox=\"0 0 32 32\" />\n </div>\n }\n {dataCombo.map((item: DataCombo) => {\n const disabled = (currents && currents.length > 0 ?\n currents.some(s => s[idKey] === item[idKey])\n : false);\n const itemSelected = Boolean(selected && selected[idKey] === item[idKey]);\n return (\n <div\n key={`dropdowmIten ${item[idKey]}}`}\n className={helper.getDropdownItemCssClass(itemSelected, disabled, striped)} >\n <button\n className=\"menubutton\"\n tabIndex={-1}\n onClick={() => { if (!disabled) { handleOnSelect(item); } }}>\n {item.iconName &&\n <Icon\n name={item.iconName}\n customClass=\"menuicon\"\n style={{ order: imageAlign === 'left' ? 0 : 1 }} />\n }\n {imgSrcKey && item.imgSrcKey &&\n <Avatar\n src={item.imgSrcKey}\n customClass=\"menuicon\"\n style={{ order: imageAlign === 'left' ? 0 : 1 }} />\n }\n <span className=\"label\">{typeof descriptionKey === 'string' ? item[descriptionKey] : descriptionKey(item)}</span>\n </button>\n </div>\n );\n })}\n {dataCombo && dataCombo.length === 0 &&\n <div className=\"notfound\">{searchNotFoundText}</div>\n }\n </div>\n </DropdownPopup>\n );\n};\n\nexport default Dropdown;\n"],"names":["Dropdown","props","imageAlign","striped","dataCombo","descriptionKey","imgSrcKey","dropdownRef","currents","dropdownWidth","gridWrapperStyle","handleOnSelect","inputValue","handleOnFocus","opened","handleOnFilter","selected","searchOnDropdown","handleOnKeydown","searchNotFoundText","idKey","selectFieldRef","onEndReached","onEndReachedThreshold","itemsCount","dropdownDynamicStyles","setDropdownDynamicStyles","useState","helper","useEffect","current","useScrollEndReached","elementRef","length","left","top","width","marginLeft","paddingLeft","maxHeight","e","target","value","map","item","disabled","some","s","itemSelected","Boolean","iconName","order"],"mappings":";;;;;;;AASA,MAAMA,WAAWA,CAACC,UAAgC;AAChD,QAAM;AAAA,IACJC,aAAa;AAAA,IAAQC,UAAU;AAAA,IAAOC;AAAAA,IAAWC;AAAAA,IAAgBC;AAAAA,IAAWC;AAAAA,IAC5EC,WAAW,CAAA;AAAA,IAAIC;AAAAA,IAAeC;AAAAA,IAAkBC;AAAAA,IAAgBC;AAAAA,IA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26
26
|
customClassForInputContent,
|
|
27
27
|
customClassForSideButtons,
|
|
28
28
|
disabled = false,
|
|
29
|
-
dropdownMaxWidth = void 0
|
|
29
|
+
dropdownMaxWidth = void 0,
|
|
30
|
+
onEndReached,
|
|
31
|
+
onEndReachedThreshold,
|
|
32
|
+
itemsCount
|
|
30
33
|
} = props;
|
|
31
34
|
const [dataCombo, setDataCombo] = useState(dataSource);
|
|
32
35
|
const [currents, setCurrents] = useState([]);
|
|
@@ -225,7 +228,7 @@ const MultipleSelect = (props) => {
|
|
|
225
228
|
if (shouldDisable()) return null;
|
|
226
229
|
return onClearClick();
|
|
227
230
|
}, handlerOpenClose: onOpenClose, customClassForSideButtons }, "action-buttons-multiselect")], children: /* @__PURE__ */ jsx(Selecteds, { ...props, currents, handlerOnUnselect: onUnselect }) }),
|
|
228
|
-
opened && /* @__PURE__ */ jsx(Dropdown, { ...props, selected, selectFieldRef: componentRef, dropdownRef, gridWrapperStyle: props.gridLayout && gridElRef.current ? window.getComputedStyle(gridElRef.current) : void 0, handleOnSelect: onSelect, handleOnFilter: onFilter, handleOnKeydown: onInputKeyDown, handleOnBlur: () => onBlur, handleOnFocus: onFocus, opened, dataCombo, currents, dropdownWidth: dropdownMaxWidth || dropdownWidth || 0 }),
|
|
231
|
+
opened && /* @__PURE__ */ jsx(Dropdown, { ...props, selected, selectFieldRef: componentRef, dropdownRef, gridWrapperStyle: props.gridLayout && gridElRef.current ? window.getComputedStyle(gridElRef.current) : void 0, handleOnSelect: onSelect, handleOnFilter: onFilter, handleOnKeydown: onInputKeyDown, handleOnBlur: () => onBlur, handleOnFocus: onFocus, opened, dataCombo, currents, dropdownWidth: dropdownMaxWidth || dropdownWidth || 0, onEndReached, onEndReachedThreshold, itemsCount }),
|
|
229
232
|
/* @__PURE__ */ jsx(Hint, { visible: !!hint && hintPosition === "below", customClass: "hint", description: hint })
|
|
230
233
|
] });
|
|
231
234
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/lib/inputs/select/multiple/index.tsx"],"sourcesContent":["import { KeyboardEvent, useEffect, useRef, useState } from 'react';\nimport _ from 'lodash';\nimport * as uuid from 'uuid';\nimport Dropdown from '../Dropdown';\nimport ActionButtons from '../ActionButtons';\nimport Selecteds from './Selecteds';\nimport * as constants from '../../../internals/constants';\nimport InputTextBase from '../../base/InputTextBase';\nimport { getFilteredMultipleDataCombo } from '../helper';\nimport { OnDenied } from '../../../@types/PermissionAttr';\nimport { DataCombo } from '../../../@types/DataCombo';\nimport { IMultipleSelectProps } from '../types';\nimport { CustomInputEvent } from '../../base/types';\nimport Hint from '../../../hint';\n\nconst MultipleSelect = (props: IMultipleSelectProps) => {\n const {\n idKey, dataSource = [], handlerClear, value = [], remoteSearch = false, descriptionKey,\n showClearButton, rightElements = [], hint, hintPosition = 'below', customClassForLabel,\n customClassForWrapper, customClassForInputContent, customClassForSideButtons, disabled = false,\n dropdownMaxWidth = undefined,\n } = props;\n const [dataCombo, setDataCombo] = useState(dataSource);\n const [currents, setCurrents] = useState<DataCombo[]>([]);\n const [selected, setSelected] = useState<DataCombo>();\n const [inputValue, setInputValue] = useState<string[] | number[]>([]);\n const [opened, setOpened] = useState(false);\n const [dropdownWidth, setDropdownWidth] = useState(0);\n const [insideComponent, setInsideComponent] = useState(false);\n const [onDenied, setOnDeniedSelect] = useState<OnDenied>();\n const [valueFromProps, setValueFromProps] = useState<string[] | number[]>([]);\n\n const componentId = `select-component${uuid.v1()}`;\n const componentRef = useRef<HTMLInputElement>(null);\n const dropdownRef = useRef<HTMLInputElement>(null);\n const selectWrapper = useRef<HTMLDivElement | HTMLTextAreaElement>(null);\n const gridElRef = useRef<Element>(null);\n const inputTextRef = useRef<HTMLInputElement | HTMLTextAreaElement | null>(null);\n const descriptionKeyIsString = typeof descriptionKey === 'string';\n const insideComponents =\n ['item', 'menubutton', 'filterinput', 'filtercontainer', 'label', 'actionbutton'];\n\n const onScreenResize = () => {\n if (selectWrapper.current) setDropdownWidth(selectWrapper.current.clientWidth);\n };\n\n const onClickOutside = (event: MouseEvent) => {\n const { target } = event;\n if (!insideComponents.includes((target as Element).className) &&\n target !== selectWrapper.current && selectWrapper.current &&\n !selectWrapper.current.contains(target as Node) &&\n dropdownRef.current && !dropdownRef.current.contains(target as Node)) {\n setOpened(false);\n }\n };\n\n const onMouseMove = (event: MouseEvent) => {\n const target = event.target as Element;\n const idDropdown = dropdownRef.current?.parentElement?.id || '';\n const dropdownElement = document.getElementById(idDropdown);\n const keepDropdownOpen = Boolean(dropdownElement?.contains(target));\n setInsideComponent(keepDropdownOpen);\n };\n\n const onClearClick = () => {\n setSelected(undefined);\n setCurrents([]);\n if (props.onSelect) props.onSelect();\n };\n\n const onFilter = (filteredValue: string) => {\n let selectedFilter = null;\n if (remoteSearch) {\n if (props.onSearch) props.onSearch(filteredValue);\n setOpened(true);\n setInputValue([filteredValue]);\n } else {\n let dataComboFilter = dataSource;\n if (filteredValue.length > 0) {\n dataComboFilter = getFilteredMultipleDataCombo({\n inputText: [filteredValue],\n dataSource,\n descriptionKey,\n currents,\n });\n }\n if (dataComboFilter && dataComboFilter.length > 0) selectedFilter = dataComboFilter[0];\n setDataCombo(dataComboFilter);\n setOpened(true);\n if (selectedFilter) setSelected(selectedFilter);\n setInputValue([filteredValue]);\n }\n };\n\n const onFocus = () => {\n const dropdownWidthFocus =\n selectWrapper.current ? selectWrapper.current.clientWidth : dropdownWidth;\n setOpened(true);\n setDropdownWidth(dropdownWidthFocus);\n };\n\n const onSelect = (select: DataCombo) => {\n if (select === null) return;\n const currentsSelect = [...currents, select];\n\n setCurrents(currentsSelect);\n setDataCombo(dataSource);\n setInputValue([]);\n if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();\n if (props.onSelect) setSelected(props.onSelect(currentsSelect.map(i => i[idKey])));\n dropdownRef.current?.focus();\n };\n\n const onUnselect = (id: string) => {\n if (currents) {\n const result = currents.filter(item => item[idKey] !== id);\n setCurrents(result);\n if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();\n setOpened(false);\n if (props.onSelect) setSelected(props.onSelect(result.map(i => i[idKey])));\n dropdownRef.current?.focus();\n }\n };\n\n const onOpenClose = () => {\n setOpened(prevState => !prevState);\n if (selectWrapper.current) setDropdownWidth(selectWrapper.current.clientWidth);\n };\n\n const onBlur = (e: CustomInputEvent) => {\n if (props.onBlur) props.onBlur(e);\n if (selected && opened) {\n onSelect(selected);\n }\n if (!insideComponent) {\n setOpened(false);\n setDataCombo(dataSource);\n }\n };\n\n const onInputKeyDown = (e: CustomInputEvent | KeyboardEvent) => {\n if (e.keyCode) {\n if ((e.keyCode === constants.keyCodes.ENTER || e.key === constants.keys.TAB) \n && selected && opened) {\n if (e.keyCode === constants.keyCodes.ENTER) e.preventDefault?.();\n if (!currents.some(current => current[idKey] === selected[idKey])) {\n onSelect(selected);\n }\n } else if ([constants.keyCodes.ARROW_UP, constants.keyCodes.ARROW_DOWN].includes(e.keyCode)) {\n if (!opened) setOpened(true);\n let index = dataCombo ? dataCombo.findIndex(d => d === selected) : 0;\n if (e.keyCode === constants.keyCodes.ARROW_DOWN) {\n index = (dataCombo && index === dataCombo.length - 1 ? 0 : index + 1);\n } else {\n index = (dataCombo && index === 0 ? dataCombo.length - 1 : index - 1);\n }\n if (dataCombo && dataCombo.length) {\n if (descriptionKeyIsString && dataCombo[index][descriptionKey]) {\n setInputValue(dataCombo[index][descriptionKey]);\n } else if (!descriptionKeyIsString) setInputValue([descriptionKey(dataCombo[index])]);\n }\n if (dataCombo) setSelected(dataCombo[index]);\n } else if (e.keyCode === constants.keyCodes.BACKSPACE) {\n if (inputValue.length === 0) {\n const currentsKeyDown = _.dropRight(currents);\n setCurrents(currentsKeyDown);\n if (props.onSelect) props.onSelect(currentsKeyDown.map(i => i[idKey]));\n }\n } else if (e.keyCode === constants.keyCodes.TAB) {\n setOpened(false);\n }\n }\n };\n\n const setOnDenied = (denied: OnDenied) => {\n setOnDeniedSelect(denied);\n };\n\n const shouldDisable = () =>\n disabled ||\n (onDenied && (onDenied.disabled || onDenied.hideContent));\n\n const shouldBeReadOnly = () => props.readOnly || (onDenied && (onDenied.readOnly));\n\n useEffect(() => {\n window.addEventListener('resize', onScreenResize);\n document.addEventListener('click', onClickOutside);\n document.addEventListener('mousemove', onMouseMove);\n if (handlerClear) onClearClick();\n\n return () => {\n window.removeEventListener('resize', onScreenResize);\n document.removeEventListener('click', onClickOutside);\n document.removeEventListener('mousemove', onMouseMove);\n };\n }, []);\n\n useEffect(() => {\n if (props.gridLayout) {\n const gridEl = document.querySelector(`#${componentId}>.-withinput.grid-container`);\n if (gridElRef.current !== gridEl && gridEl) gridElRef.current = gridEl;\n }\n }, []);\n\n useEffect(() => {\n if (value.length > 0 && value !== valueFromProps && dataSource.length > 0) {\n const newCurrents = dataSource.filter((item: { [id: string]: string }) =>\n value.includes(item[idKey] as never));\n\n setValueFromProps(value);\n setCurrents(newCurrents);\n }\n }, [dataSource.length, value.length]);\n\n useEffect(() => {\n if (!_.isEqual(dataSource, dataCombo)) {\n const filteredDataCombo = remoteSearch\n ? dataSource\n : getFilteredMultipleDataCombo({\n currents, dataSource, descriptionKey, inputText: inputValue,\n });\n\n setDataCombo(filteredDataCombo);\n setSelected(filteredDataCombo.length > 0 ? dataCombo[0] : null);\n }\n }, [dataSource]);\n\n return (\n <span\n id={componentId}\n ref={componentRef}\n className=\"select-component\">\n <InputTextBase\n {...props}\n inputRef={(ref) => {\n if (props.inputRef) {\n if (!_.isFunction(props.inputRef)) {\n props.inputRef.current = ref;\n } else {\n props.inputRef(ref);\n }\n }\n inputTextRef.current = ref;\n }}\n autoComplete=\"off\"\n value={inputValue.toString()}\n readOnly={shouldBeReadOnly()}\n onFocus={() => { onFocus(); }}\n onBlur={(e: CustomInputEvent) => { onBlur(e); }}\n onChange={(e?: CustomInputEvent) => {\n if (e) onFilter(e.target.value);\n }}\n onClick={onFocus}\n onKeyDown={onInputKeyDown}\n customClassForLabel={customClassForLabel}\n customClassForWrapper={\n `selectwrapper ${(props.readOnly || shouldDisable() || shouldBeReadOnly()) && ' -undigitable'} ${customClassForWrapper}`\n }\n customClassForInputContent={`multiselect ${customClassForInputContent}`}\n inputBaseRef={(r: HTMLDivElement | HTMLTextAreaElement) => { selectWrapper.current = r; }}\n handlerSetOnDenied={setOnDenied}\n rightElements={[\n ...rightElements,\n <ActionButtons\n key=\"action-buttons-multiselect\"\n showClearButton={showClearButton}\n disabled={shouldDisable() || shouldBeReadOnly()}\n dropDownOpened={opened}\n handlerClear={() => {\n if (shouldDisable()) return null;\n return onClearClick();\n }}\n handlerOpenClose={onOpenClose}\n customClassForSideButtons={customClassForSideButtons} />,\n ]}>\n <Selecteds\n {...props}\n currents={currents}\n handlerOnUnselect={onUnselect} />\n </InputTextBase>\n {opened &&\n <Dropdown\n {...props}\n selected={selected}\n selectFieldRef={componentRef}\n dropdownRef={dropdownRef}\n gridWrapperStyle={props.gridLayout && gridElRef.current\n ? window.getComputedStyle(gridElRef.current)\n : undefined}\n handleOnSelect={onSelect}\n handleOnFilter={onFilter}\n handleOnKeydown={onInputKeyDown}\n handleOnBlur={() => onBlur}\n handleOnFocus={onFocus}\n opened={opened}\n dataCombo={dataCombo}\n currents={currents}\n dropdownWidth={dropdownMaxWidth || dropdownWidth || 0} />\n }\n <Hint visible={!!hint && hintPosition === 'below'} customClass=\"hint\" description={hint} />\n </span>\n );\n};\n\nexport default MultipleSelect;\n"],"names":["MultipleSelect","props","idKey","dataSource","handlerClear","value","remoteSearch","descriptionKey","showClearButton","rightElements","hint","hintPosition","customClassForLabel","customClassForWrapper","customClassForInputContent","customClassForSideButtons","disabled","dropdownMaxWidth","undefined","dataCombo","setDataCombo","useState","currents","setCurrents","selected","setSelected","inputValue","setInputValue","opened","setOpened","dropdownWidth","setDropdownWidth","insideComponent","setInsideComponent","onDenied","setOnDeniedSelect","valueFromProps","setValueFromProps","componentId","uuid","v1","componentRef","useRef","dropdownRef","selectWrapper","gridElRef","inputTextRef","descriptionKeyIsString","insideComponents","onScreenResize","current","clientWidth","onClickOutside","event","target","includes","className","contains","onMouseMove","idDropdown","parentElement","id","dropdownElement","document","getElementById","keepDropdownOpen","Boolean","onClearClick","onSelect","onFilter","filteredValue","selectedFilter","onSearch","dataComboFilter","length","getFilteredMultipleDataCombo","inputText","onFocus","dropdownWidthFocus","select","currentsSelect","focus","map","i","onUnselect","result","filter","item","onOpenClose","prevState","onBlur","e","onInputKeyDown","keyCode","constants","ENTER","key","TAB","preventDefault","some","ARROW_UP","ARROW_DOWN","index","findIndex","d","BACKSPACE","currentsKeyDown","_","dropRight","setOnDenied","denied","shouldDisable","hideContent","shouldBeReadOnly","readOnly","useEffect","window","addEventListener","removeEventListener","gridLayout","gridEl","querySelector","newCurrents","isEqual","filteredDataCombo","ref","inputRef","isFunction","toString","r","getComputedStyle"],"mappings":";;;;;;;;;;;AAeA,MAAMA,iBAAiBA,CAACC,UAAgC;AACtD,QAAM;AAAA,IACJC;AAAAA,IAAOC,aAAa,CAAA;AAAA,IAAIC;AAAAA,IAAcC,QAAQ,CAAA;AAAA,IAAIC,eAAe;AAAA,IAAOC;AAAAA,IACxEC;AAAAA,IAAiBC,gBAAgB,CAAA;AAAA,IAAIC;AAAAA,IAAMC,eAAe;AAAA,IAASC;AAAAA,IACnEC;AAAAA,IAAuBC;AAAAA,IAA4BC;AAAAA,IAA2BC,WAAW;AAAA,IACzFC,mBAAmBC;AAAAA,EAAAA,IACjBjB;AACJ,QAAM,CAACkB,WAAWC,YAAY,IAAIC,SAASlB,UAAU;AACrD,QAAM,CAACmB,UAAUC,WAAW,IAAIF,SAAsB,CAAA,CAAE;AACxD,QAAM,CAACG,UAAUC,WAAW,IAAIJ,SAAAA;AAChC,QAAM,CAACK,YAAYC,aAAa,IAAIN,SAA8B,CAAA,CAAE;AACpE,QAAM,CAACO,QAAQC,SAAS,IAAIR,SAAS,KAAK;AAC1C,QAAM,CAACS,eAAeC,gBAAgB,IAAIV,SAAS,CAAC;AACpD,QAAM,CAACW,iBAAiB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,gBACjB,cAAc,MAAMF,QACpB,eAAeb,SACf,QACA,WACA,UACA,eAAe5D,oBAAoBa,iBAAiB,GAAE;AAAA,IAE1D,oBAAC,MAAA,EAAK,SAAS,CAAC,CAACpB,QAAQC,iBAAiB,SAAS,aAAY,QAAO,aAAaD,KAAAA,CAAK;AAAA,EAAA,GAC1F;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/lib/inputs/select/multiple/index.tsx"],"sourcesContent":["import { KeyboardEvent, useEffect, useRef, useState } from 'react';\nimport _ from 'lodash';\nimport * as uuid from 'uuid';\nimport Dropdown from '../Dropdown';\nimport ActionButtons from '../ActionButtons';\nimport Selecteds from './Selecteds';\nimport * as constants from '../../../internals/constants';\nimport InputTextBase from '../../base/InputTextBase';\nimport { getFilteredMultipleDataCombo } from '../helper';\nimport { OnDenied } from '../../../@types/PermissionAttr';\nimport { DataCombo } from '../../../@types/DataCombo';\nimport { IMultipleSelectProps } from '../types';\nimport { CustomInputEvent } from '../../base/types';\nimport Hint from '../../../hint';\n\nconst MultipleSelect = (props: IMultipleSelectProps) => {\n const {\n idKey, dataSource = [], handlerClear, value = [], remoteSearch = false, descriptionKey,\n showClearButton, rightElements = [], hint, hintPosition = 'below', customClassForLabel,\n customClassForWrapper, customClassForInputContent, customClassForSideButtons, disabled = false,\n dropdownMaxWidth = undefined, onEndReached, onEndReachedThreshold, itemsCount,\n } = props;\n const [dataCombo, setDataCombo] = useState(dataSource);\n const [currents, setCurrents] = useState<DataCombo[]>([]);\n const [selected, setSelected] = useState<DataCombo>();\n const [inputValue, setInputValue] = useState<string[] | number[]>([]);\n const [opened, setOpened] = useState(false);\n const [dropdownWidth, setDropdownWidth] = useState(0);\n const [insideComponent, setInsideComponent] = useState(false);\n const [onDenied, setOnDeniedSelect] = useState<OnDenied>();\n const [valueFromProps, setValueFromProps] = useState<string[] | number[]>([]);\n\n const componentId = `select-component${uuid.v1()}`;\n const componentRef = useRef<HTMLInputElement>(null);\n const dropdownRef = useRef<HTMLInputElement>(null);\n const selectWrapper = useRef<HTMLDivElement | HTMLTextAreaElement>(null);\n const gridElRef = useRef<Element>(null);\n const inputTextRef = useRef<HTMLInputElement | HTMLTextAreaElement | null>(null);\n const descriptionKeyIsString = typeof descriptionKey === 'string';\n const insideComponents =\n ['item', 'menubutton', 'filterinput', 'filtercontainer', 'label', 'actionbutton'];\n\n const onScreenResize = () => {\n if (selectWrapper.current) setDropdownWidth(selectWrapper.current.clientWidth);\n };\n\n const onClickOutside = (event: MouseEvent) => {\n const { target } = event;\n if (!insideComponents.includes((target as Element).className) &&\n target !== selectWrapper.current && selectWrapper.current &&\n !selectWrapper.current.contains(target as Node) &&\n dropdownRef.current && !dropdownRef.current.contains(target as Node)) {\n setOpened(false);\n }\n };\n\n const onMouseMove = (event: MouseEvent) => {\n const target = event.target as Element;\n const idDropdown = dropdownRef.current?.parentElement?.id || '';\n const dropdownElement = document.getElementById(idDropdown);\n const keepDropdownOpen = Boolean(dropdownElement?.contains(target));\n setInsideComponent(keepDropdownOpen);\n };\n\n const onClearClick = () => {\n setSelected(undefined);\n setCurrents([]);\n if (props.onSelect) props.onSelect();\n };\n\n const onFilter = (filteredValue: string) => {\n let selectedFilter = null;\n if (remoteSearch) {\n if (props.onSearch) props.onSearch(filteredValue);\n setOpened(true);\n setInputValue([filteredValue]);\n } else {\n let dataComboFilter = dataSource;\n if (filteredValue.length > 0) {\n dataComboFilter = getFilteredMultipleDataCombo({\n inputText: [filteredValue],\n dataSource,\n descriptionKey,\n currents,\n });\n }\n if (dataComboFilter && dataComboFilter.length > 0) selectedFilter = dataComboFilter[0];\n setDataCombo(dataComboFilter);\n setOpened(true);\n if (selectedFilter) setSelected(selectedFilter);\n setInputValue([filteredValue]);\n }\n };\n\n const onFocus = () => {\n const dropdownWidthFocus =\n selectWrapper.current ? selectWrapper.current.clientWidth : dropdownWidth;\n setOpened(true);\n setDropdownWidth(dropdownWidthFocus);\n };\n\n const onSelect = (select: DataCombo) => {\n if (select === null) return;\n const currentsSelect = [...currents, select];\n\n setCurrents(currentsSelect);\n setDataCombo(dataSource);\n setInputValue([]);\n if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();\n if (props.onSelect) setSelected(props.onSelect(currentsSelect.map(i => i[idKey])));\n dropdownRef.current?.focus();\n };\n\n const onUnselect = (id: string) => {\n if (currents) {\n const result = currents.filter(item => item[idKey] !== id);\n setCurrents(result);\n if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();\n setOpened(false);\n if (props.onSelect) setSelected(props.onSelect(result.map(i => i[idKey])));\n dropdownRef.current?.focus();\n }\n };\n\n const onOpenClose = () => {\n setOpened(prevState => !prevState);\n if (selectWrapper.current) setDropdownWidth(selectWrapper.current.clientWidth);\n };\n\n const onBlur = (e: CustomInputEvent) => {\n if (props.onBlur) props.onBlur(e);\n if (selected && opened) {\n onSelect(selected);\n }\n if (!insideComponent) {\n setOpened(false);\n setDataCombo(dataSource);\n }\n };\n\n const onInputKeyDown = (e: CustomInputEvent | KeyboardEvent) => {\n if (e.keyCode) {\n if ((e.keyCode === constants.keyCodes.ENTER || e.key === constants.keys.TAB) \n && selected && opened) {\n if (e.keyCode === constants.keyCodes.ENTER) e.preventDefault?.();\n if (!currents.some(current => current[idKey] === selected[idKey])) {\n onSelect(selected);\n }\n } else if ([constants.keyCodes.ARROW_UP, constants.keyCodes.ARROW_DOWN].includes(e.keyCode)) {\n if (!opened) setOpened(true);\n let index = dataCombo ? dataCombo.findIndex(d => d === selected) : 0;\n if (e.keyCode === constants.keyCodes.ARROW_DOWN) {\n index = (dataCombo && index === dataCombo.length - 1 ? 0 : index + 1);\n } else {\n index = (dataCombo && index === 0 ? dataCombo.length - 1 : index - 1);\n }\n if (dataCombo && dataCombo.length) {\n if (descriptionKeyIsString && dataCombo[index][descriptionKey]) {\n setInputValue(dataCombo[index][descriptionKey]);\n } else if (!descriptionKeyIsString) setInputValue([descriptionKey(dataCombo[index])]);\n }\n if (dataCombo) setSelected(dataCombo[index]);\n } else if (e.keyCode === constants.keyCodes.BACKSPACE) {\n if (inputValue.length === 0) {\n const currentsKeyDown = _.dropRight(currents);\n setCurrents(currentsKeyDown);\n if (props.onSelect) props.onSelect(currentsKeyDown.map(i => i[idKey]));\n }\n } else if (e.keyCode === constants.keyCodes.TAB) {\n setOpened(false);\n }\n }\n };\n\n const setOnDenied = (denied: OnDenied) => {\n setOnDeniedSelect(denied);\n };\n\n const shouldDisable = () =>\n disabled ||\n (onDenied && (onDenied.disabled || onDenied.hideContent));\n\n const shouldBeReadOnly = () => props.readOnly || (onDenied && (onDenied.readOnly));\n\n useEffect(() => {\n window.addEventListener('resize', onScreenResize);\n document.addEventListener('click', onClickOutside);\n document.addEventListener('mousemove', onMouseMove);\n if (handlerClear) onClearClick();\n\n return () => {\n window.removeEventListener('resize', onScreenResize);\n document.removeEventListener('click', onClickOutside);\n document.removeEventListener('mousemove', onMouseMove);\n };\n }, []);\n\n useEffect(() => {\n if (props.gridLayout) {\n const gridEl = document.querySelector(`#${componentId}>.-withinput.grid-container`);\n if (gridElRef.current !== gridEl && gridEl) gridElRef.current = gridEl;\n }\n }, []);\n\n useEffect(() => {\n if (value.length > 0 && value !== valueFromProps && dataSource.length > 0) {\n const newCurrents = dataSource.filter((item: { [id: string]: string }) =>\n value.includes(item[idKey] as never));\n\n setValueFromProps(value);\n setCurrents(newCurrents);\n }\n }, [dataSource.length, value.length]);\n\n useEffect(() => {\n if (!_.isEqual(dataSource, dataCombo)) {\n const filteredDataCombo = remoteSearch\n ? dataSource\n : getFilteredMultipleDataCombo({\n currents, dataSource, descriptionKey, inputText: inputValue,\n });\n\n setDataCombo(filteredDataCombo);\n setSelected(filteredDataCombo.length > 0 ? dataCombo[0] : null);\n }\n }, [dataSource]);\n\n return (\n <span\n id={componentId}\n ref={componentRef}\n className=\"select-component\">\n <InputTextBase\n {...props}\n inputRef={(ref) => {\n if (props.inputRef) {\n if (!_.isFunction(props.inputRef)) {\n props.inputRef.current = ref;\n } else {\n props.inputRef(ref);\n }\n }\n inputTextRef.current = ref;\n }}\n autoComplete=\"off\"\n value={inputValue.toString()}\n readOnly={shouldBeReadOnly()}\n onFocus={() => { onFocus(); }}\n onBlur={(e: CustomInputEvent) => { onBlur(e); }}\n onChange={(e?: CustomInputEvent) => {\n if (e) onFilter(e.target.value);\n }}\n onClick={onFocus}\n onKeyDown={onInputKeyDown}\n customClassForLabel={customClassForLabel}\n customClassForWrapper={\n `selectwrapper ${(props.readOnly || shouldDisable() || shouldBeReadOnly()) && ' -undigitable'} ${customClassForWrapper}`\n }\n customClassForInputContent={`multiselect ${customClassForInputContent}`}\n inputBaseRef={(r: HTMLDivElement | HTMLTextAreaElement) => { selectWrapper.current = r; }}\n handlerSetOnDenied={setOnDenied}\n rightElements={[\n ...rightElements,\n <ActionButtons\n key=\"action-buttons-multiselect\"\n showClearButton={showClearButton}\n disabled={shouldDisable() || shouldBeReadOnly()}\n dropDownOpened={opened}\n handlerClear={() => {\n if (shouldDisable()) return null;\n return onClearClick();\n }}\n handlerOpenClose={onOpenClose}\n customClassForSideButtons={customClassForSideButtons} />,\n ]}>\n <Selecteds\n {...props}\n currents={currents}\n handlerOnUnselect={onUnselect} />\n </InputTextBase>\n {opened &&\n <Dropdown\n {...props}\n selected={selected}\n selectFieldRef={componentRef}\n dropdownRef={dropdownRef}\n gridWrapperStyle={props.gridLayout && gridElRef.current\n ? window.getComputedStyle(gridElRef.current)\n : undefined}\n handleOnSelect={onSelect}\n handleOnFilter={onFilter}\n handleOnKeydown={onInputKeyDown}\n handleOnBlur={() => onBlur}\n handleOnFocus={onFocus}\n opened={opened}\n dataCombo={dataCombo}\n currents={currents}\n dropdownWidth={dropdownMaxWidth || dropdownWidth || 0}\n onEndReached={onEndReached}\n onEndReachedThreshold={onEndReachedThreshold}\n itemsCount={itemsCount} />\n }\n <Hint visible={!!hint && hintPosition === 'below'} customClass=\"hint\" description={hint} />\n </span>\n );\n};\n\nexport default MultipleSelect;\n"],"names":["MultipleSelect","props","idKey","dataSource","handlerClear","value","remoteSearch","descriptionKey","showClearButton","rightElements","hint","hintPosition","customClassForLabel","customClassForWrapper","customClassForInputContent","customClassForSideButtons","disabled","dropdownMaxWidth","undefined","onEndReached","onEndReachedThreshold","itemsCount","dataCombo","setDataCombo","useState","currents","setCurrents","selected","setSelected","inputValue","setInputValue","opened","setOpened","dropdownWidth","setDropdownWidth","insideComponent","setInsideComponent","onDenied","setOnDeniedSelect","valueFromProps","setValueFromProps","componentId","uuid","v1","componentRef","useRef","dropdownRef","selectWrapper","gridElRef","inputTextRef","descriptionKeyIsString","insideComponents","onScreenResize","current","clientWidth","onClickOutside","event","target","includes","className","contains","onMouseMove","idDropdown","parentElement","id","dropdownElement","document","getElementById","keepDropdownOpen","Boolean","onClearClick","onSelect","onFilter","filteredValue","selectedFilter","onSearch","dataComboFilter","length","getFilteredMultipleDataCombo","inputText","onFocus","dropdownWidthFocus","select","currentsSelect","focus","map","i","onUnselect","result","filter","item","onOpenClose","prevState","onBlur","e","onInputKeyDown","keyCode","constants","ENTER","key","TAB","preventDefault","some","ARROW_UP","ARROW_DOWN","index","findIndex","d","BACKSPACE","currentsKeyDown","_","dropRight","setOnDenied","denied","shouldDisable","hideContent","shouldBeReadOnly","readOnly","useEffect","window","addEventListener","removeEventListener","gridLayout","gridEl","querySelector","newCurrents","isEqual","filteredDataCombo","ref","inputRef","isFunction","toString","r","getComputedStyle"],"mappings":";;;;;;;;;;;AAeA,MAAMA,iBAAiBA,CAACC,UAAgC;AACtD,QAAM;AAAA,IACJC;AAAAA,IAAOC,aAAa,CAAA;AAAA,IAAIC;AAAAA,IAAcC,QAAQ,CAAA;AAAA,IAAIC,eAAe;AAAA,IAAOC;AAAAA,IACxEC;AAAAA,IAAiBC,gBAAgB,CAAA;AAAA,IAAIC;AAAAA,IAAMC,eAAe;AAAA,IAASC;AAAAA,IACnEC;AAAAA,IAAuBC;AAAAA,IAA4BC;AAAAA,IAA2BC,WAAW;AAAA,IACzFC,mBAAmBC;AAAA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,QAChB,cAAc,MAAM;AAClB,UAAImF,cAAAA,EAAiB,QAAO;AAC5B,aAAO5C,aAAAA;AAAAA,IACT,GACA,kBAAkBqB,aAClB,0BAAA,GATI,4BASiD,CAAG,GAE5D,UAAA,oBAAC,WAAA,EACC,GAAI1F,OACJ,UACA,mBAAmBsF,YAAW,GAClC;AAAA,IACCxD,UACC,oBAAC,UAAA,EACC,GAAI9B,OACJ,UACA,gBAAgB2C,cAChB,aACA,kBAAkB3C,MAAMyH,cAAc1E,UAAUK,UAC5CkE,OAAOc,iBAAiBrF,UAAUK,OAAO,IACzCnC,QACJ,gBAAgBqD,UAChB,gBAAgBC,UAChB,iBAAiBuB,gBACjB,cAAc,MAAMF,QACpB,eAAeb,SACf,QACA,WACA,UACA,eAAe/D,oBAAoBgB,iBAAiB,GACpD,cACA,uBACA,YAAuB;AAAA,IAE3B,oBAAC,MAAA,EAAK,SAAS,CAAC,CAACvB,QAAQC,iBAAiB,SAAS,aAAY,QAAO,aAAaD,KAAAA,CAAK;AAAA,EAAA,GAC1F;AAEJ;"}
|
|
@@ -31,7 +31,10 @@ const SimpleSelect = (props) => {
|
|
|
31
31
|
customClassForInputContent,
|
|
32
32
|
customClassForLabel,
|
|
33
33
|
customClassForSideButtons,
|
|
34
|
-
dropdownMaxWidth = void 0
|
|
34
|
+
dropdownMaxWidth = void 0,
|
|
35
|
+
onEndReached,
|
|
36
|
+
onEndReachedThreshold,
|
|
37
|
+
itemsCount
|
|
35
38
|
} = props;
|
|
36
39
|
const descriptionKeyIsString = typeof descriptionKey === "string";
|
|
37
40
|
const dataSourceWithAllOptions = allOptions ? [{
|
|
@@ -258,7 +261,7 @@ const SimpleSelect = (props) => {
|
|
|
258
261
|
}, handlerOpenClose: onOpenClose, customClassForSideButtons }, "action-buttons-simpleselect")] }),
|
|
259
262
|
opened && /* @__PURE__ */ jsx(Dropdown, { ...props, opened, selected, inputValue: inputText, selectFieldRef: componentRef, dropdownRef, searchOnDropdown, gridWrapperStyle: gridLayout && gridElement.current ? window.getComputedStyle(gridElement.current) : void 0, handleOnSelect: (dataSelected) => {
|
|
260
263
|
if (dataSelected) onSelect(dataSelected);
|
|
261
|
-
}, handleOnFilter: (valueFilter_0) => onFilter(valueFilter_0), handleOnKeydown: onInputKeyDown, handleOnBlur: () => onBlur, handleOnFocus: onFocus, dataCombo, searchNotFoundText, dropdownWidth: dropdownMaxWidth || dropdownWidth || 0 })
|
|
264
|
+
}, handleOnFilter: (valueFilter_0) => onFilter(valueFilter_0), handleOnKeydown: onInputKeyDown, handleOnBlur: () => onBlur, handleOnFocus: onFocus, dataCombo, searchNotFoundText, dropdownWidth: dropdownMaxWidth || dropdownWidth || 0, onEndReached, onEndReachedThreshold, itemsCount })
|
|
262
265
|
] });
|
|
263
266
|
};
|
|
264
267
|
export {
|