primereact 10.0.0 → 10.0.1
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/README.md +1 -1
- package/componentbase/componentbase.cjs.js +12 -7
- package/componentbase/componentbase.cjs.min.js +1 -1
- package/componentbase/componentbase.esm.min.mjs +1 -1
- package/componentbase/componentbase.esm.mjs +12 -7
- package/componentbase/componentbase.js +12 -7
- package/componentbase/componentbase.min.js +1 -1
- package/core/core.js +12 -7
- package/core/core.min.js +1 -1
- package/package.json +1 -1
- package/primereact.all.cjs.js +12 -7
- package/primereact.all.cjs.min.js +1 -1
- package/primereact.all.esm.min.mjs +1 -1
- package/primereact.all.esm.mjs +12 -7
- package/primereact.all.js +12 -7
- package/primereact.all.min.js +1 -1
- package/web-types.json +1 -1
- package/accordion/accordion.esm.js +0 -421
- package/accordion/accordion.esm.min.js +0 -1
- package/api/api.esm.js +0 -944
- package/api/api.esm.min.js +0 -1
- package/autocomplete/autocomplete.esm.js +0 -1127
- package/autocomplete/autocomplete.esm.min.js +0 -1
- package/avatar/avatar.esm.js +0 -245
- package/avatar/avatar.esm.min.js +0 -1
- package/avatargroup/avatargroup.esm.js +0 -55
- package/avatargroup/avatargroup.esm.min.js +0 -1
- package/badge/badge.esm.js +0 -110
- package/badge/badge.esm.min.js +0 -1
- package/blockui/blockui.esm.js +0 -265
- package/blockui/blockui.esm.min.js +0 -1
- package/breadcrumb/breadcrumb.esm.js +0 -351
- package/breadcrumb/breadcrumb.esm.min.js +0 -1
- package/button/button.esm.js +0 -295
- package/button/button.esm.min.js +0 -1
- package/calendar/calendar.esm.js +0 -3473
- package/calendar/calendar.esm.min.js +0 -1
- package/card/card.esm.js +0 -98
- package/card/card.esm.min.js +0 -1
- package/carousel/carousel.esm.js +0 -801
- package/carousel/carousel.esm.min.js +0 -1
- package/cascadeselect/cascadeselect.esm.js +0 -819
- package/cascadeselect/cascadeselect.esm.min.js +0 -1
- package/chart/chart.esm.js +0 -155
- package/chart/chart.esm.min.js +0 -1
- package/checkbox/checkbox.esm.js +0 -357
- package/checkbox/checkbox.esm.min.js +0 -1
- package/chip/chip.esm.js +0 -248
- package/chip/chip.esm.min.js +0 -1
- package/chips/chips.esm.js +0 -501
- package/chips/chips.esm.min.js +0 -1
- package/colorpicker/colorpicker.esm.js +0 -788
- package/colorpicker/colorpicker.esm.min.js +0 -1
- package/column/column.esm.js +0 -8
- package/column/column.esm.min.js +0 -1
- package/columngroup/columngroup.esm.js +0 -6
- package/columngroup/columngroup.esm.min.js +0 -1
- package/componentbase/componentbase.esm.js +0 -323
- package/componentbase/componentbase.esm.min.js +0 -1
- package/confirmdialog/confirmdialog.esm.js +0 -376
- package/confirmdialog/confirmdialog.esm.min.js +0 -1
- package/confirmpopup/confirmpopup.esm.js +0 -610
- package/confirmpopup/confirmpopup.esm.min.js +0 -1
- package/contextmenu/contextmenu.esm.js +0 -664
- package/contextmenu/contextmenu.esm.min.js +0 -1
- package/csstransition/csstransition.esm.js +0 -138
- package/csstransition/csstransition.esm.min.js +0 -1
- package/datascroller/datascroller.esm.js +0 -320
- package/datascroller/datascroller.esm.min.js +0 -1
- package/datatable/datatable.esm.js +0 -6636
- package/datatable/datatable.esm.min.js +0 -1
- package/dataview/dataview.esm.js +0 -506
- package/dataview/dataview.esm.min.js +0 -1
- package/deferredcontent/deferredcontent.esm.js +0 -133
- package/deferredcontent/deferredcontent.esm.min.js +0 -1
- package/dialog/dialog.esm.js +0 -983
- package/dialog/dialog.esm.min.js +0 -1
- package/divider/divider.esm.js +0 -79
- package/divider/divider.esm.min.js +0 -1
- package/dock/dock.esm.js +0 -348
- package/dock/dock.esm.min.js +0 -1
- package/dropdown/dropdown.esm.js +0 -1380
- package/dropdown/dropdown.esm.min.js +0 -1
- package/editor/editor.esm.js +0 -338
- package/editor/editor.esm.min.js +0 -1
- package/fieldset/fieldset.esm.js +0 -270
- package/fieldset/fieldset.esm.min.js +0 -1
- package/fileupload/fileupload.esm.js +0 -1005
- package/fileupload/fileupload.esm.min.js +0 -1
- package/galleria/galleria.esm.js +0 -1090
- package/galleria/galleria.esm.min.js +0 -1
- package/hooks/hooks.esm.js +0 -1042
- package/hooks/hooks.esm.min.js +0 -1
- package/iconbase/iconbase.esm.js +0 -33
- package/iconbase/iconbase.esm.min.js +0 -1
- package/icons/angledoubledown/index.esm.js +0 -39
- package/icons/angledoubledown/index.esm.min.js +0 -1
- package/icons/angledoubleleft/index.esm.js +0 -39
- package/icons/angledoubleleft/index.esm.min.js +0 -1
- package/icons/angledoubleright/index.esm.js +0 -39
- package/icons/angledoubleright/index.esm.min.js +0 -1
- package/icons/angledoubleup/index.esm.js +0 -39
- package/icons/angledoubleup/index.esm.min.js +0 -1
- package/icons/angledown/index.esm.js +0 -37
- package/icons/angledown/index.esm.min.js +0 -1
- package/icons/angleleft/index.esm.js +0 -37
- package/icons/angleleft/index.esm.min.js +0 -1
- package/icons/angleright/index.esm.js +0 -37
- package/icons/angleright/index.esm.min.js +0 -1
- package/icons/angleup/index.esm.js +0 -37
- package/icons/angleup/index.esm.min.js +0 -1
- package/icons/arrowdown/index.esm.js +0 -661
- package/icons/arrowdown/index.esm.min.js +0 -1
- package/icons/arrowup/index.esm.js +0 -661
- package/icons/arrowup/index.esm.min.js +0 -1
- package/icons/ban/index.esm.js +0 -659
- package/icons/ban/index.esm.min.js +0 -1
- package/icons/bars/index.esm.js +0 -39
- package/icons/bars/index.esm.min.js +0 -1
- package/icons/calendar/index.esm.js +0 -37
- package/icons/calendar/index.esm.min.js +0 -1
- package/icons/check/index.esm.js +0 -37
- package/icons/check/index.esm.min.js +0 -1
- package/icons/chevrondown/index.esm.js +0 -37
- package/icons/chevrondown/index.esm.min.js +0 -1
- package/icons/chevronleft/index.esm.js +0 -37
- package/icons/chevronleft/index.esm.min.js +0 -1
- package/icons/chevronright/index.esm.js +0 -37
- package/icons/chevronright/index.esm.min.js +0 -1
- package/icons/chevronup/index.esm.js +0 -37
- package/icons/chevronup/index.esm.min.js +0 -1
- package/icons/download/index.esm.js +0 -661
- package/icons/download/index.esm.min.js +0 -1
- package/icons/exclamationtriangle/index.esm.js +0 -665
- package/icons/exclamationtriangle/index.esm.min.js +0 -1
- package/icons/eye/index.esm.js +0 -39
- package/icons/eye/index.esm.min.js +0 -1
- package/icons/eyeslash/index.esm.js +0 -661
- package/icons/eyeslash/index.esm.min.js +0 -1
- package/icons/filter/index.esm.js +0 -659
- package/icons/filter/index.esm.min.js +0 -1
- package/icons/filterslash/index.esm.js +0 -661
- package/icons/filterslash/index.esm.min.js +0 -1
- package/icons/infocircle/index.esm.js +0 -661
- package/icons/infocircle/index.esm.min.js +0 -1
- package/icons/minus/index.esm.js +0 -37
- package/icons/minus/index.esm.min.js +0 -1
- package/icons/pencil/index.esm.js +0 -659
- package/icons/pencil/index.esm.min.js +0 -1
- package/icons/plus/index.esm.js +0 -659
- package/icons/plus/index.esm.min.js +0 -1
- package/icons/refresh/index.esm.js +0 -661
- package/icons/refresh/index.esm.min.js +0 -1
- package/icons/search/index.esm.js +0 -661
- package/icons/search/index.esm.min.js +0 -1
- package/icons/searchminus/index.esm.js +0 -661
- package/icons/searchminus/index.esm.min.js +0 -1
- package/icons/searchplus/index.esm.js +0 -661
- package/icons/searchplus/index.esm.min.js +0 -1
- package/icons/sortalt/index.esm.js +0 -668
- package/icons/sortalt/index.esm.min.js +0 -1
- package/icons/sortamountdown/index.esm.js +0 -674
- package/icons/sortamountdown/index.esm.min.js +0 -1
- package/icons/sortamountupalt/index.esm.js +0 -674
- package/icons/sortamountupalt/index.esm.min.js +0 -1
- package/icons/spinner/index.esm.js +0 -659
- package/icons/spinner/index.esm.min.js +0 -1
- package/icons/star/index.esm.js +0 -659
- package/icons/star/index.esm.min.js +0 -1
- package/icons/starfill/index.esm.js +0 -659
- package/icons/starfill/index.esm.min.js +0 -1
- package/icons/thlarge/index.esm.js +0 -661
- package/icons/thlarge/index.esm.min.js +0 -1
- package/icons/times/index.esm.js +0 -37
- package/icons/times/index.esm.min.js +0 -1
- package/icons/timescircle/index.esm.js +0 -661
- package/icons/timescircle/index.esm.min.js +0 -1
- package/icons/trash/index.esm.js +0 -661
- package/icons/trash/index.esm.min.js +0 -1
- package/icons/undo/index.esm.js +0 -661
- package/icons/undo/index.esm.min.js +0 -1
- package/icons/upload/index.esm.js +0 -661
- package/icons/upload/index.esm.min.js +0 -1
- package/icons/windowmaximize/index.esm.js +0 -661
- package/icons/windowmaximize/index.esm.min.js +0 -1
- package/icons/windowminimize/index.esm.js +0 -661
- package/icons/windowminimize/index.esm.min.js +0 -1
- package/image/image.esm.js +0 -1162
- package/image/image.esm.min.js +0 -1
- package/inplace/inplace.esm.js +0 -243
- package/inplace/inplace.esm.min.js +0 -1
- package/inputmask/inputmask.esm.js +0 -560
- package/inputmask/inputmask.esm.min.js +0 -1
- package/inputnumber/inputnumber.esm.js +0 -1209
- package/inputnumber/inputnumber.esm.min.js +0 -1
- package/inputswitch/inputswitch.esm.js +0 -291
- package/inputswitch/inputswitch.esm.min.js +0 -1
- package/inputtext/inputtext.esm.js +0 -171
- package/inputtext/inputtext.esm.min.js +0 -1
- package/inputtextarea/inputtextarea.esm.js +0 -220
- package/inputtextarea/inputtextarea.esm.min.js +0 -1
- package/keyfilter/keyfilter.esm.js +0 -108
- package/keyfilter/keyfilter.esm.min.js +0 -1
- package/knob/knob.esm.js +0 -318
- package/knob/knob.esm.min.js +0 -1
- package/listbox/listbox.esm.js +0 -810
- package/listbox/listbox.esm.min.js +0 -1
- package/megamenu/megamenu.esm.js +0 -716
- package/megamenu/megamenu.esm.min.js +0 -1
- package/mention/mention.esm.js +0 -771
- package/mention/mention.esm.min.js +0 -1
- package/menu/menu.esm.js +0 -485
- package/menu/menu.esm.min.js +0 -1
- package/menubar/menubar.esm.js +0 -584
- package/menubar/menubar.esm.min.js +0 -1
- package/message/message.esm.js +0 -169
- package/message/message.esm.min.js +0 -1
- package/messages/messages.esm.js +0 -439
- package/messages/messages.esm.min.js +0 -1
- package/multiselect/multiselect.esm.js +0 -1724
- package/multiselect/multiselect.esm.min.js +0 -1
- package/multistatecheckbox/multistatecheckbox.esm.js +0 -352
- package/multistatecheckbox/multistatecheckbox.esm.min.js +0 -1
- package/orderlist/orderlist.esm.js +0 -816
- package/orderlist/orderlist.esm.min.js +0 -1
- package/organizationchart/organizationchart.esm.js +0 -480
- package/organizationchart/organizationchart.esm.min.js +0 -1
- package/overlaypanel/overlaypanel.esm.js +0 -516
- package/overlaypanel/overlaypanel.esm.min.js +0 -1
- package/overlayservice/overlayservice.esm.js +0 -7
- package/overlayservice/overlayservice.esm.min.js +0 -1
- package/paginator/paginator.esm.js +0 -933
- package/paginator/paginator.esm.min.js +0 -1
- package/panel/panel.esm.js +0 -316
- package/panel/panel.esm.min.js +0 -1
- package/panelmenu/panelmenu.esm.js +0 -645
- package/panelmenu/panelmenu.esm.min.js +0 -1
- package/passthrough/index.esm.js +0 -71
- package/passthrough/index.esm.min.js +0 -1
- package/passthrough/tailwind/index.esm.js +0 -3509
- package/passthrough/tailwind/index.esm.min.js +0 -1
- package/password/password.esm.js +0 -567
- package/password/password.esm.min.js +0 -1
- package/picklist/picklist.esm.js +0 -1119
- package/picklist/picklist.esm.min.js +0 -1
- package/portal/portal.esm.js +0 -110
- package/portal/portal.esm.min.js +0 -1
- package/primereact.all.esm.js +0 -51646
- package/primereact.all.esm.min.js +0 -1
- package/progressbar/progressbar.esm.js +0 -190
- package/progressbar/progressbar.esm.min.js +0 -1
- package/progressspinner/progressspinner.esm.js +0 -88
- package/progressspinner/progressspinner.esm.min.js +0 -1
- package/radiobutton/radiobutton.esm.js +0 -329
- package/radiobutton/radiobutton.esm.min.js +0 -1
- package/rating/rating.esm.js +0 -273
- package/rating/rating.esm.min.js +0 -1
- package/ripple/ripple.esm.js +0 -100
- package/ripple/ripple.esm.min.js +0 -1
- package/row/row.esm.js +0 -36
- package/row/row.esm.min.js +0 -1
- package/scrollpanel/scrollpanel.esm.js +0 -210
- package/scrollpanel/scrollpanel.esm.min.js +0 -1
- package/scrolltop/scrolltop.esm.js +0 -269
- package/scrolltop/scrolltop.esm.min.js +0 -1
- package/selectbutton/selectbutton.esm.js +0 -327
- package/selectbutton/selectbutton.esm.min.js +0 -1
- package/sidebar/sidebar.esm.js +0 -543
- package/sidebar/sidebar.esm.min.js +0 -1
- package/skeleton/skeleton.esm.js +0 -125
- package/skeleton/skeleton.esm.min.js +0 -1
- package/slidemenu/slidemenu.esm.js +0 -689
- package/slidemenu/slidemenu.esm.min.js +0 -1
- package/slider/slider.esm.js +0 -478
- package/slider/slider.esm.min.js +0 -1
- package/speeddial/speeddial.esm.js +0 -521
- package/speeddial/speeddial.esm.min.js +0 -1
- package/splitbutton/splitbutton.esm.js +0 -545
- package/splitbutton/splitbutton.esm.min.js +0 -1
- package/splitter/splitter.esm.js +0 -466
- package/splitter/splitter.esm.min.js +0 -1
- package/steps/steps.esm.js +0 -294
- package/steps/steps.esm.min.js +0 -1
- package/styleclass/styleclass.esm.js +0 -269
- package/styleclass/styleclass.esm.min.js +0 -1
- package/tabmenu/tabmenu.esm.js +0 -332
- package/tabmenu/tabmenu.esm.min.js +0 -1
- package/tabview/tabview.esm.js +0 -678
- package/tabview/tabview.esm.min.js +0 -1
- package/tag/tag.esm.js +0 -117
- package/tag/tag.esm.min.js +0 -1
- package/terminal/terminal.esm.js +0 -280
- package/terminal/terminal.esm.min.js +0 -1
- package/terminalservice/terminalservice.esm.js +0 -7
- package/terminalservice/terminalservice.esm.min.js +0 -1
- package/tieredmenu/tieredmenu.esm.js +0 -699
- package/tieredmenu/tieredmenu.esm.min.js +0 -1
- package/timeline/timeline.esm.js +0 -164
- package/timeline/timeline.esm.min.js +0 -1
- package/toast/toast.esm.js +0 -739
- package/toast/toast.esm.min.js +0 -1
- package/togglebutton/togglebutton.esm.js +0 -217
- package/togglebutton/togglebutton.esm.min.js +0 -1
- package/toolbar/toolbar.esm.js +0 -79
- package/toolbar/toolbar.esm.min.js +0 -1
- package/tooltip/tooltip.esm.js +0 -696
- package/tooltip/tooltip.esm.min.js +0 -1
- package/tree/tree.esm.js +0 -1403
- package/tree/tree.esm.min.js +0 -1
- package/treeselect/treeselect.esm.js +0 -930
- package/treeselect/treeselect.esm.min.js +0 -1
- package/treetable/treetable.esm.js +0 -3094
- package/treetable/treetable.esm.min.js +0 -1
- package/tristatecheckbox/tristatecheckbox.esm.js +0 -292
- package/tristatecheckbox/tristatecheckbox.esm.min.js +0 -1
- package/utils/utils.esm.js +0 -2383
- package/utils/utils.esm.min.js +0 -1
- package/virtualscroller/virtualscroller.esm.js +0 -972
- package/virtualscroller/virtualscroller.esm.min.js +0 -1
|
@@ -1,972 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { usePrevious, useStyle, useResizeListener, useEventListener, useMountEffect, useUpdateEffect } from 'primereact/hooks';
|
|
5
|
-
import { DomHandler, ObjectUtils, classNames, mergeProps, IconUtils } from 'primereact/utils';
|
|
6
|
-
import { ComponentBase } from 'primereact/componentbase';
|
|
7
|
-
import { SpinnerIcon } from 'primereact/icons/spinner';
|
|
8
|
-
import { PrimeReactContext } from 'primereact/api';
|
|
9
|
-
|
|
10
|
-
function _extends() {
|
|
11
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
12
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
13
|
-
var source = arguments[i];
|
|
14
|
-
for (var key in source) {
|
|
15
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
16
|
-
target[key] = source[key];
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return target;
|
|
21
|
-
};
|
|
22
|
-
return _extends.apply(this, arguments);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function _typeof(o) {
|
|
26
|
-
"@babel/helpers - typeof";
|
|
27
|
-
|
|
28
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
29
|
-
return typeof o;
|
|
30
|
-
} : function (o) {
|
|
31
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
32
|
-
}, _typeof(o);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function _toPrimitive(input, hint) {
|
|
36
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
37
|
-
var prim = input[Symbol.toPrimitive];
|
|
38
|
-
if (prim !== undefined) {
|
|
39
|
-
var res = prim.call(input, hint || "default");
|
|
40
|
-
if (_typeof(res) !== "object") return res;
|
|
41
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
42
|
-
}
|
|
43
|
-
return (hint === "string" ? String : Number)(input);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function _toPropertyKey(arg) {
|
|
47
|
-
var key = _toPrimitive(arg, "string");
|
|
48
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function _defineProperty(obj, key, value) {
|
|
52
|
-
key = _toPropertyKey(key);
|
|
53
|
-
if (key in obj) {
|
|
54
|
-
Object.defineProperty(obj, key, {
|
|
55
|
-
value: value,
|
|
56
|
-
enumerable: true,
|
|
57
|
-
configurable: true,
|
|
58
|
-
writable: true
|
|
59
|
-
});
|
|
60
|
-
} else {
|
|
61
|
-
obj[key] = value;
|
|
62
|
-
}
|
|
63
|
-
return obj;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function _arrayWithHoles(arr) {
|
|
67
|
-
if (Array.isArray(arr)) return arr;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function _iterableToArrayLimit(r, l) {
|
|
71
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
72
|
-
if (null != t) {
|
|
73
|
-
var e,
|
|
74
|
-
n,
|
|
75
|
-
i,
|
|
76
|
-
u,
|
|
77
|
-
a = [],
|
|
78
|
-
f = !0,
|
|
79
|
-
o = !1;
|
|
80
|
-
try {
|
|
81
|
-
if (i = (t = t.call(r)).next, 0 === l) {
|
|
82
|
-
if (Object(t) !== t) return;
|
|
83
|
-
f = !1;
|
|
84
|
-
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
85
|
-
} catch (r) {
|
|
86
|
-
o = !0, n = r;
|
|
87
|
-
} finally {
|
|
88
|
-
try {
|
|
89
|
-
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
|
|
90
|
-
} finally {
|
|
91
|
-
if (o) throw n;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return a;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function _arrayLikeToArray(arr, len) {
|
|
99
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
100
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
101
|
-
return arr2;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
105
|
-
if (!o) return;
|
|
106
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
107
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
108
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
109
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
110
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function _nonIterableRest() {
|
|
114
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function _slicedToArray(arr, i) {
|
|
118
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
var styles = "\n.p-virtualscroller {\n position: relative;\n overflow: auto;\n contain: strict;\n transform: translateZ(0);\n will-change: scroll-position;\n outline: 0 none;\n}\n\n.p-virtualscroller-content {\n position: absolute;\n top: 0;\n left: 0;\n /*contain: content;*/\n min-height: 100%;\n min-width: 100%;\n will-change: transform;\n}\n\n.p-virtualscroller-spacer {\n position: absolute;\n top: 0;\n left: 0;\n height: 1px;\n width: 1px;\n transform-origin: 0 0;\n pointer-events: none;\n}\n\n.p-virtualscroller-loader {\n position: sticky;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n}\n\n.p-virtualscroller-loader.p-component-overlay {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.p-virtualscroller-loading-icon {\n font-size: 2rem;\n}\n\n.p-virtualscroller-horizontal > .p-virtualscroller-content {\n display: flex;\n}\n\n/* Inline */\n.p-virtualscroller-inline .p-virtualscroller-content {\n position: static;\n}\n";
|
|
122
|
-
var VirtualScrollerBase = ComponentBase.extend({
|
|
123
|
-
defaultProps: {
|
|
124
|
-
__TYPE: 'VirtualScroller',
|
|
125
|
-
__parentMetadata: null,
|
|
126
|
-
id: null,
|
|
127
|
-
style: null,
|
|
128
|
-
className: null,
|
|
129
|
-
tabIndex: 0,
|
|
130
|
-
items: null,
|
|
131
|
-
itemSize: 0,
|
|
132
|
-
scrollHeight: null,
|
|
133
|
-
scrollWidth: null,
|
|
134
|
-
orientation: 'vertical',
|
|
135
|
-
step: 0,
|
|
136
|
-
numToleratedItems: null,
|
|
137
|
-
delay: 0,
|
|
138
|
-
resizeDelay: 10,
|
|
139
|
-
appendOnly: false,
|
|
140
|
-
inline: false,
|
|
141
|
-
lazy: false,
|
|
142
|
-
disabled: false,
|
|
143
|
-
loaderDisabled: false,
|
|
144
|
-
loadingIcon: null,
|
|
145
|
-
columns: null,
|
|
146
|
-
loading: undefined,
|
|
147
|
-
autoSize: false,
|
|
148
|
-
showSpacer: true,
|
|
149
|
-
showLoader: false,
|
|
150
|
-
loadingTemplate: null,
|
|
151
|
-
loaderIconTemplate: null,
|
|
152
|
-
itemTemplate: null,
|
|
153
|
-
contentTemplate: null,
|
|
154
|
-
onScroll: null,
|
|
155
|
-
onScrollIndexChange: null,
|
|
156
|
-
onLazyLoad: null,
|
|
157
|
-
children: undefined
|
|
158
|
-
},
|
|
159
|
-
css: {
|
|
160
|
-
styles: styles
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
165
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
166
|
-
var VirtualScroller = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (inProps, ref) {
|
|
167
|
-
var context = React.useContext(PrimeReactContext);
|
|
168
|
-
var props = VirtualScrollerBase.getProps(inProps, context);
|
|
169
|
-
var prevProps = usePrevious(inProps) || {};
|
|
170
|
-
var vertical = props.orientation === 'vertical';
|
|
171
|
-
var horizontal = props.orientation === 'horizontal';
|
|
172
|
-
var both = props.orientation === 'both';
|
|
173
|
-
var _React$useState = React.useState(both ? {
|
|
174
|
-
rows: 0,
|
|
175
|
-
cols: 0
|
|
176
|
-
} : 0),
|
|
177
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
178
|
-
firstState = _React$useState2[0],
|
|
179
|
-
setFirstState = _React$useState2[1];
|
|
180
|
-
var _React$useState3 = React.useState(both ? {
|
|
181
|
-
rows: 0,
|
|
182
|
-
cols: 0
|
|
183
|
-
} : 0),
|
|
184
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
185
|
-
lastState = _React$useState4[0],
|
|
186
|
-
setLastState = _React$useState4[1];
|
|
187
|
-
var _React$useState5 = React.useState(0),
|
|
188
|
-
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
189
|
-
pageState = _React$useState6[0],
|
|
190
|
-
setPageState = _React$useState6[1];
|
|
191
|
-
var _React$useState7 = React.useState(both ? {
|
|
192
|
-
rows: 0,
|
|
193
|
-
cols: 0
|
|
194
|
-
} : 0),
|
|
195
|
-
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
196
|
-
numItemsInViewportState = _React$useState8[0],
|
|
197
|
-
setNumItemsInViewportState = _React$useState8[1];
|
|
198
|
-
var _React$useState9 = React.useState(props.numToleratedItems),
|
|
199
|
-
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
200
|
-
numToleratedItemsState = _React$useState10[0],
|
|
201
|
-
setNumToleratedItemsState = _React$useState10[1];
|
|
202
|
-
var _React$useState11 = React.useState(props.loading || false),
|
|
203
|
-
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
204
|
-
loadingState = _React$useState12[0],
|
|
205
|
-
setLoadingState = _React$useState12[1];
|
|
206
|
-
var _React$useState13 = React.useState([]),
|
|
207
|
-
_React$useState14 = _slicedToArray(_React$useState13, 2),
|
|
208
|
-
loaderArrState = _React$useState14[0],
|
|
209
|
-
setLoaderArrState = _React$useState14[1];
|
|
210
|
-
var _VirtualScrollerBase$ = VirtualScrollerBase.setMetaData({
|
|
211
|
-
props: props,
|
|
212
|
-
state: {
|
|
213
|
-
first: firstState,
|
|
214
|
-
last: lastState,
|
|
215
|
-
page: pageState,
|
|
216
|
-
numItemsInViewport: numItemsInViewportState,
|
|
217
|
-
numToleratedItems: numToleratedItemsState,
|
|
218
|
-
loading: loadingState,
|
|
219
|
-
loaderArr: loaderArrState
|
|
220
|
-
}
|
|
221
|
-
}),
|
|
222
|
-
ptm = _VirtualScrollerBase$.ptm;
|
|
223
|
-
useStyle(VirtualScrollerBase.css.styles, {
|
|
224
|
-
name: 'virtualscroller'
|
|
225
|
-
});
|
|
226
|
-
var elementRef = React.useRef(null);
|
|
227
|
-
var _contentRef = React.useRef(null);
|
|
228
|
-
var _spacerRef = React.useRef(null);
|
|
229
|
-
var _stickyRef = React.useRef(null);
|
|
230
|
-
var lastScrollPos = React.useRef(both ? {
|
|
231
|
-
top: 0,
|
|
232
|
-
left: 0
|
|
233
|
-
} : 0);
|
|
234
|
-
var scrollTimeout = React.useRef(null);
|
|
235
|
-
var resizeTimeout = React.useRef(null);
|
|
236
|
-
var contentStyle = React.useRef({});
|
|
237
|
-
var spacerStyle = React.useRef({});
|
|
238
|
-
var defaultWidth = React.useRef(null);
|
|
239
|
-
var defaultHeight = React.useRef(null);
|
|
240
|
-
var defaultContentWidth = React.useRef(null);
|
|
241
|
-
var defaultContentHeight = React.useRef(null);
|
|
242
|
-
var isItemRangeChanged = React.useRef(false);
|
|
243
|
-
var lazyLoadState = React.useRef(null);
|
|
244
|
-
var _useResizeListener = useResizeListener({
|
|
245
|
-
listener: function listener(event) {
|
|
246
|
-
return onResize();
|
|
247
|
-
},
|
|
248
|
-
when: !props.disabled
|
|
249
|
-
}),
|
|
250
|
-
_useResizeListener2 = _slicedToArray(_useResizeListener, 1),
|
|
251
|
-
bindWindowResizeListener = _useResizeListener2[0];
|
|
252
|
-
var _useEventListener = useEventListener({
|
|
253
|
-
target: 'window',
|
|
254
|
-
type: 'orientationchange',
|
|
255
|
-
listener: function listener(event) {
|
|
256
|
-
return onResize();
|
|
257
|
-
},
|
|
258
|
-
when: !props.disabled
|
|
259
|
-
}),
|
|
260
|
-
_useEventListener2 = _slicedToArray(_useEventListener, 1),
|
|
261
|
-
bindOrientationChangeListener = _useEventListener2[0];
|
|
262
|
-
var getElementRef = function getElementRef() {
|
|
263
|
-
return elementRef;
|
|
264
|
-
};
|
|
265
|
-
var getPageByFirst = function getPageByFirst(first) {
|
|
266
|
-
return Math.floor((first + numToleratedItemsState * 4) / (props.step || 1));
|
|
267
|
-
};
|
|
268
|
-
var setContentElement = function setContentElement(element) {
|
|
269
|
-
_contentRef.current = element || _contentRef.current || DomHandler.findSingle(elementRef.current, '.p-virtualscroller-content');
|
|
270
|
-
};
|
|
271
|
-
var isPageChanged = function isPageChanged(first) {
|
|
272
|
-
return props.step ? pageState !== getPageByFirst(first) : true;
|
|
273
|
-
};
|
|
274
|
-
var scrollTo = function scrollTo(options) {
|
|
275
|
-
lastScrollPos.current = both ? {
|
|
276
|
-
top: 0,
|
|
277
|
-
left: 0
|
|
278
|
-
} : 0;
|
|
279
|
-
elementRef.current && elementRef.current.scrollTo(options);
|
|
280
|
-
};
|
|
281
|
-
var scrollToIndex = function scrollToIndex(index) {
|
|
282
|
-
var behavior = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'auto';
|
|
283
|
-
var _calculateNumItems = calculateNumItems(),
|
|
284
|
-
numToleratedItems = _calculateNumItems.numToleratedItems;
|
|
285
|
-
var contentPos = getContentPosition();
|
|
286
|
-
var calculateFirst = function calculateFirst() {
|
|
287
|
-
var _index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
288
|
-
var _numT = arguments.length > 1 ? arguments[1] : undefined;
|
|
289
|
-
return _index <= _numT ? 0 : _index;
|
|
290
|
-
};
|
|
291
|
-
var calculateCoord = function calculateCoord(_first, _size, _cpos) {
|
|
292
|
-
return _first * _size + _cpos;
|
|
293
|
-
};
|
|
294
|
-
var scrollToItem = function scrollToItem() {
|
|
295
|
-
var left = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
296
|
-
var top = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
297
|
-
return scrollTo({
|
|
298
|
-
left: left,
|
|
299
|
-
top: top,
|
|
300
|
-
behavior: behavior
|
|
301
|
-
});
|
|
302
|
-
};
|
|
303
|
-
var newFirst = both ? {
|
|
304
|
-
rows: 0,
|
|
305
|
-
cols: 0
|
|
306
|
-
} : 0;
|
|
307
|
-
var isRangeChanged = false;
|
|
308
|
-
if (both) {
|
|
309
|
-
newFirst = {
|
|
310
|
-
rows: calculateFirst(index[0], numToleratedItems[0]),
|
|
311
|
-
cols: calculateFirst(index[1], numToleratedItems[1])
|
|
312
|
-
};
|
|
313
|
-
scrollToItem(calculateCoord(newFirst.cols, props.itemSize[1], contentPos.left), calculateCoord(newFirst.rows, props.itemSize[0], contentPos.top));
|
|
314
|
-
isRangeChanged = firstState.rows !== newFirst.rows || firstState.cols !== newFirst.cols;
|
|
315
|
-
} else {
|
|
316
|
-
newFirst = calculateFirst(index, numToleratedItems);
|
|
317
|
-
horizontal ? scrollToItem(calculateCoord(newFirst, props.itemSize, contentPos.left), 0) : scrollToItem(0, calculateCoord(newFirst, props.itemSize, contentPos.top));
|
|
318
|
-
isRangeChanged = firstState !== newFirst;
|
|
319
|
-
}
|
|
320
|
-
isItemRangeChanged.current = isRangeChanged;
|
|
321
|
-
setFirstState(newFirst);
|
|
322
|
-
};
|
|
323
|
-
var scrollInView = function scrollInView(index, to) {
|
|
324
|
-
var behavior = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'auto';
|
|
325
|
-
if (to) {
|
|
326
|
-
var _getRenderedRange = getRenderedRange(),
|
|
327
|
-
first = _getRenderedRange.first,
|
|
328
|
-
viewport = _getRenderedRange.viewport;
|
|
329
|
-
var scrollToItem = function scrollToItem() {
|
|
330
|
-
var left = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
331
|
-
var top = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
332
|
-
return scrollTo({
|
|
333
|
-
left: left,
|
|
334
|
-
top: top,
|
|
335
|
-
behavior: behavior
|
|
336
|
-
});
|
|
337
|
-
};
|
|
338
|
-
var isToStart = to === 'to-start';
|
|
339
|
-
var isToEnd = to === 'to-end';
|
|
340
|
-
if (isToStart) {
|
|
341
|
-
if (both) {
|
|
342
|
-
if (viewport.first.rows - first.rows > index[0]) {
|
|
343
|
-
scrollToItem(viewport.first.cols * props.itemSize[1], (viewport.first.rows - 1) * props.itemSize[0]);
|
|
344
|
-
} else if (viewport.first.cols - first.cols > index[1]) {
|
|
345
|
-
scrollToItem((viewport.first.cols - 1) * props.itemSize[1], viewport.first.rows * props.itemSize[0]);
|
|
346
|
-
}
|
|
347
|
-
} else {
|
|
348
|
-
if (viewport.first - first > index) {
|
|
349
|
-
var pos = (viewport.first - 1) * props.itemSize;
|
|
350
|
-
horizontal ? scrollToItem(pos, 0) : scrollToItem(0, pos);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
} else if (isToEnd) {
|
|
354
|
-
if (both) {
|
|
355
|
-
if (viewport.last.rows - first.rows <= index[0] + 1) {
|
|
356
|
-
scrollToItem(viewport.first.cols * props.itemSize[1], (viewport.first.rows + 1) * props.itemSize[0]);
|
|
357
|
-
} else if (viewport.last.cols - first.cols <= index[1] + 1) {
|
|
358
|
-
scrollToItem((viewport.first.cols + 1) * props.itemSize[1], viewport.first.rows * props.itemSize[0]);
|
|
359
|
-
}
|
|
360
|
-
} else {
|
|
361
|
-
if (viewport.last - first <= index + 1) {
|
|
362
|
-
var _pos2 = (viewport.first + 1) * props.itemSize;
|
|
363
|
-
horizontal ? scrollToItem(_pos2, 0) : scrollToItem(0, _pos2);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
} else {
|
|
368
|
-
scrollToIndex(index, behavior);
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
var getRows = function getRows() {
|
|
372
|
-
return loadingState ? props.loaderDisabled ? loaderArrState : [] : loadedItems();
|
|
373
|
-
};
|
|
374
|
-
var getColumns = function getColumns() {
|
|
375
|
-
if (props.columns && both || horizontal) {
|
|
376
|
-
return loadingState && props.loaderDisabled ? both ? loaderArrState[0] : loaderArrState : props.columns.slice(both ? firstState.cols : firstState, both ? lastState.cols : lastState);
|
|
377
|
-
}
|
|
378
|
-
return props.columns;
|
|
379
|
-
};
|
|
380
|
-
var getRenderedRange = function getRenderedRange() {
|
|
381
|
-
var calculateFirstInViewport = function calculateFirstInViewport(_pos, _size) {
|
|
382
|
-
return Math.floor(_pos / (_size || _pos));
|
|
383
|
-
};
|
|
384
|
-
var firstInViewport = firstState;
|
|
385
|
-
var lastInViewport = 0;
|
|
386
|
-
if (elementRef.current) {
|
|
387
|
-
var _elementRef$current = elementRef.current,
|
|
388
|
-
scrollTop = _elementRef$current.scrollTop,
|
|
389
|
-
scrollLeft = _elementRef$current.scrollLeft;
|
|
390
|
-
if (both) {
|
|
391
|
-
firstInViewport = {
|
|
392
|
-
rows: calculateFirstInViewport(scrollTop, props.itemSize[0]),
|
|
393
|
-
cols: calculateFirstInViewport(scrollLeft, props.itemSize[1])
|
|
394
|
-
};
|
|
395
|
-
lastInViewport = {
|
|
396
|
-
rows: firstInViewport.rows + numItemsInViewportState.rows,
|
|
397
|
-
cols: firstInViewport.cols + numItemsInViewportState.cols
|
|
398
|
-
};
|
|
399
|
-
} else {
|
|
400
|
-
var scrollPos = horizontal ? scrollLeft : scrollTop;
|
|
401
|
-
firstInViewport = calculateFirstInViewport(scrollPos, props.itemSize);
|
|
402
|
-
lastInViewport = firstInViewport + numItemsInViewportState;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
return {
|
|
406
|
-
first: firstState,
|
|
407
|
-
last: lastState,
|
|
408
|
-
viewport: {
|
|
409
|
-
first: firstInViewport,
|
|
410
|
-
last: lastInViewport
|
|
411
|
-
}
|
|
412
|
-
};
|
|
413
|
-
};
|
|
414
|
-
var calculateNumItems = function calculateNumItems() {
|
|
415
|
-
var contentPos = getContentPosition();
|
|
416
|
-
var contentWidth = elementRef.current ? elementRef.current.offsetWidth - contentPos.left : 0;
|
|
417
|
-
var contentHeight = elementRef.current ? elementRef.current.offsetHeight - contentPos.top : 0;
|
|
418
|
-
var calculateNumItemsInViewport = function calculateNumItemsInViewport(_contentSize, _itemSize) {
|
|
419
|
-
return Math.ceil(_contentSize / (_itemSize || _contentSize));
|
|
420
|
-
};
|
|
421
|
-
var calculateNumToleratedItems = function calculateNumToleratedItems(_numItems) {
|
|
422
|
-
return Math.ceil(_numItems / 2);
|
|
423
|
-
};
|
|
424
|
-
var numItemsInViewport = both ? {
|
|
425
|
-
rows: calculateNumItemsInViewport(contentHeight, props.itemSize[0]),
|
|
426
|
-
cols: calculateNumItemsInViewport(contentWidth, props.itemSize[1])
|
|
427
|
-
} : calculateNumItemsInViewport(horizontal ? contentWidth : contentHeight, props.itemSize);
|
|
428
|
-
var numToleratedItems = numToleratedItemsState || (both ? [calculateNumToleratedItems(numItemsInViewport.rows), calculateNumToleratedItems(numItemsInViewport.cols)] : calculateNumToleratedItems(numItemsInViewport));
|
|
429
|
-
return {
|
|
430
|
-
numItemsInViewport: numItemsInViewport,
|
|
431
|
-
numToleratedItems: numToleratedItems
|
|
432
|
-
};
|
|
433
|
-
};
|
|
434
|
-
var calculateOptions = function calculateOptions() {
|
|
435
|
-
var _calculateNumItems2 = calculateNumItems(),
|
|
436
|
-
numItemsInViewport = _calculateNumItems2.numItemsInViewport,
|
|
437
|
-
numToleratedItems = _calculateNumItems2.numToleratedItems;
|
|
438
|
-
var calculateLast = function calculateLast(_first, _num, _numT) {
|
|
439
|
-
var _isCols = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
440
|
-
return getLast(_first + _num + (_first < _numT ? 2 : 3) * _numT, _isCols);
|
|
441
|
-
};
|
|
442
|
-
var last = both ? {
|
|
443
|
-
rows: calculateLast(firstState.rows, numItemsInViewport.rows, numToleratedItems[0]),
|
|
444
|
-
cols: calculateLast(firstState.cols, numItemsInViewport.cols, numToleratedItems[1], true)
|
|
445
|
-
} : calculateLast(firstState, numItemsInViewport, numToleratedItems);
|
|
446
|
-
setNumItemsInViewportState(numItemsInViewport);
|
|
447
|
-
setNumToleratedItemsState(numToleratedItems);
|
|
448
|
-
setLastState(last);
|
|
449
|
-
if (props.showLoader) {
|
|
450
|
-
setLoaderArrState(both ? Array.from({
|
|
451
|
-
length: numItemsInViewport.rows
|
|
452
|
-
}).map(function () {
|
|
453
|
-
return Array.from({
|
|
454
|
-
length: numItemsInViewport.cols
|
|
455
|
-
});
|
|
456
|
-
}) : Array.from({
|
|
457
|
-
length: numItemsInViewport
|
|
458
|
-
}));
|
|
459
|
-
}
|
|
460
|
-
if (props.lazy) {
|
|
461
|
-
Promise.resolve().then(function () {
|
|
462
|
-
lazyLoadState.current = {
|
|
463
|
-
first: props.step ? both ? {
|
|
464
|
-
rows: 0,
|
|
465
|
-
cols: firstState.cols
|
|
466
|
-
} : 0 : firstState,
|
|
467
|
-
last: Math.min(props.step ? props.step : last, props.items.length)
|
|
468
|
-
};
|
|
469
|
-
props.onLazyLoad && props.onLazyLoad(lazyLoadState.current);
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
};
|
|
473
|
-
var calculateAutoSize = function calculateAutoSize(loading) {
|
|
474
|
-
if (props.autoSize && !loading) {
|
|
475
|
-
Promise.resolve().then(function () {
|
|
476
|
-
if (_contentRef.current) {
|
|
477
|
-
_contentRef.current.style.minHeight = _contentRef.current.style.minWidth = 'auto';
|
|
478
|
-
_contentRef.current.style.position = 'relative';
|
|
479
|
-
elementRef.current.style.contain = 'none';
|
|
480
|
-
|
|
481
|
-
/*const [contentWidth, contentHeight] = [DomHandler.getWidth(contentRef.current), DomHandler.getHeight(contentRef.current)];
|
|
482
|
-
contentWidth !== defaultContentWidth.current && (elementRef.current.style.width = '');
|
|
483
|
-
contentHeight !== defaultContentHeight.current && (elementRef.current.style.height = '');*/
|
|
484
|
-
|
|
485
|
-
var _ref = [DomHandler.getWidth(elementRef.current), DomHandler.getHeight(elementRef.current)],
|
|
486
|
-
width = _ref[0],
|
|
487
|
-
height = _ref[1];
|
|
488
|
-
(both || horizontal) && (elementRef.current.style.width = (width < defaultWidth.current ? width : props.scrollWidth || defaultWidth.current) + 'px');
|
|
489
|
-
(both || vertical) && (elementRef.current.style.height = (height < defaultHeight.current ? height : props.scrollHeight || defaultHeight.current) + 'px');
|
|
490
|
-
_contentRef.current.style.minHeight = _contentRef.current.style.minWidth = '';
|
|
491
|
-
_contentRef.current.style.position = '';
|
|
492
|
-
elementRef.current.style.contain = '';
|
|
493
|
-
}
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
var getLast = function getLast() {
|
|
498
|
-
var last = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
499
|
-
var isCols = arguments.length > 1 ? arguments[1] : undefined;
|
|
500
|
-
return props.items ? Math.min(isCols ? (props.columns || props.items[0]).length : props.items.length, last) : 0;
|
|
501
|
-
};
|
|
502
|
-
var getContentPosition = function getContentPosition() {
|
|
503
|
-
if (_contentRef.current) {
|
|
504
|
-
var style = getComputedStyle(_contentRef.current);
|
|
505
|
-
var left = parseFloat(style.paddingLeft) + Math.max(parseFloat(style.left) || 0, 0);
|
|
506
|
-
var right = parseFloat(style.paddingRight) + Math.max(parseFloat(style.right) || 0, 0);
|
|
507
|
-
var top = parseFloat(style.paddingTop) + Math.max(parseFloat(style.top) || 0, 0);
|
|
508
|
-
var bottom = parseFloat(style.paddingBottom) + Math.max(parseFloat(style.bottom) || 0, 0);
|
|
509
|
-
return {
|
|
510
|
-
left: left,
|
|
511
|
-
right: right,
|
|
512
|
-
top: top,
|
|
513
|
-
bottom: bottom,
|
|
514
|
-
x: left + right,
|
|
515
|
-
y: top + bottom
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
return {
|
|
519
|
-
left: 0,
|
|
520
|
-
right: 0,
|
|
521
|
-
top: 0,
|
|
522
|
-
bottom: 0,
|
|
523
|
-
x: 0,
|
|
524
|
-
y: 0
|
|
525
|
-
};
|
|
526
|
-
};
|
|
527
|
-
var setSize = function setSize() {
|
|
528
|
-
if (elementRef.current) {
|
|
529
|
-
var parentElement = elementRef.current.parentElement;
|
|
530
|
-
var width = props.scrollWidth || "".concat(elementRef.current.offsetWidth || parentElement.offsetWidth, "px");
|
|
531
|
-
var height = props.scrollHeight || "".concat(elementRef.current.offsetHeight || parentElement.offsetHeight, "px");
|
|
532
|
-
var setProp = function setProp(_name, _value) {
|
|
533
|
-
return elementRef.current.style[_name] = _value;
|
|
534
|
-
};
|
|
535
|
-
if (both || horizontal) {
|
|
536
|
-
setProp('height', height);
|
|
537
|
-
setProp('width', width);
|
|
538
|
-
} else {
|
|
539
|
-
setProp('height', height);
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
};
|
|
543
|
-
var setSpacerSize = function setSpacerSize() {
|
|
544
|
-
var items = props.items;
|
|
545
|
-
if (items) {
|
|
546
|
-
var contentPos = getContentPosition();
|
|
547
|
-
var setProp = function setProp(_name, _value, _size) {
|
|
548
|
-
var _cpos = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
549
|
-
return spacerStyle.current = _objectSpread(_objectSpread({}, spacerStyle.current), _defineProperty({}, "".concat(_name), (_value || []).length * _size + _cpos + 'px'));
|
|
550
|
-
};
|
|
551
|
-
if (both) {
|
|
552
|
-
setProp('height', items, props.itemSize[0], contentPos.y);
|
|
553
|
-
setProp('width', props.columns || items[1], props.itemSize[1], contentPos.x);
|
|
554
|
-
} else {
|
|
555
|
-
horizontal ? setProp('width', props.columns || items, props.itemSize, contentPos.x) : setProp('height', items, props.itemSize, contentPos.y);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
};
|
|
559
|
-
var setContentPosition = function setContentPosition(pos) {
|
|
560
|
-
if (_contentRef.current && !props.appendOnly) {
|
|
561
|
-
var first = pos ? pos.first : firstState;
|
|
562
|
-
var calculateTranslateVal = function calculateTranslateVal(_first, _size) {
|
|
563
|
-
return _first * _size;
|
|
564
|
-
};
|
|
565
|
-
var setTransform = function setTransform() {
|
|
566
|
-
var _x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
567
|
-
var _y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
568
|
-
_stickyRef.current && (_stickyRef.current.style.top = "-".concat(_y, "px"));
|
|
569
|
-
contentStyle.current = _objectSpread(_objectSpread({}, contentStyle.current), {
|
|
570
|
-
transform: "translate3d(".concat(_x, "px, ").concat(_y, "px, 0)")
|
|
571
|
-
});
|
|
572
|
-
};
|
|
573
|
-
if (both) {
|
|
574
|
-
setTransform(calculateTranslateVal(first.cols, props.itemSize[1]), calculateTranslateVal(first.rows, props.itemSize[0]));
|
|
575
|
-
} else {
|
|
576
|
-
var translateVal = calculateTranslateVal(first, props.itemSize);
|
|
577
|
-
horizontal ? setTransform(translateVal, 0) : setTransform(0, translateVal);
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
};
|
|
581
|
-
var onScrollPositionChange = function onScrollPositionChange(event) {
|
|
582
|
-
var target = event.target;
|
|
583
|
-
var contentPos = getContentPosition();
|
|
584
|
-
var calculateScrollPos = function calculateScrollPos(_pos, _cpos) {
|
|
585
|
-
return _pos ? _pos > _cpos ? _pos - _cpos : _pos : 0;
|
|
586
|
-
};
|
|
587
|
-
var calculateCurrentIndex = function calculateCurrentIndex(_pos, _size) {
|
|
588
|
-
return Math.floor(_pos / (_size || _pos));
|
|
589
|
-
};
|
|
590
|
-
var calculateTriggerIndex = function calculateTriggerIndex(_currentIndex, _first, _last, _num, _numT, _isScrollDownOrRight) {
|
|
591
|
-
return _currentIndex <= _numT ? _numT : _isScrollDownOrRight ? _last - _num - _numT : _first + _numT - 1;
|
|
592
|
-
};
|
|
593
|
-
var calculateFirst = function calculateFirst(_currentIndex, _triggerIndex, _first, _last, _num, _numT, _isScrollDownOrRight) {
|
|
594
|
-
if (_currentIndex <= _numT) return 0;else return Math.max(0, _isScrollDownOrRight ? _currentIndex < _triggerIndex ? _first : _currentIndex - _numT : _currentIndex > _triggerIndex ? _first : _currentIndex - 2 * _numT);
|
|
595
|
-
};
|
|
596
|
-
var calculateLast = function calculateLast(_currentIndex, _first, _last, _num, _numT, _isCols) {
|
|
597
|
-
var lastValue = _first + _num + 2 * _numT;
|
|
598
|
-
if (_currentIndex >= _numT) {
|
|
599
|
-
lastValue += _numT + 1;
|
|
600
|
-
}
|
|
601
|
-
return getLast(lastValue, _isCols);
|
|
602
|
-
};
|
|
603
|
-
var scrollTop = calculateScrollPos(target.scrollTop, contentPos.top);
|
|
604
|
-
var scrollLeft = calculateScrollPos(target.scrollLeft, contentPos.left);
|
|
605
|
-
var newFirst = both ? {
|
|
606
|
-
rows: 0,
|
|
607
|
-
cols: 0
|
|
608
|
-
} : 0;
|
|
609
|
-
var newLast = lastState;
|
|
610
|
-
var isRangeChanged = false;
|
|
611
|
-
var newScrollPos = lastScrollPos.current;
|
|
612
|
-
if (both) {
|
|
613
|
-
var isScrollDown = lastScrollPos.current.top <= scrollTop;
|
|
614
|
-
var isScrollRight = lastScrollPos.current.left <= scrollLeft;
|
|
615
|
-
if (!props.appendOnly || props.appendOnly && (isScrollDown || isScrollRight)) {
|
|
616
|
-
var currentIndex = {
|
|
617
|
-
rows: calculateCurrentIndex(scrollTop, props.itemSize[0]),
|
|
618
|
-
cols: calculateCurrentIndex(scrollLeft, props.itemSize[1])
|
|
619
|
-
};
|
|
620
|
-
var triggerIndex = {
|
|
621
|
-
rows: calculateTriggerIndex(currentIndex.rows, firstState.rows, lastState.rows, numItemsInViewportState.rows, numToleratedItemsState[0], isScrollDown),
|
|
622
|
-
cols: calculateTriggerIndex(currentIndex.cols, firstState.cols, lastState.cols, numItemsInViewportState.cols, numToleratedItemsState[1], isScrollRight)
|
|
623
|
-
};
|
|
624
|
-
newFirst = {
|
|
625
|
-
rows: calculateFirst(currentIndex.rows, triggerIndex.rows, firstState.rows, lastState.rows, numItemsInViewportState.rows, numToleratedItemsState[0], isScrollDown),
|
|
626
|
-
cols: calculateFirst(currentIndex.cols, triggerIndex.cols, firstState.cols, lastState.cols, numItemsInViewportState.cols, numToleratedItemsState[1], isScrollRight)
|
|
627
|
-
};
|
|
628
|
-
newLast = {
|
|
629
|
-
rows: calculateLast(currentIndex.rows, newFirst.rows, lastState.rows, numItemsInViewportState.rows, numToleratedItemsState[0]),
|
|
630
|
-
cols: calculateLast(currentIndex.cols, newFirst.cols, lastState.cols, numItemsInViewportState.cols, numToleratedItemsState[1], true)
|
|
631
|
-
};
|
|
632
|
-
isRangeChanged = newFirst.rows !== firstState.rows || newLast.rows !== lastState.rows || newFirst.cols !== firstState.cols || newLast.cols !== lastState.cols || isItemRangeChanged.current;
|
|
633
|
-
newScrollPos = {
|
|
634
|
-
top: scrollTop,
|
|
635
|
-
left: scrollLeft
|
|
636
|
-
};
|
|
637
|
-
}
|
|
638
|
-
} else {
|
|
639
|
-
var scrollPos = horizontal ? scrollLeft : scrollTop;
|
|
640
|
-
var isScrollDownOrRight = lastScrollPos.current <= scrollPos;
|
|
641
|
-
if (!props.appendOnly || props.appendOnly && isScrollDownOrRight) {
|
|
642
|
-
var _currentIndex2 = calculateCurrentIndex(scrollPos, props.itemSize);
|
|
643
|
-
var _triggerIndex2 = calculateTriggerIndex(_currentIndex2, firstState, lastState, numItemsInViewportState, numToleratedItemsState, isScrollDownOrRight);
|
|
644
|
-
newFirst = calculateFirst(_currentIndex2, _triggerIndex2, firstState, lastState, numItemsInViewportState, numToleratedItemsState, isScrollDownOrRight);
|
|
645
|
-
newLast = calculateLast(_currentIndex2, newFirst, lastState, numItemsInViewportState, numToleratedItemsState);
|
|
646
|
-
isRangeChanged = newFirst !== firstState || newLast !== lastState || isItemRangeChanged.current;
|
|
647
|
-
newScrollPos = scrollPos;
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
return {
|
|
651
|
-
first: newFirst,
|
|
652
|
-
last: newLast,
|
|
653
|
-
isRangeChanged: isRangeChanged,
|
|
654
|
-
scrollPos: newScrollPos
|
|
655
|
-
};
|
|
656
|
-
};
|
|
657
|
-
var onScrollChange = function onScrollChange(event) {
|
|
658
|
-
var _onScrollPositionChan = onScrollPositionChange(event),
|
|
659
|
-
first = _onScrollPositionChan.first,
|
|
660
|
-
last = _onScrollPositionChan.last,
|
|
661
|
-
isRangeChanged = _onScrollPositionChan.isRangeChanged,
|
|
662
|
-
scrollPos = _onScrollPositionChan.scrollPos;
|
|
663
|
-
if (isRangeChanged) {
|
|
664
|
-
var newState = {
|
|
665
|
-
first: first,
|
|
666
|
-
last: last
|
|
667
|
-
};
|
|
668
|
-
setContentPosition(newState);
|
|
669
|
-
setFirstState(first);
|
|
670
|
-
setLastState(last);
|
|
671
|
-
lastScrollPos.current = scrollPos;
|
|
672
|
-
props.onScrollIndexChange && props.onScrollIndexChange(newState);
|
|
673
|
-
if (props.lazy && isPageChanged(first)) {
|
|
674
|
-
var newLazyLoadState = {
|
|
675
|
-
first: props.step ? Math.min(getPageByFirst(first) * props.step, props.items.length - props.step) : first,
|
|
676
|
-
last: Math.min(props.step ? (getPageByFirst(first) + 1) * props.step : last, props.items.length)
|
|
677
|
-
};
|
|
678
|
-
var isLazyStateChanged = !lazyLoadState.current || lazyLoadState.current.first !== newLazyLoadState.first || lazyLoadState.current.last !== newLazyLoadState.last;
|
|
679
|
-
isLazyStateChanged && props.onLazyLoad && props.onLazyLoad(newLazyLoadState);
|
|
680
|
-
lazyLoadState.current = newLazyLoadState;
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
};
|
|
684
|
-
var _onScroll = function onScroll(event) {
|
|
685
|
-
props.onScroll && props.onScroll(event);
|
|
686
|
-
if (props.delay) {
|
|
687
|
-
if (scrollTimeout.current) {
|
|
688
|
-
clearTimeout(scrollTimeout.current);
|
|
689
|
-
}
|
|
690
|
-
if (isPageChanged(firstState)) {
|
|
691
|
-
if (!loadingState && props.showLoader) {
|
|
692
|
-
var _onScrollPositionChan2 = onScrollPositionChange(event),
|
|
693
|
-
isRangeChanged = _onScrollPositionChan2.isRangeChanged;
|
|
694
|
-
var changed = isRangeChanged || (props.step ? isPageChanged(firstState) : false);
|
|
695
|
-
changed && setLoadingState(true);
|
|
696
|
-
}
|
|
697
|
-
scrollTimeout.current = setTimeout(function () {
|
|
698
|
-
onScrollChange(event);
|
|
699
|
-
if (loadingState && props.showLoader && (!props.lazy || props.loading === undefined)) {
|
|
700
|
-
setLoadingState(false);
|
|
701
|
-
setPageState(getPageByFirst(firstState));
|
|
702
|
-
}
|
|
703
|
-
}, props.delay);
|
|
704
|
-
}
|
|
705
|
-
} else {
|
|
706
|
-
onScrollChange(event);
|
|
707
|
-
}
|
|
708
|
-
};
|
|
709
|
-
var onResize = function onResize() {
|
|
710
|
-
if (resizeTimeout.current) {
|
|
711
|
-
clearTimeout(resizeTimeout.current);
|
|
712
|
-
}
|
|
713
|
-
resizeTimeout.current = setTimeout(function () {
|
|
714
|
-
if (elementRef.current) {
|
|
715
|
-
var _ref2 = [DomHandler.getWidth(elementRef.current), DomHandler.getHeight(elementRef.current)],
|
|
716
|
-
width = _ref2[0],
|
|
717
|
-
height = _ref2[1];
|
|
718
|
-
var isDiffWidth = width !== defaultWidth.current,
|
|
719
|
-
isDiffHeight = height !== defaultHeight.current;
|
|
720
|
-
var reinit = both ? isDiffWidth || isDiffHeight : horizontal ? isDiffWidth : vertical ? isDiffHeight : false;
|
|
721
|
-
if (reinit) {
|
|
722
|
-
setNumToleratedItemsState(props.numToleratedItems);
|
|
723
|
-
defaultWidth.current = width;
|
|
724
|
-
defaultHeight.current = height;
|
|
725
|
-
defaultContentWidth.current = DomHandler.getWidth(_contentRef.current);
|
|
726
|
-
defaultContentHeight.current = DomHandler.getHeight(_contentRef.current);
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
}, props.resizeDelay);
|
|
730
|
-
};
|
|
731
|
-
var getOptions = function getOptions(renderedIndex) {
|
|
732
|
-
var count = (props.items || []).length;
|
|
733
|
-
var index = both ? firstState.rows + renderedIndex : firstState + renderedIndex;
|
|
734
|
-
return {
|
|
735
|
-
index: index,
|
|
736
|
-
count: count,
|
|
737
|
-
first: index === 0,
|
|
738
|
-
last: index === count - 1,
|
|
739
|
-
even: index % 2 === 0,
|
|
740
|
-
odd: index % 2 !== 0,
|
|
741
|
-
props: props
|
|
742
|
-
};
|
|
743
|
-
};
|
|
744
|
-
var loaderOptions = function loaderOptions(index, extOptions) {
|
|
745
|
-
var count = loaderArrState.length;
|
|
746
|
-
return _objectSpread({
|
|
747
|
-
index: index,
|
|
748
|
-
count: count,
|
|
749
|
-
first: index === 0,
|
|
750
|
-
last: index === count - 1,
|
|
751
|
-
even: index % 2 === 0,
|
|
752
|
-
odd: index % 2 !== 0,
|
|
753
|
-
props: props
|
|
754
|
-
}, extOptions);
|
|
755
|
-
};
|
|
756
|
-
var loadedItems = function loadedItems() {
|
|
757
|
-
var items = props.items;
|
|
758
|
-
if (items && !loadingState) {
|
|
759
|
-
if (both) return items.slice(props.appendOnly ? 0 : firstState.rows, lastState.rows).map(function (item) {
|
|
760
|
-
return props.columns ? item : item.slice(props.appendOnly ? 0 : firstState.cols, lastState.cols);
|
|
761
|
-
});else if (horizontal && props.columns) return items;else return items.slice(props.appendOnly ? 0 : firstState, lastState);
|
|
762
|
-
}
|
|
763
|
-
return [];
|
|
764
|
-
};
|
|
765
|
-
var viewInit = function viewInit() {
|
|
766
|
-
if (elementRef.current && DomHandler.isVisible(elementRef.current)) {
|
|
767
|
-
setContentElement(_contentRef.current);
|
|
768
|
-
init();
|
|
769
|
-
bindWindowResizeListener();
|
|
770
|
-
bindOrientationChangeListener();
|
|
771
|
-
defaultWidth.current = DomHandler.getWidth(elementRef.current);
|
|
772
|
-
defaultHeight.current = DomHandler.getHeight(elementRef.current);
|
|
773
|
-
defaultContentWidth.current = DomHandler.getWidth(_contentRef.current);
|
|
774
|
-
defaultContentHeight.current = DomHandler.getHeight(_contentRef.current);
|
|
775
|
-
}
|
|
776
|
-
};
|
|
777
|
-
var init = function init() {
|
|
778
|
-
if (!props.disabled) {
|
|
779
|
-
setSize();
|
|
780
|
-
calculateOptions();
|
|
781
|
-
setSpacerSize();
|
|
782
|
-
}
|
|
783
|
-
};
|
|
784
|
-
useMountEffect(function () {
|
|
785
|
-
viewInit();
|
|
786
|
-
});
|
|
787
|
-
useUpdateEffect(function () {
|
|
788
|
-
init();
|
|
789
|
-
}, [props.itemSize, props.scrollHeight, props.scrollWidth]);
|
|
790
|
-
useUpdateEffect(function () {
|
|
791
|
-
if (props.numToleratedItems !== numToleratedItemsState) {
|
|
792
|
-
setNumToleratedItemsState(props.numToleratedItems);
|
|
793
|
-
}
|
|
794
|
-
}, [props.numToleratedItems]);
|
|
795
|
-
useUpdateEffect(function () {
|
|
796
|
-
if (props.numToleratedItems === numToleratedItemsState) {
|
|
797
|
-
init(); // reinit after resizing
|
|
798
|
-
}
|
|
799
|
-
}, [numToleratedItemsState]);
|
|
800
|
-
useUpdateEffect(function () {
|
|
801
|
-
if (!prevProps.items || prevProps.items.length !== (props.items || []).length) {
|
|
802
|
-
init();
|
|
803
|
-
}
|
|
804
|
-
var loading = loadingState;
|
|
805
|
-
if (props.lazy && prevProps.loading !== props.loading && props.loading !== loadingState) {
|
|
806
|
-
setLoadingState(props.loading);
|
|
807
|
-
loading = props.loading;
|
|
808
|
-
}
|
|
809
|
-
calculateAutoSize(loading);
|
|
810
|
-
});
|
|
811
|
-
useUpdateEffect(function () {
|
|
812
|
-
lastScrollPos.current = both ? {
|
|
813
|
-
top: 0,
|
|
814
|
-
left: 0
|
|
815
|
-
} : 0;
|
|
816
|
-
}, [props.orientation]);
|
|
817
|
-
React.useImperativeHandle(ref, function () {
|
|
818
|
-
return {
|
|
819
|
-
props: props,
|
|
820
|
-
getElementRef: getElementRef,
|
|
821
|
-
scrollTo: scrollTo,
|
|
822
|
-
scrollToIndex: scrollToIndex,
|
|
823
|
-
scrollInView: scrollInView,
|
|
824
|
-
getRenderedRange: getRenderedRange
|
|
825
|
-
};
|
|
826
|
-
});
|
|
827
|
-
var createLoaderItem = function createLoaderItem(index) {
|
|
828
|
-
var extOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
829
|
-
var options = loaderOptions(index, extOptions);
|
|
830
|
-
var content = ObjectUtils.getJSXElement(props.loadingTemplate, options);
|
|
831
|
-
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
832
|
-
key: index
|
|
833
|
-
}, content);
|
|
834
|
-
};
|
|
835
|
-
var createLoader = function createLoader() {
|
|
836
|
-
var iconClassName = 'p-virtualscroller-loading-icon';
|
|
837
|
-
var loadingIconProps = mergeProps({
|
|
838
|
-
className: iconClassName
|
|
839
|
-
}, ptm('loadingIcon'));
|
|
840
|
-
var icon = props.loadingIcon || /*#__PURE__*/React.createElement(SpinnerIcon, _extends({}, loadingIconProps, {
|
|
841
|
-
spin: true
|
|
842
|
-
}));
|
|
843
|
-
var loadingIcon = IconUtils.getJSXIcon(icon, _objectSpread({}, loadingIconProps), {
|
|
844
|
-
props: props
|
|
845
|
-
});
|
|
846
|
-
if (!props.loaderDisabled && props.showLoader && loadingState) {
|
|
847
|
-
var className = classNames('p-virtualscroller-loader', {
|
|
848
|
-
'p-component-overlay': !props.loadingTemplate
|
|
849
|
-
});
|
|
850
|
-
var content = loadingIcon;
|
|
851
|
-
if (props.loadingTemplate) {
|
|
852
|
-
content = loaderArrState.map(function (_, index) {
|
|
853
|
-
return createLoaderItem(index, both && {
|
|
854
|
-
numCols: numItemsInViewportState.cols
|
|
855
|
-
});
|
|
856
|
-
});
|
|
857
|
-
} else if (props.loaderIconTemplate) {
|
|
858
|
-
var defaultContentOptions = {
|
|
859
|
-
iconClassName: iconClassName,
|
|
860
|
-
element: content,
|
|
861
|
-
props: props
|
|
862
|
-
};
|
|
863
|
-
content = ObjectUtils.getJSXElement(props.loaderIconTemplate, defaultContentOptions);
|
|
864
|
-
}
|
|
865
|
-
var loaderProps = mergeProps({
|
|
866
|
-
className: className
|
|
867
|
-
}, ptm('loader'));
|
|
868
|
-
return /*#__PURE__*/React.createElement("div", loaderProps, content);
|
|
869
|
-
}
|
|
870
|
-
return null;
|
|
871
|
-
};
|
|
872
|
-
var createSpacer = function createSpacer() {
|
|
873
|
-
if (props.showSpacer) {
|
|
874
|
-
var spacerProps = mergeProps({
|
|
875
|
-
ref: _spacerRef,
|
|
876
|
-
style: spacerStyle.current,
|
|
877
|
-
className: 'p-virtualscroller-spacer'
|
|
878
|
-
}, ptm('spacer'));
|
|
879
|
-
return /*#__PURE__*/React.createElement("div", spacerProps);
|
|
880
|
-
}
|
|
881
|
-
return null;
|
|
882
|
-
};
|
|
883
|
-
var createItem = function createItem(item, index) {
|
|
884
|
-
var options = getOptions(index);
|
|
885
|
-
var content = ObjectUtils.getJSXElement(props.itemTemplate, item, options);
|
|
886
|
-
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
887
|
-
key: options.index
|
|
888
|
-
}, content);
|
|
889
|
-
};
|
|
890
|
-
var createItems = function createItems() {
|
|
891
|
-
var items = loadedItems();
|
|
892
|
-
return items.map(createItem);
|
|
893
|
-
};
|
|
894
|
-
var createContent = function createContent() {
|
|
895
|
-
var items = createItems();
|
|
896
|
-
var className = classNames('p-virtualscroller-content', {
|
|
897
|
-
'p-virtualscroller-loading': loadingState
|
|
898
|
-
});
|
|
899
|
-
var contentProps = mergeProps({
|
|
900
|
-
ref: _contentRef,
|
|
901
|
-
style: contentStyle.current,
|
|
902
|
-
className: className
|
|
903
|
-
}, ptm('content'));
|
|
904
|
-
var content = /*#__PURE__*/React.createElement("div", contentProps, items);
|
|
905
|
-
if (props.contentTemplate) {
|
|
906
|
-
var defaultOptions = {
|
|
907
|
-
style: contentStyle.current,
|
|
908
|
-
className: className,
|
|
909
|
-
spacerStyle: spacerStyle.current,
|
|
910
|
-
contentRef: function contentRef(el) {
|
|
911
|
-
return _contentRef.current = ObjectUtils.getRefElement(el);
|
|
912
|
-
},
|
|
913
|
-
spacerRef: function spacerRef(el) {
|
|
914
|
-
return _spacerRef.current = ObjectUtils.getRefElement(el);
|
|
915
|
-
},
|
|
916
|
-
stickyRef: function stickyRef(el) {
|
|
917
|
-
return _stickyRef.current = ObjectUtils.getRefElement(el);
|
|
918
|
-
},
|
|
919
|
-
items: loadedItems(),
|
|
920
|
-
getItemOptions: function getItemOptions(index) {
|
|
921
|
-
return getOptions(index);
|
|
922
|
-
},
|
|
923
|
-
children: items,
|
|
924
|
-
element: content,
|
|
925
|
-
props: props,
|
|
926
|
-
loading: loadingState,
|
|
927
|
-
getLoaderOptions: function getLoaderOptions(index, ext) {
|
|
928
|
-
return loaderOptions(index, ext);
|
|
929
|
-
},
|
|
930
|
-
loadingTemplate: props.loadingTemplate,
|
|
931
|
-
itemSize: props.itemSize,
|
|
932
|
-
rows: getRows(),
|
|
933
|
-
columns: getColumns(),
|
|
934
|
-
vertical: vertical,
|
|
935
|
-
horizontal: horizontal,
|
|
936
|
-
both: both
|
|
937
|
-
};
|
|
938
|
-
return ObjectUtils.getJSXElement(props.contentTemplate, defaultOptions);
|
|
939
|
-
}
|
|
940
|
-
return content;
|
|
941
|
-
};
|
|
942
|
-
if (props.disabled) {
|
|
943
|
-
var content = ObjectUtils.getJSXElement(props.contentTemplate, {
|
|
944
|
-
items: props.items,
|
|
945
|
-
rows: props.items,
|
|
946
|
-
columns: props.columns
|
|
947
|
-
});
|
|
948
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, props.children, content);
|
|
949
|
-
} else {
|
|
950
|
-
var className = classNames('p-virtualscroller', {
|
|
951
|
-
'p-virtualscroller-inline': props.inline,
|
|
952
|
-
'p-virtualscroller-both p-both-scroll': both,
|
|
953
|
-
'p-virtualscroller-horizontal p-horizontal-scroll': horizontal
|
|
954
|
-
}, props.className);
|
|
955
|
-
var loader = createLoader();
|
|
956
|
-
var _content = createContent();
|
|
957
|
-
var spacer = createSpacer();
|
|
958
|
-
var rootProps = mergeProps({
|
|
959
|
-
ref: elementRef,
|
|
960
|
-
className: className,
|
|
961
|
-
tabIndex: props.tabIndex,
|
|
962
|
-
style: props.style,
|
|
963
|
-
onScroll: function onScroll(e) {
|
|
964
|
-
return _onScroll(e);
|
|
965
|
-
}
|
|
966
|
-
}, VirtualScrollerBase.getOtherProps(props), ptm('root'));
|
|
967
|
-
return /*#__PURE__*/React.createElement("div", rootProps, _content, spacer, loader);
|
|
968
|
-
}
|
|
969
|
-
}));
|
|
970
|
-
VirtualScroller.displayName = 'VirtualScroller';
|
|
971
|
-
|
|
972
|
-
export { VirtualScroller };
|