linear-react-components-ui 2.2.0-beta.8 → 2.2.0
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 +14 -3
- package/lib/hooks/useScrollEndReached/index.js.map +1 -1
- package/lib/hooks/useScrollEndReached/types.d.ts +1 -0
- package/lib/inputs/select/Dropdown.js +4 -2
- package/lib/inputs/select/Dropdown.js.map +1 -1
- package/lib/inputs/select/multiple/index.js +3 -2
- package/lib/inputs/select/multiple/index.js.map +1 -1
- package/lib/inputs/select/simple/index.js +3 -2
- package/lib/inputs/select/simple/index.js.map +1 -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;
|
|
@@ -15,10 +15,20 @@ function getCurrentThreshold(scrollableElement, scrollThreshold) {
|
|
|
15
15
|
function useScrollEndReached({
|
|
16
16
|
elementRef,
|
|
17
17
|
onEndReached,
|
|
18
|
-
onEndReachedThreshold = 0.25
|
|
18
|
+
onEndReachedThreshold = 0.25,
|
|
19
|
+
itemsCount
|
|
19
20
|
}) {
|
|
20
21
|
const lastScrollTop = useRef(null);
|
|
21
22
|
const enableOnEndReached = useRef(true);
|
|
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]);
|
|
22
32
|
const onScrollEndReached = async () => {
|
|
23
33
|
const element = elementRef.current;
|
|
24
34
|
if (element && onEndReached) {
|
|
@@ -31,12 +41,13 @@ function useScrollEndReached({
|
|
|
31
41
|
lastScrollTop.current = scrollTop;
|
|
32
42
|
const scrollOffset = scrollHeight - clientHeight - scrollTop - 1;
|
|
33
43
|
const threshold = getCurrentThreshold(element, onEndReachedThreshold);
|
|
34
|
-
if (scrollOffset <= threshold && isScrollingDown && enableOnEndReached.current) {
|
|
44
|
+
if (scrollOffset <= threshold && isScrollingDown && enableOnEndReached.current && !waitingForItems.current) {
|
|
35
45
|
enableOnEndReached.current = false;
|
|
46
|
+
waitingForItems.current = itemsCount !== void 0;
|
|
36
47
|
try {
|
|
37
48
|
await onEndReached();
|
|
38
49
|
} finally {
|
|
39
|
-
enableOnEndReached.current =
|
|
50
|
+
enableOnEndReached.current = itemsCount === void 0;
|
|
40
51
|
}
|
|
41
52
|
}
|
|
42
53
|
}
|
|
@@ -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 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}: ScrollEndReachedParams) {\n const lastScrollTop = useRef<number | null>(null);\n const enableOnEndReached = useRef(true);\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 ) {\n enableOnEndReached.current = false;\n try {\n await onEndReached();\n } finally {\n enableOnEndReached.current =
|
|
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,iBACQ;AACR,QAAMC,gBAAgB;AACtB,QAAMC,gBAAgB;AACtB,MAAIF,kBAAkBC,cAAe,QAAOA;AAC5C,MAAID,kBAAkBE,cAAe,QAAOA;AAC5C,QAAM;AAAA,IAAEC;AAAAA,IAAcC;AAAAA,EAAAA,IAAiBL;AACvC,QAAMM,mBAAmBC,KAAKC,IAAIJ,eAAeC,cAAc,CAAC;AAChE,QAAMI,gBAAgBF,KAAKG,IAAIL,cAAcC,gBAAgB;AAE7D,SAAOC,KAAKI,MAAMF,gBAAgBR,eAAe;AACnD;AAEO,SAASW,oBAAoB;AAAA,EAClCC;AAAAA,EACAC;AAAAA,EACAC,wBAAwB;AAAA,EACxBC;AACsB,GAAG;AACzB,QAAMC,gBAAgBC,OAAsB,IAAI;AAChD,QAAMC,qBAAqBD,OAAO,IAAI;AACtC,QAAME,iBAAiBF,OAA2BF,UAAU;AAC5D,QAAMK,kBAAkBH,OAAO,KAAK;AAEpCI,YAAU,MAAM;AACd,QAAIN,eAAeO,UAAaH,eAAeI,YAAYR,YAAY;AACrEI,qBAAeI,UAAUR;AACzBK,sBAAgBG,UAAU;AAC1BL,yBAAmBK,UAAU;AAAA,IAC/B;AAAA,EACF,GAAG,CAACR,UAAU,CAAC;AAEf,QAAMS,qBAAqB,YAAY;AACrC,UAAMC,UAAUb,WAAWW;AAE3B,QAAIE,WAAWZ,cAAc;AAC3B,YAAM;AAAA,QAAEa;AAAAA,QAAWvB;AAAAA,QAAcC;AAAAA,MAAAA,IAAiBqB;AAClD,YAAME,kBACJX,cAAcO,YAAY,QAAQG,YAAYV,cAAcO;AAC9DP,oBAAcO,UAAUG;AACxB,YAAME,eAAezB,eAAeC,eAAesB,YAAY;AAC/D,YAAMG,YAAY/B,oBAAoB2B,SAASX,qBAAqB;AAEpE,UACEc,gBAAgBC,aAChBF,mBACAT,mBAAmBK,WACnB,CAACH,gBAAgBG,SACjB;AACAL,2BAAmBK,UAAU;AAC7BH,wBAAgBG,UAAUR,eAAeO;AACzC,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;"}
|
|
@@ -28,7 +28,8 @@ const Dropdown = (props) => {
|
|
|
28
28
|
idKey,
|
|
29
29
|
selectFieldRef,
|
|
30
30
|
onEndReached,
|
|
31
|
-
onEndReachedThreshold
|
|
31
|
+
onEndReachedThreshold,
|
|
32
|
+
itemsCount
|
|
32
33
|
} = props;
|
|
33
34
|
const [dropdownDynamicStyles, setDropdownDynamicStyles] = useState(returnDropdownDynamicStyles({
|
|
34
35
|
...props
|
|
@@ -43,7 +44,8 @@ const Dropdown = (props) => {
|
|
|
43
44
|
useScrollEndReached({
|
|
44
45
|
elementRef: dropdownRef,
|
|
45
46
|
onEndReached,
|
|
46
|
-
onEndReachedThreshold
|
|
47
|
+
onEndReachedThreshold,
|
|
48
|
+
itemsCount: itemsCount ?? dataCombo.length
|
|
47
49
|
});
|
|
48
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: {
|
|
49
51
|
width: dropdownWidth,
|
|
@@ -1 +1 @@
|
|
|
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,\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 });\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","dropdownDynamicStyles","setDropdownDynamicStyles","useState","helper","useEffect","current","useScrollEndReached","elementRef","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,IAChEC;AAAAA,IAAeC;AAAAA,IAAQC;AAAAA,IAAgBC,WAAW;AAAA,IAAMC;AAAAA,IAAkBC;AAAAA,IAC1EC;AAAAA,IAAoBC;AAAAA,IAAOC;AAAAA,IAAgBC;AAAAA,IAAcC;AAAAA,IAAuBC;AAAAA,EAAAA,IAC9EvB;AACJ,QAAM,CAACwB,uBAAuBC,wBAAwB,IACpDC,SAASC,4BAAmC;AAAA,IAAE,GAAG3B;AAAAA,EAAAA,CAAO,CAAC;AAE3D4B,YAAU,MAAM;AACd,QAAItB,YAAYuB,SAAS;AACvBJ,+BAAyBE,4BAAmC;AAAA,QAAE,GAAG3B;AAAAA,MAAAA,CAAO,CAAC;AAAA,IAC3E;AAAA,EACF,GAAG,CAACM,YAAYuB,SAAS1B,SAAS,CAAC;AAEnC2B,sBAAoB;AAAA,IAClBC,YAAYzB;AAAAA,IACZe;AAAAA,IACAC;AAAAA,IACAC,YAAYA,cAAcpB,UAAU6B;AAAAA,EAAAA,CACrC;AAED,6BACG,eAAA,EACC,OAAM,QACN,cAAcR,sBAAsBS,MACpC,aAAaT,sBAAsBU,KACnC,WAAWd,gBAAgBS,SAC3B,UAAA,qBAAC,OAAA,EACC,WAAU,mBACV,KAAKvB,aACL,OAAO;AAAA,IACL6B,OAAO3B;AAAAA,IACP4B,YAAY3B,mBAAmBA,iBAAiB4B,cAAc;AAAA,IAC9DC,WAAWd,sBAAsBc;AAAAA,EAAAA,GAElCtB,UAAAA;AAAAA,IAAAA,oBACC,qBAAC,O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AI,EAAA,CAAE;AAAA,MAAA,EAAA,CAC5G,EAAA,GAnBK,gBAAgBA,KAAKxB,KAAK,CAAC,GAoBlC;AAAA,IAEJ,CAAC;AAAA,IACAhB,aAAaA,UAAU6B,WAAW,yBAChC,OAAA,EAAI,WAAU,YAAYd,UAAAA,mBAAAA,CAAmB;AAAA,EAAA,EAAA,CAElD,EAAA,CACF;AAEJ;"}
|
|
@@ -28,7 +28,8 @@ const MultipleSelect = (props) => {
|
|
|
28
28
|
disabled = false,
|
|
29
29
|
dropdownMaxWidth = void 0,
|
|
30
30
|
onEndReached,
|
|
31
|
-
onEndReachedThreshold
|
|
31
|
+
onEndReachedThreshold,
|
|
32
|
+
itemsCount
|
|
32
33
|
} = props;
|
|
33
34
|
const [dataCombo, setDataCombo] = useState(dataSource);
|
|
34
35
|
const [currents, setCurrents] = useState([]);
|
|
@@ -227,7 +228,7 @@ const MultipleSelect = (props) => {
|
|
|
227
228
|
if (shouldDisable()) return null;
|
|
228
229
|
return onClearClick();
|
|
229
230
|
}, handlerOpenClose: onOpenClose, customClassForSideButtons }, "action-buttons-multiselect")], children: /* @__PURE__ */ jsx(Selecteds, { ...props, currents, handlerOnUnselect: onUnselect }) }),
|
|
230
|
-
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 }),
|
|
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 }),
|
|
231
232
|
/* @__PURE__ */ jsx(Hint, { visible: !!hint && hintPosition === "below", customClass: "hint", description: hint })
|
|
232
233
|
] });
|
|
233
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, onEndReached, onEndReachedThreshold,\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 }\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","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,IAAWC;AAAAA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,cAAAA,EAAiB,QAAO;AAC5B,aAAO5C,aAAAA;AAAAA,IACT,GACA,kBAAkBqB,aAClB,0BAAA,GATI,4BASiD,CAAG,GAE5D,UAAA,oBAAC,WAAA,EACC,GAAIzF,OACJ,UACA,mBAAmBqF,YAAW,GAClC;AAAA,IACCxD,UACC,oBAAC,UAAA,EACC,GAAI7B,OACJ,UACA,gBAAgB0C,cAChB,aACA,kBAAkB1C,MAAMwH,cAAc1E,UAAUK,UAC5CkE,OAAOc,iBAAiBrF,UAAUK,OAAO,IACzClC,QACJ,gBAAgBoD,UAChB,gBAAgBC,UAChB,iBAAiBuB,gBACjB,cAAc,MAAMF,QACpB,eAAeb,SACf,QACA,WACA,UACA,eAAe9D,oBAAoBe,iBAAiB,GACpD,cACA,uBAA6C;AAAA,IAEjD,oBAAC,MAAA,EAAK,SAAS,CAAC,CAACtB,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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A,QAAyB;AAClC,UAAIA,IAAGtB,UAASsB,IAAErC,OAAOpD,KAAK;AAAA,IAChC,GACA,SAAS2E,SACT,WAAWe,gBACX,qBACA,uBACE,kBAAkB9F,MAAMoH,YAAYH,cAAAA,KAAmBE,uBAAuB,eAAe,IAAIvG,qBAAqB,IAExH,4BAA4B,eAAeC,0BAA0B,IACrE,cAAc,CAACsH,MAA4C;AAAErF,oBAAcM,UAAU+E;AAAAA,IAAG,GACxF,oBAAoBpB,aACpB,eAAe,CACb,GAAGvG,eACH,oBAAC,eAAA,EAEC,iBACA,UAAUyG,mBAAmBE,iBAAAA,GAC7B,gBAAgBrF,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;"}
|
|
@@ -33,7 +33,8 @@ const SimpleSelect = (props) => {
|
|
|
33
33
|
customClassForSideButtons,
|
|
34
34
|
dropdownMaxWidth = void 0,
|
|
35
35
|
onEndReached,
|
|
36
|
-
onEndReachedThreshold
|
|
36
|
+
onEndReachedThreshold,
|
|
37
|
+
itemsCount
|
|
37
38
|
} = props;
|
|
38
39
|
const descriptionKeyIsString = typeof descriptionKey === "string";
|
|
39
40
|
const dataSourceWithAllOptions = allOptions ? [{
|
|
@@ -260,7 +261,7 @@ const SimpleSelect = (props) => {
|
|
|
260
261
|
}, handlerOpenClose: onOpenClose, customClassForSideButtons }, "action-buttons-simpleselect")] }),
|
|
261
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) => {
|
|
262
263
|
if (dataSelected) onSelect(dataSelected);
|
|
263
|
-
}, handleOnFilter: (valueFilter_0) => onFilter(valueFilter_0), handleOnKeydown: onInputKeyDown, handleOnBlur: () => onBlur, handleOnFocus: onFocus, dataCombo, searchNotFoundText, dropdownWidth: dropdownMaxWidth || dropdownWidth || 0, onEndReached, onEndReachedThreshold })
|
|
264
|
+
}, handleOnFilter: (valueFilter_0) => onFilter(valueFilter_0), handleOnKeydown: onInputKeyDown, handleOnBlur: () => onBlur, handleOnFocus: onFocus, dataCombo, searchNotFoundText, dropdownWidth: dropdownMaxWidth || dropdownWidth || 0, onEndReached, onEndReachedThreshold, itemsCount })
|
|
264
265
|
] });
|
|
265
266
|
};
|
|
266
267
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/lib/inputs/select/simple/index.tsx"],"sourcesContent":["import { KeyboardEvent as KeyboardEventReact, useEffect, useRef, useState } from 'react';\nimport * as uuid from 'uuid';\nimport _ from 'lodash';\nimport Dropdown from '../Dropdown';\nimport ActionButtons from '../ActionButtons';\nimport * as constants from '../../../internals/constants';\nimport { getFilteredSimpleDataCombo } from '../helper';\nimport { DataCombo } from '../../../@types/DataCombo';\nimport { OnDenied } from '../../../@types/PermissionAttr';\nimport InputTextBase from '../../base/InputTextBase';\nimport { ISimpleSelectProps } from '../types';\nimport { CustomInputEvent } from '../../base/types';\n\nconst SimpleSelect = (props: ISimpleSelectProps) => {\n const {\n value, descriptionKey, dataSource = [], gridLayout, onSearch, disabled, readOnly,\n openDropdownOnFocus = true, selectFirstOnEnter = false, idKey, remoteSearch = false, name = '',\n undigitable, searchOnDropdown = false, allOptions = undefined, showClearButton = false,\n searchNotFoundText, rightElements = [], customClassForWrapper, customClassForInputContent, \n customClassForLabel, customClassForSideButtons, dropdownMaxWidth = undefined,\n onEndReached, onEndReachedThreshold,\n } = props;\n\n const descriptionKeyIsString = typeof descriptionKey === 'string';\n const dataSourceWithAllOptions = allOptions\n ? [{\n [idKey]: allOptions.idValue,\n [descriptionKeyIsString ?\n descriptionKey :\n descriptionKey(allOptions.label)]: allOptions.label,\n }, ...dataSource]\n : dataSource;\n const [dataCombo, setDataCombo] = useState<DataCombo[]>(dataSourceWithAllOptions);\n const [selected, setSelected] = useState<DataCombo | null>(null);\n const [inputText, setInputText] = useState('');\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 [isTyping, setIsTyping] = useState(false);\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n const componentId = `select-component-${name}-${uuid.v1()}`;\n const componentRef = useRef<HTMLInputElement>(null);\n const selectWrapper = useRef<HTMLDivElement>(null);\n const gridElement = useRef<Element>(null);\n const inputTextRef = useRef<HTMLInputElement | HTMLTextAreaElement | null>(null);\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 (target !== selectWrapper.current && !selectWrapper.current?.contains(target as Node) &&\n !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 getSelectEvent = (selectedEvent?: DataCombo) => (\n {\n target: {\n value: selectedEvent ? selectedEvent[idKey] : undefined,\n name,\n },\n }\n );\n\n const onChange = (selectedChange?: DataCombo) => {\n if (props.onChange) {\n const event = getSelectEvent(selectedChange);\n props.onChange(event);\n }\n };\n\n const onFilter = (valueFilter: string) => {\n let selectedFilter = null;\n if (remoteSearch) {\n if (onSearch) onSearch(valueFilter);\n } else {\n const dataComboFilter = getFilteredSimpleDataCombo({\n inputText: valueFilter,\n descriptionKey,\n dataSource: dataSourceWithAllOptions,\n });\n\n if (dataComboFilter && dataComboFilter.length > 0) {\n selectedFilter = dataComboFilter[0];\n setSelected(selectedFilter);\n }\n setDataCombo(dataComboFilter);\n }\n setOpened(true);\n setInputText(valueFilter);\n if (selectedFilter) {\n if ((descriptionKeyIsString && valueFilter === selectedFilter[descriptionKey])\n || (!descriptionKeyIsString && valueFilter === descriptionKey(selectedFilter))) {\n onChange(selectedFilter);\n }\n }\n };\n\n const onSelect = (selectedDropdown: DataCombo) => {\n if (!selectedDropdown) return;\n setSelected(selectedDropdown);\n\n if (descriptionKeyIsString) setInputText(selectedDropdown[descriptionKey]);\n else setInputText(descriptionKey(selectedDropdown));\n new Promise((resolve) => {\n resolve(onChange(selectedDropdown));\n }).finally(() => {\n if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();\n setOpened(false);\n });\n dropdownRef.current?.focus();\n };\n\n const onOpenClose = () => {\n setOpened(prevState => !prevState);\n if (selectWrapper.current) setDropdownWidth(selectWrapper.current.clientWidth);\n };\n\n const onFocus = () => {\n if (openDropdownOnFocus) setOpened(true);\n if (selectWrapper) {\n const dropdownWidthFocus = selectWrapper.current ? selectWrapper.current.clientWidth : 0;\n setDropdownWidth(dropdownWidthFocus);\n }\n };\n\n const onBlur = () => {\n if (props.onBlur) {\n const event = getSelectEvent(selected);\n props.onBlur(event);\n if (selected && (descriptionKeyIsString && inputText !== selected[descriptionKey])\n || (!descriptionKeyIsString && inputText !== descriptionKey(selected))) {\n setSelected(null);\n setInputText(inputText);\n new Promise((resolve) => {\n resolve(onChange(null));\n }).finally(() => {\n onChange();\n });\n }\n }\n if (!insideComponent) {\n setOpened(false);\n setIsTyping(false);\n setDataCombo(dataSourceWithAllOptions);\n }\n };\n\n const onInputKeyDown = (e: CustomInputEvent | KeyboardEventReact) => {\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 onSelect(selected);\n } else if ([constants.keyCodes.ARROW_UP, constants.keyCodes.ARROW_DOWN].includes(e.keyCode)) {\n if (!opened) setOpened(true);\n let index = dataCombo.length > 0\n ? dataCombo.findIndex(d => selected &&\n d[idKey] === selected[idKey])\n : 0;\n if (e.keyCode === constants.keyCodes.ARROW_DOWN) {\n index = (dataCombo\n && index === dataCombo.length - 1\n ? 0\n : index + 1);\n } else {\n index = (dataCombo\n && index === 0\n ? dataCombo?.length - 1\n : index - 1);\n }\n setSelected(dataCombo[index]);\n if (descriptionKeyIsString) setInputText(dataCombo[index][descriptionKey]);\n if (!descriptionKeyIsString) setInputText(descriptionKey(dataCombo[index]));\n }\n }\n if (!isTyping) setIsTyping(true);\n };\n\n const onClearClick = () => {\n new Promise((resolve) => {\n resolve(onChange(null));\n }).finally(() => {\n setSelected(null);\n setInputText('');\n onChange();\n if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();\n setOpened(false);\n });\n };\n\n const setOnDenied = (onDeniedSelect: OnDenied) => {\n setOnDeniedSelect(onDeniedSelect);\n };\n\n const shouldDisable = () =>\n disabled || (onDenied && (onDenied.disabled || onDenied.hideContent));\n\n const shouldBeReadOnly = () => readOnly || (onDenied && (onDenied.readOnly));\n\n useEffect(() => {\n window.addEventListener('resize', onScreenResize);\n document.addEventListener('click', onClickOutside);\n document.addEventListener('mousemove', onMouseMove);\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 (gridLayout) {\n const gridEl = document.querySelector(`#${componentId}>.-withinput.grid-container`);\n if (gridElement.current !== gridEl && gridEl) gridElement.current = gridEl;\n }\n }, [gridLayout]);\n\n useEffect(() => {\n if (dataSourceWithAllOptions.length > 0) {\n let newCurrent = null;\n if (value || value === 0) {\n newCurrent = dataSourceWithAllOptions.find(i => (value || value === 0)\n && i[idKey]?.toString().toLowerCase() === value?.toString().toLowerCase());\n } else if (dataSourceWithAllOptions.length > 0 && selectFirstOnEnter) {\n newCurrent = dataSourceWithAllOptions[0];\n }\n\n setSelected(newCurrent);\n if (descriptionKeyIsString) setInputText(newCurrent ? newCurrent[descriptionKey] : '');\n else setInputText(newCurrent ? descriptionKey(newCurrent) : '');\n }\n\n if (dataSourceWithAllOptions.length === 0 && inputText) {\n setInputText('');\n }\n }, [dataSourceWithAllOptions.length, value]);\n\n useEffect(() => {\n if (!_.isEqual(dataCombo, dataSourceWithAllOptions)) {\n const dataComboFilteredSimple = (undigitable || remoteSearch || !isTyping) ?\n dataSourceWithAllOptions\n : getFilteredSimpleDataCombo({\n inputText, dataSource: dataSourceWithAllOptions, descriptionKey,\n });\n setDataCombo(dataComboFilteredSimple);\n if (dataSourceWithAllOptions.length > 0 && remoteSearch) {\n const data = dataSourceWithAllOptions[0];\n setSelected(data);\n }\n }\n\n if (allOptions) {\n setDataCombo([\n {\n [idKey]: allOptions.idValue,\n [descriptionKeyIsString ?\n descriptionKey :\n descriptionKey(allOptions.label)]: allOptions.label,\n },\n ...dataSource,\n ]);\n }\n }, [JSON.stringify(dataSourceWithAllOptions)]);\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 readOnly={undigitable || shouldBeReadOnly()}\n value={inputText}\n onFocus={onFocus}\n onBlur={onBlur}\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 ${(undigitable || searchOnDropdown || shouldBeReadOnly()) && ' -undigitable'} ${customClassForWrapper}`\n }\n customClassForInputContent={`multiselect ${customClassForInputContent}`}\n inputBaseRef={(r: HTMLDivElement) => { selectWrapper.current = r; }}\n handlerSetOnDenied={(inputOnDenied: OnDenied) => setOnDenied(inputOnDenied)}\n rightElements={[\n ...rightElements,\n <ActionButtons\n key=\"action-buttons-simpleselect\"\n disabled={shouldDisable() || shouldBeReadOnly()}\n showClearButton={showClearButton}\n dropDownOpened={opened}\n handlerClear={() => {\n if (shouldDisable()) return null;\n return onClearClick();\n }}\n handlerOpenClose={onOpenClose}\n customClassForSideButtons={customClassForSideButtons} />,\n ]} />\n {opened &&\n <Dropdown\n {...props}\n opened={opened}\n selected={selected}\n inputValue={inputText}\n selectFieldRef={componentRef}\n dropdownRef={dropdownRef}\n searchOnDropdown={searchOnDropdown}\n gridWrapperStyle={gridLayout && gridElement.current ?\n window.getComputedStyle(gridElement.current)\n : undefined}\n handleOnSelect={(dataSelected?: DataCombo) => {\n if (dataSelected) onSelect(dataSelected);\n }}\n handleOnFilter={(valueFilter: string) => onFilter(valueFilter)}\n handleOnKeydown={onInputKeyDown}\n handleOnBlur={() => onBlur}\n handleOnFocus={onFocus}\n dataCombo={dataCombo}\n searchNotFoundText={searchNotFoundText}\n dropdownWidth={dropdownMaxWidth || dropdownWidth || 0}\n onEndReached={onEndReached}\n onEndReachedThreshold={onEndReachedThreshold} />\n }\n </span>\n );\n};\nexport default SimpleSelect;\n"],"names":["SimpleSelect","props","value","descriptionKey","dataSource","gridLayout","onSearch","disabled","readOnly","openDropdownOnFocus","selectFirstOnEnter","idKey","remoteSearch","name","undigitable","searchOnDropdown","allOptions","undefined","showClearButton","searchNotFoundText","rightElements","customClassForWrapper","customClassForInputContent","customClassForLabel","customClassForSideButtons","dropdownMaxWidth","onEndReached","onEndReachedThreshold","descriptionKeyIsString","dataSourceWithAllOptions","idValue","label","dataCombo","setDataCombo","useState","selected","setSelected","inputText","setInputText","opened","setOpened","dropdownWidth","setDropdownWidth","insideComponent","setInsideComponent","onDenied","setOnDeniedSelect","isTyping","setIsTyping","dropdownRef","useRef","componentId","uuid","componentRef","selectWrapper","gridElement","inputTextRef","onScreenResize","current","clientWidth","onClickOutside","event","target","contains","onMouseMove","idDropdown","parentElement","id","dropdownElement","document","getElementById","keepDropdownOpen","Boolean","getSelectEvent","selectedEvent","onChange","selectedChange","onFilter","valueFilter","selectedFilter","dataComboFilter","getFilteredSimpleDataCombo","length","onSelect","selectedDropdown","Promise","resolve","finally","focus","onOpenClose","prevState","onFocus","dropdownWidthFocus","onBlur","onInputKeyDown","e","keyCode","constants","ENTER","key","TAB","preventDefault","ARROW_UP","ARROW_DOWN","includes","index","findIndex","d","onClearClick","setOnDenied","onDeniedSelect","shouldDisable","hideContent","shouldBeReadOnly","useEffect","window","addEventListener","removeEventListener","gridEl","querySelector","newCurrent","find","i","toString","toLowerCase","_","isEqual","dataComboFilteredSimple","data","JSON","stringify","ref","inputRef","isFunction","r","inputOnDenied","getComputedStyle","dataSelected"],"mappings":";;;;;;;;;AAaA,MAAMA,eAAeA,CAACC,UAA8B;AAClD,QAAM;AAAA,IACJC;AAAAA,IAAOC;AAAAA,IAAgBC,aAAa,CAAA;AAAA,IAAIC;AAAAA,IAAYC;AAAAA,IAAUC;AAAAA,IAAUC;AAAAA,IACxEC,sBAAsB;AAAA,IAAMC,qBAAqB;AAAA,IAAOC;AAAAA,IAAOC,eAAe;AAAA,IAAOC,OAAO;A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AEJ;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/lib/inputs/select/simple/index.tsx"],"sourcesContent":["import { KeyboardEvent as KeyboardEventReact, useEffect, useRef, useState } from 'react';\nimport * as uuid from 'uuid';\nimport _ from 'lodash';\nimport Dropdown from '../Dropdown';\nimport ActionButtons from '../ActionButtons';\nimport * as constants from '../../../internals/constants';\nimport { getFilteredSimpleDataCombo } from '../helper';\nimport { DataCombo } from '../../../@types/DataCombo';\nimport { OnDenied } from '../../../@types/PermissionAttr';\nimport InputTextBase from '../../base/InputTextBase';\nimport { ISimpleSelectProps } from '../types';\nimport { CustomInputEvent } from '../../base/types';\n\nconst SimpleSelect = (props: ISimpleSelectProps) => {\n const {\n value, descriptionKey, dataSource = [], gridLayout, onSearch, disabled, readOnly,\n openDropdownOnFocus = true, selectFirstOnEnter = false, idKey, remoteSearch = false, name = '',\n undigitable, searchOnDropdown = false, allOptions = undefined, showClearButton = false,\n searchNotFoundText, rightElements = [], customClassForWrapper, customClassForInputContent, \n customClassForLabel, customClassForSideButtons, dropdownMaxWidth = undefined,\n onEndReached, onEndReachedThreshold, itemsCount,\n } = props;\n\n const descriptionKeyIsString = typeof descriptionKey === 'string';\n const dataSourceWithAllOptions = allOptions\n ? [{\n [idKey]: allOptions.idValue,\n [descriptionKeyIsString ?\n descriptionKey :\n descriptionKey(allOptions.label)]: allOptions.label,\n }, ...dataSource]\n : dataSource;\n const [dataCombo, setDataCombo] = useState<DataCombo[]>(dataSourceWithAllOptions);\n const [selected, setSelected] = useState<DataCombo | null>(null);\n const [inputText, setInputText] = useState('');\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 [isTyping, setIsTyping] = useState(false);\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n const componentId = `select-component-${name}-${uuid.v1()}`;\n const componentRef = useRef<HTMLInputElement>(null);\n const selectWrapper = useRef<HTMLDivElement>(null);\n const gridElement = useRef<Element>(null);\n const inputTextRef = useRef<HTMLInputElement | HTMLTextAreaElement | null>(null);\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 (target !== selectWrapper.current && !selectWrapper.current?.contains(target as Node) &&\n !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 getSelectEvent = (selectedEvent?: DataCombo) => (\n {\n target: {\n value: selectedEvent ? selectedEvent[idKey] : undefined,\n name,\n },\n }\n );\n\n const onChange = (selectedChange?: DataCombo) => {\n if (props.onChange) {\n const event = getSelectEvent(selectedChange);\n props.onChange(event);\n }\n };\n\n const onFilter = (valueFilter: string) => {\n let selectedFilter = null;\n if (remoteSearch) {\n if (onSearch) onSearch(valueFilter);\n } else {\n const dataComboFilter = getFilteredSimpleDataCombo({\n inputText: valueFilter,\n descriptionKey,\n dataSource: dataSourceWithAllOptions,\n });\n\n if (dataComboFilter && dataComboFilter.length > 0) {\n selectedFilter = dataComboFilter[0];\n setSelected(selectedFilter);\n }\n setDataCombo(dataComboFilter);\n }\n setOpened(true);\n setInputText(valueFilter);\n if (selectedFilter) {\n if ((descriptionKeyIsString && valueFilter === selectedFilter[descriptionKey])\n || (!descriptionKeyIsString && valueFilter === descriptionKey(selectedFilter))) {\n onChange(selectedFilter);\n }\n }\n };\n\n const onSelect = (selectedDropdown: DataCombo) => {\n if (!selectedDropdown) return;\n setSelected(selectedDropdown);\n\n if (descriptionKeyIsString) setInputText(selectedDropdown[descriptionKey]);\n else setInputText(descriptionKey(selectedDropdown));\n new Promise((resolve) => {\n resolve(onChange(selectedDropdown));\n }).finally(() => {\n if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();\n setOpened(false);\n });\n dropdownRef.current?.focus();\n };\n\n const onOpenClose = () => {\n setOpened(prevState => !prevState);\n if (selectWrapper.current) setDropdownWidth(selectWrapper.current.clientWidth);\n };\n\n const onFocus = () => {\n if (openDropdownOnFocus) setOpened(true);\n if (selectWrapper) {\n const dropdownWidthFocus = selectWrapper.current ? selectWrapper.current.clientWidth : 0;\n setDropdownWidth(dropdownWidthFocus);\n }\n };\n\n const onBlur = () => {\n if (props.onBlur) {\n const event = getSelectEvent(selected);\n props.onBlur(event);\n if (selected && (descriptionKeyIsString && inputText !== selected[descriptionKey])\n || (!descriptionKeyIsString && inputText !== descriptionKey(selected))) {\n setSelected(null);\n setInputText(inputText);\n new Promise((resolve) => {\n resolve(onChange(null));\n }).finally(() => {\n onChange();\n });\n }\n }\n if (!insideComponent) {\n setOpened(false);\n setIsTyping(false);\n setDataCombo(dataSourceWithAllOptions);\n }\n };\n\n const onInputKeyDown = (e: CustomInputEvent | KeyboardEventReact) => {\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 onSelect(selected);\n } else if ([constants.keyCodes.ARROW_UP, constants.keyCodes.ARROW_DOWN].includes(e.keyCode)) {\n if (!opened) setOpened(true);\n let index = dataCombo.length > 0\n ? dataCombo.findIndex(d => selected &&\n d[idKey] === selected[idKey])\n : 0;\n if (e.keyCode === constants.keyCodes.ARROW_DOWN) {\n index = (dataCombo\n && index === dataCombo.length - 1\n ? 0\n : index + 1);\n } else {\n index = (dataCombo\n && index === 0\n ? dataCombo?.length - 1\n : index - 1);\n }\n setSelected(dataCombo[index]);\n if (descriptionKeyIsString) setInputText(dataCombo[index][descriptionKey]);\n if (!descriptionKeyIsString) setInputText(descriptionKey(dataCombo[index]));\n }\n }\n if (!isTyping) setIsTyping(true);\n };\n\n const onClearClick = () => {\n new Promise((resolve) => {\n resolve(onChange(null));\n }).finally(() => {\n setSelected(null);\n setInputText('');\n onChange();\n if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();\n setOpened(false);\n });\n };\n\n const setOnDenied = (onDeniedSelect: OnDenied) => {\n setOnDeniedSelect(onDeniedSelect);\n };\n\n const shouldDisable = () =>\n disabled || (onDenied && (onDenied.disabled || onDenied.hideContent));\n\n const shouldBeReadOnly = () => readOnly || (onDenied && (onDenied.readOnly));\n\n useEffect(() => {\n window.addEventListener('resize', onScreenResize);\n document.addEventListener('click', onClickOutside);\n document.addEventListener('mousemove', onMouseMove);\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 (gridLayout) {\n const gridEl = document.querySelector(`#${componentId}>.-withinput.grid-container`);\n if (gridElement.current !== gridEl && gridEl) gridElement.current = gridEl;\n }\n }, [gridLayout]);\n\n useEffect(() => {\n if (dataSourceWithAllOptions.length > 0) {\n let newCurrent = null;\n if (value || value === 0) {\n newCurrent = dataSourceWithAllOptions.find(i => (value || value === 0)\n && i[idKey]?.toString().toLowerCase() === value?.toString().toLowerCase());\n } else if (dataSourceWithAllOptions.length > 0 && selectFirstOnEnter) {\n newCurrent = dataSourceWithAllOptions[0];\n }\n\n setSelected(newCurrent);\n if (descriptionKeyIsString) setInputText(newCurrent ? newCurrent[descriptionKey] : '');\n else setInputText(newCurrent ? descriptionKey(newCurrent) : '');\n }\n\n if (dataSourceWithAllOptions.length === 0 && inputText) {\n setInputText('');\n }\n }, [dataSourceWithAllOptions.length, value]);\n\n useEffect(() => {\n if (!_.isEqual(dataCombo, dataSourceWithAllOptions)) {\n const dataComboFilteredSimple = (undigitable || remoteSearch || !isTyping) ?\n dataSourceWithAllOptions\n : getFilteredSimpleDataCombo({\n inputText, dataSource: dataSourceWithAllOptions, descriptionKey,\n });\n setDataCombo(dataComboFilteredSimple);\n if (dataSourceWithAllOptions.length > 0 && remoteSearch) {\n const data = dataSourceWithAllOptions[0];\n setSelected(data);\n }\n }\n\n if (allOptions) {\n setDataCombo([\n {\n [idKey]: allOptions.idValue,\n [descriptionKeyIsString ?\n descriptionKey :\n descriptionKey(allOptions.label)]: allOptions.label,\n },\n ...dataSource,\n ]);\n }\n }, [JSON.stringify(dataSourceWithAllOptions)]);\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 readOnly={undigitable || shouldBeReadOnly()}\n value={inputText}\n onFocus={onFocus}\n onBlur={onBlur}\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 ${(undigitable || searchOnDropdown || shouldBeReadOnly()) && ' -undigitable'} ${customClassForWrapper}`\n }\n customClassForInputContent={`multiselect ${customClassForInputContent}`}\n inputBaseRef={(r: HTMLDivElement) => { selectWrapper.current = r; }}\n handlerSetOnDenied={(inputOnDenied: OnDenied) => setOnDenied(inputOnDenied)}\n rightElements={[\n ...rightElements,\n <ActionButtons\n key=\"action-buttons-simpleselect\"\n disabled={shouldDisable() || shouldBeReadOnly()}\n showClearButton={showClearButton}\n dropDownOpened={opened}\n handlerClear={() => {\n if (shouldDisable()) return null;\n return onClearClick();\n }}\n handlerOpenClose={onOpenClose}\n customClassForSideButtons={customClassForSideButtons} />,\n ]} />\n {opened &&\n <Dropdown\n {...props}\n opened={opened}\n selected={selected}\n inputValue={inputText}\n selectFieldRef={componentRef}\n dropdownRef={dropdownRef}\n searchOnDropdown={searchOnDropdown}\n gridWrapperStyle={gridLayout && gridElement.current ?\n window.getComputedStyle(gridElement.current)\n : undefined}\n handleOnSelect={(dataSelected?: DataCombo) => {\n if (dataSelected) onSelect(dataSelected);\n }}\n handleOnFilter={(valueFilter: string) => onFilter(valueFilter)}\n handleOnKeydown={onInputKeyDown}\n handleOnBlur={() => onBlur}\n handleOnFocus={onFocus}\n dataCombo={dataCombo}\n searchNotFoundText={searchNotFoundText}\n dropdownWidth={dropdownMaxWidth || dropdownWidth || 0}\n onEndReached={onEndReached}\n onEndReachedThreshold={onEndReachedThreshold}\n itemsCount={itemsCount} />\n }\n </span>\n );\n};\nexport default SimpleSelect;\n"],"names":["SimpleSelect","props","value","descriptionKey","dataSource","gridLayout","onSearch","disabled","readOnly","openDropdownOnFocus","selectFirstOnEnter","idKey","remoteSearch","name","undigitable","searchOnDropdown","allOptions","undefined","showClearButton","searchNotFoundText","rightElements","customClassForWrapper","customClassForInputContent","customClassForLabel","customClassForSideButtons","dropdownMaxWidth","onEndReached","onEndReachedThreshold","itemsCount","descriptionKeyIsString","dataSourceWithAllOptions","idValue","label","dataCombo","setDataCombo","useState","selected","setSelected","inputText","setInputText","opened","setOpened","dropdownWidth","setDropdownWidth","insideComponent","setInsideComponent","onDenied","setOnDeniedSelect","isTyping","setIsTyping","dropdownRef","useRef","componentId","uuid","componentRef","selectWrapper","gridElement","inputTextRef","onScreenResize","current","clientWidth","onClickOutside","event","target","contains","onMouseMove","idDropdown","parentElement","id","dropdownElement","document","getElementById","keepDropdownOpen","Boolean","getSelectEvent","selectedEvent","onChange","selectedChange","onFilter","valueFilter","selectedFilter","dataComboFilter","getFilteredSimpleDataCombo","length","onSelect","selectedDropdown","Promise","resolve","finally","focus","onOpenClose","prevState","onFocus","dropdownWidthFocus","onBlur","onInputKeyDown","e","keyCode","constants","ENTER","key","TAB","preventDefault","ARROW_UP","ARROW_DOWN","includes","index","findIndex","d","onClearClick","setOnDenied","onDeniedSelect","shouldDisable","hideContent","shouldBeReadOnly","useEffect","window","addEventListener","removeEventListener","gridEl","querySelector","newCurrent","find","i","toString","toLowerCase","_","isEqual","dataComboFilteredSimple","data","JSON","stringify","ref","inputRef","isFunction","r","inputOnDenied","getComputedStyle","dataSelected"],"mappings":";;;;;;;;;AAaA,MAAMA,eAAeA,CAACC,UAA8B;AAClD,QAAM;AAAA,IACJC;AAAAA,IAAOC;AAAAA,IAAgBC,aAAa,CAAA;AAAA,IAAIC;AAAAA,IAAYC;AAAAA,IAAUC;AAAAA,IAAUC;AAAAA,IACxEC,sBAAsB;AAAA,IAAMC,qBAAqB;AAAA,IAAOC;AAAAA,IAAOC,eAAe;AAAA,IAAOC,OAAO;AAAA,IAC5FC;AAAAA,IAAaC,mBAAmB;AAAA,IAAOC,aAAaC;AAAAA,IAAWC,kBAAkB;AAAA,IACjFC;AAAAA,IAAoBC,gBAAgB,CAAA;AAAA,IAAIC;AAAAA,IAAuBC;AAAAA,IAC/DC;AAAAA,IAAqBC;AAAAA,IAA2BC,mBAAmBR;AAAAA,IACnES;AAAAA,IAAcC;AAAAA,IAAuBC;AAAAA,EAAAA,IACnC3B;AAEJ,QAAM4B,yBAAyB,OAAO1B,mBAAmB;AACzD,QAAM2B,2BAA2Bd,aAC7B,CAAC;AAAA,IACC,CAACL,KAAK,GAAGK,WAAWe;AAAAA,IACpB,CAACF,yBACC1B,iBACEA,eAAea,WAAWgB,KAAK,CAAC,GAAGhB,WAAWgB;AAAAA,EAAAA,GACjD,GAAG5B,UAAU,IAChBA;AACJ,QAAM,CAAC6B,WAAWC,YAAY,IAAIC,SAAsBL,wBAAwB;AAChF,QAAM,CAACM,UAAUC,WAAW,IAAIF,SAA2B,IAAI;AAC/D,QAAM,CAACG,WAAWC,YAAY,IAAIJ,SAAS,EAAE;AAC7C,QAAM,CAACK,QAAQC,SAAS,IAAIN,SAAS,KAAK;AAC1C,QAAM,CAACO,eAAeC,gBAAgB,IAAIR,SAAS,CAAC;AACpD,QAAM,CAACS,iBAAiBC,kBAAkB,IAAIV,SAAS,KAAK;AAC5D,Q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,oBAAC,UAAA,EACC,GAAIvC,OACJ,QACA,UACA,YAAYqC,WACZ,gBAAgBgB,cAChB,aACA,kBACA,kBAAkBjD,cAAcmD,YAAYG,UACxCyD,OAAOqB,iBAAiBjF,YAAYG,OAAO,IAC3C1C,QACJ,gBAAgB,CAACyH,iBAA6B;AAC5C,UAAIA,uBAAuBA,YAAY;AAAA,IACzC,GACA,gBAAgB,CAAC3D,kBAAwBD,SAASC,aAAW,GAC7D,iBAAiBgB,gBACjB,cAAc,MAAMD,QACpB,eAAeF,SACf,WACA,oBACA,eAAenE,oBAAoBiB,iBAAiB,GACpD,cACA,uBACA,WAAA,CAAuB;AAAA,EAAA,GAE7B;AAEJ;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Moment } from 'moment';
|
|
2
|
+
import { ReactNode, RefObject } from 'react';
|
|
3
|
+
interface CalendarDayState {
|
|
4
|
+
isSelected: boolean;
|
|
5
|
+
isInRange?: boolean;
|
|
6
|
+
isDisabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
interface CalendarBoxProps {
|
|
9
|
+
testIdPrefix: string;
|
|
10
|
+
headerId: string;
|
|
11
|
+
calendarBoxOpen: boolean;
|
|
12
|
+
activeDescendant: string;
|
|
13
|
+
calendarDisplayDate: Moment;
|
|
14
|
+
containerRef: RefObject<HTMLDivElement | null>;
|
|
15
|
+
onNextMonth: () => void;
|
|
16
|
+
onPreviousMonth: () => void;
|
|
17
|
+
getDayState: (day: Moment) => CalendarDayState;
|
|
18
|
+
onSelectDay: (day: Moment) => void;
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
declare const CalendarBox: import('react').ForwardRefExoticComponent<CalendarBoxProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
22
|
+
export { CalendarBox };
|
|
23
|
+
export type { CalendarBoxProps, CalendarDayState };
|