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,1209 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import PrimeReact, { PrimeReactContext } from 'primereact/api';
|
|
5
|
-
import { ComponentBase, useHandleStyle } from 'primereact/componentbase';
|
|
6
|
-
import { useMountEffect, useUpdateEffect } from 'primereact/hooks';
|
|
7
|
-
import { AngleDownIcon } from 'primereact/icons/angledown';
|
|
8
|
-
import { AngleUpIcon } from 'primereact/icons/angleup';
|
|
9
|
-
import { InputText } from 'primereact/inputtext';
|
|
10
|
-
import { Ripple } from 'primereact/ripple';
|
|
11
|
-
import { Tooltip } from 'primereact/tooltip';
|
|
12
|
-
import { classNames, DomHandler, ObjectUtils, mergeProps, IconUtils } from 'primereact/utils';
|
|
13
|
-
|
|
14
|
-
function _extends() {
|
|
15
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
16
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
17
|
-
var source = arguments[i];
|
|
18
|
-
for (var key in source) {
|
|
19
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
20
|
-
target[key] = source[key];
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return target;
|
|
25
|
-
};
|
|
26
|
-
return _extends.apply(this, arguments);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function _arrayLikeToArray(arr, len) {
|
|
30
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
31
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
32
|
-
return arr2;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function _arrayWithoutHoles(arr) {
|
|
36
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function _iterableToArray(iter) {
|
|
40
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
44
|
-
if (!o) return;
|
|
45
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
46
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
47
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
48
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
49
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function _nonIterableSpread() {
|
|
53
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function _toConsumableArray(arr) {
|
|
57
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function _typeof(o) {
|
|
61
|
-
"@babel/helpers - typeof";
|
|
62
|
-
|
|
63
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
64
|
-
return typeof o;
|
|
65
|
-
} : function (o) {
|
|
66
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
67
|
-
}, _typeof(o);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function _toPrimitive(input, hint) {
|
|
71
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
72
|
-
var prim = input[Symbol.toPrimitive];
|
|
73
|
-
if (prim !== undefined) {
|
|
74
|
-
var res = prim.call(input, hint || "default");
|
|
75
|
-
if (_typeof(res) !== "object") return res;
|
|
76
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
77
|
-
}
|
|
78
|
-
return (hint === "string" ? String : Number)(input);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function _toPropertyKey(arg) {
|
|
82
|
-
var key = _toPrimitive(arg, "string");
|
|
83
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function _defineProperty(obj, key, value) {
|
|
87
|
-
key = _toPropertyKey(key);
|
|
88
|
-
if (key in obj) {
|
|
89
|
-
Object.defineProperty(obj, key, {
|
|
90
|
-
value: value,
|
|
91
|
-
enumerable: true,
|
|
92
|
-
configurable: true,
|
|
93
|
-
writable: true
|
|
94
|
-
});
|
|
95
|
-
} else {
|
|
96
|
-
obj[key] = value;
|
|
97
|
-
}
|
|
98
|
-
return obj;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function _arrayWithHoles(arr) {
|
|
102
|
-
if (Array.isArray(arr)) return arr;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function _iterableToArrayLimit(r, l) {
|
|
106
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
107
|
-
if (null != t) {
|
|
108
|
-
var e,
|
|
109
|
-
n,
|
|
110
|
-
i,
|
|
111
|
-
u,
|
|
112
|
-
a = [],
|
|
113
|
-
f = !0,
|
|
114
|
-
o = !1;
|
|
115
|
-
try {
|
|
116
|
-
if (i = (t = t.call(r)).next, 0 === l) {
|
|
117
|
-
if (Object(t) !== t) return;
|
|
118
|
-
f = !1;
|
|
119
|
-
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
120
|
-
} catch (r) {
|
|
121
|
-
o = !0, n = r;
|
|
122
|
-
} finally {
|
|
123
|
-
try {
|
|
124
|
-
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
|
|
125
|
-
} finally {
|
|
126
|
-
if (o) throw n;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return a;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function _nonIterableRest() {
|
|
134
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function _slicedToArray(arr, i) {
|
|
138
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
var classes = {
|
|
142
|
-
root: function root(_ref) {
|
|
143
|
-
var props = _ref.props,
|
|
144
|
-
focusedState = _ref.focusedState,
|
|
145
|
-
stacked = _ref.stacked,
|
|
146
|
-
horizontal = _ref.horizontal,
|
|
147
|
-
vertical = _ref.vertical;
|
|
148
|
-
return classNames('p-inputnumber p-component p-inputwrapper', {
|
|
149
|
-
'p-inputwrapper-filled': props.value != null && props.value.toString().length > 0,
|
|
150
|
-
'p-inputwrapper-focus': focusedState,
|
|
151
|
-
'p-inputnumber-buttons-stacked': stacked,
|
|
152
|
-
'p-inputnumber-buttons-horizontal': horizontal,
|
|
153
|
-
'p-inputnumber-buttons-vertical': vertical
|
|
154
|
-
});
|
|
155
|
-
},
|
|
156
|
-
buttonGroup: 'p-inputnumber-button-group',
|
|
157
|
-
incrementButton: function incrementButton(_ref2) {
|
|
158
|
-
var props = _ref2.props;
|
|
159
|
-
return classNames('p-inputnumber-button p-inputnumber-button-up p-button p-button-icon-only p-component', {
|
|
160
|
-
'p-disabled': props.disabled
|
|
161
|
-
});
|
|
162
|
-
},
|
|
163
|
-
incrementIcon: 'p-button-icon',
|
|
164
|
-
decrementButton: function decrementButton(_ref3) {
|
|
165
|
-
var props = _ref3.props;
|
|
166
|
-
return classNames('p-inputnumber-button p-inputnumber-button-down p-button p-button-icon-only p-component', {
|
|
167
|
-
'p-disabled': props.disabled
|
|
168
|
-
});
|
|
169
|
-
},
|
|
170
|
-
decrementIcon: 'p-button-icon'
|
|
171
|
-
};
|
|
172
|
-
var styles = "\n@layer primereact {\n .p-inputnumber {\n display: inline-flex;\n }\n \n .p-inputnumber-button {\n display: flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n }\n \n .p-inputnumber-buttons-stacked .p-button.p-inputnumber-button .p-button-label,\n .p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button .p-button-label {\n display: none;\n }\n \n .p-inputnumber-buttons-stacked .p-button.p-inputnumber-button-up {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n padding: 0;\n }\n \n .p-inputnumber-buttons-stacked .p-inputnumber-input {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n }\n \n .p-inputnumber-buttons-stacked .p-button.p-inputnumber-button-down {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n border-bottom-left-radius: 0;\n padding: 0;\n }\n \n .p-inputnumber-buttons-stacked .p-inputnumber-button-group {\n display: flex;\n flex-direction: column;\n }\n \n .p-inputnumber-buttons-stacked .p-inputnumber-button-group .p-button.p-inputnumber-button {\n flex: 1 1 auto;\n }\n \n .p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button-up {\n order: 3;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n }\n \n .p-inputnumber-buttons-horizontal .p-inputnumber-input {\n order: 2;\n border-radius: 0;\n }\n \n .p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button-down {\n order: 1;\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n }\n \n .p-inputnumber-buttons-vertical {\n flex-direction: column;\n }\n \n .p-inputnumber-buttons-vertical .p-button.p-inputnumber-button-up {\n order: 1;\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n width: 100%;\n }\n \n .p-inputnumber-buttons-vertical .p-inputnumber-input {\n order: 2;\n border-radius: 0;\n text-align: center;\n }\n \n .p-inputnumber-buttons-vertical .p-button.p-inputnumber-button-down {\n order: 3;\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n width: 100%;\n }\n \n .p-inputnumber-input {\n flex: 1 1 auto;\n }\n \n .p-fluid .p-inputnumber {\n width: 100%;\n }\n \n .p-fluid .p-inputnumber .p-inputnumber-input {\n width: 1%;\n }\n \n .p-fluid .p-inputnumber-buttons-vertical .p-inputnumber-input {\n width: 100%;\n }\n}\n";
|
|
173
|
-
var InputNumberBase = ComponentBase.extend({
|
|
174
|
-
defaultProps: {
|
|
175
|
-
__TYPE: 'InputNumber',
|
|
176
|
-
__parentMetadata: null,
|
|
177
|
-
allowEmpty: true,
|
|
178
|
-
ariaLabelledBy: null,
|
|
179
|
-
autoFocus: false,
|
|
180
|
-
buttonLayout: 'stacked',
|
|
181
|
-
className: null,
|
|
182
|
-
currency: undefined,
|
|
183
|
-
currencyDisplay: undefined,
|
|
184
|
-
decrementButtonClassName: null,
|
|
185
|
-
decrementButtonIcon: null,
|
|
186
|
-
disabled: false,
|
|
187
|
-
format: true,
|
|
188
|
-
id: null,
|
|
189
|
-
incrementButtonClassName: null,
|
|
190
|
-
incrementButtonIcon: null,
|
|
191
|
-
inputClassName: null,
|
|
192
|
-
inputId: null,
|
|
193
|
-
inputMode: null,
|
|
194
|
-
inputRef: null,
|
|
195
|
-
inputStyle: null,
|
|
196
|
-
locale: undefined,
|
|
197
|
-
localeMatcher: undefined,
|
|
198
|
-
max: null,
|
|
199
|
-
maxFractionDigits: undefined,
|
|
200
|
-
maxLength: null,
|
|
201
|
-
min: null,
|
|
202
|
-
minFractionDigits: undefined,
|
|
203
|
-
mode: 'decimal',
|
|
204
|
-
name: null,
|
|
205
|
-
onBlur: null,
|
|
206
|
-
onChange: null,
|
|
207
|
-
onFocus: null,
|
|
208
|
-
onKeyDown: null,
|
|
209
|
-
onKeyUp: null,
|
|
210
|
-
onValueChange: null,
|
|
211
|
-
pattern: null,
|
|
212
|
-
placeholder: null,
|
|
213
|
-
prefix: null,
|
|
214
|
-
readOnly: false,
|
|
215
|
-
required: false,
|
|
216
|
-
showButtons: false,
|
|
217
|
-
size: null,
|
|
218
|
-
step: 1,
|
|
219
|
-
style: null,
|
|
220
|
-
suffix: null,
|
|
221
|
-
tabIndex: null,
|
|
222
|
-
tooltip: null,
|
|
223
|
-
tooltipOptions: null,
|
|
224
|
-
type: 'text',
|
|
225
|
-
useGrouping: true,
|
|
226
|
-
value: null,
|
|
227
|
-
children: undefined
|
|
228
|
-
},
|
|
229
|
-
css: {
|
|
230
|
-
classes: classes,
|
|
231
|
-
styles: styles
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
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; }
|
|
236
|
-
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; }
|
|
237
|
-
var InputNumber = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (inProps, ref) {
|
|
238
|
-
var context = React.useContext(PrimeReactContext);
|
|
239
|
-
var props = InputNumberBase.getProps(inProps, context);
|
|
240
|
-
var _React$useState = React.useState(false),
|
|
241
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
242
|
-
focusedState = _React$useState2[0],
|
|
243
|
-
setFocusedState = _React$useState2[1];
|
|
244
|
-
var metaData = _objectSpread(_objectSpread({
|
|
245
|
-
props: props
|
|
246
|
-
}, props.__parentMetadata), {}, {
|
|
247
|
-
state: {
|
|
248
|
-
focused: focusedState
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
var _InputNumberBase$setM = InputNumberBase.setMetaData(metaData),
|
|
252
|
-
ptm = _InputNumberBase$setM.ptm,
|
|
253
|
-
cx = _InputNumberBase$setM.cx,
|
|
254
|
-
isUnstyled = _InputNumberBase$setM.isUnstyled;
|
|
255
|
-
useHandleStyle(InputNumberBase.css.styles, isUnstyled, {
|
|
256
|
-
name: 'inputnumber'
|
|
257
|
-
});
|
|
258
|
-
var elementRef = React.useRef(null);
|
|
259
|
-
var inputRef = React.useRef(null);
|
|
260
|
-
var timer = React.useRef(null);
|
|
261
|
-
var lastValue = React.useRef(null);
|
|
262
|
-
var numberFormat = React.useRef(null);
|
|
263
|
-
var groupChar = React.useRef(null);
|
|
264
|
-
var prefixChar = React.useRef(null);
|
|
265
|
-
var suffixChar = React.useRef(null);
|
|
266
|
-
var isSpecialChar = React.useRef(null);
|
|
267
|
-
var _numeral = React.useRef(null);
|
|
268
|
-
var _group = React.useRef(null);
|
|
269
|
-
var _minusSign = React.useRef(null);
|
|
270
|
-
var _currency = React.useRef(null);
|
|
271
|
-
var _decimal = React.useRef(null);
|
|
272
|
-
var _suffix = React.useRef(null);
|
|
273
|
-
var _prefix = React.useRef(null);
|
|
274
|
-
var _index = React.useRef(null);
|
|
275
|
-
var _locale = props.locale || context && context.locale || PrimeReact.locale;
|
|
276
|
-
var stacked = props.showButtons && props.buttonLayout === 'stacked';
|
|
277
|
-
var horizontal = props.showButtons && props.buttonLayout === 'horizontal';
|
|
278
|
-
var vertical = props.showButtons && props.buttonLayout === 'vertical';
|
|
279
|
-
var inputMode = props.inputMode || (props.mode === 'decimal' && !props.minFractionDigits ? 'numeric' : 'decimal');
|
|
280
|
-
var getOptions = function getOptions() {
|
|
281
|
-
return {
|
|
282
|
-
localeMatcher: props.localeMatcher,
|
|
283
|
-
style: props.mode,
|
|
284
|
-
currency: props.currency,
|
|
285
|
-
currencyDisplay: props.currencyDisplay,
|
|
286
|
-
useGrouping: props.useGrouping,
|
|
287
|
-
minimumFractionDigits: props.minFractionDigits,
|
|
288
|
-
maximumFractionDigits: props.maxFractionDigits
|
|
289
|
-
};
|
|
290
|
-
};
|
|
291
|
-
var constructParser = function constructParser() {
|
|
292
|
-
numberFormat.current = new Intl.NumberFormat(_locale, getOptions());
|
|
293
|
-
var numerals = _toConsumableArray(new Intl.NumberFormat(_locale, {
|
|
294
|
-
useGrouping: false
|
|
295
|
-
}).format(9876543210)).reverse();
|
|
296
|
-
var index = new Map(numerals.map(function (d, i) {
|
|
297
|
-
return [d, i];
|
|
298
|
-
}));
|
|
299
|
-
_numeral.current = new RegExp("[".concat(numerals.join(''), "]"), 'g');
|
|
300
|
-
_group.current = getGroupingExpression();
|
|
301
|
-
_minusSign.current = getMinusSignExpression();
|
|
302
|
-
_currency.current = getCurrencyExpression();
|
|
303
|
-
_decimal.current = getDecimalExpression();
|
|
304
|
-
_suffix.current = getSuffixExpression();
|
|
305
|
-
_prefix.current = getPrefixExpression();
|
|
306
|
-
_index.current = function (d) {
|
|
307
|
-
return index.get(d);
|
|
308
|
-
};
|
|
309
|
-
};
|
|
310
|
-
var escapeRegExp = function escapeRegExp(text) {
|
|
311
|
-
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
312
|
-
};
|
|
313
|
-
var getDecimalExpression = function getDecimalExpression() {
|
|
314
|
-
var formatter = new Intl.NumberFormat(_locale, _objectSpread(_objectSpread({}, getOptions()), {}, {
|
|
315
|
-
useGrouping: false
|
|
316
|
-
}));
|
|
317
|
-
return new RegExp("[".concat(formatter.format(1.1).replace(_currency.current, '').trim().replace(_numeral.current, ''), "]"), 'g');
|
|
318
|
-
};
|
|
319
|
-
var getGroupingExpression = function getGroupingExpression() {
|
|
320
|
-
var formatter = new Intl.NumberFormat(_locale, {
|
|
321
|
-
useGrouping: true
|
|
322
|
-
});
|
|
323
|
-
groupChar.current = formatter.format(1000000).trim().replace(_numeral.current, '').charAt(0);
|
|
324
|
-
return new RegExp("[".concat(groupChar.current, "]"), 'g');
|
|
325
|
-
};
|
|
326
|
-
var getMinusSignExpression = function getMinusSignExpression() {
|
|
327
|
-
var formatter = new Intl.NumberFormat(_locale, {
|
|
328
|
-
useGrouping: false
|
|
329
|
-
});
|
|
330
|
-
return new RegExp("[".concat(formatter.format(-1).trim().replace(_numeral.current, ''), "]"), 'g');
|
|
331
|
-
};
|
|
332
|
-
var getCurrencyExpression = function getCurrencyExpression() {
|
|
333
|
-
if (props.currency) {
|
|
334
|
-
var formatter = new Intl.NumberFormat(_locale, {
|
|
335
|
-
style: 'currency',
|
|
336
|
-
currency: props.currency,
|
|
337
|
-
currencyDisplay: props.currencyDisplay,
|
|
338
|
-
minimumFractionDigits: 0,
|
|
339
|
-
maximumFractionDigits: 0
|
|
340
|
-
});
|
|
341
|
-
return new RegExp("[".concat(formatter.format(1).replace(/\s/g, '').replace(_numeral.current, '').replace(_group.current, ''), "]"), 'g');
|
|
342
|
-
}
|
|
343
|
-
return new RegExp("[]", 'g');
|
|
344
|
-
};
|
|
345
|
-
var getPrefixExpression = function getPrefixExpression() {
|
|
346
|
-
if (props.prefix) {
|
|
347
|
-
prefixChar.current = props.prefix;
|
|
348
|
-
} else {
|
|
349
|
-
var formatter = new Intl.NumberFormat(_locale, {
|
|
350
|
-
style: props.mode,
|
|
351
|
-
currency: props.currency,
|
|
352
|
-
currencyDisplay: props.currencyDisplay
|
|
353
|
-
});
|
|
354
|
-
prefixChar.current = formatter.format(1).split('1')[0];
|
|
355
|
-
}
|
|
356
|
-
return new RegExp("".concat(escapeRegExp(prefixChar.current || '')), 'g');
|
|
357
|
-
};
|
|
358
|
-
var getSuffixExpression = function getSuffixExpression() {
|
|
359
|
-
if (props.suffix) {
|
|
360
|
-
suffixChar.current = props.suffix;
|
|
361
|
-
} else {
|
|
362
|
-
var formatter = new Intl.NumberFormat(_locale, {
|
|
363
|
-
style: props.mode,
|
|
364
|
-
currency: props.currency,
|
|
365
|
-
currencyDisplay: props.currencyDisplay,
|
|
366
|
-
minimumFractionDigits: 0,
|
|
367
|
-
maximumFractionDigits: 0
|
|
368
|
-
});
|
|
369
|
-
suffixChar.current = formatter.format(1).split('1')[1];
|
|
370
|
-
}
|
|
371
|
-
return new RegExp("".concat(escapeRegExp(suffixChar.current || '')), 'g');
|
|
372
|
-
};
|
|
373
|
-
var formatValue = function formatValue(value) {
|
|
374
|
-
if (value != null) {
|
|
375
|
-
if (value === '-') {
|
|
376
|
-
// Minus sign
|
|
377
|
-
return value;
|
|
378
|
-
}
|
|
379
|
-
if (props.format) {
|
|
380
|
-
var formatter = new Intl.NumberFormat(_locale, getOptions());
|
|
381
|
-
var _formattedValue = formatter.format(value);
|
|
382
|
-
if (props.prefix) {
|
|
383
|
-
_formattedValue = props.prefix + _formattedValue;
|
|
384
|
-
}
|
|
385
|
-
if (props.suffix) {
|
|
386
|
-
_formattedValue = _formattedValue + props.suffix;
|
|
387
|
-
}
|
|
388
|
-
return _formattedValue;
|
|
389
|
-
}
|
|
390
|
-
return value.toString();
|
|
391
|
-
}
|
|
392
|
-
return '';
|
|
393
|
-
};
|
|
394
|
-
var parseValue = function parseValue(text) {
|
|
395
|
-
var filteredText = text.replace(_suffix.current, '').replace(_prefix.current, '').trim().replace(/\s/g, '').replace(_currency.current, '').replace(_group.current, '').replace(_minusSign.current, '-').replace(_decimal.current, '.').replace(_numeral.current, _index.current);
|
|
396
|
-
if (filteredText) {
|
|
397
|
-
if (filteredText === '-')
|
|
398
|
-
// Minus sign
|
|
399
|
-
return filteredText;
|
|
400
|
-
var parsedValue = +filteredText;
|
|
401
|
-
return isNaN(parsedValue) ? null : parsedValue;
|
|
402
|
-
}
|
|
403
|
-
return null;
|
|
404
|
-
};
|
|
405
|
-
var repeat = function repeat(event, interval, dir) {
|
|
406
|
-
var i = interval || 500;
|
|
407
|
-
clearTimer();
|
|
408
|
-
timer.current = setTimeout(function () {
|
|
409
|
-
repeat(event, 40, dir);
|
|
410
|
-
}, i);
|
|
411
|
-
spin(event, dir);
|
|
412
|
-
};
|
|
413
|
-
var spin = function spin(event, dir) {
|
|
414
|
-
if (inputRef.current) {
|
|
415
|
-
var step = props.step * dir;
|
|
416
|
-
var currentValue = parseValue(inputRef.current.value) || 0;
|
|
417
|
-
var newValue = validateValue(currentValue + step);
|
|
418
|
-
if (props.maxLength && props.maxLength < formatValue(newValue).length) {
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// #3913 onChange should be called before onValueChange
|
|
423
|
-
handleOnChange(event, currentValue, newValue);
|
|
424
|
-
// touch devices trigger the keyboard to display because of setSelectionRange
|
|
425
|
-
!DomHandler.isTouchDevice() && updateInput(newValue, null, 'spin');
|
|
426
|
-
updateModel(event, newValue);
|
|
427
|
-
}
|
|
428
|
-
};
|
|
429
|
-
var onUpButtonMouseDown = function onUpButtonMouseDown(event) {
|
|
430
|
-
if (!props.disabled && !props.readOnly) {
|
|
431
|
-
props.autoFocus && DomHandler.focus(inputRef.current, props.autoFocus);
|
|
432
|
-
repeat(event, null, 1);
|
|
433
|
-
}
|
|
434
|
-
};
|
|
435
|
-
var onUpButtonMouseUp = function onUpButtonMouseUp() {
|
|
436
|
-
if (!props.disabled && !props.readOnly) {
|
|
437
|
-
clearTimer();
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
var onUpButtonMouseLeave = function onUpButtonMouseLeave() {
|
|
441
|
-
if (!props.disabled && !props.readOnly) {
|
|
442
|
-
clearTimer();
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
var onUpButtonKeyUp = function onUpButtonKeyUp() {
|
|
446
|
-
if (!props.disabled && !props.readOnly) {
|
|
447
|
-
clearTimer();
|
|
448
|
-
}
|
|
449
|
-
};
|
|
450
|
-
var onUpButtonKeyDown = function onUpButtonKeyDown(event) {
|
|
451
|
-
if (!props.disabled && !props.readOnly && (event.keyCode === 32 || event.keyCode === 13)) {
|
|
452
|
-
repeat(event, null, 1);
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
var onDownButtonMouseDown = function onDownButtonMouseDown(event) {
|
|
456
|
-
if (!props.disabled && !props.readOnly) {
|
|
457
|
-
props.autoFocus && DomHandler.focus(inputRef.current, props.autoFocus);
|
|
458
|
-
repeat(event, null, -1);
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
|
-
var onDownButtonMouseUp = function onDownButtonMouseUp() {
|
|
462
|
-
if (!props.disabled && !props.readOnly) {
|
|
463
|
-
clearTimer();
|
|
464
|
-
}
|
|
465
|
-
};
|
|
466
|
-
var onDownButtonMouseLeave = function onDownButtonMouseLeave() {
|
|
467
|
-
if (!props.disabled && !props.readOnly) {
|
|
468
|
-
clearTimer();
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
var onDownButtonKeyUp = function onDownButtonKeyUp() {
|
|
472
|
-
if (!props.disabled && !props.readOnly) {
|
|
473
|
-
clearTimer();
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
|
-
var onDownButtonKeyDown = function onDownButtonKeyDown(event) {
|
|
477
|
-
if (!props.disabled && !props.readOnly && (event.keyCode === 32 || event.keyCode === 13)) {
|
|
478
|
-
repeat(event, null, -1);
|
|
479
|
-
}
|
|
480
|
-
};
|
|
481
|
-
var onInput = function onInput(event) {
|
|
482
|
-
if (props.disabled || props.readOnly) {
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
if (isSpecialChar.current) {
|
|
486
|
-
event.target.value = lastValue.current;
|
|
487
|
-
}
|
|
488
|
-
isSpecialChar.current = false;
|
|
489
|
-
};
|
|
490
|
-
var onInputKeyDown = function onInputKeyDown(event) {
|
|
491
|
-
if (props.disabled || props.readOnly) {
|
|
492
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
if (props.onKeyDown) {
|
|
495
|
-
props.onKeyDown(event);
|
|
496
|
-
|
|
497
|
-
// do not continue if the user defined event wants to prevent
|
|
498
|
-
if (event.defaultPrevented) {
|
|
499
|
-
return;
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
lastValue.current = event.target.value;
|
|
503
|
-
if (event.shiftKey || event.altKey) {
|
|
504
|
-
isSpecialChar.current = true;
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
var selectionStart = event.target.selectionStart;
|
|
508
|
-
var selectionEnd = event.target.selectionEnd;
|
|
509
|
-
var inputValue = event.target.value;
|
|
510
|
-
var newValueStr = null;
|
|
511
|
-
if (event.altKey) {
|
|
512
|
-
event.preventDefault();
|
|
513
|
-
}
|
|
514
|
-
switch (event.which) {
|
|
515
|
-
//up
|
|
516
|
-
case 38:
|
|
517
|
-
spin(event, 1);
|
|
518
|
-
event.preventDefault();
|
|
519
|
-
break;
|
|
520
|
-
|
|
521
|
-
//down
|
|
522
|
-
case 40:
|
|
523
|
-
spin(event, -1);
|
|
524
|
-
event.preventDefault();
|
|
525
|
-
break;
|
|
526
|
-
|
|
527
|
-
//left
|
|
528
|
-
case 37:
|
|
529
|
-
if (!isNumeralChar(inputValue.charAt(selectionStart - 1))) {
|
|
530
|
-
event.preventDefault();
|
|
531
|
-
}
|
|
532
|
-
break;
|
|
533
|
-
|
|
534
|
-
//right
|
|
535
|
-
case 39:
|
|
536
|
-
if (!isNumeralChar(inputValue.charAt(selectionStart))) {
|
|
537
|
-
event.preventDefault();
|
|
538
|
-
}
|
|
539
|
-
break;
|
|
540
|
-
|
|
541
|
-
//enter and tab
|
|
542
|
-
case 13:
|
|
543
|
-
case 9:
|
|
544
|
-
newValueStr = validateValue(parseValue(inputValue));
|
|
545
|
-
inputRef.current.value = formatValue(newValueStr);
|
|
546
|
-
inputRef.current.setAttribute('aria-valuenow', newValueStr);
|
|
547
|
-
updateModel(event, newValueStr);
|
|
548
|
-
break;
|
|
549
|
-
|
|
550
|
-
//backspace
|
|
551
|
-
case 8:
|
|
552
|
-
event.preventDefault();
|
|
553
|
-
if (selectionStart === selectionEnd) {
|
|
554
|
-
var deleteChar = inputValue.charAt(selectionStart - 1);
|
|
555
|
-
if (isNumeralChar(deleteChar)) {
|
|
556
|
-
var _getDecimalCharIndexe = getDecimalCharIndexes(inputValue),
|
|
557
|
-
decimalCharIndex = _getDecimalCharIndexe.decimalCharIndex,
|
|
558
|
-
decimalCharIndexWithoutPrefix = _getDecimalCharIndexe.decimalCharIndexWithoutPrefix;
|
|
559
|
-
var decimalLength = getDecimalLength(inputValue);
|
|
560
|
-
if (_group.current.test(deleteChar)) {
|
|
561
|
-
_group.current.lastIndex = 0;
|
|
562
|
-
newValueStr = inputValue.slice(0, selectionStart - 2) + inputValue.slice(selectionStart - 1);
|
|
563
|
-
} else if (_decimal.current.test(deleteChar)) {
|
|
564
|
-
_decimal.current.lastIndex = 0;
|
|
565
|
-
if (decimalLength) {
|
|
566
|
-
inputRef.current.setSelectionRange(selectionStart - 1, selectionStart - 1);
|
|
567
|
-
} else {
|
|
568
|
-
newValueStr = inputValue.slice(0, selectionStart - 1) + inputValue.slice(selectionStart);
|
|
569
|
-
}
|
|
570
|
-
} else if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) {
|
|
571
|
-
var insertedText = isDecimalMode() && (props.minFractionDigits || 0) < decimalLength ? '' : '0';
|
|
572
|
-
newValueStr = inputValue.slice(0, selectionStart - 1) + insertedText + inputValue.slice(selectionStart);
|
|
573
|
-
} else if (decimalCharIndexWithoutPrefix === 1) {
|
|
574
|
-
newValueStr = inputValue.slice(0, selectionStart - 1) + '0' + inputValue.slice(selectionStart);
|
|
575
|
-
newValueStr = parseValue(newValueStr) > 0 ? newValueStr : '';
|
|
576
|
-
} else {
|
|
577
|
-
newValueStr = inputValue.slice(0, selectionStart - 1) + inputValue.slice(selectionStart);
|
|
578
|
-
}
|
|
579
|
-
} else if (_currency.current.test(deleteChar)) {
|
|
580
|
-
var _getCharIndexes = getCharIndexes(inputValue),
|
|
581
|
-
minusCharIndex = _getCharIndexes.minusCharIndex,
|
|
582
|
-
currencyCharIndex = _getCharIndexes.currencyCharIndex;
|
|
583
|
-
if (minusCharIndex === currencyCharIndex - 1) {
|
|
584
|
-
newValueStr = inputValue.slice(0, minusCharIndex) + inputValue.slice(selectionStart);
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
updateValue(event, newValueStr, null, 'delete-single');
|
|
588
|
-
} else {
|
|
589
|
-
newValueStr = deleteRange(inputValue, selectionStart, selectionEnd);
|
|
590
|
-
updateValue(event, newValueStr, null, 'delete-range');
|
|
591
|
-
}
|
|
592
|
-
break;
|
|
593
|
-
|
|
594
|
-
// del
|
|
595
|
-
case 46:
|
|
596
|
-
event.preventDefault();
|
|
597
|
-
if (selectionStart === selectionEnd) {
|
|
598
|
-
var _deleteChar = inputValue.charAt(selectionStart);
|
|
599
|
-
var _getDecimalCharIndexe2 = getDecimalCharIndexes(inputValue),
|
|
600
|
-
_decimalCharIndex = _getDecimalCharIndexe2.decimalCharIndex,
|
|
601
|
-
_decimalCharIndexWithoutPrefix = _getDecimalCharIndexe2.decimalCharIndexWithoutPrefix;
|
|
602
|
-
if (isNumeralChar(_deleteChar)) {
|
|
603
|
-
var _decimalLength = getDecimalLength(inputValue);
|
|
604
|
-
if (_group.current.test(_deleteChar)) {
|
|
605
|
-
_group.current.lastIndex = 0;
|
|
606
|
-
newValueStr = inputValue.slice(0, selectionStart) + inputValue.slice(selectionStart + 2);
|
|
607
|
-
} else if (_decimal.current.test(_deleteChar)) {
|
|
608
|
-
_decimal.current.lastIndex = 0;
|
|
609
|
-
if (_decimalLength) {
|
|
610
|
-
inputRef.current.setSelectionRange(selectionStart + 1, selectionStart + 1);
|
|
611
|
-
} else {
|
|
612
|
-
newValueStr = inputValue.slice(0, selectionStart) + inputValue.slice(selectionStart + 1);
|
|
613
|
-
}
|
|
614
|
-
} else if (_decimalCharIndex > 0 && selectionStart > _decimalCharIndex) {
|
|
615
|
-
var _insertedText = isDecimalMode() && (props.minFractionDigits || 0) < _decimalLength ? '' : '0';
|
|
616
|
-
newValueStr = inputValue.slice(0, selectionStart) + _insertedText + inputValue.slice(selectionStart + 1);
|
|
617
|
-
} else if (_decimalCharIndexWithoutPrefix === 1) {
|
|
618
|
-
newValueStr = inputValue.slice(0, selectionStart) + '0' + inputValue.slice(selectionStart + 1);
|
|
619
|
-
newValueStr = parseValue(newValueStr) > 0 ? newValueStr : '';
|
|
620
|
-
} else {
|
|
621
|
-
newValueStr = inputValue.slice(0, selectionStart) + inputValue.slice(selectionStart + 1);
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
updateValue(event, newValueStr, null, 'delete-back-single');
|
|
625
|
-
} else {
|
|
626
|
-
newValueStr = deleteRange(inputValue, selectionStart, selectionEnd);
|
|
627
|
-
updateValue(event, newValueStr, null, 'delete-range');
|
|
628
|
-
}
|
|
629
|
-
break;
|
|
630
|
-
}
|
|
631
|
-
};
|
|
632
|
-
var onInputKeyUp = function onInputKeyUp(event) {
|
|
633
|
-
if (props.disabled || props.readOnly) {
|
|
634
|
-
return;
|
|
635
|
-
}
|
|
636
|
-
if (props.onKeyUp) {
|
|
637
|
-
props.onKeyUp(event);
|
|
638
|
-
|
|
639
|
-
// do not continue if the user defined event wants to prevent
|
|
640
|
-
if (event.defaultPrevented) {
|
|
641
|
-
return;
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
var code = event.which || event.keyCode;
|
|
645
|
-
if (code !== 13) {
|
|
646
|
-
// to submit a form
|
|
647
|
-
event.preventDefault();
|
|
648
|
-
}
|
|
649
|
-
var _char = String.fromCharCode(code);
|
|
650
|
-
var _isDecimalSign = isDecimalSign(_char);
|
|
651
|
-
var _isMinusSign = isMinusSign(_char);
|
|
652
|
-
if (48 <= code && code <= 57 || _isMinusSign || _isDecimalSign) {
|
|
653
|
-
insert(event, _char, {
|
|
654
|
-
isDecimalSign: _isDecimalSign,
|
|
655
|
-
isMinusSign: _isMinusSign
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
|
-
};
|
|
659
|
-
var onPaste = function onPaste(event) {
|
|
660
|
-
event.preventDefault();
|
|
661
|
-
if (props.disabled || props.readOnly) {
|
|
662
|
-
return;
|
|
663
|
-
}
|
|
664
|
-
var data = (event.clipboardData || window['clipboardData']).getData('Text');
|
|
665
|
-
if (data) {
|
|
666
|
-
var filteredData = parseValue(data);
|
|
667
|
-
if (filteredData != null) {
|
|
668
|
-
insert(event, filteredData.toString());
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
};
|
|
672
|
-
var allowMinusSign = function allowMinusSign() {
|
|
673
|
-
return ObjectUtils.isEmpty(props.min) || props.min < 0;
|
|
674
|
-
};
|
|
675
|
-
var isMinusSign = function isMinusSign(_char2) {
|
|
676
|
-
if (_minusSign.current.test(_char2) || _char2 === '-') {
|
|
677
|
-
_minusSign.current.lastIndex = 0;
|
|
678
|
-
return true;
|
|
679
|
-
}
|
|
680
|
-
return false;
|
|
681
|
-
};
|
|
682
|
-
var isDecimalSign = function isDecimalSign(_char3) {
|
|
683
|
-
if (_decimal.current.test(_char3)) {
|
|
684
|
-
_decimal.current.lastIndex = 0;
|
|
685
|
-
return true;
|
|
686
|
-
}
|
|
687
|
-
return false;
|
|
688
|
-
};
|
|
689
|
-
var isDecimalMode = function isDecimalMode() {
|
|
690
|
-
return props.mode === 'decimal';
|
|
691
|
-
};
|
|
692
|
-
var getDecimalCharIndexes = function getDecimalCharIndexes(val) {
|
|
693
|
-
var decimalCharIndex = val.search(_decimal.current);
|
|
694
|
-
_decimal.current.lastIndex = 0;
|
|
695
|
-
var filteredVal = val.replace(_prefix.current, '').trim().replace(/\s/g, '').replace(_currency.current, '');
|
|
696
|
-
var decimalCharIndexWithoutPrefix = filteredVal.search(_decimal.current);
|
|
697
|
-
_decimal.current.lastIndex = 0;
|
|
698
|
-
return {
|
|
699
|
-
decimalCharIndex: decimalCharIndex,
|
|
700
|
-
decimalCharIndexWithoutPrefix: decimalCharIndexWithoutPrefix
|
|
701
|
-
};
|
|
702
|
-
};
|
|
703
|
-
var getCharIndexes = function getCharIndexes(val) {
|
|
704
|
-
var decimalCharIndex = val.search(_decimal.current);
|
|
705
|
-
_decimal.current.lastIndex = 0;
|
|
706
|
-
var minusCharIndex = val.search(_minusSign.current);
|
|
707
|
-
_minusSign.current.lastIndex = 0;
|
|
708
|
-
var suffixCharIndex = val.search(_suffix.current);
|
|
709
|
-
_suffix.current.lastIndex = 0;
|
|
710
|
-
var currencyCharIndex = val.search(_currency.current);
|
|
711
|
-
_currency.current.lastIndex = 0;
|
|
712
|
-
return {
|
|
713
|
-
decimalCharIndex: decimalCharIndex,
|
|
714
|
-
minusCharIndex: minusCharIndex,
|
|
715
|
-
suffixCharIndex: suffixCharIndex,
|
|
716
|
-
currencyCharIndex: currencyCharIndex
|
|
717
|
-
};
|
|
718
|
-
};
|
|
719
|
-
var insert = function insert(event, text) {
|
|
720
|
-
var sign = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
721
|
-
isDecimalSign: false,
|
|
722
|
-
isMinusSign: false
|
|
723
|
-
};
|
|
724
|
-
var minusCharIndexOnText = text.search(_minusSign.current);
|
|
725
|
-
_minusSign.current.lastIndex = 0;
|
|
726
|
-
if (!allowMinusSign() && minusCharIndexOnText !== -1) {
|
|
727
|
-
return;
|
|
728
|
-
}
|
|
729
|
-
var selectionStart = inputRef.current.selectionStart;
|
|
730
|
-
var selectionEnd = inputRef.current.selectionEnd;
|
|
731
|
-
var inputValue = inputRef.current.value.trim();
|
|
732
|
-
var _getCharIndexes2 = getCharIndexes(inputValue),
|
|
733
|
-
decimalCharIndex = _getCharIndexes2.decimalCharIndex,
|
|
734
|
-
minusCharIndex = _getCharIndexes2.minusCharIndex,
|
|
735
|
-
suffixCharIndex = _getCharIndexes2.suffixCharIndex,
|
|
736
|
-
currencyCharIndex = _getCharIndexes2.currencyCharIndex;
|
|
737
|
-
var newValueStr;
|
|
738
|
-
if (sign.isMinusSign) {
|
|
739
|
-
var isNewMinusSign = minusCharIndex === -1;
|
|
740
|
-
if (isNewMinusSign && (selectionStart === 0 || selectionStart === currencyCharIndex + 1)) {
|
|
741
|
-
newValueStr = inputValue;
|
|
742
|
-
if (isNewMinusSign || selectionEnd !== 0) {
|
|
743
|
-
newValueStr = insertText(inputValue, text, 0, selectionEnd);
|
|
744
|
-
}
|
|
745
|
-
updateValue(event, newValueStr, text, 'insert');
|
|
746
|
-
}
|
|
747
|
-
} else if (sign.isDecimalSign) {
|
|
748
|
-
if (decimalCharIndex > 0 && selectionStart === decimalCharIndex) {
|
|
749
|
-
updateValue(event, inputValue, text, 'insert');
|
|
750
|
-
} else if (decimalCharIndex > selectionStart && decimalCharIndex < selectionEnd) {
|
|
751
|
-
newValueStr = insertText(inputValue, text, selectionStart, selectionEnd);
|
|
752
|
-
updateValue(event, newValueStr, text, 'insert');
|
|
753
|
-
} else if (decimalCharIndex === -1 && props.maxFractionDigits) {
|
|
754
|
-
newValueStr = insertText(inputValue, text, selectionStart, selectionEnd);
|
|
755
|
-
updateValue(event, newValueStr, text, 'insert');
|
|
756
|
-
}
|
|
757
|
-
} else {
|
|
758
|
-
var maxFractionDigits = numberFormat.current.resolvedOptions().maximumFractionDigits;
|
|
759
|
-
var operation = selectionStart !== selectionEnd ? 'range-insert' : 'insert';
|
|
760
|
-
if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) {
|
|
761
|
-
if (selectionStart + text.length - (decimalCharIndex + 1) <= maxFractionDigits) {
|
|
762
|
-
var charIndex = currencyCharIndex >= selectionStart ? currencyCharIndex - 1 : suffixCharIndex >= selectionStart ? suffixCharIndex : inputValue.length;
|
|
763
|
-
newValueStr = inputValue.slice(0, selectionStart) + text + inputValue.slice(selectionStart + text.length, charIndex) + inputValue.slice(charIndex);
|
|
764
|
-
updateValue(event, newValueStr, text, operation);
|
|
765
|
-
}
|
|
766
|
-
} else {
|
|
767
|
-
newValueStr = insertText(inputValue, text, selectionStart, selectionEnd);
|
|
768
|
-
updateValue(event, newValueStr, text, operation);
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
};
|
|
772
|
-
var insertText = function insertText(value, text, start, end) {
|
|
773
|
-
var textSplit = text === '.' ? text : text.split('.');
|
|
774
|
-
if (textSplit.length === 2) {
|
|
775
|
-
var decimalCharIndex = value.slice(start, end).search(_decimal.current);
|
|
776
|
-
_decimal.current.lastIndex = 0;
|
|
777
|
-
return decimalCharIndex > 0 ? value.slice(0, start) + formatValue(text) + value.slice(end) : value || formatValue(text);
|
|
778
|
-
} else if (end - start === value.length) {
|
|
779
|
-
return formatValue(text);
|
|
780
|
-
} else if (start === 0) {
|
|
781
|
-
var suffix = ObjectUtils.isLetter(value[end]) ? end - 1 : end;
|
|
782
|
-
return text + value.slice(suffix);
|
|
783
|
-
} else if (end === value.length) {
|
|
784
|
-
return value.slice(0, start) + text;
|
|
785
|
-
} else {
|
|
786
|
-
return value.slice(0, start) + text + value.slice(end);
|
|
787
|
-
}
|
|
788
|
-
};
|
|
789
|
-
var deleteRange = function deleteRange(value, start, end) {
|
|
790
|
-
var newValueStr;
|
|
791
|
-
if (end - start === value.length) newValueStr = '';else if (start === 0) newValueStr = value.slice(end);else if (end === value.length) newValueStr = value.slice(0, start);else newValueStr = value.slice(0, start) + value.slice(end);
|
|
792
|
-
return newValueStr;
|
|
793
|
-
};
|
|
794
|
-
var initCursor = function initCursor() {
|
|
795
|
-
var selectionStart = inputRef.current.selectionStart;
|
|
796
|
-
var inputValue = inputRef.current.value;
|
|
797
|
-
var valueLength = inputValue.length;
|
|
798
|
-
var index = null;
|
|
799
|
-
|
|
800
|
-
// remove prefix
|
|
801
|
-
var prefixLength = (prefixChar.current || '').length;
|
|
802
|
-
inputValue = inputValue.replace(_prefix.current, '');
|
|
803
|
-
selectionStart = selectionStart - prefixLength;
|
|
804
|
-
var _char4 = inputValue.charAt(selectionStart);
|
|
805
|
-
if (isNumeralChar(_char4)) {
|
|
806
|
-
return selectionStart + prefixLength;
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
//left
|
|
810
|
-
var i = selectionStart - 1;
|
|
811
|
-
while (i >= 0) {
|
|
812
|
-
_char4 = inputValue.charAt(i);
|
|
813
|
-
if (isNumeralChar(_char4)) {
|
|
814
|
-
index = i + prefixLength;
|
|
815
|
-
break;
|
|
816
|
-
} else {
|
|
817
|
-
i--;
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
if (index !== null) {
|
|
821
|
-
inputRef.current.setSelectionRange(index + 1, index + 1);
|
|
822
|
-
} else {
|
|
823
|
-
i = selectionStart;
|
|
824
|
-
while (i < valueLength) {
|
|
825
|
-
_char4 = inputValue.charAt(i);
|
|
826
|
-
if (isNumeralChar(_char4)) {
|
|
827
|
-
index = i + prefixLength;
|
|
828
|
-
break;
|
|
829
|
-
} else {
|
|
830
|
-
i++;
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
if (index !== null) {
|
|
834
|
-
inputRef.current.setSelectionRange(index, index);
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
return index || 0;
|
|
838
|
-
};
|
|
839
|
-
var onInputClick = function onInputClick() {
|
|
840
|
-
initCursor();
|
|
841
|
-
};
|
|
842
|
-
var isNumeralChar = function isNumeralChar(_char5) {
|
|
843
|
-
if (_char5.length === 1 && (_numeral.current.test(_char5) || _decimal.current.test(_char5) || _group.current.test(_char5) || _minusSign.current.test(_char5))) {
|
|
844
|
-
resetRegex();
|
|
845
|
-
return true;
|
|
846
|
-
} else {
|
|
847
|
-
return false;
|
|
848
|
-
}
|
|
849
|
-
};
|
|
850
|
-
var resetRegex = function resetRegex() {
|
|
851
|
-
_numeral.current.lastIndex = 0;
|
|
852
|
-
_decimal.current.lastIndex = 0;
|
|
853
|
-
_group.current.lastIndex = 0;
|
|
854
|
-
_minusSign.current.lastIndex = 0;
|
|
855
|
-
};
|
|
856
|
-
var updateValue = function updateValue(event, valueStr, insertedValueStr, operation) {
|
|
857
|
-
var currentValue = inputRef.current.value;
|
|
858
|
-
var newValue = null;
|
|
859
|
-
if (valueStr != null) {
|
|
860
|
-
newValue = evaluateEmpty(parseValue(valueStr));
|
|
861
|
-
updateInput(newValue, insertedValueStr, operation, valueStr);
|
|
862
|
-
handleOnChange(event, currentValue, newValue);
|
|
863
|
-
}
|
|
864
|
-
};
|
|
865
|
-
var evaluateEmpty = function evaluateEmpty(newValue) {
|
|
866
|
-
return !newValue && !props.allowEmpty ? props.min || 0 : newValue;
|
|
867
|
-
};
|
|
868
|
-
var handleOnChange = function handleOnChange(event, currentValue, newValue) {
|
|
869
|
-
if (props.onChange && isValueChanged(currentValue, newValue)) {
|
|
870
|
-
props.onChange({
|
|
871
|
-
originalEvent: event,
|
|
872
|
-
value: newValue
|
|
873
|
-
});
|
|
874
|
-
}
|
|
875
|
-
};
|
|
876
|
-
var isValueChanged = function isValueChanged(currentValue, newValue) {
|
|
877
|
-
if (newValue === null && currentValue !== null) {
|
|
878
|
-
return true;
|
|
879
|
-
}
|
|
880
|
-
if (newValue != null) {
|
|
881
|
-
var parsedCurrentValue = typeof currentValue === 'string' ? parseValue(currentValue) : currentValue;
|
|
882
|
-
return newValue !== parsedCurrentValue;
|
|
883
|
-
}
|
|
884
|
-
return false;
|
|
885
|
-
};
|
|
886
|
-
var validateValue = function validateValue(value) {
|
|
887
|
-
if (value === '-') {
|
|
888
|
-
return null;
|
|
889
|
-
}
|
|
890
|
-
return validateValueByLimit(value);
|
|
891
|
-
};
|
|
892
|
-
var validateValueByLimit = function validateValueByLimit(value) {
|
|
893
|
-
if (ObjectUtils.isEmpty(value)) {
|
|
894
|
-
return null;
|
|
895
|
-
}
|
|
896
|
-
if (props.min !== null && value < props.min) {
|
|
897
|
-
return props.min;
|
|
898
|
-
}
|
|
899
|
-
if (props.max !== null && value > props.max) {
|
|
900
|
-
return props.max;
|
|
901
|
-
}
|
|
902
|
-
return value;
|
|
903
|
-
};
|
|
904
|
-
var updateInput = function updateInput(value, insertedValueStr, operation, valueStr) {
|
|
905
|
-
insertedValueStr = insertedValueStr || '';
|
|
906
|
-
var inputEl = inputRef.current;
|
|
907
|
-
var inputValue = inputEl.value;
|
|
908
|
-
var newValue = formatValue(value);
|
|
909
|
-
var currentLength = inputValue.length;
|
|
910
|
-
if (newValue !== valueStr) {
|
|
911
|
-
newValue = concatValues(newValue, valueStr);
|
|
912
|
-
}
|
|
913
|
-
if (currentLength === 0) {
|
|
914
|
-
inputEl.value = newValue;
|
|
915
|
-
inputEl.setSelectionRange(0, 0);
|
|
916
|
-
var index = initCursor();
|
|
917
|
-
var selectionEnd = index + insertedValueStr.length;
|
|
918
|
-
inputEl.setSelectionRange(selectionEnd, selectionEnd);
|
|
919
|
-
} else {
|
|
920
|
-
var selectionStart = inputEl.selectionStart;
|
|
921
|
-
var _selectionEnd = inputEl.selectionEnd;
|
|
922
|
-
if (props.maxLength && props.maxLength < newValue.length) {
|
|
923
|
-
return;
|
|
924
|
-
}
|
|
925
|
-
inputEl.value = newValue;
|
|
926
|
-
var newLength = newValue.length;
|
|
927
|
-
if (operation === 'range-insert') {
|
|
928
|
-
var startValue = parseValue((inputValue || '').slice(0, selectionStart));
|
|
929
|
-
var startValueStr = startValue !== null ? startValue.toString() : '';
|
|
930
|
-
var startExpr = startValueStr.split('').join("(".concat(groupChar.current, ")?"));
|
|
931
|
-
var sRegex = new RegExp(startExpr, 'g');
|
|
932
|
-
sRegex.test(newValue);
|
|
933
|
-
var tExpr = insertedValueStr.split('').join("(".concat(groupChar.current, ")?"));
|
|
934
|
-
var tRegex = new RegExp(tExpr, 'g');
|
|
935
|
-
tRegex.test(newValue.slice(sRegex.lastIndex));
|
|
936
|
-
_selectionEnd = sRegex.lastIndex + tRegex.lastIndex;
|
|
937
|
-
inputEl.setSelectionRange(_selectionEnd, _selectionEnd);
|
|
938
|
-
} else if (newLength === currentLength) {
|
|
939
|
-
if (operation === 'insert' || operation === 'delete-back-single') inputEl.setSelectionRange(_selectionEnd + 1, _selectionEnd + 1);else if (operation === 'delete-single') inputEl.setSelectionRange(_selectionEnd - 1, _selectionEnd - 1);else if (operation === 'delete-range' || operation === 'spin') inputEl.setSelectionRange(_selectionEnd, _selectionEnd);
|
|
940
|
-
} else if (operation === 'delete-back-single') {
|
|
941
|
-
var prevChar = inputValue.charAt(_selectionEnd - 1);
|
|
942
|
-
var nextChar = inputValue.charAt(_selectionEnd);
|
|
943
|
-
var diff = currentLength - newLength;
|
|
944
|
-
var isGroupChar = _group.current.test(nextChar);
|
|
945
|
-
if (isGroupChar && diff === 1) {
|
|
946
|
-
_selectionEnd += 1;
|
|
947
|
-
} else if (!isGroupChar && isNumeralChar(prevChar)) {
|
|
948
|
-
_selectionEnd += -1 * diff + 1;
|
|
949
|
-
}
|
|
950
|
-
_group.current.lastIndex = 0;
|
|
951
|
-
inputEl.setSelectionRange(_selectionEnd, _selectionEnd);
|
|
952
|
-
} else if (inputValue === '-' && operation === 'insert') {
|
|
953
|
-
inputEl.setSelectionRange(0, 0);
|
|
954
|
-
var _index2 = initCursor();
|
|
955
|
-
var _selectionEnd2 = _index2 + insertedValueStr.length + 1;
|
|
956
|
-
inputEl.setSelectionRange(_selectionEnd2, _selectionEnd2);
|
|
957
|
-
} else {
|
|
958
|
-
_selectionEnd = _selectionEnd + (newLength - currentLength);
|
|
959
|
-
inputEl.setSelectionRange(_selectionEnd, _selectionEnd);
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
inputEl.setAttribute('aria-valuenow', value);
|
|
963
|
-
};
|
|
964
|
-
var updateInputValue = function updateInputValue(newValue) {
|
|
965
|
-
newValue = evaluateEmpty(newValue);
|
|
966
|
-
var inputEl = inputRef.current;
|
|
967
|
-
var value = inputEl.value;
|
|
968
|
-
var _formattedValue = formattedValue(newValue);
|
|
969
|
-
if (value !== _formattedValue) {
|
|
970
|
-
inputEl.value = _formattedValue;
|
|
971
|
-
inputEl.setAttribute('aria-valuenow', newValue);
|
|
972
|
-
}
|
|
973
|
-
};
|
|
974
|
-
var formattedValue = function formattedValue(val) {
|
|
975
|
-
return formatValue(evaluateEmpty(val));
|
|
976
|
-
};
|
|
977
|
-
var concatValues = function concatValues(val1, val2) {
|
|
978
|
-
if (val1 && val2) {
|
|
979
|
-
var decimalCharIndex = val2.search(_decimal.current);
|
|
980
|
-
_decimal.current.lastIndex = 0;
|
|
981
|
-
return decimalCharIndex !== -1 ? val1.split(_decimal.current)[0] + val2.slice(decimalCharIndex) : val1;
|
|
982
|
-
}
|
|
983
|
-
return val1;
|
|
984
|
-
};
|
|
985
|
-
var getDecimalLength = function getDecimalLength(value) {
|
|
986
|
-
if (value) {
|
|
987
|
-
var valueSplit = value.split(_decimal.current);
|
|
988
|
-
if (valueSplit.length === 2) {
|
|
989
|
-
return valueSplit[1].replace(_suffix.current, '').trim().replace(/\s/g, '').replace(_currency.current, '').length;
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
return 0;
|
|
993
|
-
};
|
|
994
|
-
var updateModel = function updateModel(event, value) {
|
|
995
|
-
if (props.onValueChange) {
|
|
996
|
-
props.onValueChange({
|
|
997
|
-
originalEvent: event,
|
|
998
|
-
value: value,
|
|
999
|
-
stopPropagation: function stopPropagation() {
|
|
1000
|
-
event.stopPropagation();
|
|
1001
|
-
},
|
|
1002
|
-
preventDefault: function preventDefault() {
|
|
1003
|
-
event.preventDefault();
|
|
1004
|
-
},
|
|
1005
|
-
target: {
|
|
1006
|
-
name: props.name,
|
|
1007
|
-
id: props.id,
|
|
1008
|
-
value: value
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
|
-
};
|
|
1013
|
-
var onInputFocus = function onInputFocus(event) {
|
|
1014
|
-
setFocusedState(true);
|
|
1015
|
-
props.onFocus && props.onFocus(event);
|
|
1016
|
-
if ((props.suffix || props.currency || props.prefix) && inputRef.current) {
|
|
1017
|
-
// GitHub #1866 Cursor must be placed before/after symbol or arrow keys don't work
|
|
1018
|
-
var selectionEnd = initCursor();
|
|
1019
|
-
inputRef.current.setSelectionRange(selectionEnd, selectionEnd);
|
|
1020
|
-
}
|
|
1021
|
-
};
|
|
1022
|
-
var onInputBlur = function onInputBlur(event) {
|
|
1023
|
-
setFocusedState(false);
|
|
1024
|
-
if (inputRef.current) {
|
|
1025
|
-
var currentValue = inputRef.current.value;
|
|
1026
|
-
if (isValueChanged(currentValue, props.value)) {
|
|
1027
|
-
var newValue = validateValue(parseValue(currentValue));
|
|
1028
|
-
updateInputValue(newValue);
|
|
1029
|
-
updateModel(event, newValue);
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
props.onBlur && props.onBlur(event);
|
|
1033
|
-
};
|
|
1034
|
-
var clearTimer = function clearTimer() {
|
|
1035
|
-
if (timer.current) {
|
|
1036
|
-
clearInterval(timer.current);
|
|
1037
|
-
}
|
|
1038
|
-
};
|
|
1039
|
-
var changeValue = function changeValue() {
|
|
1040
|
-
updateInputValue(validateValueByLimit(props.value));
|
|
1041
|
-
var newValue = validateValue(props.value);
|
|
1042
|
-
if (props.value !== null && props.value !== newValue) {
|
|
1043
|
-
updateModel(null, newValue);
|
|
1044
|
-
}
|
|
1045
|
-
};
|
|
1046
|
-
var getFormatter = function getFormatter() {
|
|
1047
|
-
return numberFormat.current;
|
|
1048
|
-
};
|
|
1049
|
-
React.useImperativeHandle(ref, function () {
|
|
1050
|
-
return {
|
|
1051
|
-
props: props,
|
|
1052
|
-
focus: function focus() {
|
|
1053
|
-
return DomHandler.focus(inputRef.current);
|
|
1054
|
-
},
|
|
1055
|
-
getFormatter: getFormatter,
|
|
1056
|
-
getElement: function getElement() {
|
|
1057
|
-
return elementRef.current;
|
|
1058
|
-
},
|
|
1059
|
-
getInput: function getInput() {
|
|
1060
|
-
return inputRef.current;
|
|
1061
|
-
}
|
|
1062
|
-
};
|
|
1063
|
-
});
|
|
1064
|
-
React.useEffect(function () {
|
|
1065
|
-
ObjectUtils.combinedRefs(inputRef, props.inputRef);
|
|
1066
|
-
}, [inputRef, props.inputRef]);
|
|
1067
|
-
useMountEffect(function () {
|
|
1068
|
-
constructParser();
|
|
1069
|
-
var newValue = validateValue(props.value);
|
|
1070
|
-
if (props.value !== null && props.value !== newValue) {
|
|
1071
|
-
updateModel(null, newValue);
|
|
1072
|
-
}
|
|
1073
|
-
});
|
|
1074
|
-
useUpdateEffect(function () {
|
|
1075
|
-
constructParser();
|
|
1076
|
-
changeValue();
|
|
1077
|
-
}, [props.locale, props.localeMatcher, props.mode, props.currency, props.currencyDisplay, props.useGrouping, props.minFractionDigits, props.maxFractionDigits, props.suffix, props.prefix]);
|
|
1078
|
-
useUpdateEffect(function () {
|
|
1079
|
-
changeValue();
|
|
1080
|
-
}, [props.value]);
|
|
1081
|
-
var createInputElement = function createInputElement() {
|
|
1082
|
-
var className = classNames('p-inputnumber-input', props.inputClassName);
|
|
1083
|
-
var valueToRender = formattedValue(props.value);
|
|
1084
|
-
return /*#__PURE__*/React.createElement(InputText, _extends({
|
|
1085
|
-
ref: inputRef,
|
|
1086
|
-
id: props.inputId,
|
|
1087
|
-
style: props.inputStyle,
|
|
1088
|
-
role: "spinbutton",
|
|
1089
|
-
className: className,
|
|
1090
|
-
defaultValue: valueToRender,
|
|
1091
|
-
type: props.type,
|
|
1092
|
-
size: props.size,
|
|
1093
|
-
tabIndex: props.tabIndex,
|
|
1094
|
-
inputMode: inputMode,
|
|
1095
|
-
maxLength: props.maxLength,
|
|
1096
|
-
disabled: props.disabled,
|
|
1097
|
-
required: props.required,
|
|
1098
|
-
pattern: props.pattern,
|
|
1099
|
-
placeholder: props.placeholder,
|
|
1100
|
-
readOnly: props.readOnly,
|
|
1101
|
-
name: props.name,
|
|
1102
|
-
autoFocus: props.autoFocus,
|
|
1103
|
-
onKeyDown: onInputKeyDown,
|
|
1104
|
-
onKeyPress: onInputKeyUp,
|
|
1105
|
-
onInput: onInput,
|
|
1106
|
-
onClick: onInputClick,
|
|
1107
|
-
onBlur: onInputBlur,
|
|
1108
|
-
onFocus: onInputFocus,
|
|
1109
|
-
onPaste: onPaste,
|
|
1110
|
-
min: props.min,
|
|
1111
|
-
max: props.max,
|
|
1112
|
-
"aria-valuemin": props.min,
|
|
1113
|
-
"aria-valuemax": props.max,
|
|
1114
|
-
"aria-valuenow": props.value
|
|
1115
|
-
}, ariaProps, dataProps, {
|
|
1116
|
-
pt: ptm('input'),
|
|
1117
|
-
__parentMetadata: {
|
|
1118
|
-
parent: metaData
|
|
1119
|
-
}
|
|
1120
|
-
}));
|
|
1121
|
-
};
|
|
1122
|
-
var createUpButton = function createUpButton() {
|
|
1123
|
-
var incrementIconProps = mergeProps({
|
|
1124
|
-
className: cx('incrementIcon')
|
|
1125
|
-
}, ptm('incrementIcon'));
|
|
1126
|
-
var icon = props.incrementButtonIcon || /*#__PURE__*/React.createElement(AngleUpIcon, incrementIconProps);
|
|
1127
|
-
var upButton = IconUtils.getJSXIcon(icon, _objectSpread({}, incrementIconProps), {
|
|
1128
|
-
props: props
|
|
1129
|
-
});
|
|
1130
|
-
var incrementButtonProps = mergeProps({
|
|
1131
|
-
type: 'button',
|
|
1132
|
-
className: classNames(props.incrementButtonClassName, cx('incrementButton')),
|
|
1133
|
-
onPointerLeave: onUpButtonMouseLeave,
|
|
1134
|
-
onPointerDown: function onPointerDown(e) {
|
|
1135
|
-
return onUpButtonMouseDown(e);
|
|
1136
|
-
},
|
|
1137
|
-
onPointerUp: onUpButtonMouseUp,
|
|
1138
|
-
onKeyDown: function onKeyDown(e) {
|
|
1139
|
-
return onUpButtonKeyDown(e);
|
|
1140
|
-
},
|
|
1141
|
-
onKeyUp: onUpButtonKeyUp,
|
|
1142
|
-
disabled: props.disabled,
|
|
1143
|
-
tabIndex: -1
|
|
1144
|
-
}, ptm('incrementButton'));
|
|
1145
|
-
return /*#__PURE__*/React.createElement("button", incrementButtonProps, upButton, /*#__PURE__*/React.createElement(Ripple, null));
|
|
1146
|
-
};
|
|
1147
|
-
var createDownButton = function createDownButton() {
|
|
1148
|
-
var decrementIconProps = mergeProps({
|
|
1149
|
-
className: cx('decrementIcon')
|
|
1150
|
-
}, ptm('decrementIcon'));
|
|
1151
|
-
var icon = props.decrementButtonIcon || /*#__PURE__*/React.createElement(AngleDownIcon, decrementIconProps);
|
|
1152
|
-
var downButton = IconUtils.getJSXIcon(icon, _objectSpread({}, decrementIconProps), {
|
|
1153
|
-
props: props
|
|
1154
|
-
});
|
|
1155
|
-
var decrementButtonProps = mergeProps({
|
|
1156
|
-
type: 'button',
|
|
1157
|
-
className: classNames(props.decrementButtonClassName, cx('decrementButton')),
|
|
1158
|
-
onPointerLeave: onDownButtonMouseLeave,
|
|
1159
|
-
onPointerDown: function onPointerDown(e) {
|
|
1160
|
-
return onDownButtonMouseDown(e);
|
|
1161
|
-
},
|
|
1162
|
-
onPointerUp: onDownButtonMouseUp,
|
|
1163
|
-
onKeyDown: function onKeyDown(e) {
|
|
1164
|
-
return onDownButtonKeyDown(e);
|
|
1165
|
-
},
|
|
1166
|
-
onKeyUp: onDownButtonKeyUp,
|
|
1167
|
-
disabled: props.disabled,
|
|
1168
|
-
tabIndex: -1
|
|
1169
|
-
}, ptm('decrementButton'));
|
|
1170
|
-
return /*#__PURE__*/React.createElement("button", decrementButtonProps, downButton, /*#__PURE__*/React.createElement(Ripple, null));
|
|
1171
|
-
};
|
|
1172
|
-
var createButtonGroup = function createButtonGroup() {
|
|
1173
|
-
var upButton = props.showButtons && createUpButton();
|
|
1174
|
-
var downButton = props.showButtons && createDownButton();
|
|
1175
|
-
var buttonGroupProps = mergeProps({
|
|
1176
|
-
className: cx('buttonGroup')
|
|
1177
|
-
}, ptm('buttonGroup'));
|
|
1178
|
-
if (stacked) {
|
|
1179
|
-
return /*#__PURE__*/React.createElement("span", buttonGroupProps, upButton, downButton);
|
|
1180
|
-
}
|
|
1181
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, upButton, downButton);
|
|
1182
|
-
};
|
|
1183
|
-
var hasTooltip = ObjectUtils.isNotEmpty(props.tooltip);
|
|
1184
|
-
var otherProps = InputNumberBase.getOtherProps(props);
|
|
1185
|
-
var dataProps = ObjectUtils.reduceKeys(otherProps, DomHandler.DATA_PROPS);
|
|
1186
|
-
var ariaProps = ObjectUtils.reduceKeys(otherProps, DomHandler.ARIA_PROPS);
|
|
1187
|
-
var inputElement = createInputElement();
|
|
1188
|
-
var buttonGroup = createButtonGroup();
|
|
1189
|
-
var rootProps = mergeProps({
|
|
1190
|
-
id: props.id,
|
|
1191
|
-
ref: elementRef,
|
|
1192
|
-
className: classNames(props.className, cx('root', {
|
|
1193
|
-
focusedState: focusedState,
|
|
1194
|
-
stacked: stacked,
|
|
1195
|
-
horizontal: horizontal,
|
|
1196
|
-
vertical: vertical
|
|
1197
|
-
})),
|
|
1198
|
-
style: props.style
|
|
1199
|
-
}, otherProps, ptm('root'));
|
|
1200
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", rootProps, inputElement, buttonGroup), hasTooltip && /*#__PURE__*/React.createElement(Tooltip, _extends({
|
|
1201
|
-
target: elementRef,
|
|
1202
|
-
content: props.tooltip
|
|
1203
|
-
}, props.tooltipOptions, {
|
|
1204
|
-
pt: ptm('tooltip')
|
|
1205
|
-
})));
|
|
1206
|
-
}));
|
|
1207
|
-
InputNumber.displayName = 'InputNumber';
|
|
1208
|
-
|
|
1209
|
-
export { InputNumber };
|