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
package/calendar/calendar.esm.js
DELETED
|
@@ -1,3473 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import PrimeReact, { PrimeReactContext, localeOptions, localeOption } from 'primereact/api';
|
|
5
|
-
import { Button } from 'primereact/button';
|
|
6
|
-
import { ComponentBase, useHandleStyle } from 'primereact/componentbase';
|
|
7
|
-
import { usePrevious, useOverlayListener, useMountEffect, useUpdateEffect, useUnmountEffect } from 'primereact/hooks';
|
|
8
|
-
import { CalendarIcon } from 'primereact/icons/calendar';
|
|
9
|
-
import { ChevronDownIcon } from 'primereact/icons/chevrondown';
|
|
10
|
-
import { ChevronLeftIcon } from 'primereact/icons/chevronleft';
|
|
11
|
-
import { ChevronRightIcon } from 'primereact/icons/chevronright';
|
|
12
|
-
import { ChevronUpIcon } from 'primereact/icons/chevronup';
|
|
13
|
-
import { InputText } from 'primereact/inputtext';
|
|
14
|
-
import { OverlayService } from 'primereact/overlayservice';
|
|
15
|
-
import { Ripple } from 'primereact/ripple';
|
|
16
|
-
import { classNames, mergeProps, UniqueComponentId, DomHandler, ObjectUtils, mask, ZIndexUtils, IconUtils } from 'primereact/utils';
|
|
17
|
-
import { CSSTransition } from 'primereact/csstransition';
|
|
18
|
-
import { Portal } from 'primereact/portal';
|
|
19
|
-
|
|
20
|
-
function _extends() {
|
|
21
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
22
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
23
|
-
var source = arguments[i];
|
|
24
|
-
for (var key in source) {
|
|
25
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
26
|
-
target[key] = source[key];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
|
-
return _extends.apply(this, arguments);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function _typeof(o) {
|
|
36
|
-
"@babel/helpers - typeof";
|
|
37
|
-
|
|
38
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
39
|
-
return typeof o;
|
|
40
|
-
} : function (o) {
|
|
41
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
42
|
-
}, _typeof(o);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function _toPrimitive(input, hint) {
|
|
46
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
47
|
-
var prim = input[Symbol.toPrimitive];
|
|
48
|
-
if (prim !== undefined) {
|
|
49
|
-
var res = prim.call(input, hint || "default");
|
|
50
|
-
if (_typeof(res) !== "object") return res;
|
|
51
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
52
|
-
}
|
|
53
|
-
return (hint === "string" ? String : Number)(input);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function _toPropertyKey(arg) {
|
|
57
|
-
var key = _toPrimitive(arg, "string");
|
|
58
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function _defineProperty(obj, key, value) {
|
|
62
|
-
key = _toPropertyKey(key);
|
|
63
|
-
if (key in obj) {
|
|
64
|
-
Object.defineProperty(obj, key, {
|
|
65
|
-
value: value,
|
|
66
|
-
enumerable: true,
|
|
67
|
-
configurable: true,
|
|
68
|
-
writable: true
|
|
69
|
-
});
|
|
70
|
-
} else {
|
|
71
|
-
obj[key] = value;
|
|
72
|
-
}
|
|
73
|
-
return obj;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function _arrayLikeToArray$1(arr, len) {
|
|
77
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
78
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
79
|
-
return arr2;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function _arrayWithoutHoles(arr) {
|
|
83
|
-
if (Array.isArray(arr)) return _arrayLikeToArray$1(arr);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function _iterableToArray(iter) {
|
|
87
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function _unsupportedIterableToArray$1(o, minLen) {
|
|
91
|
-
if (!o) return;
|
|
92
|
-
if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
|
|
93
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
94
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
95
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
96
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function _nonIterableSpread() {
|
|
100
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function _toConsumableArray(arr) {
|
|
104
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function _arrayWithHoles(arr) {
|
|
108
|
-
if (Array.isArray(arr)) return arr;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function _iterableToArrayLimit(r, l) {
|
|
112
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
113
|
-
if (null != t) {
|
|
114
|
-
var e,
|
|
115
|
-
n,
|
|
116
|
-
i,
|
|
117
|
-
u,
|
|
118
|
-
a = [],
|
|
119
|
-
f = !0,
|
|
120
|
-
o = !1;
|
|
121
|
-
try {
|
|
122
|
-
if (i = (t = t.call(r)).next, 0 === l) {
|
|
123
|
-
if (Object(t) !== t) return;
|
|
124
|
-
f = !1;
|
|
125
|
-
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
126
|
-
} catch (r) {
|
|
127
|
-
o = !0, n = r;
|
|
128
|
-
} finally {
|
|
129
|
-
try {
|
|
130
|
-
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
|
|
131
|
-
} finally {
|
|
132
|
-
if (o) throw n;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return a;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function _nonIterableRest() {
|
|
140
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function _slicedToArray(arr, i) {
|
|
144
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
var styles = "\n@layer primereact {\n .p-calendar {\n position: relative;\n display: inline-flex;\n max-width: 100%;\n }\n \n .p-calendar .p-inputtext {\n flex: 1 1 auto;\n width: 1%;\n }\n \n .p-calendar-w-btn-right .p-inputtext {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n }\n \n .p-calendar-w-btn-right .p-datepicker-trigger {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n }\n \n .p-calendar-w-btn-left .p-inputtext {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n }\n \n .p-calendar-w-btn-left .p-datepicker-trigger {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n }\n \n /* Fluid */\n .p-fluid .p-calendar {\n display: flex;\n }\n \n .p-fluid .p-calendar .p-inputtext {\n width: 1%;\n }\n \n /* Datepicker */\n .p-calendar .p-datepicker {\n min-width: 100%;\n }\n \n .p-datepicker {\n width: auto;\n position: absolute;\n top: 0;\n left: 0;\n }\n \n .p-datepicker-inline {\n display: inline-block;\n position: static;\n overflow-x: auto;\n }\n \n /* Header */\n .p-datepicker-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n }\n \n .p-datepicker-header .p-datepicker-title {\n margin: 0 auto;\n }\n \n .p-datepicker-prev,\n .p-datepicker-next {\n cursor: pointer;\n display: inline-flex;\n justify-content: center;\n align-items: center;\n overflow: hidden;\n position: relative;\n }\n \n /* Multiple Month DatePicker */\n .p-datepicker-multiple-month .p-datepicker-group-container {\n display: flex;\n }\n \n .p-datepicker-multiple-month .p-datepicker-group-container .p-datepicker-group {\n flex: 1 1 auto;\n }\n \n /* Multiple Month DatePicker */\n .p-datepicker-multiple-month .p-datepicker-group-container {\n display: flex;\n }\n \n /* DatePicker Table */\n .p-datepicker table {\n width: 100%;\n border-collapse: collapse;\n }\n \n .p-datepicker td > span {\n display: flex;\n justify-content: center;\n align-items: center;\n cursor: pointer;\n margin: 0 auto;\n overflow: hidden;\n position: relative;\n }\n \n /* Month Picker */\n .p-monthpicker-month {\n width: 33.3%;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n overflow: hidden;\n position: relative;\n }\n \n /* Button Bar */\n .p-datepicker-buttonbar {\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n \n /* Time Picker */\n .p-timepicker {\n display: flex;\n justify-content: center;\n align-items: center;\n }\n \n .p-timepicker button {\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n overflow: hidden;\n position: relative;\n }\n \n .p-timepicker > div {\n display: flex;\n align-items: center;\n flex-direction: column;\n }\n \n /* Touch UI */\n .p-datepicker-touch-ui,\n .p-calendar .p-datepicker-touch-ui {\n position: fixed;\n top: 50%;\n left: 50%;\n min-width: 80vw;\n transform: translate(-50%, -50%);\n }\n \n /* Year Picker */\n .p-yearpicker-year {\n width: 50%;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n overflow: hidden;\n position: relative;\n }\n}\n";
|
|
148
|
-
var classes = {
|
|
149
|
-
root: function root(_ref) {
|
|
150
|
-
var _classNames;
|
|
151
|
-
var props = _ref.props,
|
|
152
|
-
focusedState = _ref.focusedState,
|
|
153
|
-
isFilled = _ref.isFilled;
|
|
154
|
-
return classNames('p-calendar p-component p-inputwrapper', (_classNames = {}, _defineProperty(_classNames, "p-calendar-w-btn p-calendar-w-btn-".concat(props.iconPos), props.showIcon), _defineProperty(_classNames, 'p-calendar-disabled', props.disabled), _defineProperty(_classNames, 'p-calendar-timeonly', props.timeOnly), _defineProperty(_classNames, 'p-inputwrapper-filled', props.value || isFilled), _defineProperty(_classNames, 'p-inputwrapper-focus', focusedState), _classNames));
|
|
155
|
-
},
|
|
156
|
-
dropdownButton: 'p-datepicker-trigger',
|
|
157
|
-
buttonbar: 'p-datepicker-buttonbar',
|
|
158
|
-
todayButton: 'p-button-text',
|
|
159
|
-
clearButton: 'p-button-text',
|
|
160
|
-
footer: 'p-datepicker-footer',
|
|
161
|
-
yearPicker: 'p-yearpicker',
|
|
162
|
-
year: function year(_ref2) {
|
|
163
|
-
var isYearSelected = _ref2.isYearSelected,
|
|
164
|
-
isSelectable = _ref2.isSelectable,
|
|
165
|
-
y = _ref2.y;
|
|
166
|
-
return classNames('p-yearpicker-year', {
|
|
167
|
-
'p-highlight': isYearSelected(y),
|
|
168
|
-
'p-disabled': !isSelectable(0, -1, y)
|
|
169
|
-
});
|
|
170
|
-
},
|
|
171
|
-
monthPicker: 'p-monthpicker',
|
|
172
|
-
month: function month(_ref3) {
|
|
173
|
-
var isMonthSelected = _ref3.isMonthSelected,
|
|
174
|
-
isSelectable = _ref3.isSelectable,
|
|
175
|
-
i = _ref3.i,
|
|
176
|
-
currentYear = _ref3.currentYear;
|
|
177
|
-
return classNames('p-monthpicker-month', {
|
|
178
|
-
'p-highlight': isMonthSelected(i),
|
|
179
|
-
'p-disabled': !isSelectable(0, i, currentYear)
|
|
180
|
-
});
|
|
181
|
-
},
|
|
182
|
-
hourPicker: 'p-hour-picker',
|
|
183
|
-
secondPicker: 'p-second-picker',
|
|
184
|
-
minutePicker: 'p-minute-picker',
|
|
185
|
-
millisecondPicker: 'p-millisecond-picker',
|
|
186
|
-
ampmPicker: 'p-ampm-picker',
|
|
187
|
-
separatorContainer: 'p-separator',
|
|
188
|
-
dayLabel: function dayLabel(_ref4) {
|
|
189
|
-
var className = _ref4.className;
|
|
190
|
-
return className;
|
|
191
|
-
},
|
|
192
|
-
day: function day(_ref5) {
|
|
193
|
-
var date = _ref5.date;
|
|
194
|
-
return classNames({
|
|
195
|
-
'p-datepicker-other-month': date.otherMonth,
|
|
196
|
-
'p-datepicker-today': date.today
|
|
197
|
-
});
|
|
198
|
-
},
|
|
199
|
-
panel: function panel(_ref6) {
|
|
200
|
-
var panelClassName = _ref6.panelClassName;
|
|
201
|
-
return panelClassName;
|
|
202
|
-
},
|
|
203
|
-
previousIcon: 'p-datepicker-prev-icon',
|
|
204
|
-
previousButton: 'p-datepicker-prev',
|
|
205
|
-
nextIcon: 'p-datepicker-next-icon',
|
|
206
|
-
nextButton: 'p-datepicker-next',
|
|
207
|
-
incrementButton: 'p-link',
|
|
208
|
-
decrementButton: 'p-link',
|
|
209
|
-
title: 'p-datepicker-title',
|
|
210
|
-
timePicker: 'p-timepicker',
|
|
211
|
-
monthTitle: 'p-datepicker-month p-link',
|
|
212
|
-
yearTitle: 'p-datepicker-year p-link',
|
|
213
|
-
decadeTitle: 'p-datepicker-decade',
|
|
214
|
-
header: 'p-datepicker-header',
|
|
215
|
-
groupContainer: 'p-datepicker-group-container',
|
|
216
|
-
group: 'p-datepicker-group',
|
|
217
|
-
select: function select(_ref7) {
|
|
218
|
-
var props = _ref7.props;
|
|
219
|
-
return props.monthNavigator && props.view !== 'month' ? 'p-datepicker-month' : props.yearNavigator ? 'p-datepicker-year' : undefined;
|
|
220
|
-
},
|
|
221
|
-
weekHeader: 'p-datepicker-weekheader p-disabled',
|
|
222
|
-
weekNumber: 'p-datepicker-weeknumber',
|
|
223
|
-
weekLabelContainer: 'p-disabled',
|
|
224
|
-
container: 'p-datepicker-calendar-container',
|
|
225
|
-
table: 'p-datepicker-calendar',
|
|
226
|
-
transition: 'p-connected-overlay'
|
|
227
|
-
};
|
|
228
|
-
var CalendarBase = ComponentBase.extend({
|
|
229
|
-
defaultProps: {
|
|
230
|
-
__TYPE: 'Calendar',
|
|
231
|
-
appendTo: null,
|
|
232
|
-
ariaLabelledBy: null,
|
|
233
|
-
autoZIndex: true,
|
|
234
|
-
autoFocus: false,
|
|
235
|
-
baseZIndex: 0,
|
|
236
|
-
className: null,
|
|
237
|
-
clearButtonClassName: 'p-button-secondary',
|
|
238
|
-
dateFormat: null,
|
|
239
|
-
dateTemplate: null,
|
|
240
|
-
decadeTemplate: null,
|
|
241
|
-
decrementIcon: null,
|
|
242
|
-
disabled: false,
|
|
243
|
-
disabledDates: null,
|
|
244
|
-
disabledDays: null,
|
|
245
|
-
enabledDates: null,
|
|
246
|
-
footerTemplate: null,
|
|
247
|
-
formatDateTime: null,
|
|
248
|
-
headerTemplate: null,
|
|
249
|
-
hideOnDateTimeSelect: false,
|
|
250
|
-
hourFormat: '24',
|
|
251
|
-
icon: null,
|
|
252
|
-
iconPos: 'right',
|
|
253
|
-
id: null,
|
|
254
|
-
incrementIcon: null,
|
|
255
|
-
inline: false,
|
|
256
|
-
inputClassName: null,
|
|
257
|
-
inputId: null,
|
|
258
|
-
inputMode: 'none',
|
|
259
|
-
inputRef: null,
|
|
260
|
-
inputStyle: null,
|
|
261
|
-
keepInvalid: false,
|
|
262
|
-
locale: null,
|
|
263
|
-
mask: null,
|
|
264
|
-
maskSlotChar: '_',
|
|
265
|
-
maxDate: null,
|
|
266
|
-
maxDateCount: null,
|
|
267
|
-
minDate: null,
|
|
268
|
-
monthNavigator: false,
|
|
269
|
-
monthNavigatorTemplate: null,
|
|
270
|
-
name: null,
|
|
271
|
-
nextIcon: null,
|
|
272
|
-
numberOfMonths: 1,
|
|
273
|
-
onBlur: null,
|
|
274
|
-
onChange: null,
|
|
275
|
-
onClearButtonClick: null,
|
|
276
|
-
onFocus: null,
|
|
277
|
-
onHide: null,
|
|
278
|
-
onInput: null,
|
|
279
|
-
onMonthChange: null,
|
|
280
|
-
onSelect: null,
|
|
281
|
-
onShow: null,
|
|
282
|
-
onTodayButtonClick: null,
|
|
283
|
-
onViewDateChange: null,
|
|
284
|
-
onVisibleChange: null,
|
|
285
|
-
panelClassName: null,
|
|
286
|
-
panelStyle: null,
|
|
287
|
-
parseDateTime: null,
|
|
288
|
-
placeholder: null,
|
|
289
|
-
prevIcon: null,
|
|
290
|
-
readOnlyInput: false,
|
|
291
|
-
required: false,
|
|
292
|
-
selectOtherMonths: false,
|
|
293
|
-
selectionMode: 'single',
|
|
294
|
-
shortYearCutoff: '+10',
|
|
295
|
-
showButtonBar: false,
|
|
296
|
-
showIcon: false,
|
|
297
|
-
showMillisec: false,
|
|
298
|
-
showMinMaxRange: false,
|
|
299
|
-
showOnFocus: true,
|
|
300
|
-
showOtherMonths: true,
|
|
301
|
-
showSeconds: false,
|
|
302
|
-
showTime: false,
|
|
303
|
-
showWeek: false,
|
|
304
|
-
stepHour: 1,
|
|
305
|
-
stepMillisec: 1,
|
|
306
|
-
stepMinute: 1,
|
|
307
|
-
stepSecond: 1,
|
|
308
|
-
style: null,
|
|
309
|
-
tabIndex: null,
|
|
310
|
-
timeOnly: false,
|
|
311
|
-
todayButtonClassName: 'p-button-secondary',
|
|
312
|
-
tooltip: null,
|
|
313
|
-
tooltipOptions: null,
|
|
314
|
-
touchUI: false,
|
|
315
|
-
transitionOptions: null,
|
|
316
|
-
value: null,
|
|
317
|
-
view: 'date',
|
|
318
|
-
viewDate: null,
|
|
319
|
-
visible: false,
|
|
320
|
-
yearNavigator: false,
|
|
321
|
-
yearNavigatorTemplate: null,
|
|
322
|
-
yearRange: null,
|
|
323
|
-
children: undefined
|
|
324
|
-
},
|
|
325
|
-
css: {
|
|
326
|
-
classes: classes,
|
|
327
|
-
styles: styles
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
var CalendarPanel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
332
|
-
var cx = props.cx;
|
|
333
|
-
var createElement = function createElement() {
|
|
334
|
-
var panelProps = mergeProps({
|
|
335
|
-
className: cx('panel', {
|
|
336
|
-
panelClassName: props.className
|
|
337
|
-
}),
|
|
338
|
-
style: props.style,
|
|
339
|
-
onClick: props.onClick,
|
|
340
|
-
onMouseUp: props.onMouseUp
|
|
341
|
-
}, props.ptm('panel', {
|
|
342
|
-
hostName: props.hostName
|
|
343
|
-
}));
|
|
344
|
-
var transitionProps = mergeProps({
|
|
345
|
-
classNames: cx('transition'),
|
|
346
|
-
"in": props["in"],
|
|
347
|
-
timeout: {
|
|
348
|
-
enter: 120,
|
|
349
|
-
exit: 100
|
|
350
|
-
},
|
|
351
|
-
options: props.transitionOptions,
|
|
352
|
-
unmountOnExit: true,
|
|
353
|
-
onEnter: props.onEnter,
|
|
354
|
-
onEntered: props.onEntered,
|
|
355
|
-
onExit: props.onExit,
|
|
356
|
-
onExited: props.onExited
|
|
357
|
-
}, props.ptm('transition', {
|
|
358
|
-
hostName: props.hostName
|
|
359
|
-
}));
|
|
360
|
-
return /*#__PURE__*/React.createElement(CSSTransition, _extends({
|
|
361
|
-
nodeRef: ref
|
|
362
|
-
}, transitionProps), /*#__PURE__*/React.createElement("div", _extends({
|
|
363
|
-
ref: ref
|
|
364
|
-
}, panelProps), props.children));
|
|
365
|
-
};
|
|
366
|
-
var element = createElement();
|
|
367
|
-
return props.inline ? element : /*#__PURE__*/React.createElement(Portal, {
|
|
368
|
-
element: element,
|
|
369
|
-
appendTo: props.appendTo
|
|
370
|
-
});
|
|
371
|
-
});
|
|
372
|
-
CalendarPanel.displayName = 'CalendarPanel';
|
|
373
|
-
|
|
374
|
-
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; }
|
|
375
|
-
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; }
|
|
376
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
377
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
378
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
379
|
-
var Calendar = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (inProps, ref) {
|
|
380
|
-
var context = React.useContext(PrimeReactContext);
|
|
381
|
-
var props = CalendarBase.getProps(inProps, context);
|
|
382
|
-
var _React$useState = React.useState(false),
|
|
383
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
384
|
-
focusedState = _React$useState2[0],
|
|
385
|
-
setFocusedState = _React$useState2[1];
|
|
386
|
-
var _React$useState3 = React.useState(false),
|
|
387
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
388
|
-
overlayVisibleState = _React$useState4[0],
|
|
389
|
-
setOverlayVisibleState = _React$useState4[1];
|
|
390
|
-
var _React$useState5 = React.useState(null),
|
|
391
|
-
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
392
|
-
viewDateState = _React$useState6[0],
|
|
393
|
-
setViewDateState = _React$useState6[1];
|
|
394
|
-
var metaData = {
|
|
395
|
-
props: props,
|
|
396
|
-
state: {
|
|
397
|
-
focused: focusedState,
|
|
398
|
-
overlayVisible: overlayVisibleState,
|
|
399
|
-
viewDate: viewDateState
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
var _CalendarBase$setMeta = CalendarBase.setMetaData(metaData),
|
|
403
|
-
ptm = _CalendarBase$setMeta.ptm,
|
|
404
|
-
cx = _CalendarBase$setMeta.cx,
|
|
405
|
-
isUnstyled = _CalendarBase$setMeta.isUnstyled;
|
|
406
|
-
useHandleStyle(CalendarBase.css.styles, isUnstyled, {
|
|
407
|
-
name: 'calendar'
|
|
408
|
-
});
|
|
409
|
-
var elementRef = React.useRef(null);
|
|
410
|
-
var overlayRef = React.useRef(null);
|
|
411
|
-
var inputRef = React.useRef(props.inputRef);
|
|
412
|
-
var navigation = React.useRef(null);
|
|
413
|
-
var ignoreFocusFunctionality = React.useRef(false);
|
|
414
|
-
var timePickerTimer = React.useRef(null);
|
|
415
|
-
var viewStateChanged = React.useRef(false);
|
|
416
|
-
var touchUIMask = React.useRef(null);
|
|
417
|
-
var overlayEventListener = React.useRef(null);
|
|
418
|
-
var touchUIMaskClickListener = React.useRef(null);
|
|
419
|
-
var isOverlayClicked = React.useRef(false);
|
|
420
|
-
var ignoreMaskChange = React.useRef(false);
|
|
421
|
-
var previousButton = React.useRef(false);
|
|
422
|
-
var nextButton = React.useRef(false);
|
|
423
|
-
var onChangeRef = React.useRef(null);
|
|
424
|
-
var _React$useState7 = React.useState('date'),
|
|
425
|
-
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
426
|
-
currentView = _React$useState8[0],
|
|
427
|
-
setCurrentView = _React$useState8[1];
|
|
428
|
-
var _React$useState9 = React.useState(null),
|
|
429
|
-
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
430
|
-
currentMonth = _React$useState10[0],
|
|
431
|
-
setCurrentMonth = _React$useState10[1];
|
|
432
|
-
var _React$useState11 = React.useState(null),
|
|
433
|
-
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
434
|
-
currentYear = _React$useState12[0],
|
|
435
|
-
setCurrentYear = _React$useState12[1];
|
|
436
|
-
var _React$useState13 = React.useState([]),
|
|
437
|
-
_React$useState14 = _slicedToArray(_React$useState13, 2),
|
|
438
|
-
yearOptions = _React$useState14[0],
|
|
439
|
-
setYearOptions = _React$useState14[1];
|
|
440
|
-
var previousValue = usePrevious(props.value);
|
|
441
|
-
var visible = props.inline || (props.onVisibleChange ? props.visible : overlayVisibleState);
|
|
442
|
-
var attributeSelector = UniqueComponentId();
|
|
443
|
-
var _useOverlayListener = useOverlayListener({
|
|
444
|
-
target: elementRef,
|
|
445
|
-
overlay: overlayRef,
|
|
446
|
-
listener: function listener(event, _ref) {
|
|
447
|
-
var type = _ref.type,
|
|
448
|
-
valid = _ref.valid;
|
|
449
|
-
if (valid) {
|
|
450
|
-
type === 'outside' ? !isOverlayClicked.current && !isNavIconClicked(event.target) && hide('outside') : hide();
|
|
451
|
-
}
|
|
452
|
-
isOverlayClicked.current = false;
|
|
453
|
-
},
|
|
454
|
-
when: !(props.touchUI || props.inline) && visible
|
|
455
|
-
}),
|
|
456
|
-
_useOverlayListener2 = _slicedToArray(_useOverlayListener, 2),
|
|
457
|
-
bindOverlayListener = _useOverlayListener2[0],
|
|
458
|
-
unbindOverlayListener = _useOverlayListener2[1];
|
|
459
|
-
var getDateFormat = function getDateFormat() {
|
|
460
|
-
return props.dateFormat || localeOption('dateFormat', props.locale);
|
|
461
|
-
};
|
|
462
|
-
var onInputFocus = function onInputFocus(event) {
|
|
463
|
-
if (ignoreFocusFunctionality.current) {
|
|
464
|
-
setFocusedState(true);
|
|
465
|
-
ignoreFocusFunctionality.current = false;
|
|
466
|
-
} else {
|
|
467
|
-
if (props.showOnFocus && !visible) {
|
|
468
|
-
show();
|
|
469
|
-
}
|
|
470
|
-
setFocusedState(true);
|
|
471
|
-
props.onFocus && props.onFocus(event);
|
|
472
|
-
}
|
|
473
|
-
};
|
|
474
|
-
var onInputBlur = function onInputBlur(event) {
|
|
475
|
-
!props.keepInvalid && updateInputfield(props.value);
|
|
476
|
-
props.onBlur && props.onBlur(event);
|
|
477
|
-
setFocusedState(false);
|
|
478
|
-
};
|
|
479
|
-
var onInputKeyDown = function onInputKeyDown(event) {
|
|
480
|
-
switch (event.which) {
|
|
481
|
-
//escape
|
|
482
|
-
case 27:
|
|
483
|
-
{
|
|
484
|
-
hide();
|
|
485
|
-
break;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
//tab
|
|
489
|
-
case 9:
|
|
490
|
-
{
|
|
491
|
-
visible && trapFocus(event);
|
|
492
|
-
props.touchUI && disableModality();
|
|
493
|
-
break;
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
var onUserInput = function onUserInput(event) {
|
|
498
|
-
updateValueOnInput(event, event.target.value);
|
|
499
|
-
props.onInput && props.onInput(event);
|
|
500
|
-
};
|
|
501
|
-
var updateValueOnInput = function updateValueOnInput(event, rawValue) {
|
|
502
|
-
try {
|
|
503
|
-
var value = parseValueFromString(rawValue);
|
|
504
|
-
if (isValidSelection(value)) {
|
|
505
|
-
updateModel(event, value);
|
|
506
|
-
updateViewDate(event, value.length ? value[0] : value);
|
|
507
|
-
}
|
|
508
|
-
} catch (err) {
|
|
509
|
-
//invalid date
|
|
510
|
-
var _value = props.keepInvalid ? rawValue : null;
|
|
511
|
-
updateModel(event, _value);
|
|
512
|
-
}
|
|
513
|
-
};
|
|
514
|
-
var reFocusInputField = function reFocusInputField() {
|
|
515
|
-
if (!props.inline && inputRef.current) {
|
|
516
|
-
ignoreFocusFunctionality.current = true;
|
|
517
|
-
DomHandler.focus(inputRef.current);
|
|
518
|
-
}
|
|
519
|
-
};
|
|
520
|
-
var isValidSelection = function isValidSelection(value) {
|
|
521
|
-
var isValid = true;
|
|
522
|
-
if (isSingleSelection()) {
|
|
523
|
-
if (!(isSelectable(value.getDate(), value.getMonth(), value.getFullYear(), false) && isSelectableTime(value))) {
|
|
524
|
-
isValid = false;
|
|
525
|
-
}
|
|
526
|
-
} else if (value.every(function (v) {
|
|
527
|
-
return isSelectable(v.getDate(), v.getMonth(), v.getFullYear(), false) && isSelectableTime(v);
|
|
528
|
-
})) {
|
|
529
|
-
if (isRangeSelection()) {
|
|
530
|
-
isValid = value.length > 1 && value[1] > value[0] ? true : false;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
return isValid;
|
|
534
|
-
};
|
|
535
|
-
var onButtonClick = function onButtonClick() {
|
|
536
|
-
visible ? hide() : show();
|
|
537
|
-
};
|
|
538
|
-
var onPrevButtonClick = function onPrevButtonClick(event) {
|
|
539
|
-
navigation.current = {
|
|
540
|
-
backward: true,
|
|
541
|
-
button: true
|
|
542
|
-
};
|
|
543
|
-
navBackward(event);
|
|
544
|
-
};
|
|
545
|
-
var onNextButtonClick = function onNextButtonClick(event) {
|
|
546
|
-
navigation.current = {
|
|
547
|
-
backward: false,
|
|
548
|
-
button: true
|
|
549
|
-
};
|
|
550
|
-
navForward(event);
|
|
551
|
-
};
|
|
552
|
-
var onContainerButtonKeydown = function onContainerButtonKeydown(event) {
|
|
553
|
-
switch (event.which) {
|
|
554
|
-
//tab
|
|
555
|
-
case 9:
|
|
556
|
-
trapFocus(event);
|
|
557
|
-
break;
|
|
558
|
-
|
|
559
|
-
//escape
|
|
560
|
-
case 27:
|
|
561
|
-
hide(null, reFocusInputField);
|
|
562
|
-
event.preventDefault();
|
|
563
|
-
break;
|
|
564
|
-
}
|
|
565
|
-
};
|
|
566
|
-
var trapFocus = function trapFocus(event) {
|
|
567
|
-
event.preventDefault();
|
|
568
|
-
var focusableElements = DomHandler.getFocusableElements(overlayRef.current);
|
|
569
|
-
if (focusableElements && focusableElements.length > 0) {
|
|
570
|
-
if (!document.activeElement) {
|
|
571
|
-
focusableElements[0].focus();
|
|
572
|
-
} else {
|
|
573
|
-
var focusedIndex = focusableElements.indexOf(document.activeElement);
|
|
574
|
-
if (event.shiftKey) {
|
|
575
|
-
if (focusedIndex === -1 || focusedIndex === 0) focusableElements[focusableElements.length - 1].focus();else focusableElements[focusedIndex - 1].focus();
|
|
576
|
-
} else {
|
|
577
|
-
if (focusedIndex === -1 || focusedIndex === focusableElements.length - 1) focusableElements[0].focus();else focusableElements[focusedIndex + 1].focus();
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
};
|
|
582
|
-
var updateFocus = function updateFocus() {
|
|
583
|
-
if (navigation.current) {
|
|
584
|
-
if (navigation.current.button) {
|
|
585
|
-
initFocusableCell();
|
|
586
|
-
if (navigation.current.backward) previousButton.current.focus();else nextButton.current.focus();
|
|
587
|
-
} else {
|
|
588
|
-
var cell;
|
|
589
|
-
if (navigation.current.backward) {
|
|
590
|
-
var cells = DomHandler.find(overlayRef.current, 'table td span:not([data-p-disabled="true"])');
|
|
591
|
-
cell = cells[cells.length - 1];
|
|
592
|
-
} else {
|
|
593
|
-
cell = DomHandler.findSingle(overlayRef.current, 'table td span:not([data-p-disabled="true"])');
|
|
594
|
-
}
|
|
595
|
-
if (cell) {
|
|
596
|
-
cell.tabIndex = '0';
|
|
597
|
-
cell.focus();
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
navigation.current = null;
|
|
601
|
-
} else {
|
|
602
|
-
initFocusableCell();
|
|
603
|
-
}
|
|
604
|
-
};
|
|
605
|
-
var initFocusableCell = function initFocusableCell() {
|
|
606
|
-
var cell;
|
|
607
|
-
if (props.view === 'month') {
|
|
608
|
-
var cells = DomHandler.find(overlayRef.current, '[data-pc-section="monthpicker"] [data-pc-section="month"]');
|
|
609
|
-
var selectedCell = DomHandler.findSingle(overlayRef.current, '[data-pc-section="monthpicker"] [data-pc-section="month"][data-p-highlight="true"]');
|
|
610
|
-
cells.forEach(function (cell) {
|
|
611
|
-
return cell.tabIndex = -1;
|
|
612
|
-
});
|
|
613
|
-
cell = selectedCell || cells[0];
|
|
614
|
-
} else {
|
|
615
|
-
cell = DomHandler.findSingle(overlayRef.current, 'span[data-p-highlight="true"]');
|
|
616
|
-
if (!cell) {
|
|
617
|
-
var todayCell = DomHandler.findSingle(overlayRef.current, 'td.p-datepicker-today span:not(.p-disabled)');
|
|
618
|
-
cell = todayCell || DomHandler.findSingle(overlayRef.current, 'table td span:not([data-p-disabled="true"])');
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
if (cell) {
|
|
622
|
-
cell.tabIndex = '0';
|
|
623
|
-
}
|
|
624
|
-
};
|
|
625
|
-
var navBackward = function navBackward(event) {
|
|
626
|
-
if (props.disabled) {
|
|
627
|
-
event.preventDefault();
|
|
628
|
-
return;
|
|
629
|
-
}
|
|
630
|
-
var newViewDate = cloneDate(getViewDate());
|
|
631
|
-
newViewDate.setDate(1);
|
|
632
|
-
if (currentView === 'date') {
|
|
633
|
-
if (newViewDate.getMonth() === 0) {
|
|
634
|
-
newViewDate.setMonth(11);
|
|
635
|
-
newViewDate.setFullYear(decrementYear());
|
|
636
|
-
setCurrentMonth(11);
|
|
637
|
-
} else {
|
|
638
|
-
newViewDate.setMonth(newViewDate.getMonth() - 1);
|
|
639
|
-
setCurrentMonth(function (prevState) {
|
|
640
|
-
return prevState - 1;
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
} else if (currentView === 'month') {
|
|
644
|
-
var newYear = newViewDate.getFullYear() - 1;
|
|
645
|
-
if (props.yearNavigator) {
|
|
646
|
-
var minYear = parseInt(props.yearRange.split(':')[0], 10);
|
|
647
|
-
if (newYear < minYear) {
|
|
648
|
-
newYear = minYear;
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
newViewDate.setFullYear(newYear);
|
|
652
|
-
}
|
|
653
|
-
if (currentView === 'month') {
|
|
654
|
-
newViewDate.setFullYear(decrementYear());
|
|
655
|
-
} else if (currentView === 'year') {
|
|
656
|
-
newViewDate.setFullYear(decrementDecade());
|
|
657
|
-
}
|
|
658
|
-
updateViewDate(event, newViewDate);
|
|
659
|
-
event.preventDefault();
|
|
660
|
-
};
|
|
661
|
-
var navForward = function navForward(event) {
|
|
662
|
-
if (props.disabled) {
|
|
663
|
-
event.preventDefault();
|
|
664
|
-
return;
|
|
665
|
-
}
|
|
666
|
-
var newViewDate = cloneDate(getViewDate());
|
|
667
|
-
newViewDate.setDate(1);
|
|
668
|
-
if (currentView === 'date') {
|
|
669
|
-
if (newViewDate.getMonth() === 11) {
|
|
670
|
-
newViewDate.setMonth(0);
|
|
671
|
-
newViewDate.setFullYear(incrementYear());
|
|
672
|
-
setCurrentMonth(0);
|
|
673
|
-
} else {
|
|
674
|
-
newViewDate.setMonth(newViewDate.getMonth() + 1);
|
|
675
|
-
setCurrentMonth(function (prevState) {
|
|
676
|
-
return prevState + 1;
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
} else if (currentView === 'month') {
|
|
680
|
-
var newYear = newViewDate.getFullYear() + 1;
|
|
681
|
-
if (props.yearNavigator) {
|
|
682
|
-
var maxYear = parseInt(props.yearRange.split(':')[1], 10);
|
|
683
|
-
if (newYear > maxYear) {
|
|
684
|
-
newYear = maxYear;
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
newViewDate.setFullYear(newYear);
|
|
688
|
-
}
|
|
689
|
-
if (currentView === 'month') {
|
|
690
|
-
newViewDate.setFullYear(incrementYear());
|
|
691
|
-
} else if (currentView === 'year') {
|
|
692
|
-
newViewDate.setFullYear(incrementDecade());
|
|
693
|
-
}
|
|
694
|
-
updateViewDate(event, newViewDate);
|
|
695
|
-
event.preventDefault();
|
|
696
|
-
};
|
|
697
|
-
var populateYearOptions = function populateYearOptions(start, end) {
|
|
698
|
-
var _yearOptions = [];
|
|
699
|
-
for (var i = start; i <= end; i++) {
|
|
700
|
-
yearOptions.push(i);
|
|
701
|
-
}
|
|
702
|
-
setYearOptions(_yearOptions);
|
|
703
|
-
};
|
|
704
|
-
var decrementYear = function decrementYear() {
|
|
705
|
-
var _currentYear = currentYear - 1;
|
|
706
|
-
setCurrentYear(_currentYear);
|
|
707
|
-
if (props.yearNavigator && _currentYear < yearOptions[0]) {
|
|
708
|
-
var difference = yearOptions[yearOptions.length - 1] - yearOptions[0];
|
|
709
|
-
populateYearOptions(yearOptions[0] - difference, yearOptions[yearOptions.length - 1] - difference);
|
|
710
|
-
}
|
|
711
|
-
return _currentYear;
|
|
712
|
-
};
|
|
713
|
-
var incrementYear = function incrementYear() {
|
|
714
|
-
var _currentYear = currentYear + 1;
|
|
715
|
-
setCurrentYear(_currentYear);
|
|
716
|
-
if (props.yearNavigator && _currentYear.current > yearOptions[yearOptions.length - 1]) {
|
|
717
|
-
var difference = yearOptions[yearOptions.length - 1] - yearOptions[0];
|
|
718
|
-
populateYearOptions(yearOptions[0] + difference, yearOptions[yearOptions.length - 1] + difference);
|
|
719
|
-
}
|
|
720
|
-
return _currentYear;
|
|
721
|
-
};
|
|
722
|
-
var onMonthDropdownChange = function onMonthDropdownChange(event, value) {
|
|
723
|
-
var currentViewDate = getViewDate();
|
|
724
|
-
var newViewDate = cloneDate(currentViewDate);
|
|
725
|
-
newViewDate.setMonth(parseInt(value, 10));
|
|
726
|
-
updateViewDate(event, newViewDate);
|
|
727
|
-
};
|
|
728
|
-
var onYearDropdownChange = function onYearDropdownChange(event, value) {
|
|
729
|
-
var currentViewDate = getViewDate();
|
|
730
|
-
var newViewDate = cloneDate(currentViewDate);
|
|
731
|
-
newViewDate.setFullYear(parseInt(value, 10));
|
|
732
|
-
updateViewDate(event, newViewDate);
|
|
733
|
-
};
|
|
734
|
-
var onTodayButtonClick = function onTodayButtonClick(event) {
|
|
735
|
-
var today = new Date();
|
|
736
|
-
var dateMeta = {
|
|
737
|
-
day: today.getDate(),
|
|
738
|
-
month: today.getMonth(),
|
|
739
|
-
year: today.getFullYear(),
|
|
740
|
-
today: true,
|
|
741
|
-
selectable: true
|
|
742
|
-
};
|
|
743
|
-
var timeMeta = {
|
|
744
|
-
hours: today.getHours(),
|
|
745
|
-
minutes: today.getMinutes(),
|
|
746
|
-
seconds: today.getSeconds(),
|
|
747
|
-
milliseconds: today.getMilliseconds()
|
|
748
|
-
};
|
|
749
|
-
updateViewDate(event, today);
|
|
750
|
-
onDateSelect(event, dateMeta, timeMeta);
|
|
751
|
-
props.onTodayButtonClick && props.onTodayButtonClick(event);
|
|
752
|
-
};
|
|
753
|
-
var onClearButtonClick = function onClearButtonClick(event) {
|
|
754
|
-
updateModel(event, null);
|
|
755
|
-
updateInputfield(null);
|
|
756
|
-
hide();
|
|
757
|
-
props.onClearButtonClick && props.onClearButtonClick(event);
|
|
758
|
-
};
|
|
759
|
-
var onPanelClick = function onPanelClick(event) {
|
|
760
|
-
if (!props.inline) {
|
|
761
|
-
OverlayService.emit('overlay-click', {
|
|
762
|
-
originalEvent: event,
|
|
763
|
-
target: elementRef.current
|
|
764
|
-
});
|
|
765
|
-
}
|
|
766
|
-
};
|
|
767
|
-
var onPanelMouseUp = function onPanelMouseUp(event) {
|
|
768
|
-
onPanelClick(event);
|
|
769
|
-
};
|
|
770
|
-
var onTimePickerElementMouseDown = function onTimePickerElementMouseDown(event, type, direction) {
|
|
771
|
-
if (!props.disabled) {
|
|
772
|
-
repeat(event, null, type, direction);
|
|
773
|
-
event.preventDefault();
|
|
774
|
-
}
|
|
775
|
-
};
|
|
776
|
-
var onTimePickerElementMouseUp = function onTimePickerElementMouseUp() {
|
|
777
|
-
if (!props.disabled) {
|
|
778
|
-
clearTimePickerTimer();
|
|
779
|
-
}
|
|
780
|
-
};
|
|
781
|
-
var onTimePickerElementMouseLeave = function onTimePickerElementMouseLeave() {
|
|
782
|
-
if (!props.disabled) {
|
|
783
|
-
clearTimePickerTimer();
|
|
784
|
-
}
|
|
785
|
-
};
|
|
786
|
-
var repeat = function repeat(event, interval, type, direction) {
|
|
787
|
-
clearTimePickerTimer();
|
|
788
|
-
timePickerTimer.current = setTimeout(function () {
|
|
789
|
-
repeat(event, 100, type, direction);
|
|
790
|
-
}, interval || 500);
|
|
791
|
-
switch (type) {
|
|
792
|
-
case 0:
|
|
793
|
-
if (direction === 1) incrementHour(event);else decrementHour(event);
|
|
794
|
-
break;
|
|
795
|
-
case 1:
|
|
796
|
-
if (direction === 1) incrementMinute(event);else decrementMinute(event);
|
|
797
|
-
break;
|
|
798
|
-
case 2:
|
|
799
|
-
if (direction === 1) incrementSecond(event);else decrementSecond(event);
|
|
800
|
-
break;
|
|
801
|
-
case 3:
|
|
802
|
-
if (direction === 1) incrementMilliSecond(event);else decrementMilliSecond(event);
|
|
803
|
-
break;
|
|
804
|
-
}
|
|
805
|
-
};
|
|
806
|
-
var clearTimePickerTimer = function clearTimePickerTimer() {
|
|
807
|
-
if (timePickerTimer.current) {
|
|
808
|
-
clearTimeout(timePickerTimer.current);
|
|
809
|
-
}
|
|
810
|
-
};
|
|
811
|
-
var incrementHour = function incrementHour(event) {
|
|
812
|
-
var currentTime = getCurrentDateTime();
|
|
813
|
-
var currentHour = currentTime.getHours();
|
|
814
|
-
var newHour = currentHour + props.stepHour;
|
|
815
|
-
newHour = newHour >= 24 ? newHour - 24 : newHour;
|
|
816
|
-
if (validateHour(newHour, currentTime)) {
|
|
817
|
-
if (props.maxDate && props.maxDate.toDateString() === currentTime.toDateString() && props.maxDate.getHours() === newHour) {
|
|
818
|
-
if (props.maxDate.getMinutes() < currentTime.getMinutes()) {
|
|
819
|
-
if (props.maxDate.getSeconds() < currentTime.getSeconds()) {
|
|
820
|
-
if (props.maxDate.getMilliseconds() < currentTime.getMilliseconds()) {
|
|
821
|
-
updateTime(event, newHour, props.maxDate.getMinutes(), props.maxDate.getSeconds(), props.maxDate.getMilliseconds());
|
|
822
|
-
} else {
|
|
823
|
-
updateTime(event, newHour, props.maxDate.getMinutes(), props.maxDate.getSeconds(), currentTime.getMilliseconds());
|
|
824
|
-
}
|
|
825
|
-
} else {
|
|
826
|
-
updateTime(event, newHour, props.maxDate.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
|
|
827
|
-
}
|
|
828
|
-
} else if (props.maxDate.getMinutes() === currentTime.getMinutes()) {
|
|
829
|
-
if (props.maxDate.getSeconds() < currentTime.getSeconds()) {
|
|
830
|
-
if (props.maxDate.getMilliseconds() < currentTime.getMilliseconds()) {
|
|
831
|
-
updateTime(event, newHour, props.maxDate.getMinutes(), props.maxDate.getSeconds(), props.maxDate.getMilliseconds());
|
|
832
|
-
} else {
|
|
833
|
-
updateTime(event, newHour, props.maxDate.getMinutes(), props.maxDate.getSeconds(), currentTime.getMilliseconds());
|
|
834
|
-
}
|
|
835
|
-
} else {
|
|
836
|
-
updateTime(event, newHour, props.maxDate.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
|
|
837
|
-
}
|
|
838
|
-
} else {
|
|
839
|
-
updateTime(event, newHour, currentTime.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
|
|
840
|
-
}
|
|
841
|
-
} else {
|
|
842
|
-
updateTime(event, newHour, currentTime.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
event.preventDefault();
|
|
846
|
-
};
|
|
847
|
-
var decrementHour = function decrementHour(event) {
|
|
848
|
-
var currentTime = getCurrentDateTime();
|
|
849
|
-
var currentHour = currentTime.getHours();
|
|
850
|
-
var newHour = currentHour - props.stepHour;
|
|
851
|
-
newHour = newHour < 0 ? newHour + 24 : newHour;
|
|
852
|
-
if (validateHour(newHour, currentTime)) {
|
|
853
|
-
if (props.minDate && props.minDate.toDateString() === currentTime.toDateString() && props.minDate.getHours() === newHour) {
|
|
854
|
-
if (props.minDate.getMinutes() > currentTime.getMinutes()) {
|
|
855
|
-
if (props.minDate.getSeconds() > currentTime.getSeconds()) {
|
|
856
|
-
if (props.minDate.getMilliseconds() > currentTime.getMilliseconds()) {
|
|
857
|
-
updateTime(event, newHour, props.minDate.getMinutes(), props.minDate.getSeconds(), props.minDate.getMilliseconds());
|
|
858
|
-
} else {
|
|
859
|
-
updateTime(event, newHour, props.minDate.getMinutes(), props.minDate.getSeconds(), currentTime.getMilliseconds());
|
|
860
|
-
}
|
|
861
|
-
} else {
|
|
862
|
-
updateTime(event, newHour, props.minDate.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
|
|
863
|
-
}
|
|
864
|
-
} else if (props.minDate.getMinutes() === currentTime.getMinutes()) {
|
|
865
|
-
if (props.minDate.getSeconds() > currentTime.getSeconds()) {
|
|
866
|
-
if (props.minDate.getMilliseconds() > currentTime.getMilliseconds()) {
|
|
867
|
-
updateTime(event, newHour, props.minDate.getMinutes(), props.minDate.getSeconds(), props.minDate.getMilliseconds());
|
|
868
|
-
} else {
|
|
869
|
-
updateTime(event, newHour, props.minDate.getMinutes(), props.minDate.getSeconds(), currentTime.getMilliseconds());
|
|
870
|
-
}
|
|
871
|
-
} else {
|
|
872
|
-
updateTime(event, newHour, props.minDate.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
|
|
873
|
-
}
|
|
874
|
-
} else {
|
|
875
|
-
updateTime(event, newHour, currentTime.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
|
|
876
|
-
}
|
|
877
|
-
} else {
|
|
878
|
-
updateTime(event, newHour, currentTime.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
event.preventDefault();
|
|
882
|
-
};
|
|
883
|
-
var doStepMinute = function doStepMinute(currentMinute, step) {
|
|
884
|
-
if (props.stepMinute <= 1) {
|
|
885
|
-
return step ? currentMinute + step : currentMinute;
|
|
886
|
-
}
|
|
887
|
-
if (!step) {
|
|
888
|
-
step = props.stepMinute;
|
|
889
|
-
if (currentMinute % step === 0) {
|
|
890
|
-
return currentMinute;
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
return Math.floor((currentMinute + step) / step) * step;
|
|
894
|
-
};
|
|
895
|
-
var incrementMinute = function incrementMinute(event) {
|
|
896
|
-
var currentTime = getCurrentDateTime();
|
|
897
|
-
var currentMinute = currentTime.getMinutes();
|
|
898
|
-
var newMinute = doStepMinute(currentMinute, props.stepMinute);
|
|
899
|
-
newMinute = newMinute > 59 ? newMinute - 60 : newMinute;
|
|
900
|
-
if (validateMinute(newMinute, currentTime)) {
|
|
901
|
-
if (props.maxDate && props.maxDate.toDateString() === currentTime.toDateString() && props.maxDate.getMinutes() === newMinute) {
|
|
902
|
-
if (props.maxDate.getSeconds() < currentTime.getSeconds()) {
|
|
903
|
-
if (props.maxDate.getMilliseconds() < currentTime.getMilliseconds()) {
|
|
904
|
-
updateTime(event, currentTime.getHours(), newMinute, props.maxDate.getSeconds(), props.maxDate.getMilliseconds());
|
|
905
|
-
} else {
|
|
906
|
-
updateTime(event, currentTime.getHours(), newMinute, props.maxDate.getSeconds(), currentTime.getMilliseconds());
|
|
907
|
-
}
|
|
908
|
-
} else {
|
|
909
|
-
updateTime(event, currentTime.getHours(), newMinute, currentTime.getSeconds(), currentTime.getMilliseconds());
|
|
910
|
-
}
|
|
911
|
-
} else {
|
|
912
|
-
updateTime(event, currentTime.getHours(), newMinute, currentTime.getSeconds(), currentTime.getMilliseconds());
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
event.preventDefault();
|
|
916
|
-
};
|
|
917
|
-
var decrementMinute = function decrementMinute(event) {
|
|
918
|
-
var currentTime = getCurrentDateTime();
|
|
919
|
-
var currentMinute = currentTime.getMinutes();
|
|
920
|
-
var newMinute = doStepMinute(currentMinute, -props.stepMinute);
|
|
921
|
-
newMinute = newMinute < 0 ? newMinute + 60 : newMinute;
|
|
922
|
-
if (validateMinute(newMinute, currentTime)) {
|
|
923
|
-
if (props.minDate && props.minDate.toDateString() === currentTime.toDateString() && props.minDate.getMinutes() === newMinute) {
|
|
924
|
-
if (props.minDate.getSeconds() > currentTime.getSeconds()) {
|
|
925
|
-
if (props.minDate.getMilliseconds() > currentTime.getMilliseconds()) {
|
|
926
|
-
updateTime(event, currentTime.getHours(), newMinute, props.minDate.getSeconds(), props.minDate.getMilliseconds());
|
|
927
|
-
} else {
|
|
928
|
-
updateTime(event, currentTime.getHours(), newMinute, props.minDate.getSeconds(), currentTime.getMilliseconds());
|
|
929
|
-
}
|
|
930
|
-
} else {
|
|
931
|
-
updateTime(event, currentTime.getHours(), newMinute, currentTime.getSeconds(), currentTime.getMilliseconds());
|
|
932
|
-
}
|
|
933
|
-
} else {
|
|
934
|
-
updateTime(event, currentTime.getHours(), newMinute, currentTime.getSeconds(), currentTime.getMilliseconds());
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
event.preventDefault();
|
|
938
|
-
};
|
|
939
|
-
var incrementSecond = function incrementSecond(event) {
|
|
940
|
-
var currentTime = getCurrentDateTime();
|
|
941
|
-
var currentSecond = currentTime.getSeconds();
|
|
942
|
-
var newSecond = currentSecond + props.stepSecond;
|
|
943
|
-
newSecond = newSecond > 59 ? newSecond - 60 : newSecond;
|
|
944
|
-
if (validateSecond(newSecond, currentTime)) {
|
|
945
|
-
if (props.maxDate && props.maxDate.toDateString() === currentTime.toDateString() && props.maxDate.getSeconds() === newSecond) {
|
|
946
|
-
if (props.maxDate.getMilliseconds() < currentTime.getMilliseconds()) {
|
|
947
|
-
updateTime(event, currentTime.getHours(), currentTime.getMinutes(), newSecond, props.maxDate.getMilliseconds());
|
|
948
|
-
} else {
|
|
949
|
-
updateTime(event, currentTime.getHours(), currentTime.getMinutes(), newSecond, currentTime.getMilliseconds());
|
|
950
|
-
}
|
|
951
|
-
} else {
|
|
952
|
-
updateTime(event, currentTime.getHours(), currentTime.getMinutes(), newSecond, currentTime.getMilliseconds());
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
event.preventDefault();
|
|
956
|
-
};
|
|
957
|
-
var decrementSecond = function decrementSecond(event) {
|
|
958
|
-
var currentTime = getCurrentDateTime();
|
|
959
|
-
var currentSecond = currentTime.getSeconds();
|
|
960
|
-
var newSecond = currentSecond - props.stepSecond;
|
|
961
|
-
newSecond = newSecond < 0 ? newSecond + 60 : newSecond;
|
|
962
|
-
if (validateSecond(newSecond, currentTime)) {
|
|
963
|
-
if (props.minDate && props.minDate.toDateString() === currentTime.toDateString() && props.minDate.getSeconds() === newSecond) {
|
|
964
|
-
if (props.minDate.getMilliseconds() > currentTime.getMilliseconds()) {
|
|
965
|
-
updateTime(event, currentTime.getHours(), currentTime.getMinutes(), newSecond, props.minDate.getMilliseconds());
|
|
966
|
-
} else {
|
|
967
|
-
updateTime(event, currentTime.getHours(), currentTime.getMinutes(), newSecond, currentTime.getMilliseconds());
|
|
968
|
-
}
|
|
969
|
-
} else {
|
|
970
|
-
updateTime(event, currentTime.getHours(), currentTime.getMinutes(), newSecond, currentTime.getMilliseconds());
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
event.preventDefault();
|
|
974
|
-
};
|
|
975
|
-
var incrementMilliSecond = function incrementMilliSecond(event) {
|
|
976
|
-
var currentTime = getCurrentDateTime();
|
|
977
|
-
var currentMillisecond = currentTime.getMilliseconds();
|
|
978
|
-
var newMillisecond = currentMillisecond + props.stepMillisec;
|
|
979
|
-
newMillisecond = newMillisecond > 999 ? newMillisecond - 1000 : newMillisecond;
|
|
980
|
-
if (validateMillisecond(newMillisecond, currentTime)) {
|
|
981
|
-
updateTime(event, currentTime.getHours(), currentTime.getMinutes(), currentTime.getSeconds(), newMillisecond);
|
|
982
|
-
}
|
|
983
|
-
event.preventDefault();
|
|
984
|
-
};
|
|
985
|
-
var decrementMilliSecond = function decrementMilliSecond(event) {
|
|
986
|
-
var currentTime = getCurrentDateTime();
|
|
987
|
-
var currentMillisecond = currentTime.getMilliseconds();
|
|
988
|
-
var newMillisecond = currentMillisecond - props.stepMillisec;
|
|
989
|
-
newMillisecond = newMillisecond < 0 ? newMillisecond + 999 : newMillisecond;
|
|
990
|
-
if (validateMillisecond(newMillisecond, currentTime)) {
|
|
991
|
-
updateTime(event, currentTime.getHours(), currentTime.getMinutes(), currentTime.getSeconds(), newMillisecond);
|
|
992
|
-
}
|
|
993
|
-
event.preventDefault();
|
|
994
|
-
};
|
|
995
|
-
var toggleAmPm = function toggleAmPm(event) {
|
|
996
|
-
var currentTime = getCurrentDateTime();
|
|
997
|
-
var currentHour = currentTime.getHours();
|
|
998
|
-
var newHour = currentHour >= 12 ? currentHour - 12 : currentHour + 12;
|
|
999
|
-
if (validateHour(convertTo24Hour(newHour, !(currentHour > 11)), currentTime)) {
|
|
1000
|
-
updateTime(event, newHour, currentTime.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
|
|
1001
|
-
}
|
|
1002
|
-
event.preventDefault();
|
|
1003
|
-
};
|
|
1004
|
-
var getViewDate = function getViewDate(date) {
|
|
1005
|
-
var propValue = props.value;
|
|
1006
|
-
var viewDate = date || (props.onViewDateChange ? props.viewDate : viewDateState);
|
|
1007
|
-
if (Array.isArray(propValue)) {
|
|
1008
|
-
propValue = propValue[0];
|
|
1009
|
-
}
|
|
1010
|
-
return viewDate && isValidDate(viewDate) ? viewDate : propValue && isValidDate(propValue) ? propValue : new Date();
|
|
1011
|
-
};
|
|
1012
|
-
var getCurrentDateTime = function getCurrentDateTime() {
|
|
1013
|
-
if (isSingleSelection()) {
|
|
1014
|
-
return props.value && props.value instanceof Date ? cloneDate(props.value) : getViewDate();
|
|
1015
|
-
} else if (isMultipleSelection()) {
|
|
1016
|
-
if (props.value && props.value.length) {
|
|
1017
|
-
return cloneDate(props.value[props.value.length - 1]);
|
|
1018
|
-
}
|
|
1019
|
-
} else if (isRangeSelection()) {
|
|
1020
|
-
if (props.value && props.value.length) {
|
|
1021
|
-
var startDate = cloneDate(props.value[0]);
|
|
1022
|
-
var endDate = cloneDate(props.value[1]);
|
|
1023
|
-
return endDate || startDate;
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
return new Date();
|
|
1027
|
-
};
|
|
1028
|
-
var cloneDate = function cloneDate(date) {
|
|
1029
|
-
return isValidDate(date) ? new Date(date.valueOf()) : date;
|
|
1030
|
-
};
|
|
1031
|
-
var isValidDate = function isValidDate(date) {
|
|
1032
|
-
return date instanceof Date && !isNaN(date);
|
|
1033
|
-
};
|
|
1034
|
-
var convertTo24Hour = function convertTo24Hour(hour, pm) {
|
|
1035
|
-
if (props.hourFormat == '12') {
|
|
1036
|
-
return hour === 12 ? pm ? 12 : 0 : pm ? hour + 12 : hour;
|
|
1037
|
-
}
|
|
1038
|
-
return hour;
|
|
1039
|
-
};
|
|
1040
|
-
var validateHour = function validateHour(hour, value) {
|
|
1041
|
-
var valid = true;
|
|
1042
|
-
var valueDateString = value ? value.toDateString() : null;
|
|
1043
|
-
if (props.minDate && valueDateString && props.minDate.toDateString() === valueDateString) {
|
|
1044
|
-
if (props.minDate.getHours() > hour) {
|
|
1045
|
-
valid = false;
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
if (props.maxDate && valueDateString && props.maxDate.toDateString() === valueDateString) {
|
|
1049
|
-
if (props.maxDate.getHours() < hour) {
|
|
1050
|
-
valid = false;
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
return valid;
|
|
1054
|
-
};
|
|
1055
|
-
var validateMinute = function validateMinute(minute, value) {
|
|
1056
|
-
var valid = true;
|
|
1057
|
-
var valueDateString = value ? value.toDateString() : null;
|
|
1058
|
-
if (props.minDate && valueDateString && props.minDate.toDateString() === valueDateString) {
|
|
1059
|
-
if (value.getHours() === props.minDate.getHours()) {
|
|
1060
|
-
if (props.minDate.getMinutes() > minute) {
|
|
1061
|
-
valid = false;
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
if (props.maxDate && valueDateString && props.maxDate.toDateString() === valueDateString) {
|
|
1066
|
-
if (value.getHours() === props.maxDate.getHours()) {
|
|
1067
|
-
if (props.maxDate.getMinutes() < minute) {
|
|
1068
|
-
valid = false;
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
return valid;
|
|
1073
|
-
};
|
|
1074
|
-
var validateSecond = function validateSecond(second, value) {
|
|
1075
|
-
var valid = true;
|
|
1076
|
-
var valueDateString = value ? value.toDateString() : null;
|
|
1077
|
-
if (props.minDate && valueDateString && props.minDate.toDateString() === valueDateString) {
|
|
1078
|
-
if (value.getHours() === props.minDate.getHours() && value.getMinutes() === props.minDate.getMinutes()) {
|
|
1079
|
-
if (props.minDate.getSeconds() > second) {
|
|
1080
|
-
valid = false;
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
if (props.maxDate && valueDateString && props.maxDate.toDateString() === valueDateString) {
|
|
1085
|
-
if (value.getHours() === props.maxDate.getHours() && value.getMinutes() === props.maxDate.getMinutes()) {
|
|
1086
|
-
if (props.maxDate.getSeconds() < second) {
|
|
1087
|
-
valid = false;
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
return valid;
|
|
1092
|
-
};
|
|
1093
|
-
var validateMillisecond = function validateMillisecond(millisecond, value) {
|
|
1094
|
-
var valid = true;
|
|
1095
|
-
var valueDateString = value ? value.toDateString() : null;
|
|
1096
|
-
if (props.minDate && valueDateString && props.minDate.toDateString() === valueDateString) {
|
|
1097
|
-
if (value.getHours() === props.minDate.getHours() && value.getSeconds() === props.minDate.getSeconds() && value.getMinutes() === props.minDate.getMinutes()) {
|
|
1098
|
-
if (props.minDate.getMilliseconds() > millisecond) {
|
|
1099
|
-
valid = false;
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
if (props.maxDate && valueDateString && props.maxDate.toDateString() === valueDateString) {
|
|
1104
|
-
if (value.getHours() === props.maxDate.getHours() && value.getSeconds() === props.maxDate.getSeconds() && value.getMinutes() === props.maxDate.getMinutes()) {
|
|
1105
|
-
if (props.maxDate.getMilliseconds() < millisecond) {
|
|
1106
|
-
valid = false;
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
return valid;
|
|
1111
|
-
};
|
|
1112
|
-
var validateDate = function validateDate(value) {
|
|
1113
|
-
if (props.yearNavigator) {
|
|
1114
|
-
var viewYear = value.getFullYear();
|
|
1115
|
-
var minRangeYear = props.yearRange ? parseInt(props.yearRange.split(':')[0], 10) : null;
|
|
1116
|
-
var maxRangeYear = props.yearRange ? parseInt(props.yearRange.split(':')[1], 10) : null;
|
|
1117
|
-
var minYear = props.minDate && minRangeYear != null ? Math.max(props.minDate.getFullYear(), minRangeYear) : props.minDate || minRangeYear;
|
|
1118
|
-
var maxYear = props.maxDate && maxRangeYear != null ? Math.min(props.maxDate.getFullYear(), maxRangeYear) : props.maxDate || maxRangeYear;
|
|
1119
|
-
if (minYear && minYear > viewYear) {
|
|
1120
|
-
viewYear = minYear;
|
|
1121
|
-
}
|
|
1122
|
-
if (maxYear && maxYear < viewYear) {
|
|
1123
|
-
viewYear = maxYear;
|
|
1124
|
-
}
|
|
1125
|
-
value.setFullYear(viewYear);
|
|
1126
|
-
}
|
|
1127
|
-
if (props.monthNavigator && props.view !== 'month') {
|
|
1128
|
-
var viewMonth = value.getMonth();
|
|
1129
|
-
var viewMonthWithMinMax = parseInt(isInMinYear(value) && Math.max(props.minDate.getMonth(), viewMonth).toString() || isInMaxYear(value) && Math.min(props.maxDate.getMonth(), viewMonth).toString() || viewMonth);
|
|
1130
|
-
value.setMonth(viewMonthWithMinMax);
|
|
1131
|
-
}
|
|
1132
|
-
};
|
|
1133
|
-
var updateTime = function updateTime(event, hour, minute, second, millisecond) {
|
|
1134
|
-
var newDateTime = getCurrentDateTime();
|
|
1135
|
-
newDateTime.setHours(hour);
|
|
1136
|
-
newDateTime.setMinutes(minute);
|
|
1137
|
-
newDateTime.setSeconds(second);
|
|
1138
|
-
newDateTime.setMilliseconds(millisecond);
|
|
1139
|
-
if (isMultipleSelection()) {
|
|
1140
|
-
if (props.value && props.value.length) {
|
|
1141
|
-
var value = _toConsumableArray(props.value);
|
|
1142
|
-
value[value.length - 1] = newDateTime;
|
|
1143
|
-
newDateTime = value;
|
|
1144
|
-
} else {
|
|
1145
|
-
newDateTime = [newDateTime];
|
|
1146
|
-
}
|
|
1147
|
-
} else if (isRangeSelection()) {
|
|
1148
|
-
if (props.value && props.value.length) {
|
|
1149
|
-
var startDate = props.value[0];
|
|
1150
|
-
var endDate = props.value[1];
|
|
1151
|
-
newDateTime = endDate ? [startDate, newDateTime] : [newDateTime, null];
|
|
1152
|
-
} else {
|
|
1153
|
-
newDateTime = [newDateTime, null];
|
|
1154
|
-
}
|
|
1155
|
-
}
|
|
1156
|
-
updateModel(event, newDateTime);
|
|
1157
|
-
if (props.onSelect) {
|
|
1158
|
-
props.onSelect({
|
|
1159
|
-
originalEvent: event,
|
|
1160
|
-
value: newDateTime
|
|
1161
|
-
});
|
|
1162
|
-
}
|
|
1163
|
-
updateInputfield(newDateTime);
|
|
1164
|
-
};
|
|
1165
|
-
var updateViewDate = function updateViewDate(event, value) {
|
|
1166
|
-
validateDate(value);
|
|
1167
|
-
if (props.onViewDateChange) {
|
|
1168
|
-
props.onViewDateChange({
|
|
1169
|
-
originalEvent: event,
|
|
1170
|
-
value: value
|
|
1171
|
-
});
|
|
1172
|
-
} else {
|
|
1173
|
-
viewStateChanged.current = true;
|
|
1174
|
-
setViewDateState(value);
|
|
1175
|
-
}
|
|
1176
|
-
setCurrentMonth(value.getMonth());
|
|
1177
|
-
setCurrentYear(value.getFullYear());
|
|
1178
|
-
};
|
|
1179
|
-
var setNavigationState = function setNavigationState(newViewDate) {
|
|
1180
|
-
if (!newViewDate || !props.showMinMaxRange || props.view !== 'date' || !overlayRef.current) {
|
|
1181
|
-
return;
|
|
1182
|
-
}
|
|
1183
|
-
var navPrev = DomHandler.findSingle(overlayRef.current, '[data-pc-section="previousbutton"]');
|
|
1184
|
-
var navNext = DomHandler.findSingle(overlayRef.current, '[data-pc-section="nextbutton"]');
|
|
1185
|
-
if (props.disabled) {
|
|
1186
|
-
!isUnstyled() && DomHandler.addClass(navPrev, 'p-disabled');
|
|
1187
|
-
navPrev.setAttribute('data-p-disabled', true);
|
|
1188
|
-
!isUnstyled() && DomHandler.addClass(navNext, 'p-disabled');
|
|
1189
|
-
navNext.setAttribute('data-p-disabled', true);
|
|
1190
|
-
return;
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
|
-
// previous (check first day of month at 00:00:00)
|
|
1194
|
-
if (props.minDate) {
|
|
1195
|
-
var firstDayOfMonth = cloneDate(newViewDate);
|
|
1196
|
-
if (firstDayOfMonth.getMonth() === 0) {
|
|
1197
|
-
firstDayOfMonth.setMonth(11, 1);
|
|
1198
|
-
firstDayOfMonth.setFullYear(firstDayOfMonth.getFullYear() - 1);
|
|
1199
|
-
} else {
|
|
1200
|
-
firstDayOfMonth.setMonth(firstDayOfMonth.getMonth(), 1);
|
|
1201
|
-
}
|
|
1202
|
-
firstDayOfMonth.setHours(0);
|
|
1203
|
-
firstDayOfMonth.setMinutes(0);
|
|
1204
|
-
firstDayOfMonth.setSeconds(0);
|
|
1205
|
-
if (props.minDate > firstDayOfMonth) {
|
|
1206
|
-
DomHandler.addClass(navPrev, 'p-disabled');
|
|
1207
|
-
} else {
|
|
1208
|
-
DomHandler.removeClass(navPrev, 'p-disabled');
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
// next (check last day of month at 11:59:59)
|
|
1213
|
-
if (props.maxDate) {
|
|
1214
|
-
var lastDayOfMonth = cloneDate(newViewDate);
|
|
1215
|
-
if (lastDayOfMonth.getMonth() === 11) {
|
|
1216
|
-
lastDayOfMonth.setMonth(0, 1);
|
|
1217
|
-
lastDayOfMonth.setFullYear(lastDayOfMonth.getFullYear() + 1);
|
|
1218
|
-
} else {
|
|
1219
|
-
lastDayOfMonth.setMonth(lastDayOfMonth.getMonth() + 1, 1);
|
|
1220
|
-
}
|
|
1221
|
-
lastDayOfMonth.setHours(0);
|
|
1222
|
-
lastDayOfMonth.setMinutes(0);
|
|
1223
|
-
lastDayOfMonth.setSeconds(0);
|
|
1224
|
-
lastDayOfMonth.setSeconds(-1);
|
|
1225
|
-
if (props.maxDate < lastDayOfMonth) {
|
|
1226
|
-
DomHandler.addClass(navNext, 'p-disabled');
|
|
1227
|
-
} else {
|
|
1228
|
-
DomHandler.removeClass(navNext, 'p-disabled');
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
};
|
|
1232
|
-
var onDateCellKeydown = function onDateCellKeydown(event, date, groupIndex) {
|
|
1233
|
-
var cellContent = event.currentTarget;
|
|
1234
|
-
var cell = cellContent.parentElement;
|
|
1235
|
-
switch (event.which) {
|
|
1236
|
-
//down arrow
|
|
1237
|
-
case 40:
|
|
1238
|
-
{
|
|
1239
|
-
cellContent.tabIndex = '-1';
|
|
1240
|
-
var cellIndex = DomHandler.index(cell);
|
|
1241
|
-
var nextRow = cell.parentElement.nextElementSibling;
|
|
1242
|
-
if (nextRow) {
|
|
1243
|
-
var focusCell = nextRow.children[cellIndex].children[0];
|
|
1244
|
-
if (DomHandler.hasClass(focusCell, 'p-disabled')) {
|
|
1245
|
-
navigation.current = {
|
|
1246
|
-
backward: false
|
|
1247
|
-
};
|
|
1248
|
-
navForward(event);
|
|
1249
|
-
} else {
|
|
1250
|
-
nextRow.children[cellIndex].children[0].tabIndex = '0';
|
|
1251
|
-
nextRow.children[cellIndex].children[0].focus();
|
|
1252
|
-
}
|
|
1253
|
-
} else {
|
|
1254
|
-
navigation.current = {
|
|
1255
|
-
backward: false
|
|
1256
|
-
};
|
|
1257
|
-
navForward(event);
|
|
1258
|
-
}
|
|
1259
|
-
event.preventDefault();
|
|
1260
|
-
break;
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
|
-
//up arrow
|
|
1264
|
-
case 38:
|
|
1265
|
-
{
|
|
1266
|
-
cellContent.tabIndex = '-1';
|
|
1267
|
-
var _cellIndex = DomHandler.index(cell);
|
|
1268
|
-
var prevRow = cell.parentElement.previousElementSibling;
|
|
1269
|
-
if (prevRow) {
|
|
1270
|
-
var _focusCell = prevRow.children[_cellIndex].children[0];
|
|
1271
|
-
if (DomHandler.hasClass(_focusCell, 'p-disabled')) {
|
|
1272
|
-
navigation.current = {
|
|
1273
|
-
backward: true
|
|
1274
|
-
};
|
|
1275
|
-
navBackward(event);
|
|
1276
|
-
} else {
|
|
1277
|
-
_focusCell.tabIndex = '0';
|
|
1278
|
-
_focusCell.focus();
|
|
1279
|
-
}
|
|
1280
|
-
} else {
|
|
1281
|
-
navigation.current = {
|
|
1282
|
-
backward: true
|
|
1283
|
-
};
|
|
1284
|
-
navBackward(event);
|
|
1285
|
-
}
|
|
1286
|
-
event.preventDefault();
|
|
1287
|
-
break;
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
|
-
//left arrow
|
|
1291
|
-
case 37:
|
|
1292
|
-
{
|
|
1293
|
-
cellContent.tabIndex = '-1';
|
|
1294
|
-
var prevCell = cell.previousElementSibling;
|
|
1295
|
-
if (prevCell) {
|
|
1296
|
-
var _focusCell2 = prevCell.children[0];
|
|
1297
|
-
if (DomHandler.hasClass(_focusCell2, 'p-disabled')) {
|
|
1298
|
-
navigateToMonth(true, groupIndex, event);
|
|
1299
|
-
} else {
|
|
1300
|
-
_focusCell2.tabIndex = '0';
|
|
1301
|
-
_focusCell2.focus();
|
|
1302
|
-
}
|
|
1303
|
-
} else {
|
|
1304
|
-
navigateToMonth(true, groupIndex, event);
|
|
1305
|
-
}
|
|
1306
|
-
event.preventDefault();
|
|
1307
|
-
break;
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
//right arrow
|
|
1311
|
-
case 39:
|
|
1312
|
-
{
|
|
1313
|
-
cellContent.tabIndex = '-1';
|
|
1314
|
-
var nextCell = cell.nextElementSibling;
|
|
1315
|
-
if (nextCell) {
|
|
1316
|
-
var _focusCell3 = nextCell.children[0];
|
|
1317
|
-
if (DomHandler.hasClass(_focusCell3, 'p-disabled')) {
|
|
1318
|
-
navigateToMonth(false, groupIndex, event);
|
|
1319
|
-
} else {
|
|
1320
|
-
_focusCell3.tabIndex = '0';
|
|
1321
|
-
_focusCell3.focus();
|
|
1322
|
-
}
|
|
1323
|
-
} else {
|
|
1324
|
-
navigateToMonth(false, groupIndex, event);
|
|
1325
|
-
}
|
|
1326
|
-
event.preventDefault();
|
|
1327
|
-
break;
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
//enter
|
|
1331
|
-
case 13:
|
|
1332
|
-
{
|
|
1333
|
-
onDateSelect(event, date);
|
|
1334
|
-
event.preventDefault();
|
|
1335
|
-
break;
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
//escape
|
|
1339
|
-
case 27:
|
|
1340
|
-
{
|
|
1341
|
-
hide(null, reFocusInputField);
|
|
1342
|
-
event.preventDefault();
|
|
1343
|
-
break;
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1346
|
-
//tab
|
|
1347
|
-
case 9:
|
|
1348
|
-
{
|
|
1349
|
-
trapFocus(event);
|
|
1350
|
-
break;
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
};
|
|
1354
|
-
var navigateToMonth = function navigateToMonth(prev, groupIndex, event) {
|
|
1355
|
-
if (prev) {
|
|
1356
|
-
if (props.numberOfMonths === 1 || groupIndex === 0) {
|
|
1357
|
-
navigation.current = {
|
|
1358
|
-
backward: true
|
|
1359
|
-
};
|
|
1360
|
-
navBackward(event);
|
|
1361
|
-
} else {
|
|
1362
|
-
var prevMonthContainer = overlayRef.current.children[groupIndex - 1];
|
|
1363
|
-
var cells = DomHandler.find(prevMonthContainer, 'table td span:not([data-p-disabled="true"])');
|
|
1364
|
-
var focusCell = cells[cells.length - 1];
|
|
1365
|
-
focusCell.tabIndex = '0';
|
|
1366
|
-
focusCell.focus();
|
|
1367
|
-
}
|
|
1368
|
-
} else {
|
|
1369
|
-
if (props.numberOfMonths === 1 || groupIndex === props.numberOfMonths - 1) {
|
|
1370
|
-
navigation.current = {
|
|
1371
|
-
backward: false
|
|
1372
|
-
};
|
|
1373
|
-
navForward(event);
|
|
1374
|
-
} else {
|
|
1375
|
-
var nextMonthContainer = overlayRef.current.children[groupIndex + 1];
|
|
1376
|
-
var _focusCell4 = DomHandler.findSingle(nextMonthContainer, 'table td span:not([data-p-disabled="true"])');
|
|
1377
|
-
_focusCell4.tabIndex = '0';
|
|
1378
|
-
_focusCell4.focus();
|
|
1379
|
-
}
|
|
1380
|
-
}
|
|
1381
|
-
};
|
|
1382
|
-
var onMonthCellKeydown = function onMonthCellKeydown(event, index) {
|
|
1383
|
-
var cell = event.currentTarget;
|
|
1384
|
-
switch (event.which) {
|
|
1385
|
-
//arrows
|
|
1386
|
-
case 38:
|
|
1387
|
-
case 40:
|
|
1388
|
-
{
|
|
1389
|
-
cell.tabIndex = '-1';
|
|
1390
|
-
var cells = cell.parentElement.children;
|
|
1391
|
-
var cellIndex = DomHandler.index(cell);
|
|
1392
|
-
var nextCell = cells[event.which === 40 ? cellIndex + 3 : cellIndex - 3];
|
|
1393
|
-
if (nextCell) {
|
|
1394
|
-
nextCell.tabIndex = '0';
|
|
1395
|
-
nextCell.focus();
|
|
1396
|
-
}
|
|
1397
|
-
event.preventDefault();
|
|
1398
|
-
break;
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
//left arrow
|
|
1402
|
-
case 37:
|
|
1403
|
-
{
|
|
1404
|
-
cell.tabIndex = '-1';
|
|
1405
|
-
var prevCell = cell.previousElementSibling;
|
|
1406
|
-
if (prevCell) {
|
|
1407
|
-
prevCell.tabIndex = '0';
|
|
1408
|
-
prevCell.focus();
|
|
1409
|
-
}
|
|
1410
|
-
event.preventDefault();
|
|
1411
|
-
break;
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
|
-
//right arrow
|
|
1415
|
-
case 39:
|
|
1416
|
-
{
|
|
1417
|
-
cell.tabIndex = '-1';
|
|
1418
|
-
var _nextCell = cell.nextElementSibling;
|
|
1419
|
-
if (_nextCell) {
|
|
1420
|
-
_nextCell.tabIndex = '0';
|
|
1421
|
-
_nextCell.focus();
|
|
1422
|
-
}
|
|
1423
|
-
event.preventDefault();
|
|
1424
|
-
break;
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
//enter
|
|
1428
|
-
case 13:
|
|
1429
|
-
{
|
|
1430
|
-
onMonthSelect(event, index);
|
|
1431
|
-
event.preventDefault();
|
|
1432
|
-
break;
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
//escape
|
|
1436
|
-
case 27:
|
|
1437
|
-
{
|
|
1438
|
-
hide(null, reFocusInputField);
|
|
1439
|
-
event.preventDefault();
|
|
1440
|
-
break;
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1443
|
-
//tab
|
|
1444
|
-
case 9:
|
|
1445
|
-
{
|
|
1446
|
-
trapFocus(event);
|
|
1447
|
-
break;
|
|
1448
|
-
}
|
|
1449
|
-
}
|
|
1450
|
-
};
|
|
1451
|
-
var onDateSelect = function onDateSelect(event, dateMeta, timeMeta) {
|
|
1452
|
-
if (props.disabled || !dateMeta.selectable) {
|
|
1453
|
-
event.preventDefault();
|
|
1454
|
-
return;
|
|
1455
|
-
}
|
|
1456
|
-
DomHandler.find(overlayRef.current, 'table td span:not([data-p-disabled="true"])').forEach(function (cell) {
|
|
1457
|
-
return cell.tabIndex = -1;
|
|
1458
|
-
});
|
|
1459
|
-
event.currentTarget.focus();
|
|
1460
|
-
if (isMultipleSelection()) {
|
|
1461
|
-
if (isSelected(dateMeta)) {
|
|
1462
|
-
var value = props.value.filter(function (date, i) {
|
|
1463
|
-
return !isDateEquals(date, dateMeta);
|
|
1464
|
-
});
|
|
1465
|
-
updateModel(event, value);
|
|
1466
|
-
updateInputfield(value);
|
|
1467
|
-
} else if (!props.maxDateCount || !props.value || props.maxDateCount > props.value.length) {
|
|
1468
|
-
selectDate(event, dateMeta, timeMeta);
|
|
1469
|
-
}
|
|
1470
|
-
} else {
|
|
1471
|
-
selectDate(event, dateMeta, timeMeta);
|
|
1472
|
-
}
|
|
1473
|
-
if (!props.inline && isSingleSelection() && (!props.showTime || props.hideOnDateTimeSelect)) {
|
|
1474
|
-
setTimeout(function () {
|
|
1475
|
-
hide('dateselect');
|
|
1476
|
-
}, 100);
|
|
1477
|
-
if (touchUIMask.current) {
|
|
1478
|
-
disableModality();
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
event.preventDefault();
|
|
1482
|
-
};
|
|
1483
|
-
var selectTime = function selectTime(date, timeMeta) {
|
|
1484
|
-
if (props.showTime) {
|
|
1485
|
-
var hours, minutes, seconds, milliseconds;
|
|
1486
|
-
if (timeMeta) {
|
|
1487
|
-
hours = timeMeta.hours;
|
|
1488
|
-
minutes = timeMeta.minutes;
|
|
1489
|
-
seconds = timeMeta.seconds;
|
|
1490
|
-
milliseconds = timeMeta.milliseconds;
|
|
1491
|
-
} else {
|
|
1492
|
-
var time = getCurrentDateTime();
|
|
1493
|
-
var _ref2 = [time.getHours(), time.getMinutes(), time.getSeconds(), time.getMilliseconds()];
|
|
1494
|
-
hours = _ref2[0];
|
|
1495
|
-
minutes = _ref2[1];
|
|
1496
|
-
seconds = _ref2[2];
|
|
1497
|
-
milliseconds = _ref2[3];
|
|
1498
|
-
}
|
|
1499
|
-
date.setHours(hours);
|
|
1500
|
-
date.setMinutes(minutes);
|
|
1501
|
-
date.setSeconds(seconds);
|
|
1502
|
-
date.setMilliseconds(milliseconds);
|
|
1503
|
-
}
|
|
1504
|
-
};
|
|
1505
|
-
var selectDate = function selectDate(event, dateMeta, timeMeta) {
|
|
1506
|
-
var date = new Date(dateMeta.year, dateMeta.month, dateMeta.day);
|
|
1507
|
-
selectTime(date, timeMeta);
|
|
1508
|
-
if (props.minDate && props.minDate > date) {
|
|
1509
|
-
date = props.minDate;
|
|
1510
|
-
}
|
|
1511
|
-
if (props.maxDate && props.maxDate < date) {
|
|
1512
|
-
date = props.maxDate;
|
|
1513
|
-
}
|
|
1514
|
-
var selectedValues = date;
|
|
1515
|
-
if (isSingleSelection()) {
|
|
1516
|
-
updateModel(event, date);
|
|
1517
|
-
} else if (isMultipleSelection()) {
|
|
1518
|
-
selectedValues = props.value ? [].concat(_toConsumableArray(props.value), [date]) : [date];
|
|
1519
|
-
updateModel(event, selectedValues);
|
|
1520
|
-
} else if (isRangeSelection()) {
|
|
1521
|
-
if (props.value && props.value.length) {
|
|
1522
|
-
var startDate = props.value[0];
|
|
1523
|
-
var endDate = props.value[1];
|
|
1524
|
-
if (!endDate) {
|
|
1525
|
-
if (date.getTime() >= startDate.getTime()) {
|
|
1526
|
-
endDate = date;
|
|
1527
|
-
} else {
|
|
1528
|
-
endDate = startDate;
|
|
1529
|
-
startDate = date;
|
|
1530
|
-
}
|
|
1531
|
-
} else {
|
|
1532
|
-
startDate = date;
|
|
1533
|
-
endDate = null;
|
|
1534
|
-
}
|
|
1535
|
-
selectedValues = [startDate, endDate];
|
|
1536
|
-
updateModel(event, selectedValues);
|
|
1537
|
-
} else {
|
|
1538
|
-
selectedValues = [date, null];
|
|
1539
|
-
updateModel(event, selectedValues);
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
if (props.onSelect) {
|
|
1543
|
-
props.onSelect({
|
|
1544
|
-
originalEvent: event,
|
|
1545
|
-
value: date
|
|
1546
|
-
});
|
|
1547
|
-
}
|
|
1548
|
-
updateInputfield(selectedValues);
|
|
1549
|
-
};
|
|
1550
|
-
var decrementDecade = function decrementDecade() {
|
|
1551
|
-
var _currentYear = currentYear - 10;
|
|
1552
|
-
setCurrentYear(_currentYear);
|
|
1553
|
-
return _currentYear;
|
|
1554
|
-
};
|
|
1555
|
-
var incrementDecade = function incrementDecade() {
|
|
1556
|
-
var _currentYear = currentYear + 10;
|
|
1557
|
-
setCurrentYear(_currentYear);
|
|
1558
|
-
return _currentYear;
|
|
1559
|
-
};
|
|
1560
|
-
var switchToMonthView = function switchToMonthView(event) {
|
|
1561
|
-
setCurrentView('month');
|
|
1562
|
-
event.preventDefault();
|
|
1563
|
-
};
|
|
1564
|
-
var switchToYearView = function switchToYearView(event) {
|
|
1565
|
-
setCurrentView('year');
|
|
1566
|
-
event.preventDefault();
|
|
1567
|
-
};
|
|
1568
|
-
var onMonthSelect = function onMonthSelect(event, month) {
|
|
1569
|
-
if (props.view === 'month') {
|
|
1570
|
-
onDateSelect(event, {
|
|
1571
|
-
year: currentYear,
|
|
1572
|
-
month: month,
|
|
1573
|
-
day: 1,
|
|
1574
|
-
selectable: true
|
|
1575
|
-
});
|
|
1576
|
-
event.preventDefault();
|
|
1577
|
-
} else {
|
|
1578
|
-
setCurrentMonth(month);
|
|
1579
|
-
createMonthsMeta(month, currentYear);
|
|
1580
|
-
var currentDate = cloneDate(getCurrentDateTime());
|
|
1581
|
-
currentDate.setDate(1); // #2948 always set to 1st of month
|
|
1582
|
-
currentDate.setMonth(month);
|
|
1583
|
-
currentDate.setYear(currentYear);
|
|
1584
|
-
setViewDateState(currentDate);
|
|
1585
|
-
setCurrentView('date');
|
|
1586
|
-
props.onMonthChange && props.onMonthChange({
|
|
1587
|
-
month: month + 1,
|
|
1588
|
-
year: currentYear
|
|
1589
|
-
});
|
|
1590
|
-
}
|
|
1591
|
-
};
|
|
1592
|
-
var onYearSelect = function onYearSelect(event, year) {
|
|
1593
|
-
if (props.view === 'year') {
|
|
1594
|
-
onDateSelect(event, {
|
|
1595
|
-
year: year,
|
|
1596
|
-
month: 0,
|
|
1597
|
-
day: 1,
|
|
1598
|
-
selectable: true
|
|
1599
|
-
});
|
|
1600
|
-
} else {
|
|
1601
|
-
setCurrentYear(year);
|
|
1602
|
-
setCurrentView('month');
|
|
1603
|
-
props.onMonthChange && props.onMonthChange({
|
|
1604
|
-
month: currentMonth + 1,
|
|
1605
|
-
year: year
|
|
1606
|
-
});
|
|
1607
|
-
}
|
|
1608
|
-
};
|
|
1609
|
-
var updateModel = function updateModel(event, value) {
|
|
1610
|
-
if (props.onChange) {
|
|
1611
|
-
var newValue = cloneDate(value);
|
|
1612
|
-
viewStateChanged.current = true;
|
|
1613
|
-
onChangeRef.current({
|
|
1614
|
-
originalEvent: event,
|
|
1615
|
-
value: newValue,
|
|
1616
|
-
stopPropagation: function stopPropagation() {
|
|
1617
|
-
event.stopPropagation();
|
|
1618
|
-
},
|
|
1619
|
-
preventDefault: function preventDefault() {
|
|
1620
|
-
event.preventDefault();
|
|
1621
|
-
},
|
|
1622
|
-
target: {
|
|
1623
|
-
name: props.name,
|
|
1624
|
-
id: props.id,
|
|
1625
|
-
value: newValue
|
|
1626
|
-
}
|
|
1627
|
-
});
|
|
1628
|
-
}
|
|
1629
|
-
};
|
|
1630
|
-
var show = function show(type) {
|
|
1631
|
-
if (props.onVisibleChange) {
|
|
1632
|
-
props.onVisibleChange({
|
|
1633
|
-
visible: true,
|
|
1634
|
-
type: type
|
|
1635
|
-
});
|
|
1636
|
-
} else {
|
|
1637
|
-
setOverlayVisibleState(true);
|
|
1638
|
-
overlayEventListener.current = function (e) {
|
|
1639
|
-
if (!isOutsideClicked(e)) {
|
|
1640
|
-
isOverlayClicked.current = true;
|
|
1641
|
-
}
|
|
1642
|
-
};
|
|
1643
|
-
OverlayService.on('overlay-click', overlayEventListener.current);
|
|
1644
|
-
}
|
|
1645
|
-
};
|
|
1646
|
-
var hide = function hide(type, callback) {
|
|
1647
|
-
var _hideCallback = function _hideCallback() {
|
|
1648
|
-
viewStateChanged.current = false;
|
|
1649
|
-
ignoreFocusFunctionality.current = false;
|
|
1650
|
-
isOverlayClicked.current = false;
|
|
1651
|
-
callback && callback();
|
|
1652
|
-
OverlayService.off('overlay-click', overlayEventListener.current);
|
|
1653
|
-
overlayEventListener.current = null;
|
|
1654
|
-
};
|
|
1655
|
-
props.touchUI && disableModality();
|
|
1656
|
-
if (props.onVisibleChange) {
|
|
1657
|
-
props.onVisibleChange({
|
|
1658
|
-
visible: type !== 'dateselect',
|
|
1659
|
-
// false only if selecting a value to close panel
|
|
1660
|
-
type: type,
|
|
1661
|
-
callback: _hideCallback
|
|
1662
|
-
});
|
|
1663
|
-
} else {
|
|
1664
|
-
setOverlayVisibleState(false);
|
|
1665
|
-
_hideCallback();
|
|
1666
|
-
}
|
|
1667
|
-
};
|
|
1668
|
-
var onOverlayEnter = function onOverlayEnter() {
|
|
1669
|
-
var styles = props.touchUI ? {
|
|
1670
|
-
position: 'fixed',
|
|
1671
|
-
top: '50%',
|
|
1672
|
-
left: '50%',
|
|
1673
|
-
transform: 'translate(-50%, -50%)'
|
|
1674
|
-
} : !props.inline ? {
|
|
1675
|
-
position: 'absolute',
|
|
1676
|
-
top: '0',
|
|
1677
|
-
left: '0'
|
|
1678
|
-
} : undefined;
|
|
1679
|
-
DomHandler.addStyles(overlayRef.current, styles);
|
|
1680
|
-
if (props.autoZIndex) {
|
|
1681
|
-
var key = props.touchUI ? 'modal' : 'overlay';
|
|
1682
|
-
ZIndexUtils.set(key, overlayRef.current, context && context.autoZIndex || PrimeReact.autoZIndex, props.baseZIndex || context && context.zIndex[key] || PrimeReact.zIndex[key]);
|
|
1683
|
-
}
|
|
1684
|
-
alignOverlay();
|
|
1685
|
-
};
|
|
1686
|
-
var onOverlayEntered = function onOverlayEntered() {
|
|
1687
|
-
bindOverlayListener();
|
|
1688
|
-
props.onShow && props.onShow();
|
|
1689
|
-
DomHandler.focusFirstElement(overlayRef.current);
|
|
1690
|
-
setFocusedState(false);
|
|
1691
|
-
};
|
|
1692
|
-
var onOverlayExit = function onOverlayExit() {
|
|
1693
|
-
unbindOverlayListener();
|
|
1694
|
-
};
|
|
1695
|
-
var onOverlayExited = function onOverlayExited() {
|
|
1696
|
-
ZIndexUtils.clear(overlayRef.current);
|
|
1697
|
-
props.onHide && props.onHide();
|
|
1698
|
-
};
|
|
1699
|
-
var appendDisabled = function appendDisabled() {
|
|
1700
|
-
return props.appendTo === 'self' || props.inline;
|
|
1701
|
-
};
|
|
1702
|
-
var alignOverlay = function alignOverlay() {
|
|
1703
|
-
if (props.touchUI) {
|
|
1704
|
-
enableModality();
|
|
1705
|
-
} else if (overlayRef && overlayRef.current && inputRef && inputRef.current) {
|
|
1706
|
-
DomHandler.alignOverlay(overlayRef.current, inputRef.current, props.appendTo || context && context.appendTo || PrimeReact.appendTo);
|
|
1707
|
-
if (appendDisabled()) {
|
|
1708
|
-
DomHandler.relativePosition(overlayRef.current, inputRef.current);
|
|
1709
|
-
} else {
|
|
1710
|
-
if (props.view === 'date') {
|
|
1711
|
-
overlayRef.current.style.width = DomHandler.getOuterWidth(overlayRef.current) + 'px';
|
|
1712
|
-
overlayRef.current.style.minWidth = DomHandler.getOuterWidth(inputRef.current) + 'px';
|
|
1713
|
-
} else {
|
|
1714
|
-
overlayRef.current.style.width = DomHandler.getOuterWidth(inputRef.current) + 'px';
|
|
1715
|
-
}
|
|
1716
|
-
DomHandler.absolutePosition(overlayRef.current, inputRef.current);
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
};
|
|
1720
|
-
var enableModality = function enableModality() {
|
|
1721
|
-
if (!touchUIMask.current) {
|
|
1722
|
-
touchUIMask.current = document.createElement('div');
|
|
1723
|
-
touchUIMask.current.style.zIndex = String(ZIndexUtils.get(overlayRef.current) - 1);
|
|
1724
|
-
!isUnstyled() && DomHandler.addMultipleClasses(touchUIMask.current, 'p-component-overlay p-datepicker-mask p-datepicker-mask-scrollblocker p-component-overlay-enter');
|
|
1725
|
-
touchUIMaskClickListener.current = function () {
|
|
1726
|
-
disableModality();
|
|
1727
|
-
hide();
|
|
1728
|
-
};
|
|
1729
|
-
touchUIMask.current.addEventListener('click', touchUIMaskClickListener.current);
|
|
1730
|
-
document.body.appendChild(touchUIMask.current);
|
|
1731
|
-
DomHandler.addClass(document.body, 'p-overflow-hidden');
|
|
1732
|
-
}
|
|
1733
|
-
};
|
|
1734
|
-
var disableModality = function disableModality() {
|
|
1735
|
-
if (touchUIMask.current) {
|
|
1736
|
-
if (isUnstyled) {
|
|
1737
|
-
destroyMask();
|
|
1738
|
-
} else {
|
|
1739
|
-
DomHandler.addClass(touchUIMask.current, 'p-component-overlay-leave');
|
|
1740
|
-
touchUIMask.current.addEventListener('animationend', function () {
|
|
1741
|
-
destroyMask();
|
|
1742
|
-
});
|
|
1743
|
-
}
|
|
1744
|
-
}
|
|
1745
|
-
};
|
|
1746
|
-
var destroyMask = function destroyMask() {
|
|
1747
|
-
if (touchUIMask.current) {
|
|
1748
|
-
touchUIMask.current.removeEventListener('click', touchUIMaskClickListener.current);
|
|
1749
|
-
touchUIMaskClickListener.current = null;
|
|
1750
|
-
document.body.removeChild(touchUIMask.current);
|
|
1751
|
-
touchUIMask.current = null;
|
|
1752
|
-
}
|
|
1753
|
-
var bodyChildren = document.body.children;
|
|
1754
|
-
var hasBlockerMasks;
|
|
1755
|
-
for (var i = 0; i < bodyChildren.length; i++) {
|
|
1756
|
-
var bodyChild = bodyChildren[i];
|
|
1757
|
-
if (DomHandler.hasClass(bodyChild, 'p-datepicker-mask-scrollblocker')) {
|
|
1758
|
-
hasBlockerMasks = true;
|
|
1759
|
-
break;
|
|
1760
|
-
}
|
|
1761
|
-
}
|
|
1762
|
-
if (!hasBlockerMasks) {
|
|
1763
|
-
DomHandler.removeClass(document.body, 'p-overflow-hidden');
|
|
1764
|
-
}
|
|
1765
|
-
};
|
|
1766
|
-
var isOutsideClicked = function isOutsideClicked(event) {
|
|
1767
|
-
return elementRef.current && !(elementRef.current.isSameNode(event.target) || isNavIconClicked(event.target) || elementRef.current.contains(event.target) || overlayRef.current && overlayRef.current.contains(event.target));
|
|
1768
|
-
};
|
|
1769
|
-
var isNavIconClicked = function isNavIconClicked(target) {
|
|
1770
|
-
return previousButton.current && (previousButton.current.isSameNode(target) || previousButton.current.contains(target)) || nextButton.current && (nextButton.current.isSameNode(target) || nextButton.current.contains(target));
|
|
1771
|
-
};
|
|
1772
|
-
var getFirstDayOfMonthIndex = function getFirstDayOfMonthIndex(month, year) {
|
|
1773
|
-
var day = new Date();
|
|
1774
|
-
day.setDate(1);
|
|
1775
|
-
day.setMonth(month);
|
|
1776
|
-
day.setFullYear(year);
|
|
1777
|
-
var dayIndex = day.getDay() + getSundayIndex();
|
|
1778
|
-
return dayIndex >= 7 ? dayIndex - 7 : dayIndex;
|
|
1779
|
-
};
|
|
1780
|
-
var getDaysCountInMonth = function getDaysCountInMonth(month, year) {
|
|
1781
|
-
return 32 - daylightSavingAdjust(new Date(year, month, 32)).getDate();
|
|
1782
|
-
};
|
|
1783
|
-
var getDaysCountInPrevMonth = function getDaysCountInPrevMonth(month, year) {
|
|
1784
|
-
var prev = getPreviousMonthAndYear(month, year);
|
|
1785
|
-
return getDaysCountInMonth(prev.month, prev.year);
|
|
1786
|
-
};
|
|
1787
|
-
var daylightSavingAdjust = function daylightSavingAdjust(date) {
|
|
1788
|
-
if (!date) {
|
|
1789
|
-
return null;
|
|
1790
|
-
}
|
|
1791
|
-
date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
|
|
1792
|
-
return date;
|
|
1793
|
-
};
|
|
1794
|
-
var getPreviousMonthAndYear = function getPreviousMonthAndYear(month, year) {
|
|
1795
|
-
var m, y;
|
|
1796
|
-
if (month === 0) {
|
|
1797
|
-
m = 11;
|
|
1798
|
-
y = year - 1;
|
|
1799
|
-
} else {
|
|
1800
|
-
m = month - 1;
|
|
1801
|
-
y = year;
|
|
1802
|
-
}
|
|
1803
|
-
return {
|
|
1804
|
-
month: m,
|
|
1805
|
-
year: y
|
|
1806
|
-
};
|
|
1807
|
-
};
|
|
1808
|
-
var getNextMonthAndYear = function getNextMonthAndYear(month, year) {
|
|
1809
|
-
var m, y;
|
|
1810
|
-
if (month === 11) {
|
|
1811
|
-
m = 0;
|
|
1812
|
-
y = year + 1;
|
|
1813
|
-
} else {
|
|
1814
|
-
m = month + 1;
|
|
1815
|
-
y = year;
|
|
1816
|
-
}
|
|
1817
|
-
return {
|
|
1818
|
-
month: m,
|
|
1819
|
-
year: y
|
|
1820
|
-
};
|
|
1821
|
-
};
|
|
1822
|
-
var getSundayIndex = function getSundayIndex() {
|
|
1823
|
-
var firstDayOfWeek = localeOption('firstDayOfWeek', props.locale);
|
|
1824
|
-
return firstDayOfWeek > 0 ? 7 - firstDayOfWeek : 0;
|
|
1825
|
-
};
|
|
1826
|
-
var createWeekDaysMeta = function createWeekDaysMeta() {
|
|
1827
|
-
var weekDays = [];
|
|
1828
|
-
var _localeOptions = localeOptions(props.locale),
|
|
1829
|
-
dayIndex = _localeOptions.firstDayOfWeek,
|
|
1830
|
-
dayNamesMin = _localeOptions.dayNamesMin;
|
|
1831
|
-
for (var i = 0; i < 7; i++) {
|
|
1832
|
-
weekDays.push(dayNamesMin[dayIndex]);
|
|
1833
|
-
dayIndex = dayIndex === 6 ? 0 : ++dayIndex;
|
|
1834
|
-
}
|
|
1835
|
-
return weekDays;
|
|
1836
|
-
};
|
|
1837
|
-
var createMonthsMeta = function createMonthsMeta(month, year) {
|
|
1838
|
-
var months = [];
|
|
1839
|
-
for (var i = 0; i < props.numberOfMonths; i++) {
|
|
1840
|
-
var m = month + i;
|
|
1841
|
-
var y = year;
|
|
1842
|
-
if (m > 11) {
|
|
1843
|
-
m = m % 11 - 1;
|
|
1844
|
-
y = year + 1;
|
|
1845
|
-
}
|
|
1846
|
-
months.push(createMonthMeta(m, y));
|
|
1847
|
-
}
|
|
1848
|
-
return months;
|
|
1849
|
-
};
|
|
1850
|
-
var createMonthMeta = function createMonthMeta(month, year) {
|
|
1851
|
-
var dates = [];
|
|
1852
|
-
var firstDay = getFirstDayOfMonthIndex(month, year);
|
|
1853
|
-
var daysLength = getDaysCountInMonth(month, year);
|
|
1854
|
-
var prevMonthDaysLength = getDaysCountInPrevMonth(month, year);
|
|
1855
|
-
var dayNo = 1;
|
|
1856
|
-
var today = new Date();
|
|
1857
|
-
var weekNumbers = [];
|
|
1858
|
-
var monthRows = Math.ceil((daysLength + firstDay) / 7);
|
|
1859
|
-
for (var i = 0; i < monthRows; i++) {
|
|
1860
|
-
var week = [];
|
|
1861
|
-
if (i === 0) {
|
|
1862
|
-
for (var j = prevMonthDaysLength - firstDay + 1; j <= prevMonthDaysLength; j++) {
|
|
1863
|
-
var prev = getPreviousMonthAndYear(month, year);
|
|
1864
|
-
week.push({
|
|
1865
|
-
day: j,
|
|
1866
|
-
month: prev.month,
|
|
1867
|
-
year: prev.year,
|
|
1868
|
-
otherMonth: true,
|
|
1869
|
-
today: isToday(today, j, prev.month, prev.year),
|
|
1870
|
-
selectable: isSelectable(j, prev.month, prev.year, true)
|
|
1871
|
-
});
|
|
1872
|
-
}
|
|
1873
|
-
var remainingDaysLength = 7 - week.length;
|
|
1874
|
-
for (var _j = 0; _j < remainingDaysLength; _j++) {
|
|
1875
|
-
week.push({
|
|
1876
|
-
day: dayNo,
|
|
1877
|
-
month: month,
|
|
1878
|
-
year: year,
|
|
1879
|
-
today: isToday(today, dayNo, month, year),
|
|
1880
|
-
selectable: isSelectable(dayNo, month, year, false)
|
|
1881
|
-
});
|
|
1882
|
-
dayNo++;
|
|
1883
|
-
}
|
|
1884
|
-
} else {
|
|
1885
|
-
for (var _j2 = 0; _j2 < 7; _j2++) {
|
|
1886
|
-
if (dayNo > daysLength) {
|
|
1887
|
-
var next = getNextMonthAndYear(month, year);
|
|
1888
|
-
week.push({
|
|
1889
|
-
day: dayNo - daysLength,
|
|
1890
|
-
month: next.month,
|
|
1891
|
-
year: next.year,
|
|
1892
|
-
otherMonth: true,
|
|
1893
|
-
today: isToday(today, dayNo - daysLength, next.month, next.year),
|
|
1894
|
-
selectable: isSelectable(dayNo - daysLength, next.month, next.year, true)
|
|
1895
|
-
});
|
|
1896
|
-
} else {
|
|
1897
|
-
week.push({
|
|
1898
|
-
day: dayNo,
|
|
1899
|
-
month: month,
|
|
1900
|
-
year: year,
|
|
1901
|
-
today: isToday(today, dayNo, month, year),
|
|
1902
|
-
selectable: isSelectable(dayNo, month, year, false)
|
|
1903
|
-
});
|
|
1904
|
-
}
|
|
1905
|
-
dayNo++;
|
|
1906
|
-
}
|
|
1907
|
-
}
|
|
1908
|
-
if (props.showWeek) {
|
|
1909
|
-
weekNumbers.push(getWeekNumber(new Date(week[0].year, week[0].month, week[0].day)));
|
|
1910
|
-
}
|
|
1911
|
-
dates.push(week);
|
|
1912
|
-
}
|
|
1913
|
-
return {
|
|
1914
|
-
month: month,
|
|
1915
|
-
year: year,
|
|
1916
|
-
dates: dates,
|
|
1917
|
-
weekNumbers: weekNumbers
|
|
1918
|
-
};
|
|
1919
|
-
};
|
|
1920
|
-
var getWeekNumber = function getWeekNumber(date) {
|
|
1921
|
-
var checkDate = cloneDate(date);
|
|
1922
|
-
checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
|
|
1923
|
-
var time = checkDate.getTime();
|
|
1924
|
-
checkDate.setMonth(0);
|
|
1925
|
-
checkDate.setDate(1);
|
|
1926
|
-
return Math.floor(Math.round((time - checkDate.getTime()) / 86400000) / 7) + 1;
|
|
1927
|
-
};
|
|
1928
|
-
var isSelectable = function isSelectable(day, month, year, otherMonth) {
|
|
1929
|
-
var validMin = true;
|
|
1930
|
-
var validMax = true;
|
|
1931
|
-
var validDate = true;
|
|
1932
|
-
var validDay = true;
|
|
1933
|
-
var validMonth = true;
|
|
1934
|
-
if (props.minDate) {
|
|
1935
|
-
if (props.minDate.getFullYear() > year) {
|
|
1936
|
-
validMin = false;
|
|
1937
|
-
} else if (props.minDate.getFullYear() === year) {
|
|
1938
|
-
if (month > -1 && props.minDate.getMonth() > month) {
|
|
1939
|
-
validMin = false;
|
|
1940
|
-
} else if (month > -1 && props.minDate.getMonth() === month) {
|
|
1941
|
-
if (day > 0 && props.minDate.getDate() > day) {
|
|
1942
|
-
validMin = false;
|
|
1943
|
-
}
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
}
|
|
1947
|
-
if (props.maxDate) {
|
|
1948
|
-
if (props.maxDate.getFullYear() < year) {
|
|
1949
|
-
validMax = false;
|
|
1950
|
-
} else if (props.maxDate.getFullYear() === year) {
|
|
1951
|
-
if (month > -1 && props.maxDate.getMonth() < month) {
|
|
1952
|
-
validMax = false;
|
|
1953
|
-
} else if (month > -1 && props.maxDate.getMonth() === month) {
|
|
1954
|
-
if (day > 0 && props.maxDate.getDate() < day) {
|
|
1955
|
-
validMax = false;
|
|
1956
|
-
}
|
|
1957
|
-
}
|
|
1958
|
-
}
|
|
1959
|
-
}
|
|
1960
|
-
if (props.disabledDates || props.enabledDates) {
|
|
1961
|
-
validDate = !isDateDisabled(day, month, year);
|
|
1962
|
-
}
|
|
1963
|
-
if (props.disabledDays && currentView === 'date') {
|
|
1964
|
-
validDay = !isDayDisabled(day, month, year);
|
|
1965
|
-
}
|
|
1966
|
-
if (props.selectOtherMonths === false && otherMonth) {
|
|
1967
|
-
validMonth = false;
|
|
1968
|
-
}
|
|
1969
|
-
return validMin && validMax && validDate && validDay && validMonth;
|
|
1970
|
-
};
|
|
1971
|
-
var isSelectableTime = function isSelectableTime(value) {
|
|
1972
|
-
var validMin = true;
|
|
1973
|
-
var validMax = true;
|
|
1974
|
-
if (props.minDate && props.minDate.toDateString() === value.toDateString()) {
|
|
1975
|
-
if (props.minDate.getHours() > value.getHours()) {
|
|
1976
|
-
validMin = false;
|
|
1977
|
-
} else if (props.minDate.getHours() === value.getHours()) {
|
|
1978
|
-
if (props.minDate.getMinutes() > value.getMinutes()) {
|
|
1979
|
-
validMin = false;
|
|
1980
|
-
} else if (props.minDate.getMinutes() === value.getMinutes()) {
|
|
1981
|
-
if (props.minDate.getSeconds() > value.getSeconds()) {
|
|
1982
|
-
validMin = false;
|
|
1983
|
-
} else if (props.minDate.getSeconds() === value.getSeconds()) {
|
|
1984
|
-
if (props.minDate.getMilliseconds() > value.getMilliseconds()) {
|
|
1985
|
-
validMin = false;
|
|
1986
|
-
}
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
|
-
}
|
|
1990
|
-
}
|
|
1991
|
-
if (props.maxDate && props.maxDate.toDateString() === value.toDateString()) {
|
|
1992
|
-
if (props.maxDate.getHours() < value.getHours()) {
|
|
1993
|
-
validMax = false;
|
|
1994
|
-
} else if (props.maxDate.getHours() === value.getHours()) {
|
|
1995
|
-
if (props.maxDate.getMinutes() < value.getMinutes()) {
|
|
1996
|
-
validMax = false;
|
|
1997
|
-
} else if (props.maxDate.getMinutes() === value.getMinutes()) {
|
|
1998
|
-
if (props.maxDate.getSeconds() < value.getSeconds()) {
|
|
1999
|
-
validMax = false;
|
|
2000
|
-
} else if (props.maxDate.getSeconds() === value.getSeconds()) {
|
|
2001
|
-
if (props.maxDate.getMilliseconds() < value.getMilliseconds()) {
|
|
2002
|
-
validMax = false;
|
|
2003
|
-
}
|
|
2004
|
-
}
|
|
2005
|
-
}
|
|
2006
|
-
}
|
|
2007
|
-
}
|
|
2008
|
-
return validMin && validMax;
|
|
2009
|
-
};
|
|
2010
|
-
var isSelected = function isSelected(dateMeta) {
|
|
2011
|
-
if (props.value) {
|
|
2012
|
-
if (isSingleSelection()) {
|
|
2013
|
-
return isDateEquals(props.value, dateMeta);
|
|
2014
|
-
} else if (isMultipleSelection()) {
|
|
2015
|
-
var selected = false;
|
|
2016
|
-
var _iterator = _createForOfIteratorHelper(props.value),
|
|
2017
|
-
_step;
|
|
2018
|
-
try {
|
|
2019
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2020
|
-
var date = _step.value;
|
|
2021
|
-
selected = isDateEquals(date, dateMeta);
|
|
2022
|
-
if (selected) {
|
|
2023
|
-
break;
|
|
2024
|
-
}
|
|
2025
|
-
}
|
|
2026
|
-
} catch (err) {
|
|
2027
|
-
_iterator.e(err);
|
|
2028
|
-
} finally {
|
|
2029
|
-
_iterator.f();
|
|
2030
|
-
}
|
|
2031
|
-
return selected;
|
|
2032
|
-
} else if (isRangeSelection()) {
|
|
2033
|
-
if (props.value[1]) return isDateEquals(props.value[0], dateMeta) || isDateEquals(props.value[1], dateMeta) || isDateBetween(props.value[0], props.value[1], dateMeta);else {
|
|
2034
|
-
return isDateEquals(props.value[0], dateMeta);
|
|
2035
|
-
}
|
|
2036
|
-
}
|
|
2037
|
-
} else {
|
|
2038
|
-
return false;
|
|
2039
|
-
}
|
|
2040
|
-
};
|
|
2041
|
-
var isComparable = function isComparable() {
|
|
2042
|
-
return props.value != null && typeof props.value !== 'string';
|
|
2043
|
-
};
|
|
2044
|
-
var isMonthSelected = function isMonthSelected(month) {
|
|
2045
|
-
if (isComparable()) {
|
|
2046
|
-
var value = isRangeSelection() ? props.value[0] : props.value;
|
|
2047
|
-
if (isMultipleSelection()) {
|
|
2048
|
-
return value.some(function (currentValue) {
|
|
2049
|
-
return currentValue.getMonth() === month && currentValue.getFullYear() === currentYear;
|
|
2050
|
-
});
|
|
2051
|
-
} else {
|
|
2052
|
-
return value.getMonth() === month && value.getFullYear() === currentYear;
|
|
2053
|
-
}
|
|
2054
|
-
}
|
|
2055
|
-
return false;
|
|
2056
|
-
};
|
|
2057
|
-
var isYearSelected = function isYearSelected(year) {
|
|
2058
|
-
if (isComparable()) {
|
|
2059
|
-
var value = isRangeSelection() ? props.value[0] : props.value;
|
|
2060
|
-
if (isMultipleSelection()) {
|
|
2061
|
-
return value.some(function (currentValue) {
|
|
2062
|
-
return currentValue.getFullYear() === year;
|
|
2063
|
-
});
|
|
2064
|
-
} else {
|
|
2065
|
-
return value.getFullYear() === year;
|
|
2066
|
-
}
|
|
2067
|
-
}
|
|
2068
|
-
return false;
|
|
2069
|
-
};
|
|
2070
|
-
var switchViewButtonDisabled = function switchViewButtonDisabled() {
|
|
2071
|
-
return props.numberOfMonths > 1 || props.disabled;
|
|
2072
|
-
};
|
|
2073
|
-
var isDateEquals = function isDateEquals(value, dateMeta) {
|
|
2074
|
-
if (value && value instanceof Date) return value.getDate() === dateMeta.day && value.getMonth() === dateMeta.month && value.getFullYear() === dateMeta.year;else return false;
|
|
2075
|
-
};
|
|
2076
|
-
var isDateBetween = function isDateBetween(start, end, dateMeta) {
|
|
2077
|
-
var between = false;
|
|
2078
|
-
if (start && end) {
|
|
2079
|
-
var date = new Date(dateMeta.year, dateMeta.month, dateMeta.day);
|
|
2080
|
-
return start.getTime() <= date.getTime() && end.getTime() >= date.getTime();
|
|
2081
|
-
}
|
|
2082
|
-
return between;
|
|
2083
|
-
};
|
|
2084
|
-
var isSingleSelection = function isSingleSelection() {
|
|
2085
|
-
return props.selectionMode === 'single';
|
|
2086
|
-
};
|
|
2087
|
-
var isRangeSelection = function isRangeSelection() {
|
|
2088
|
-
return props.selectionMode === 'range';
|
|
2089
|
-
};
|
|
2090
|
-
var isMultipleSelection = function isMultipleSelection() {
|
|
2091
|
-
return props.selectionMode === 'multiple';
|
|
2092
|
-
};
|
|
2093
|
-
var isToday = function isToday(today, day, month, year) {
|
|
2094
|
-
return today.getDate() === day && today.getMonth() === month && today.getFullYear() === year;
|
|
2095
|
-
};
|
|
2096
|
-
var isDateDisabled = function isDateDisabled(day, month, year) {
|
|
2097
|
-
if (props.disabledDates) {
|
|
2098
|
-
return props.disabledDates.some(function (d) {
|
|
2099
|
-
return d.getFullYear() === year && d.getMonth() === month && d.getDate() === day;
|
|
2100
|
-
});
|
|
2101
|
-
}
|
|
2102
|
-
if (props.enabledDates) {
|
|
2103
|
-
return !props.enabledDates.some(function (d) {
|
|
2104
|
-
return d.getFullYear() === year && d.getMonth() === month && d.getDate() === day;
|
|
2105
|
-
});
|
|
2106
|
-
}
|
|
2107
|
-
return false;
|
|
2108
|
-
};
|
|
2109
|
-
var isDayDisabled = function isDayDisabled(day, month, year) {
|
|
2110
|
-
if (props.disabledDays) {
|
|
2111
|
-
var weekday = new Date(year, month, day);
|
|
2112
|
-
var weekdayNumber = weekday.getDay();
|
|
2113
|
-
return props.disabledDays.indexOf(weekdayNumber) !== -1;
|
|
2114
|
-
}
|
|
2115
|
-
return false;
|
|
2116
|
-
};
|
|
2117
|
-
var updateInputfield = function updateInputfield(value) {
|
|
2118
|
-
if (!inputRef.current) {
|
|
2119
|
-
return;
|
|
2120
|
-
}
|
|
2121
|
-
var formattedValue = '';
|
|
2122
|
-
if (value) {
|
|
2123
|
-
try {
|
|
2124
|
-
if (isSingleSelection()) {
|
|
2125
|
-
formattedValue = isValidDate(value) ? formatDateTime(value) : props.keepInvalid ? value : '';
|
|
2126
|
-
} else if (isMultipleSelection()) {
|
|
2127
|
-
for (var i = 0; i < value.length; i++) {
|
|
2128
|
-
var selectedValue = value[i];
|
|
2129
|
-
var dateAsString = isValidDate(selectedValue) ? formatDateTime(selectedValue) : '';
|
|
2130
|
-
formattedValue += dateAsString;
|
|
2131
|
-
if (i !== value.length - 1) {
|
|
2132
|
-
formattedValue += ', ';
|
|
2133
|
-
}
|
|
2134
|
-
}
|
|
2135
|
-
} else if (isRangeSelection()) {
|
|
2136
|
-
if (value && value.length) {
|
|
2137
|
-
var startDate = value[0];
|
|
2138
|
-
var endDate = value[1];
|
|
2139
|
-
formattedValue = isValidDate(startDate) ? formatDateTime(startDate) : '';
|
|
2140
|
-
if (endDate) {
|
|
2141
|
-
formattedValue += isValidDate(endDate) ? ' - ' + formatDateTime(endDate) : '';
|
|
2142
|
-
}
|
|
2143
|
-
}
|
|
2144
|
-
}
|
|
2145
|
-
} catch (err) {
|
|
2146
|
-
formattedValue = value;
|
|
2147
|
-
}
|
|
2148
|
-
}
|
|
2149
|
-
inputRef.current.value = formattedValue;
|
|
2150
|
-
};
|
|
2151
|
-
var formatDateTime = function formatDateTime(date) {
|
|
2152
|
-
if (props.formatDateTime) {
|
|
2153
|
-
return props.formatDateTime(date);
|
|
2154
|
-
}
|
|
2155
|
-
var formattedValue = null;
|
|
2156
|
-
if (date) {
|
|
2157
|
-
if (props.timeOnly) {
|
|
2158
|
-
formattedValue = formatTime(date);
|
|
2159
|
-
} else {
|
|
2160
|
-
formattedValue = formatDate(date, getDateFormat());
|
|
2161
|
-
if (props.showTime) {
|
|
2162
|
-
formattedValue += ' ' + formatTime(date);
|
|
2163
|
-
}
|
|
2164
|
-
}
|
|
2165
|
-
}
|
|
2166
|
-
return formattedValue;
|
|
2167
|
-
};
|
|
2168
|
-
var formatDate = function formatDate(date, format) {
|
|
2169
|
-
if (!date) {
|
|
2170
|
-
return '';
|
|
2171
|
-
}
|
|
2172
|
-
var iFormat;
|
|
2173
|
-
var lookAhead = function lookAhead(match) {
|
|
2174
|
-
var matches = iFormat + 1 < format.length && format.charAt(iFormat + 1) === match;
|
|
2175
|
-
if (matches) {
|
|
2176
|
-
iFormat++;
|
|
2177
|
-
}
|
|
2178
|
-
return matches;
|
|
2179
|
-
},
|
|
2180
|
-
formatNumber = function formatNumber(match, value, len) {
|
|
2181
|
-
var num = '' + value;
|
|
2182
|
-
if (lookAhead(match)) {
|
|
2183
|
-
while (num.length < len) {
|
|
2184
|
-
num = '0' + num;
|
|
2185
|
-
}
|
|
2186
|
-
}
|
|
2187
|
-
return num;
|
|
2188
|
-
},
|
|
2189
|
-
formatName = function formatName(match, value, shortNames, longNames) {
|
|
2190
|
-
return lookAhead(match) ? longNames[value] : shortNames[value];
|
|
2191
|
-
};
|
|
2192
|
-
var output = '';
|
|
2193
|
-
var literal = false;
|
|
2194
|
-
var _localeOptions2 = localeOptions(props.locale),
|
|
2195
|
-
dayNamesShort = _localeOptions2.dayNamesShort,
|
|
2196
|
-
dayNames = _localeOptions2.dayNames,
|
|
2197
|
-
monthNamesShort = _localeOptions2.monthNamesShort,
|
|
2198
|
-
monthNames = _localeOptions2.monthNames;
|
|
2199
|
-
if (date) {
|
|
2200
|
-
for (iFormat = 0; iFormat < format.length; iFormat++) {
|
|
2201
|
-
if (literal) {
|
|
2202
|
-
if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
|
|
2203
|
-
literal = false;
|
|
2204
|
-
} else {
|
|
2205
|
-
output += format.charAt(iFormat);
|
|
2206
|
-
}
|
|
2207
|
-
} else {
|
|
2208
|
-
switch (format.charAt(iFormat)) {
|
|
2209
|
-
case 'd':
|
|
2210
|
-
output += formatNumber('d', date.getDate(), 2);
|
|
2211
|
-
break;
|
|
2212
|
-
case 'D':
|
|
2213
|
-
output += formatName('D', date.getDay(), dayNamesShort, dayNames);
|
|
2214
|
-
break;
|
|
2215
|
-
case 'o':
|
|
2216
|
-
output += formatNumber('o', Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
|
|
2217
|
-
break;
|
|
2218
|
-
case 'm':
|
|
2219
|
-
output += formatNumber('m', date.getMonth() + 1, 2);
|
|
2220
|
-
break;
|
|
2221
|
-
case 'M':
|
|
2222
|
-
output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
|
|
2223
|
-
break;
|
|
2224
|
-
case 'y':
|
|
2225
|
-
output += lookAhead('y') ? date.getFullYear() : (date.getFullYear() % 100 < 10 ? '0' : '') + date.getFullYear() % 100;
|
|
2226
|
-
break;
|
|
2227
|
-
case '@':
|
|
2228
|
-
output += date.getTime();
|
|
2229
|
-
break;
|
|
2230
|
-
case '!':
|
|
2231
|
-
output += date.getTime() * 10000 + ticksTo1970;
|
|
2232
|
-
break;
|
|
2233
|
-
case "'":
|
|
2234
|
-
if (lookAhead("'")) {
|
|
2235
|
-
output += "'";
|
|
2236
|
-
} else {
|
|
2237
|
-
literal = true;
|
|
2238
|
-
}
|
|
2239
|
-
break;
|
|
2240
|
-
default:
|
|
2241
|
-
output += format.charAt(iFormat);
|
|
2242
|
-
}
|
|
2243
|
-
}
|
|
2244
|
-
}
|
|
2245
|
-
}
|
|
2246
|
-
return output;
|
|
2247
|
-
};
|
|
2248
|
-
var formatTime = function formatTime(date) {
|
|
2249
|
-
if (!date) {
|
|
2250
|
-
return '';
|
|
2251
|
-
}
|
|
2252
|
-
var output = '';
|
|
2253
|
-
var hours = date.getHours();
|
|
2254
|
-
var minutes = date.getMinutes();
|
|
2255
|
-
var seconds = date.getSeconds();
|
|
2256
|
-
var milliseconds = date.getMilliseconds();
|
|
2257
|
-
if (props.hourFormat === '12' && hours > 11 && hours !== 12) {
|
|
2258
|
-
hours -= 12;
|
|
2259
|
-
}
|
|
2260
|
-
if (props.hourFormat === '12') {
|
|
2261
|
-
output += hours === 0 ? 12 : hours < 10 ? '0' + hours : hours;
|
|
2262
|
-
} else {
|
|
2263
|
-
output += hours < 10 ? '0' + hours : hours;
|
|
2264
|
-
}
|
|
2265
|
-
output += ':';
|
|
2266
|
-
output += minutes < 10 ? '0' + minutes : minutes;
|
|
2267
|
-
if (props.showSeconds) {
|
|
2268
|
-
output += ':';
|
|
2269
|
-
output += seconds < 10 ? '0' + seconds : seconds;
|
|
2270
|
-
}
|
|
2271
|
-
if (props.showMillisec) {
|
|
2272
|
-
output += '.';
|
|
2273
|
-
output += milliseconds < 100 ? (milliseconds < 10 ? '00' : '0') + milliseconds : milliseconds;
|
|
2274
|
-
}
|
|
2275
|
-
if (props.hourFormat === '12') {
|
|
2276
|
-
output += date.getHours() > 11 ? ' PM' : ' AM';
|
|
2277
|
-
}
|
|
2278
|
-
return output;
|
|
2279
|
-
};
|
|
2280
|
-
var parseValueFromString = function parseValueFromString(text) {
|
|
2281
|
-
if (!text || text.trim().length === 0) {
|
|
2282
|
-
return null;
|
|
2283
|
-
}
|
|
2284
|
-
var value;
|
|
2285
|
-
if (isSingleSelection()) {
|
|
2286
|
-
value = parseDateTime(text);
|
|
2287
|
-
} else if (isMultipleSelection()) {
|
|
2288
|
-
var tokens = text.split(',');
|
|
2289
|
-
value = [];
|
|
2290
|
-
var _iterator2 = _createForOfIteratorHelper(tokens),
|
|
2291
|
-
_step2;
|
|
2292
|
-
try {
|
|
2293
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2294
|
-
var token = _step2.value;
|
|
2295
|
-
value.push(parseDateTime(token.trim()));
|
|
2296
|
-
}
|
|
2297
|
-
} catch (err) {
|
|
2298
|
-
_iterator2.e(err);
|
|
2299
|
-
} finally {
|
|
2300
|
-
_iterator2.f();
|
|
2301
|
-
}
|
|
2302
|
-
} else if (isRangeSelection()) {
|
|
2303
|
-
var _tokens = text.split(' - ');
|
|
2304
|
-
value = [];
|
|
2305
|
-
for (var i = 0; i < _tokens.length; i++) {
|
|
2306
|
-
value[i] = parseDateTime(_tokens[i].trim());
|
|
2307
|
-
}
|
|
2308
|
-
}
|
|
2309
|
-
return value;
|
|
2310
|
-
};
|
|
2311
|
-
var parseDateTime = function parseDateTime(text) {
|
|
2312
|
-
if (props.parseDateTime) {
|
|
2313
|
-
return props.parseDateTime(text);
|
|
2314
|
-
}
|
|
2315
|
-
var date;
|
|
2316
|
-
var parts = text.split(' ');
|
|
2317
|
-
if (props.timeOnly) {
|
|
2318
|
-
date = new Date();
|
|
2319
|
-
populateTime(date, parts[0], parts[1]);
|
|
2320
|
-
} else {
|
|
2321
|
-
if (props.showTime) {
|
|
2322
|
-
date = parseDate(parts[0], getDateFormat());
|
|
2323
|
-
populateTime(date, parts[1], parts[2]);
|
|
2324
|
-
} else {
|
|
2325
|
-
date = parseDate(text, getDateFormat());
|
|
2326
|
-
}
|
|
2327
|
-
}
|
|
2328
|
-
return date;
|
|
2329
|
-
};
|
|
2330
|
-
var populateTime = function populateTime(value, timeString, ampm) {
|
|
2331
|
-
if (props.hourFormat === '12' && ampm !== 'PM' && ampm !== 'AM') {
|
|
2332
|
-
throw new Error('Invalid Time');
|
|
2333
|
-
}
|
|
2334
|
-
var time = parseTime(timeString, ampm);
|
|
2335
|
-
value.setHours(time.hour);
|
|
2336
|
-
value.setMinutes(time.minute);
|
|
2337
|
-
value.setSeconds(time.second);
|
|
2338
|
-
value.setMilliseconds(time.millisecond);
|
|
2339
|
-
};
|
|
2340
|
-
var parseTime = function parseTime(value, ampm) {
|
|
2341
|
-
value = props.showMillisec ? value.replace('.', ':') : value;
|
|
2342
|
-
var tokens = value.split(':');
|
|
2343
|
-
var validTokenLength = props.showSeconds ? 3 : 2;
|
|
2344
|
-
validTokenLength = props.showMillisec ? validTokenLength + 1 : validTokenLength;
|
|
2345
|
-
if (tokens.length !== validTokenLength || tokens[0].length !== 2 || tokens[1].length !== 2 || props.showSeconds && tokens[2].length !== 2 || props.showMillisec && tokens[3].length !== 3) {
|
|
2346
|
-
throw new Error('Invalid time');
|
|
2347
|
-
}
|
|
2348
|
-
var h = parseInt(tokens[0], 10);
|
|
2349
|
-
var m = parseInt(tokens[1], 10);
|
|
2350
|
-
var s = props.showSeconds ? parseInt(tokens[2], 10) : null;
|
|
2351
|
-
var ms = props.showMillisec ? parseInt(tokens[3], 10) : null;
|
|
2352
|
-
if (isNaN(h) || isNaN(m) || h > 23 || m > 59 || props.hourFormat === '12' && h > 12 || props.showSeconds && (isNaN(s) || s > 59) || props.showMillisec && (isNaN(s) || s > 1000)) {
|
|
2353
|
-
throw new Error('Invalid time');
|
|
2354
|
-
} else {
|
|
2355
|
-
if (props.hourFormat === '12' && h !== 12 && ampm === 'PM') {
|
|
2356
|
-
h += 12;
|
|
2357
|
-
}
|
|
2358
|
-
return {
|
|
2359
|
-
hour: h,
|
|
2360
|
-
minute: m,
|
|
2361
|
-
second: s,
|
|
2362
|
-
millisecond: ms
|
|
2363
|
-
};
|
|
2364
|
-
}
|
|
2365
|
-
};
|
|
2366
|
-
|
|
2367
|
-
// Ported from jquery-ui datepicker parseDate
|
|
2368
|
-
var parseDate = function parseDate(value, format) {
|
|
2369
|
-
if (format == null || value == null) {
|
|
2370
|
-
throw new Error('Invalid arguments');
|
|
2371
|
-
}
|
|
2372
|
-
value = _typeof(value) === 'object' ? value.toString() : value + '';
|
|
2373
|
-
if (value === '') {
|
|
2374
|
-
return null;
|
|
2375
|
-
}
|
|
2376
|
-
var iFormat,
|
|
2377
|
-
dim,
|
|
2378
|
-
extra,
|
|
2379
|
-
iValue = 0,
|
|
2380
|
-
shortYearCutoff = typeof props.shortYearCutoff !== 'string' ? props.shortYearCutoff : new Date().getFullYear() % 100 + parseInt(props.shortYearCutoff, 10),
|
|
2381
|
-
year = -1,
|
|
2382
|
-
month = -1,
|
|
2383
|
-
day = -1,
|
|
2384
|
-
doy = -1,
|
|
2385
|
-
literal = false,
|
|
2386
|
-
date,
|
|
2387
|
-
lookAhead = function lookAhead(match) {
|
|
2388
|
-
var matches = iFormat + 1 < format.length && format.charAt(iFormat + 1) === match;
|
|
2389
|
-
if (matches) {
|
|
2390
|
-
iFormat++;
|
|
2391
|
-
}
|
|
2392
|
-
return matches;
|
|
2393
|
-
},
|
|
2394
|
-
getNumber = function getNumber(match) {
|
|
2395
|
-
var isDoubled = lookAhead(match),
|
|
2396
|
-
size = match === '@' ? 14 : match === '!' ? 20 : match === 'y' && isDoubled ? 4 : match === 'o' ? 3 : 2,
|
|
2397
|
-
minSize = match === 'y' ? size : 1,
|
|
2398
|
-
digits = new RegExp('^\\d{' + minSize + ',' + size + '}'),
|
|
2399
|
-
num = value.substring(iValue).match(digits);
|
|
2400
|
-
if (!num) {
|
|
2401
|
-
throw new Error('Missing number at position ' + iValue);
|
|
2402
|
-
}
|
|
2403
|
-
iValue += num[0].length;
|
|
2404
|
-
return parseInt(num[0], 10);
|
|
2405
|
-
},
|
|
2406
|
-
getName = function getName(match, shortNames, longNames) {
|
|
2407
|
-
var index = -1;
|
|
2408
|
-
var arr = lookAhead(match) ? longNames : shortNames;
|
|
2409
|
-
var names = [];
|
|
2410
|
-
for (var i = 0; i < arr.length; i++) {
|
|
2411
|
-
names.push([i, arr[i]]);
|
|
2412
|
-
}
|
|
2413
|
-
names.sort(function (a, b) {
|
|
2414
|
-
return -(a[1].length - b[1].length);
|
|
2415
|
-
});
|
|
2416
|
-
for (var _i = 0; _i < names.length; _i++) {
|
|
2417
|
-
var name = names[_i][1];
|
|
2418
|
-
if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
|
|
2419
|
-
index = names[_i][0];
|
|
2420
|
-
iValue += name.length;
|
|
2421
|
-
break;
|
|
2422
|
-
}
|
|
2423
|
-
}
|
|
2424
|
-
if (index !== -1) {
|
|
2425
|
-
return index + 1;
|
|
2426
|
-
} else {
|
|
2427
|
-
throw new Error('Unknown name at position ' + iValue);
|
|
2428
|
-
}
|
|
2429
|
-
},
|
|
2430
|
-
checkLiteral = function checkLiteral() {
|
|
2431
|
-
if (value.charAt(iValue) !== format.charAt(iFormat)) {
|
|
2432
|
-
throw new Error('Unexpected literal at position ' + iValue);
|
|
2433
|
-
}
|
|
2434
|
-
iValue++;
|
|
2435
|
-
};
|
|
2436
|
-
if (props.view === 'month') {
|
|
2437
|
-
day = 1;
|
|
2438
|
-
}
|
|
2439
|
-
if (props.view === 'year') {
|
|
2440
|
-
day = 1;
|
|
2441
|
-
month = 1;
|
|
2442
|
-
}
|
|
2443
|
-
var _localeOptions3 = localeOptions(props.locale),
|
|
2444
|
-
dayNamesShort = _localeOptions3.dayNamesShort,
|
|
2445
|
-
dayNames = _localeOptions3.dayNames,
|
|
2446
|
-
monthNamesShort = _localeOptions3.monthNamesShort,
|
|
2447
|
-
monthNames = _localeOptions3.monthNames;
|
|
2448
|
-
for (iFormat = 0; iFormat < format.length; iFormat++) {
|
|
2449
|
-
if (literal) {
|
|
2450
|
-
if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
|
|
2451
|
-
literal = false;
|
|
2452
|
-
} else {
|
|
2453
|
-
checkLiteral();
|
|
2454
|
-
}
|
|
2455
|
-
} else {
|
|
2456
|
-
switch (format.charAt(iFormat)) {
|
|
2457
|
-
case 'd':
|
|
2458
|
-
day = getNumber('d');
|
|
2459
|
-
break;
|
|
2460
|
-
case 'D':
|
|
2461
|
-
getName('D', dayNamesShort, dayNames);
|
|
2462
|
-
break;
|
|
2463
|
-
case 'o':
|
|
2464
|
-
doy = getNumber('o');
|
|
2465
|
-
break;
|
|
2466
|
-
case 'm':
|
|
2467
|
-
month = getNumber('m');
|
|
2468
|
-
break;
|
|
2469
|
-
case 'M':
|
|
2470
|
-
month = getName('M', monthNamesShort, monthNames);
|
|
2471
|
-
break;
|
|
2472
|
-
case 'y':
|
|
2473
|
-
year = getNumber('y');
|
|
2474
|
-
break;
|
|
2475
|
-
case '@':
|
|
2476
|
-
date = new Date(getNumber('@'));
|
|
2477
|
-
year = date.getFullYear();
|
|
2478
|
-
month = date.getMonth() + 1;
|
|
2479
|
-
day = date.getDate();
|
|
2480
|
-
break;
|
|
2481
|
-
case '!':
|
|
2482
|
-
date = new Date((getNumber('!') - ticksTo1970) / 10000);
|
|
2483
|
-
year = date.getFullYear();
|
|
2484
|
-
month = date.getMonth() + 1;
|
|
2485
|
-
day = date.getDate();
|
|
2486
|
-
break;
|
|
2487
|
-
case "'":
|
|
2488
|
-
if (lookAhead("'")) {
|
|
2489
|
-
checkLiteral();
|
|
2490
|
-
} else {
|
|
2491
|
-
literal = true;
|
|
2492
|
-
}
|
|
2493
|
-
break;
|
|
2494
|
-
default:
|
|
2495
|
-
checkLiteral();
|
|
2496
|
-
}
|
|
2497
|
-
}
|
|
2498
|
-
}
|
|
2499
|
-
if (iValue < value.length) {
|
|
2500
|
-
extra = value.substr(iValue);
|
|
2501
|
-
if (!/^\s+/.test(extra)) {
|
|
2502
|
-
throw new Error('Extra/unparsed characters found in date: ' + extra);
|
|
2503
|
-
}
|
|
2504
|
-
}
|
|
2505
|
-
if (year === -1) {
|
|
2506
|
-
year = new Date().getFullYear();
|
|
2507
|
-
} else if (year < 100) {
|
|
2508
|
-
year += new Date().getFullYear() - new Date().getFullYear() % 100 + (year <= shortYearCutoff ? 0 : -100);
|
|
2509
|
-
}
|
|
2510
|
-
if (doy > -1) {
|
|
2511
|
-
month = 1;
|
|
2512
|
-
day = doy;
|
|
2513
|
-
do {
|
|
2514
|
-
dim = getDaysCountInMonth(year, month - 1);
|
|
2515
|
-
if (day <= dim) {
|
|
2516
|
-
break;
|
|
2517
|
-
}
|
|
2518
|
-
month++;
|
|
2519
|
-
day -= dim;
|
|
2520
|
-
} while (true);
|
|
2521
|
-
}
|
|
2522
|
-
date = daylightSavingAdjust(new Date(year, month - 1, day));
|
|
2523
|
-
if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
|
|
2524
|
-
throw new Error('Invalid date'); // E.g. 31/02/00
|
|
2525
|
-
}
|
|
2526
|
-
|
|
2527
|
-
return date;
|
|
2528
|
-
};
|
|
2529
|
-
var isInMinYear = function isInMinYear(viewDate) {
|
|
2530
|
-
return props.minDate && props.minDate.getFullYear() === viewDate.getFullYear();
|
|
2531
|
-
};
|
|
2532
|
-
var isInMaxYear = function isInMaxYear(viewDate) {
|
|
2533
|
-
return props.maxDate && props.maxDate.getFullYear() === viewDate.getFullYear();
|
|
2534
|
-
};
|
|
2535
|
-
React.useEffect(function () {
|
|
2536
|
-
ObjectUtils.combinedRefs(inputRef, props.inputRef);
|
|
2537
|
-
}, [inputRef, props.inputRef]);
|
|
2538
|
-
useMountEffect(function () {
|
|
2539
|
-
var viewDate = getViewDate(props.viewDate);
|
|
2540
|
-
validateDate(viewDate);
|
|
2541
|
-
setViewDateState(viewDate);
|
|
2542
|
-
setCurrentMonth(viewDate.getMonth());
|
|
2543
|
-
setCurrentYear(viewDate.getFullYear());
|
|
2544
|
-
setCurrentView(props.view);
|
|
2545
|
-
if (props.inline) {
|
|
2546
|
-
overlayRef && overlayRef.current.setAttribute(attributeSelector, '');
|
|
2547
|
-
if (!props.disabled) {
|
|
2548
|
-
initFocusableCell();
|
|
2549
|
-
if (props.numberOfMonths === 1) {
|
|
2550
|
-
overlayRef.current.style.width = DomHandler.getOuterWidth(overlayRef.current) + 'px';
|
|
2551
|
-
}
|
|
2552
|
-
}
|
|
2553
|
-
}
|
|
2554
|
-
if (props.value) {
|
|
2555
|
-
updateInputfield(props.value);
|
|
2556
|
-
setValue(props.value);
|
|
2557
|
-
}
|
|
2558
|
-
if (props.autoFocus) {
|
|
2559
|
-
// delay showing until rendered so `alignPanel()` method aligns the popup in the right location
|
|
2560
|
-
setTimeout(function () {
|
|
2561
|
-
return DomHandler.focus(inputRef.current, props.autoFocus);
|
|
2562
|
-
}, 200);
|
|
2563
|
-
}
|
|
2564
|
-
});
|
|
2565
|
-
React.useEffect(function () {
|
|
2566
|
-
// see https://github.com/primefaces/primereact/issues/4030
|
|
2567
|
-
onChangeRef.current = props.onChange;
|
|
2568
|
-
}, [props.onChange]);
|
|
2569
|
-
React.useEffect(function () {
|
|
2570
|
-
var unbindMaskEvents = null;
|
|
2571
|
-
if (props.mask) {
|
|
2572
|
-
unbindMaskEvents = mask(inputRef.current, {
|
|
2573
|
-
mask: props.mask,
|
|
2574
|
-
slotChar: props.maskSlotChar,
|
|
2575
|
-
readOnly: props.readOnlyInput || props.disabled,
|
|
2576
|
-
onChange: function onChange(e) {
|
|
2577
|
-
!ignoreMaskChange.current && updateValueOnInput(e.originalEvent, e.value);
|
|
2578
|
-
ignoreMaskChange.current = false;
|
|
2579
|
-
},
|
|
2580
|
-
onBlur: function onBlur() {
|
|
2581
|
-
ignoreMaskChange.current = true;
|
|
2582
|
-
}
|
|
2583
|
-
}).unbindEvents;
|
|
2584
|
-
}
|
|
2585
|
-
return function () {
|
|
2586
|
-
props.mask && unbindMaskEvents && unbindMaskEvents();
|
|
2587
|
-
};
|
|
2588
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2589
|
-
}, [props.disabled, props.mask, props.readOnlyInput]);
|
|
2590
|
-
useUpdateEffect(function () {
|
|
2591
|
-
setCurrentView(props.view);
|
|
2592
|
-
}, [props.view]);
|
|
2593
|
-
useUpdateEffect(function () {
|
|
2594
|
-
if (!props.onViewDateChange && !viewStateChanged.current) {
|
|
2595
|
-
setValue(props.value);
|
|
2596
|
-
}
|
|
2597
|
-
}, [props.onViewDateChange, props.value]);
|
|
2598
|
-
useUpdateEffect(function () {
|
|
2599
|
-
var newDate = props.value;
|
|
2600
|
-
if (previousValue !== newDate) {
|
|
2601
|
-
updateInputfield(newDate);
|
|
2602
|
-
|
|
2603
|
-
// #3516 view date not updated when value set programatically
|
|
2604
|
-
if (!visible && newDate) {
|
|
2605
|
-
var viewDate = newDate;
|
|
2606
|
-
if (isMultipleSelection()) {
|
|
2607
|
-
if (newDate.length) {
|
|
2608
|
-
viewDate = newDate[newDate.length - 1];
|
|
2609
|
-
}
|
|
2610
|
-
} else if (isRangeSelection()) {
|
|
2611
|
-
if (newDate.length) {
|
|
2612
|
-
var startDate = newDate[0];
|
|
2613
|
-
var endDate = newDate[1];
|
|
2614
|
-
viewDate = endDate || startDate;
|
|
2615
|
-
}
|
|
2616
|
-
}
|
|
2617
|
-
if (viewDate instanceof Date) {
|
|
2618
|
-
validateDate(viewDate);
|
|
2619
|
-
setViewDateState(viewDate);
|
|
2620
|
-
setCurrentMonth(viewDate.getMonth());
|
|
2621
|
-
setCurrentYear(viewDate.getFullYear());
|
|
2622
|
-
}
|
|
2623
|
-
}
|
|
2624
|
-
}
|
|
2625
|
-
}, [props.value, visible]);
|
|
2626
|
-
useUpdateEffect(function () {
|
|
2627
|
-
updateInputfield(props.value);
|
|
2628
|
-
}, [props.dateFormat, props.hourFormat, props.timeOnly, props.showSeconds, props.showMillisec, props.showTime]);
|
|
2629
|
-
useUpdateEffect(function () {
|
|
2630
|
-
if (overlayRef.current) {
|
|
2631
|
-
setNavigationState(viewDateState);
|
|
2632
|
-
updateFocus();
|
|
2633
|
-
}
|
|
2634
|
-
});
|
|
2635
|
-
useUnmountEffect(function () {
|
|
2636
|
-
if (touchUIMask.current) {
|
|
2637
|
-
disableModality();
|
|
2638
|
-
touchUIMask.current = null;
|
|
2639
|
-
}
|
|
2640
|
-
ZIndexUtils.clear(overlayRef.current);
|
|
2641
|
-
});
|
|
2642
|
-
React.useImperativeHandle(ref, function () {
|
|
2643
|
-
return {
|
|
2644
|
-
props: props,
|
|
2645
|
-
show: show,
|
|
2646
|
-
hide: hide,
|
|
2647
|
-
getCurrentDateTime: getCurrentDateTime,
|
|
2648
|
-
getViewDate: getViewDate,
|
|
2649
|
-
updateViewDate: updateViewDate,
|
|
2650
|
-
focus: function focus() {
|
|
2651
|
-
return DomHandler.focus(inputRef.current);
|
|
2652
|
-
},
|
|
2653
|
-
getElement: function getElement() {
|
|
2654
|
-
return elementRef.current;
|
|
2655
|
-
},
|
|
2656
|
-
getOverlay: function getOverlay() {
|
|
2657
|
-
return overlayRef.current;
|
|
2658
|
-
},
|
|
2659
|
-
getInput: function getInput() {
|
|
2660
|
-
return inputRef.current;
|
|
2661
|
-
}
|
|
2662
|
-
};
|
|
2663
|
-
});
|
|
2664
|
-
var setValue = function setValue(propValue) {
|
|
2665
|
-
if (Array.isArray(propValue)) {
|
|
2666
|
-
propValue = propValue[0];
|
|
2667
|
-
}
|
|
2668
|
-
var prevPropValue = previousValue;
|
|
2669
|
-
if (Array.isArray(prevPropValue)) {
|
|
2670
|
-
prevPropValue = prevPropValue[0];
|
|
2671
|
-
}
|
|
2672
|
-
if (!prevPropValue && propValue || propValue && propValue instanceof Date && propValue.getTime() !== prevPropValue.getTime()) {
|
|
2673
|
-
var viewDate = props.viewDate && isValidDate(props.viewDate) ? props.viewDate : propValue && isValidDate(propValue) ? propValue : new Date();
|
|
2674
|
-
validateDate(viewDate);
|
|
2675
|
-
setViewDateState(viewDate);
|
|
2676
|
-
viewStateChanged.current = true;
|
|
2677
|
-
}
|
|
2678
|
-
};
|
|
2679
|
-
var createBackwardNavigator = function createBackwardNavigator(isVisible) {
|
|
2680
|
-
var navigatorProps = isVisible ? {
|
|
2681
|
-
onClick: onPrevButtonClick,
|
|
2682
|
-
onKeyDown: function onKeyDown(e) {
|
|
2683
|
-
return onContainerButtonKeydown(e);
|
|
2684
|
-
}
|
|
2685
|
-
} : {
|
|
2686
|
-
style: {
|
|
2687
|
-
visibility: 'hidden'
|
|
2688
|
-
}
|
|
2689
|
-
};
|
|
2690
|
-
var previousIconProps = mergeProps({
|
|
2691
|
-
className: cx('previousIcon')
|
|
2692
|
-
}, ptm('previousIcon'));
|
|
2693
|
-
var icon = props.prevIcon || /*#__PURE__*/React.createElement(ChevronLeftIcon, previousIconProps);
|
|
2694
|
-
var backwardNavigatorIcon = IconUtils.getJSXIcon(icon, _objectSpread({}, previousIconProps), {
|
|
2695
|
-
props: props
|
|
2696
|
-
});
|
|
2697
|
-
var previousButtonProps = mergeProps(_objectSpread({
|
|
2698
|
-
type: 'button',
|
|
2699
|
-
className: cx('previousButton')
|
|
2700
|
-
}, navigatorProps), ptm('previousButton'));
|
|
2701
|
-
return /*#__PURE__*/React.createElement("button", _extends({
|
|
2702
|
-
ref: previousButton
|
|
2703
|
-
}, previousButtonProps), backwardNavigatorIcon, /*#__PURE__*/React.createElement(Ripple, null));
|
|
2704
|
-
};
|
|
2705
|
-
var createForwardNavigator = function createForwardNavigator(isVisible) {
|
|
2706
|
-
var navigatorProps = isVisible ? {
|
|
2707
|
-
onClick: onNextButtonClick,
|
|
2708
|
-
onKeyDown: function onKeyDown(e) {
|
|
2709
|
-
return onContainerButtonKeydown(e);
|
|
2710
|
-
}
|
|
2711
|
-
} : {
|
|
2712
|
-
style: {
|
|
2713
|
-
visibility: 'hidden'
|
|
2714
|
-
}
|
|
2715
|
-
};
|
|
2716
|
-
var nextIconProps = mergeProps({
|
|
2717
|
-
className: cx('nextIcon')
|
|
2718
|
-
}, ptm('nextIcon'));
|
|
2719
|
-
var icon = props.nextIcon || /*#__PURE__*/React.createElement(ChevronRightIcon, nextIconProps);
|
|
2720
|
-
var forwardNavigatorIcon = IconUtils.getJSXIcon(icon, _objectSpread({}, nextIconProps), {
|
|
2721
|
-
props: props
|
|
2722
|
-
});
|
|
2723
|
-
var nextButtonProps = mergeProps(_objectSpread({
|
|
2724
|
-
type: 'button',
|
|
2725
|
-
className: cx('nextButton')
|
|
2726
|
-
}, navigatorProps), ptm('nextButton'));
|
|
2727
|
-
return /*#__PURE__*/React.createElement("button", _extends({
|
|
2728
|
-
ref: nextButton
|
|
2729
|
-
}, nextButtonProps), forwardNavigatorIcon, /*#__PURE__*/React.createElement(Ripple, null));
|
|
2730
|
-
};
|
|
2731
|
-
var createTitleMonthElement = function createTitleMonthElement(month) {
|
|
2732
|
-
var monthNames = localeOption('monthNames', props.locale);
|
|
2733
|
-
if (props.monthNavigator && props.view !== 'month') {
|
|
2734
|
-
var viewDate = getViewDate();
|
|
2735
|
-
var viewMonth = viewDate.getMonth();
|
|
2736
|
-
var displayedMonthOptions = monthNames.map(function (month, index) {
|
|
2737
|
-
return (!isInMinYear(viewDate) || index >= props.minDate.getMonth()) && (!isInMaxYear(viewDate) || index <= props.maxDate.getMonth()) ? {
|
|
2738
|
-
label: month,
|
|
2739
|
-
value: index,
|
|
2740
|
-
index: index
|
|
2741
|
-
} : null;
|
|
2742
|
-
}).filter(function (option) {
|
|
2743
|
-
return !!option;
|
|
2744
|
-
});
|
|
2745
|
-
var displayedMonthNames = displayedMonthOptions.map(function (option) {
|
|
2746
|
-
return option.label;
|
|
2747
|
-
});
|
|
2748
|
-
var selectProps = mergeProps({
|
|
2749
|
-
className: cx('select'),
|
|
2750
|
-
onChange: function onChange(e) {
|
|
2751
|
-
return onMonthDropdownChange(e, e.target.value);
|
|
2752
|
-
},
|
|
2753
|
-
value: viewMonth
|
|
2754
|
-
}, ptm('select'));
|
|
2755
|
-
var _content = /*#__PURE__*/React.createElement("select", selectProps, displayedMonthOptions.map(function (option) {
|
|
2756
|
-
var optionProps = mergeProps({
|
|
2757
|
-
value: option.value
|
|
2758
|
-
}, ptm('option'));
|
|
2759
|
-
return /*#__PURE__*/React.createElement("option", _extends({}, optionProps, {
|
|
2760
|
-
key: option.label
|
|
2761
|
-
}), option.label);
|
|
2762
|
-
}));
|
|
2763
|
-
if (props.monthNavigatorTemplate) {
|
|
2764
|
-
var defaultContentOptions = {
|
|
2765
|
-
onChange: onMonthDropdownChange,
|
|
2766
|
-
className: 'p-datepicker-month',
|
|
2767
|
-
value: viewMonth,
|
|
2768
|
-
names: displayedMonthNames,
|
|
2769
|
-
options: displayedMonthOptions,
|
|
2770
|
-
element: _content,
|
|
2771
|
-
props: props
|
|
2772
|
-
};
|
|
2773
|
-
return ObjectUtils.getJSXElement(props.monthNavigatorTemplate, defaultContentOptions);
|
|
2774
|
-
}
|
|
2775
|
-
return _content;
|
|
2776
|
-
}
|
|
2777
|
-
var monthTitleProps = mergeProps({
|
|
2778
|
-
className: cx('monthTitle'),
|
|
2779
|
-
onClick: switchToMonthView,
|
|
2780
|
-
disabled: switchViewButtonDisabled()
|
|
2781
|
-
}, ptm('monthTitle'));
|
|
2782
|
-
return currentView === 'date' && /*#__PURE__*/React.createElement("button", monthTitleProps, monthNames[month]);
|
|
2783
|
-
};
|
|
2784
|
-
var createTitleYearElement = function createTitleYearElement(metaYear) {
|
|
2785
|
-
if (props.yearNavigator) {
|
|
2786
|
-
var _yearOptions2 = [];
|
|
2787
|
-
var years = props.yearRange.split(':');
|
|
2788
|
-
var yearStart = parseInt(years[0], 10);
|
|
2789
|
-
var yearEnd = parseInt(years[1], 10);
|
|
2790
|
-
for (var i = yearStart; i <= yearEnd; i++) {
|
|
2791
|
-
_yearOptions2.push(i);
|
|
2792
|
-
}
|
|
2793
|
-
var viewDate = getViewDate();
|
|
2794
|
-
var viewYear = viewDate.getFullYear();
|
|
2795
|
-
var displayedYearNames = _yearOptions2.filter(function (year) {
|
|
2796
|
-
return !(props.minDate && props.minDate.getFullYear() > year) && !(props.maxDate && props.maxDate.getFullYear() < year);
|
|
2797
|
-
});
|
|
2798
|
-
var selectProps = mergeProps({
|
|
2799
|
-
className: cx('select'),
|
|
2800
|
-
onChange: function onChange(e) {
|
|
2801
|
-
return onYearDropdownChange(e, e.target.value);
|
|
2802
|
-
},
|
|
2803
|
-
value: viewYear
|
|
2804
|
-
}, ptm('select'));
|
|
2805
|
-
var _content2 = /*#__PURE__*/React.createElement("select", selectProps, displayedYearNames.map(function (year) {
|
|
2806
|
-
var optionProps = mergeProps({
|
|
2807
|
-
value: year
|
|
2808
|
-
}, ptm('option'));
|
|
2809
|
-
return /*#__PURE__*/React.createElement("option", _extends({}, optionProps, {
|
|
2810
|
-
key: year
|
|
2811
|
-
}), year);
|
|
2812
|
-
}));
|
|
2813
|
-
if (props.yearNavigatorTemplate) {
|
|
2814
|
-
var options = displayedYearNames.map(function (name, i) {
|
|
2815
|
-
return {
|
|
2816
|
-
label: name,
|
|
2817
|
-
value: name,
|
|
2818
|
-
index: i
|
|
2819
|
-
};
|
|
2820
|
-
});
|
|
2821
|
-
var defaultContentOptions = {
|
|
2822
|
-
onChange: onYearDropdownChange,
|
|
2823
|
-
className: 'p-datepicker-year',
|
|
2824
|
-
value: viewYear,
|
|
2825
|
-
names: displayedYearNames,
|
|
2826
|
-
options: options,
|
|
2827
|
-
element: _content2,
|
|
2828
|
-
props: props
|
|
2829
|
-
};
|
|
2830
|
-
return ObjectUtils.getJSXElement(props.yearNavigatorTemplate, defaultContentOptions);
|
|
2831
|
-
}
|
|
2832
|
-
return _content2;
|
|
2833
|
-
}
|
|
2834
|
-
var displayYear = props.numberOfMonths > 1 ? metaYear : currentYear;
|
|
2835
|
-
var yearTitleProps = mergeProps({
|
|
2836
|
-
className: cx('yearTitle'),
|
|
2837
|
-
onClick: function onClick(e) {
|
|
2838
|
-
return switchToYearView(e);
|
|
2839
|
-
},
|
|
2840
|
-
disabled: switchViewButtonDisabled()
|
|
2841
|
-
}, ptm('yearTitle'));
|
|
2842
|
-
return currentView !== 'year' && /*#__PURE__*/React.createElement("button", yearTitleProps, displayYear);
|
|
2843
|
-
};
|
|
2844
|
-
var createTitleDecadeElement = function createTitleDecadeElement() {
|
|
2845
|
-
var years = yearPickerValues();
|
|
2846
|
-
var decadeTitleProps = mergeProps({
|
|
2847
|
-
className: cx('decadeTitle')
|
|
2848
|
-
}, ptm('decadeTitle'));
|
|
2849
|
-
if (currentView === 'year') {
|
|
2850
|
-
var decadeTitleTextProps = mergeProps(ptm('decadeTitleText'));
|
|
2851
|
-
return /*#__PURE__*/React.createElement("span", decadeTitleProps, props.decadeTemplate ? props.decadeTemplate(years) : /*#__PURE__*/React.createElement("span", decadeTitleTextProps, "".concat(yearPickerValues()[0], " - ").concat(yearPickerValues()[yearPickerValues().length - 1])));
|
|
2852
|
-
}
|
|
2853
|
-
return null;
|
|
2854
|
-
};
|
|
2855
|
-
var createTitle = function createTitle(monthMetaData) {
|
|
2856
|
-
var month = createTitleMonthElement(monthMetaData.month);
|
|
2857
|
-
var year = createTitleYearElement(monthMetaData.year);
|
|
2858
|
-
var decade = createTitleDecadeElement();
|
|
2859
|
-
var titleProps = mergeProps({
|
|
2860
|
-
className: cx('title')
|
|
2861
|
-
}, ptm('title'));
|
|
2862
|
-
var showMonthAfterYear = localeOption('showMonthAfterYear', props.locale);
|
|
2863
|
-
return /*#__PURE__*/React.createElement("div", titleProps, showMonthAfterYear ? year : month, showMonthAfterYear ? month : year, decade);
|
|
2864
|
-
};
|
|
2865
|
-
var createDayNames = function createDayNames(weekDays) {
|
|
2866
|
-
var weekDayProps = mergeProps(ptm('weekDay'));
|
|
2867
|
-
var tableHeaderCellProps = mergeProps({
|
|
2868
|
-
scope: 'col'
|
|
2869
|
-
}, ptm('tableHeaderCell'));
|
|
2870
|
-
var dayNames = weekDays.map(function (weekDay, index) {
|
|
2871
|
-
return /*#__PURE__*/React.createElement("th", _extends({}, tableHeaderCellProps, {
|
|
2872
|
-
key: "".concat(weekDay, "-").concat(index)
|
|
2873
|
-
}), /*#__PURE__*/React.createElement("span", weekDayProps, weekDay));
|
|
2874
|
-
});
|
|
2875
|
-
if (props.showWeek) {
|
|
2876
|
-
var weekHeaderProps = mergeProps({
|
|
2877
|
-
scope: 'col',
|
|
2878
|
-
className: cx('weekHeader'),
|
|
2879
|
-
'data-p-disabled': props.showWeek
|
|
2880
|
-
}, ptm('weekHeader', {
|
|
2881
|
-
context: {
|
|
2882
|
-
disabled: props.showWeek
|
|
2883
|
-
}
|
|
2884
|
-
}));
|
|
2885
|
-
var weekLabel = mergeProps(ptm('weekLabel'));
|
|
2886
|
-
var weekHeader = /*#__PURE__*/React.createElement("th", _extends({}, weekHeaderProps, {
|
|
2887
|
-
key: "wn"
|
|
2888
|
-
}), /*#__PURE__*/React.createElement("span", weekLabel, localeOption('weekHeader', props.locale)));
|
|
2889
|
-
return [weekHeader].concat(_toConsumableArray(dayNames));
|
|
2890
|
-
}
|
|
2891
|
-
return dayNames;
|
|
2892
|
-
};
|
|
2893
|
-
var createDateCellContent = function createDateCellContent(date, className, groupIndex) {
|
|
2894
|
-
var content = props.dateTemplate ? props.dateTemplate(date) : date.day;
|
|
2895
|
-
var dayLabelProps = mergeProps({
|
|
2896
|
-
className: cx('dayLabel', {
|
|
2897
|
-
className: className
|
|
2898
|
-
}),
|
|
2899
|
-
onClick: function onClick(e) {
|
|
2900
|
-
return onDateSelect(e, date);
|
|
2901
|
-
},
|
|
2902
|
-
onKeyDown: function onKeyDown(e) {
|
|
2903
|
-
return onDateCellKeydown(e, date, groupIndex);
|
|
2904
|
-
},
|
|
2905
|
-
'data-p-highlight': isSelected(date),
|
|
2906
|
-
'data-p-disabled': !date.selectable
|
|
2907
|
-
}, ptm('dayLabel', {
|
|
2908
|
-
context: {
|
|
2909
|
-
selected: isSelected(date),
|
|
2910
|
-
disabled: !date.selectable
|
|
2911
|
-
}
|
|
2912
|
-
}));
|
|
2913
|
-
return /*#__PURE__*/React.createElement("span", dayLabelProps, content, /*#__PURE__*/React.createElement(Ripple, null));
|
|
2914
|
-
};
|
|
2915
|
-
var createWeek = function createWeek(weekDates, weekNumber, groupIndex) {
|
|
2916
|
-
var week = weekDates.map(function (date) {
|
|
2917
|
-
var selected = isSelected(date);
|
|
2918
|
-
var dateClassName = classNames({
|
|
2919
|
-
'p-highlight': selected,
|
|
2920
|
-
'p-disabled': !date.selectable
|
|
2921
|
-
});
|
|
2922
|
-
var content = date.otherMonth && !props.showOtherMonths ? null : createDateCellContent(date, dateClassName, groupIndex);
|
|
2923
|
-
var dayProps = mergeProps({
|
|
2924
|
-
className: cx('day', {
|
|
2925
|
-
date: date
|
|
2926
|
-
}),
|
|
2927
|
-
'data-p-today': date.today,
|
|
2928
|
-
'data-p-other-month': date.otherMonth
|
|
2929
|
-
}, ptm('day', {
|
|
2930
|
-
context: {
|
|
2931
|
-
date: date,
|
|
2932
|
-
today: date.today,
|
|
2933
|
-
otherMonth: date.otherMonth
|
|
2934
|
-
}
|
|
2935
|
-
}));
|
|
2936
|
-
return /*#__PURE__*/React.createElement("td", _extends({}, dayProps, {
|
|
2937
|
-
key: date.day
|
|
2938
|
-
}), content);
|
|
2939
|
-
});
|
|
2940
|
-
if (props.showWeek) {
|
|
2941
|
-
var weekNumberProps = mergeProps({
|
|
2942
|
-
className: cx('weekNumber')
|
|
2943
|
-
}, ptm('weekNumber'));
|
|
2944
|
-
var weekLabelContainerProps = mergeProps({
|
|
2945
|
-
className: cx('weekLabelContainer'),
|
|
2946
|
-
'data-p-disabled': props.showWeek
|
|
2947
|
-
}, ptm('weekLabelContainer', {
|
|
2948
|
-
context: {
|
|
2949
|
-
disabled: props.showWeek
|
|
2950
|
-
}
|
|
2951
|
-
}));
|
|
2952
|
-
var weekNumberCell = /*#__PURE__*/React.createElement("td", _extends({}, weekNumberProps, {
|
|
2953
|
-
key: 'wn' + weekNumber
|
|
2954
|
-
}), /*#__PURE__*/React.createElement("span", weekLabelContainerProps, weekNumber));
|
|
2955
|
-
return [weekNumberCell].concat(_toConsumableArray(week));
|
|
2956
|
-
}
|
|
2957
|
-
return week;
|
|
2958
|
-
};
|
|
2959
|
-
var createDates = function createDates(monthMetaData, groupIndex) {
|
|
2960
|
-
var tableBodyRowProps = mergeProps(ptm('tableBodyRowProps'));
|
|
2961
|
-
return monthMetaData.dates.map(function (weekDates, index) {
|
|
2962
|
-
return /*#__PURE__*/React.createElement("tr", _extends({}, tableBodyRowProps, {
|
|
2963
|
-
key: index
|
|
2964
|
-
}), createWeek(weekDates, monthMetaData.weekNumbers[index], groupIndex));
|
|
2965
|
-
});
|
|
2966
|
-
};
|
|
2967
|
-
var createDateViewGrid = function createDateViewGrid(monthMetaData, weekDays, groupIndex) {
|
|
2968
|
-
var dayNames = createDayNames(weekDays);
|
|
2969
|
-
var dates = createDates(monthMetaData, groupIndex);
|
|
2970
|
-
var containerProps = mergeProps({
|
|
2971
|
-
className: cx('container'),
|
|
2972
|
-
key: UniqueComponentId('calendar_container_')
|
|
2973
|
-
}, ptm('container'));
|
|
2974
|
-
var tableProps = mergeProps({
|
|
2975
|
-
className: cx('table')
|
|
2976
|
-
}, ptm('table'));
|
|
2977
|
-
var tableHeaderProps = mergeProps(ptm('tableHeader'));
|
|
2978
|
-
var tableHeaderRowProps = mergeProps(ptm('tableHeaderRow'));
|
|
2979
|
-
var tableBodyProps = mergeProps(ptm('tableBody'));
|
|
2980
|
-
return currentView === 'date' && /*#__PURE__*/React.createElement("div", containerProps, /*#__PURE__*/React.createElement("table", tableProps, /*#__PURE__*/React.createElement("thead", tableHeaderProps, /*#__PURE__*/React.createElement("tr", tableHeaderRowProps, dayNames)), /*#__PURE__*/React.createElement("tbody", tableBodyProps, dates)));
|
|
2981
|
-
};
|
|
2982
|
-
var createMonth = function createMonth(monthMetaData, index) {
|
|
2983
|
-
var weekDays = createWeekDaysMeta();
|
|
2984
|
-
var backwardNavigator = createBackwardNavigator(index === 0);
|
|
2985
|
-
var forwardNavigator = createForwardNavigator(props.numberOfMonths === 1 || index === props.numberOfMonths - 1);
|
|
2986
|
-
var title = createTitle(monthMetaData);
|
|
2987
|
-
var dateViewGrid = createDateViewGrid(monthMetaData, weekDays, index);
|
|
2988
|
-
var header = props.headerTemplate ? props.headerTemplate() : null;
|
|
2989
|
-
var monthKey = monthMetaData.month + '-' + monthMetaData.year;
|
|
2990
|
-
var groupProps = mergeProps({
|
|
2991
|
-
className: cx('group')
|
|
2992
|
-
}, ptm('group'));
|
|
2993
|
-
var headerProps = mergeProps({
|
|
2994
|
-
className: cx('header'),
|
|
2995
|
-
key: index
|
|
2996
|
-
}, ptm('header'));
|
|
2997
|
-
return /*#__PURE__*/React.createElement("div", _extends({}, groupProps, {
|
|
2998
|
-
key: monthKey
|
|
2999
|
-
}), /*#__PURE__*/React.createElement("div", headerProps, header, backwardNavigator, title, forwardNavigator), dateViewGrid);
|
|
3000
|
-
};
|
|
3001
|
-
var createMonths = function createMonths(monthsMetaData) {
|
|
3002
|
-
var groups = monthsMetaData.map(createMonth);
|
|
3003
|
-
var groupContainerProps = mergeProps({
|
|
3004
|
-
className: cx('groupContainer')
|
|
3005
|
-
}, ptm('groupContainer'));
|
|
3006
|
-
return /*#__PURE__*/React.createElement("div", groupContainerProps, groups);
|
|
3007
|
-
};
|
|
3008
|
-
var createDateView = function createDateView() {
|
|
3009
|
-
var viewDate = getViewDate();
|
|
3010
|
-
var monthsMetaData = createMonthsMeta(viewDate.getMonth(), viewDate.getFullYear());
|
|
3011
|
-
var months = createMonths(monthsMetaData);
|
|
3012
|
-
return months;
|
|
3013
|
-
};
|
|
3014
|
-
var monthPickerValues = function monthPickerValues() {
|
|
3015
|
-
var monthPickerValues = [];
|
|
3016
|
-
var monthNamesShort = localeOption('monthNamesShort', props.locale);
|
|
3017
|
-
for (var i = 0; i <= 11; i++) {
|
|
3018
|
-
monthPickerValues.push(monthNamesShort[i]);
|
|
3019
|
-
}
|
|
3020
|
-
return monthPickerValues;
|
|
3021
|
-
};
|
|
3022
|
-
var yearPickerValues = function yearPickerValues() {
|
|
3023
|
-
var yearPickerValues = [];
|
|
3024
|
-
var base = currentYear - currentYear % 10;
|
|
3025
|
-
for (var i = 0; i < 10; i++) {
|
|
3026
|
-
yearPickerValues.push(base + i);
|
|
3027
|
-
}
|
|
3028
|
-
return yearPickerValues;
|
|
3029
|
-
};
|
|
3030
|
-
var createMonthYearView = function createMonthYearView() {
|
|
3031
|
-
var backwardNavigator = createBackwardNavigator(true);
|
|
3032
|
-
var forwardNavigator = createForwardNavigator(true);
|
|
3033
|
-
var yearElement = createTitleYearElement(getViewDate().getFullYear());
|
|
3034
|
-
var decade = createTitleDecadeElement();
|
|
3035
|
-
var groupContainerProps = mergeProps({
|
|
3036
|
-
className: cx('groupContainer')
|
|
3037
|
-
}, ptm('groupContainer'));
|
|
3038
|
-
var groupProps = mergeProps({
|
|
3039
|
-
className: cx('group')
|
|
3040
|
-
}, ptm('group'));
|
|
3041
|
-
var headerProps = mergeProps({
|
|
3042
|
-
className: cx('header')
|
|
3043
|
-
}, ptm('header'));
|
|
3044
|
-
var titleProps = mergeProps({
|
|
3045
|
-
className: cx('title')
|
|
3046
|
-
}, ptm('title'));
|
|
3047
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", groupContainerProps, /*#__PURE__*/React.createElement("div", groupProps, /*#__PURE__*/React.createElement("div", headerProps, backwardNavigator, /*#__PURE__*/React.createElement("div", titleProps, yearElement, decade), forwardNavigator))));
|
|
3048
|
-
};
|
|
3049
|
-
var createDatePicker = function createDatePicker() {
|
|
3050
|
-
if (!props.timeOnly) {
|
|
3051
|
-
if (props.view === 'date') {
|
|
3052
|
-
return createDateView();
|
|
3053
|
-
} else {
|
|
3054
|
-
return createMonthYearView();
|
|
3055
|
-
}
|
|
3056
|
-
}
|
|
3057
|
-
return null;
|
|
3058
|
-
};
|
|
3059
|
-
var incrementIconProps = mergeProps(ptm('incrementIcon'));
|
|
3060
|
-
var decrementIconProps = mergeProps(ptm('decrementIcon'));
|
|
3061
|
-
var incrementIcon = IconUtils.getJSXIcon(props.incrementIcon || /*#__PURE__*/React.createElement(ChevronUpIcon, incrementIconProps), _objectSpread({}, incrementIconProps), {
|
|
3062
|
-
props: props
|
|
3063
|
-
});
|
|
3064
|
-
var decrementIcon = IconUtils.getJSXIcon(props.decrementIcon || /*#__PURE__*/React.createElement(ChevronDownIcon, decrementIconProps), _objectSpread({}, decrementIconProps), {
|
|
3065
|
-
props: props
|
|
3066
|
-
});
|
|
3067
|
-
var createHourPicker = function createHourPicker() {
|
|
3068
|
-
var currentTime = getCurrentDateTime();
|
|
3069
|
-
var minute = doStepMinute(currentTime.getMinutes());
|
|
3070
|
-
var hour = currentTime.getHours();
|
|
3071
|
-
|
|
3072
|
-
// #3770 account for step minutes rolling to next hour
|
|
3073
|
-
hour = minute > 59 ? hour + 1 : hour;
|
|
3074
|
-
if (props.hourFormat === '12') {
|
|
3075
|
-
if (hour === 0) hour = 12;else if (hour > 11 && hour !== 12) hour = hour - 12;
|
|
3076
|
-
}
|
|
3077
|
-
var hourProps = mergeProps(ptm('hour'));
|
|
3078
|
-
var hourDisplay = hour < 10 ? '0' + hour : hour;
|
|
3079
|
-
var hourPickerProps = mergeProps({
|
|
3080
|
-
className: cx('hourPicker')
|
|
3081
|
-
}, ptm('hourPicker'));
|
|
3082
|
-
var incrementButtonProps = mergeProps({
|
|
3083
|
-
type: 'button',
|
|
3084
|
-
className: cx('incrementButton'),
|
|
3085
|
-
onMouseDown: function onMouseDown(e) {
|
|
3086
|
-
return onTimePickerElementMouseDown(e, 0, 1);
|
|
3087
|
-
},
|
|
3088
|
-
onMouseUp: onTimePickerElementMouseUp,
|
|
3089
|
-
onMouseLeave: onTimePickerElementMouseLeave,
|
|
3090
|
-
onKeyDown: function onKeyDown(e) {
|
|
3091
|
-
return onContainerButtonKeydown(e);
|
|
3092
|
-
}
|
|
3093
|
-
}, ptm('incrementButton'));
|
|
3094
|
-
var decrementButtonProps = mergeProps({
|
|
3095
|
-
type: 'button',
|
|
3096
|
-
className: cx('decrementButton'),
|
|
3097
|
-
onMouseDown: function onMouseDown(e) {
|
|
3098
|
-
return onTimePickerElementMouseDown(e, 0, -1);
|
|
3099
|
-
},
|
|
3100
|
-
onMouseUp: onTimePickerElementMouseUp,
|
|
3101
|
-
onMouseLeave: onTimePickerElementMouseLeave,
|
|
3102
|
-
onKeyDown: function onKeyDown(e) {
|
|
3103
|
-
return onContainerButtonKeydown(e);
|
|
3104
|
-
}
|
|
3105
|
-
}, ptm('decrementButton'));
|
|
3106
|
-
return /*#__PURE__*/React.createElement("div", hourPickerProps, /*#__PURE__*/React.createElement("button", incrementButtonProps, incrementIcon, /*#__PURE__*/React.createElement(Ripple, null)), /*#__PURE__*/React.createElement("span", hourProps, hourDisplay), /*#__PURE__*/React.createElement("button", decrementButtonProps, decrementIcon, /*#__PURE__*/React.createElement(Ripple, null)));
|
|
3107
|
-
};
|
|
3108
|
-
var createMinutePicker = function createMinutePicker() {
|
|
3109
|
-
var currentTime = getCurrentDateTime();
|
|
3110
|
-
var minute = doStepMinute(currentTime.getMinutes());
|
|
3111
|
-
minute = minute > 59 ? minute - 60 : minute;
|
|
3112
|
-
var minuteProps = mergeProps(ptm('minute'));
|
|
3113
|
-
var minuteDisplay = minute < 10 ? '0' + minute : minute;
|
|
3114
|
-
var minutePickerProps = mergeProps({
|
|
3115
|
-
className: cx('minutePicker')
|
|
3116
|
-
}, ptm('minutePicker'));
|
|
3117
|
-
var incrementButtonProps = mergeProps({
|
|
3118
|
-
type: 'button',
|
|
3119
|
-
className: cx('incrementButton'),
|
|
3120
|
-
onMouseDown: function onMouseDown(e) {
|
|
3121
|
-
return onTimePickerElementMouseDown(e, 1, 1);
|
|
3122
|
-
},
|
|
3123
|
-
onMouseUp: onTimePickerElementMouseUp,
|
|
3124
|
-
onMouseLeave: onTimePickerElementMouseLeave,
|
|
3125
|
-
onKeyDown: function onKeyDown(e) {
|
|
3126
|
-
return onContainerButtonKeydown(e);
|
|
3127
|
-
}
|
|
3128
|
-
}, ptm('incrementButton'));
|
|
3129
|
-
var decrementButtonProps = mergeProps({
|
|
3130
|
-
type: 'button',
|
|
3131
|
-
className: cx('decrementButton'),
|
|
3132
|
-
onMouseDown: function onMouseDown(e) {
|
|
3133
|
-
return onTimePickerElementMouseDown(e, 1, -1);
|
|
3134
|
-
},
|
|
3135
|
-
onMouseUp: onTimePickerElementMouseUp,
|
|
3136
|
-
onMouseLeave: onTimePickerElementMouseLeave,
|
|
3137
|
-
onKeyDown: function onKeyDown(e) {
|
|
3138
|
-
return onContainerButtonKeydown(e);
|
|
3139
|
-
}
|
|
3140
|
-
}, ptm('decrementButton'));
|
|
3141
|
-
return /*#__PURE__*/React.createElement("div", minutePickerProps, /*#__PURE__*/React.createElement("button", incrementButtonProps, incrementIcon, /*#__PURE__*/React.createElement(Ripple, null)), /*#__PURE__*/React.createElement("span", minuteProps, minuteDisplay), /*#__PURE__*/React.createElement("button", decrementButtonProps, decrementIcon, /*#__PURE__*/React.createElement(Ripple, null)));
|
|
3142
|
-
};
|
|
3143
|
-
var createSecondPicker = function createSecondPicker() {
|
|
3144
|
-
if (props.showSeconds) {
|
|
3145
|
-
var currentTime = getCurrentDateTime();
|
|
3146
|
-
var secondProps = mergeProps(ptm('second'));
|
|
3147
|
-
var second = currentTime.getSeconds();
|
|
3148
|
-
var secondDisplay = second < 10 ? '0' + second : second;
|
|
3149
|
-
var secondPickerProps = mergeProps({
|
|
3150
|
-
className: cx('secondPicker')
|
|
3151
|
-
}, ptm('secondPicker'));
|
|
3152
|
-
var incrementButtonProps = mergeProps({
|
|
3153
|
-
type: 'button',
|
|
3154
|
-
className: cx('incrementButton'),
|
|
3155
|
-
onMouseDown: function onMouseDown(e) {
|
|
3156
|
-
return onTimePickerElementMouseDown(e, 2, 1);
|
|
3157
|
-
},
|
|
3158
|
-
onMouseUp: onTimePickerElementMouseUp,
|
|
3159
|
-
onMouseLeave: onTimePickerElementMouseLeave,
|
|
3160
|
-
onKeyDown: function onKeyDown(e) {
|
|
3161
|
-
return onContainerButtonKeydown(e);
|
|
3162
|
-
}
|
|
3163
|
-
}, ptm('incrementButton'));
|
|
3164
|
-
var decrementButtonProps = mergeProps({
|
|
3165
|
-
type: 'button',
|
|
3166
|
-
className: cx('decrementButton'),
|
|
3167
|
-
onMouseDown: function onMouseDown(e) {
|
|
3168
|
-
return onTimePickerElementMouseDown(e, 2, -1);
|
|
3169
|
-
},
|
|
3170
|
-
onMouseUp: onTimePickerElementMouseUp,
|
|
3171
|
-
onMouseLeave: onTimePickerElementMouseLeave,
|
|
3172
|
-
onKeyDown: function onKeyDown(e) {
|
|
3173
|
-
return onContainerButtonKeydown(e);
|
|
3174
|
-
}
|
|
3175
|
-
}, ptm('decrementButton'));
|
|
3176
|
-
return /*#__PURE__*/React.createElement("div", secondPickerProps, /*#__PURE__*/React.createElement("button", incrementButtonProps, incrementIcon, /*#__PURE__*/React.createElement(Ripple, null)), /*#__PURE__*/React.createElement("span", secondProps, secondDisplay), /*#__PURE__*/React.createElement("button", decrementButtonProps, decrementIcon, /*#__PURE__*/React.createElement(Ripple, null)));
|
|
3177
|
-
}
|
|
3178
|
-
return null;
|
|
3179
|
-
};
|
|
3180
|
-
var createMiliSecondPicker = function createMiliSecondPicker() {
|
|
3181
|
-
if (props.showMillisec) {
|
|
3182
|
-
var currentTime = getCurrentDateTime();
|
|
3183
|
-
var millisecondProps = mergeProps(ptm('millisecond'));
|
|
3184
|
-
var millisecond = currentTime.getMilliseconds();
|
|
3185
|
-
var millisecondDisplay = millisecond < 100 ? (millisecond < 10 ? '00' : '0') + millisecond : millisecond;
|
|
3186
|
-
var millisecondPickerProps = mergeProps({
|
|
3187
|
-
className: cx('millisecondPicker')
|
|
3188
|
-
}, ptm('millisecondPicker'));
|
|
3189
|
-
var incrementButtonProps = mergeProps({
|
|
3190
|
-
type: 'button',
|
|
3191
|
-
className: cx('incrementButton'),
|
|
3192
|
-
onMouseDown: function onMouseDown(e) {
|
|
3193
|
-
return onTimePickerElementMouseDown(e, 3, 1);
|
|
3194
|
-
},
|
|
3195
|
-
onMouseUp: onTimePickerElementMouseUp,
|
|
3196
|
-
onMouseLeave: onTimePickerElementMouseLeave,
|
|
3197
|
-
onKeyDown: function onKeyDown(e) {
|
|
3198
|
-
return onContainerButtonKeydown(e);
|
|
3199
|
-
}
|
|
3200
|
-
}, ptm('incrementButton'));
|
|
3201
|
-
var decrementButtonProps = mergeProps({
|
|
3202
|
-
type: 'button',
|
|
3203
|
-
className: cx('decrementButton'),
|
|
3204
|
-
onMouseDown: function onMouseDown(e) {
|
|
3205
|
-
return onTimePickerElementMouseDown(e, 3, -1);
|
|
3206
|
-
},
|
|
3207
|
-
onMouseUp: onTimePickerElementMouseUp,
|
|
3208
|
-
onMouseLeave: onTimePickerElementMouseLeave,
|
|
3209
|
-
onKeyDown: function onKeyDown(e) {
|
|
3210
|
-
return onContainerButtonKeydown(e);
|
|
3211
|
-
}
|
|
3212
|
-
}, ptm('decrementButton'));
|
|
3213
|
-
return /*#__PURE__*/React.createElement("div", millisecondPickerProps, /*#__PURE__*/React.createElement("button", incrementButtonProps, incrementIcon, /*#__PURE__*/React.createElement(Ripple, null)), /*#__PURE__*/React.createElement("span", millisecondProps, millisecondDisplay), /*#__PURE__*/React.createElement("button", decrementButtonProps, decrementIcon, /*#__PURE__*/React.createElement(Ripple, null)));
|
|
3214
|
-
}
|
|
3215
|
-
return null;
|
|
3216
|
-
};
|
|
3217
|
-
var createAmPmPicker = function createAmPmPicker() {
|
|
3218
|
-
if (props.hourFormat === '12') {
|
|
3219
|
-
var currentTime = getCurrentDateTime();
|
|
3220
|
-
var hour = currentTime.getHours();
|
|
3221
|
-
var display = hour > 11 ? 'PM' : 'AM';
|
|
3222
|
-
var ampmProps = mergeProps(ptm('ampm'));
|
|
3223
|
-
var ampmPickerProps = mergeProps({
|
|
3224
|
-
className: cx('ampmPicker')
|
|
3225
|
-
}, ptm('ampmPicker'));
|
|
3226
|
-
var incrementButtonProps = mergeProps({
|
|
3227
|
-
type: 'button',
|
|
3228
|
-
className: cx('incrementButton'),
|
|
3229
|
-
onClick: function onClick(e) {
|
|
3230
|
-
return toggleAmPm(e);
|
|
3231
|
-
}
|
|
3232
|
-
}, ptm('incrementButton'));
|
|
3233
|
-
var decrementButtonProps = mergeProps({
|
|
3234
|
-
type: 'button',
|
|
3235
|
-
className: cx('decrementButton'),
|
|
3236
|
-
onClick: function onClick(e) {
|
|
3237
|
-
return toggleAmPm(e);
|
|
3238
|
-
}
|
|
3239
|
-
}, ptm('decrementButton'));
|
|
3240
|
-
return /*#__PURE__*/React.createElement("div", ampmPickerProps, /*#__PURE__*/React.createElement("button", incrementButtonProps, incrementIcon, /*#__PURE__*/React.createElement(Ripple, null)), /*#__PURE__*/React.createElement("span", ampmProps, display), /*#__PURE__*/React.createElement("button", decrementButtonProps, decrementIcon, /*#__PURE__*/React.createElement(Ripple, null)));
|
|
3241
|
-
}
|
|
3242
|
-
return null;
|
|
3243
|
-
};
|
|
3244
|
-
var createSeparator = function createSeparator(separator) {
|
|
3245
|
-
var separatorContainerProps = mergeProps({
|
|
3246
|
-
className: cx('separatorContainer')
|
|
3247
|
-
}, ptm('separatorContainer'));
|
|
3248
|
-
var separatorProps = mergeProps(ptm('separator'));
|
|
3249
|
-
return /*#__PURE__*/React.createElement("div", separatorContainerProps, /*#__PURE__*/React.createElement("span", separatorProps, separator));
|
|
3250
|
-
};
|
|
3251
|
-
var createTimePicker = function createTimePicker() {
|
|
3252
|
-
if ((props.showTime || props.timeOnly) && currentView === 'date') {
|
|
3253
|
-
var timePickerProps = mergeProps({
|
|
3254
|
-
className: cx('timePicker')
|
|
3255
|
-
}, ptm('timePicker'));
|
|
3256
|
-
return /*#__PURE__*/React.createElement("div", timePickerProps, createHourPicker(), createSeparator(':'), createMinutePicker(), props.showSeconds && createSeparator(':'), createSecondPicker(), props.showMillisec && createSeparator('.'), createMiliSecondPicker(), props.hourFormat === '12' && createSeparator(':'), createAmPmPicker());
|
|
3257
|
-
}
|
|
3258
|
-
return null;
|
|
3259
|
-
};
|
|
3260
|
-
var createInputElement = function createInputElement() {
|
|
3261
|
-
if (!props.inline) {
|
|
3262
|
-
return /*#__PURE__*/React.createElement(InputText, {
|
|
3263
|
-
ref: inputRef,
|
|
3264
|
-
id: props.inputId,
|
|
3265
|
-
name: props.name,
|
|
3266
|
-
type: "text",
|
|
3267
|
-
className: props.inputClassName,
|
|
3268
|
-
style: props.inputStyle,
|
|
3269
|
-
readOnly: props.readOnlyInput,
|
|
3270
|
-
disabled: props.disabled,
|
|
3271
|
-
required: props.required,
|
|
3272
|
-
autoComplete: "off",
|
|
3273
|
-
placeholder: props.placeholder,
|
|
3274
|
-
tabIndex: props.tabIndex,
|
|
3275
|
-
onInput: onUserInput,
|
|
3276
|
-
onFocus: onInputFocus,
|
|
3277
|
-
onBlur: onInputBlur,
|
|
3278
|
-
onKeyDown: onInputKeyDown,
|
|
3279
|
-
"aria-labelledby": props.ariaLabelledBy,
|
|
3280
|
-
inputMode: props.inputMode,
|
|
3281
|
-
tooltip: props.tooltip,
|
|
3282
|
-
tooltipOptions: props.tooltipOptions,
|
|
3283
|
-
pt: ptm('input'),
|
|
3284
|
-
__parentMetadata: {
|
|
3285
|
-
parent: metaData
|
|
3286
|
-
}
|
|
3287
|
-
});
|
|
3288
|
-
}
|
|
3289
|
-
return null;
|
|
3290
|
-
};
|
|
3291
|
-
var createButton = function createButton() {
|
|
3292
|
-
if (props.showIcon) {
|
|
3293
|
-
return /*#__PURE__*/React.createElement(Button, {
|
|
3294
|
-
type: "button",
|
|
3295
|
-
icon: props.icon || /*#__PURE__*/React.createElement(CalendarIcon, null),
|
|
3296
|
-
onClick: onButtonClick,
|
|
3297
|
-
tabIndex: "-1",
|
|
3298
|
-
disabled: props.disabled,
|
|
3299
|
-
className: cx('dropdownButton'),
|
|
3300
|
-
pt: ptm('dropdownButton'),
|
|
3301
|
-
__parentMetadata: {
|
|
3302
|
-
parent: metaData
|
|
3303
|
-
}
|
|
3304
|
-
});
|
|
3305
|
-
}
|
|
3306
|
-
return null;
|
|
3307
|
-
};
|
|
3308
|
-
var createContent = function createContent() {
|
|
3309
|
-
var input = createInputElement();
|
|
3310
|
-
var button = createButton();
|
|
3311
|
-
if (props.iconPos === 'left') {
|
|
3312
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, button, input);
|
|
3313
|
-
}
|
|
3314
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, input, button);
|
|
3315
|
-
};
|
|
3316
|
-
var createButtonBar = function createButtonBar() {
|
|
3317
|
-
if (props.showButtonBar) {
|
|
3318
|
-
var _localeOptions4 = localeOptions(props.locale),
|
|
3319
|
-
today = _localeOptions4.today,
|
|
3320
|
-
clear = _localeOptions4.clear;
|
|
3321
|
-
var buttonbarProps = mergeProps({
|
|
3322
|
-
className: cx('buttonbar')
|
|
3323
|
-
}, ptm('buttonbar'));
|
|
3324
|
-
return /*#__PURE__*/React.createElement("div", buttonbarProps, /*#__PURE__*/React.createElement(Button, {
|
|
3325
|
-
type: "button",
|
|
3326
|
-
label: today,
|
|
3327
|
-
onClick: onTodayButtonClick,
|
|
3328
|
-
onKeyDown: function onKeyDown(e) {
|
|
3329
|
-
return onContainerButtonKeydown(e);
|
|
3330
|
-
},
|
|
3331
|
-
className: classNames(props.todayButtonClassName, cx('todayButton')),
|
|
3332
|
-
pt: ptm('todayButton')
|
|
3333
|
-
}), /*#__PURE__*/React.createElement(Button, {
|
|
3334
|
-
type: "button",
|
|
3335
|
-
label: clear,
|
|
3336
|
-
onClick: onClearButtonClick,
|
|
3337
|
-
onKeyDown: function onKeyDown(e) {
|
|
3338
|
-
return onContainerButtonKeydown(e);
|
|
3339
|
-
},
|
|
3340
|
-
className: classNames(props.clearButtonClassName, cx('clearButton')),
|
|
3341
|
-
pt: ptm('clearButton')
|
|
3342
|
-
}));
|
|
3343
|
-
}
|
|
3344
|
-
return null;
|
|
3345
|
-
};
|
|
3346
|
-
var createFooter = function createFooter() {
|
|
3347
|
-
if (props.footerTemplate) {
|
|
3348
|
-
var _content3 = props.footerTemplate();
|
|
3349
|
-
var footerProps = mergeProps({
|
|
3350
|
-
className: cx('footer')
|
|
3351
|
-
}, ptm('footer'));
|
|
3352
|
-
return /*#__PURE__*/React.createElement("div", footerProps, _content3);
|
|
3353
|
-
}
|
|
3354
|
-
return null;
|
|
3355
|
-
};
|
|
3356
|
-
var createMonthPicker = function createMonthPicker() {
|
|
3357
|
-
if (currentView === 'month') {
|
|
3358
|
-
var monthPickerProps = mergeProps({
|
|
3359
|
-
className: cx('monthPicker')
|
|
3360
|
-
}, ptm('monthPicker'));
|
|
3361
|
-
return /*#__PURE__*/React.createElement("div", monthPickerProps, monthPickerValues().map(function (m, i) {
|
|
3362
|
-
var monthProps = mergeProps({
|
|
3363
|
-
className: cx('month', {
|
|
3364
|
-
isMonthSelected: isMonthSelected,
|
|
3365
|
-
isSelectable: isSelectable,
|
|
3366
|
-
i: i,
|
|
3367
|
-
currentYear: currentYear
|
|
3368
|
-
}),
|
|
3369
|
-
onClick: function onClick(event) {
|
|
3370
|
-
return onMonthSelect(event, i);
|
|
3371
|
-
},
|
|
3372
|
-
onKeyDown: function onKeyDown(event) {
|
|
3373
|
-
return onMonthCellKeydown(event, i);
|
|
3374
|
-
},
|
|
3375
|
-
'data-p-disabled': !m.selectable,
|
|
3376
|
-
'data-p-highlight': isMonthSelected(i)
|
|
3377
|
-
}, ptm('month', {
|
|
3378
|
-
context: {
|
|
3379
|
-
month: m,
|
|
3380
|
-
monthIndex: i,
|
|
3381
|
-
selected: isMonthSelected(i),
|
|
3382
|
-
disabled: !m.selectable
|
|
3383
|
-
}
|
|
3384
|
-
}));
|
|
3385
|
-
return /*#__PURE__*/React.createElement("span", _extends({}, monthProps, {
|
|
3386
|
-
key: "month".concat(i + 1)
|
|
3387
|
-
}), m);
|
|
3388
|
-
}));
|
|
3389
|
-
}
|
|
3390
|
-
return null;
|
|
3391
|
-
};
|
|
3392
|
-
var createYearPicker = function createYearPicker() {
|
|
3393
|
-
if (currentView === 'year') {
|
|
3394
|
-
var yearPickerProps = mergeProps({
|
|
3395
|
-
className: cx('yearPicker')
|
|
3396
|
-
}, ptm('yearPicker'));
|
|
3397
|
-
return /*#__PURE__*/React.createElement("div", yearPickerProps, yearPickerValues().map(function (y, i) {
|
|
3398
|
-
var yearProps = mergeProps({
|
|
3399
|
-
className: cx('year', {
|
|
3400
|
-
isYearSelected: isYearSelected,
|
|
3401
|
-
isSelectable: isSelectable,
|
|
3402
|
-
y: y
|
|
3403
|
-
}),
|
|
3404
|
-
onClick: function onClick(event) {
|
|
3405
|
-
return onYearSelect(event, y);
|
|
3406
|
-
},
|
|
3407
|
-
'data-p-highlight': isYearSelected(y),
|
|
3408
|
-
'data-p-disabled': !isSelectable(0, -1, y)
|
|
3409
|
-
}, ptm('year', {
|
|
3410
|
-
context: {
|
|
3411
|
-
year: y,
|
|
3412
|
-
yearIndex: i,
|
|
3413
|
-
selected: isYearSelected(i),
|
|
3414
|
-
disabled: !y.selectable
|
|
3415
|
-
}
|
|
3416
|
-
}));
|
|
3417
|
-
return /*#__PURE__*/React.createElement("span", _extends({}, yearProps, {
|
|
3418
|
-
key: "year".concat(i + 1)
|
|
3419
|
-
}), y);
|
|
3420
|
-
}));
|
|
3421
|
-
}
|
|
3422
|
-
return null;
|
|
3423
|
-
};
|
|
3424
|
-
var panelClassName = classNames('p-datepicker p-component', props.panelClassName, {
|
|
3425
|
-
'p-datepicker-inline': props.inline,
|
|
3426
|
-
'p-disabled': props.disabled,
|
|
3427
|
-
'p-datepicker-timeonly': props.timeOnly,
|
|
3428
|
-
'p-datepicker-multiple-month': props.numberOfMonths > 1,
|
|
3429
|
-
'p-datepicker-monthpicker': currentView === 'month',
|
|
3430
|
-
'p-datepicker-touch-ui': props.touchUI,
|
|
3431
|
-
'p-input-filled': context && context.inputStyle === 'filled' || PrimeReact.inputStyle === 'filled',
|
|
3432
|
-
'p-ripple-disabled': context && context.ripple === false || PrimeReact.ripple === false
|
|
3433
|
-
});
|
|
3434
|
-
var content = createContent();
|
|
3435
|
-
var datePicker = createDatePicker();
|
|
3436
|
-
var timePicker = createTimePicker();
|
|
3437
|
-
var buttonBar = createButtonBar();
|
|
3438
|
-
var footer = createFooter();
|
|
3439
|
-
var monthPicker = createMonthPicker();
|
|
3440
|
-
var yearPicker = createYearPicker();
|
|
3441
|
-
var isFilled = DomHandler.hasClass(inputRef.current, 'p-filled') && inputRef.current.value !== '';
|
|
3442
|
-
var rootProps = mergeProps({
|
|
3443
|
-
id: props.id,
|
|
3444
|
-
className: classNames(props.className, cx('root', {
|
|
3445
|
-
focusedState: focusedState,
|
|
3446
|
-
isFilled: isFilled
|
|
3447
|
-
})),
|
|
3448
|
-
style: props.style
|
|
3449
|
-
}, CalendarBase.getOtherProps(props), ptm('root'));
|
|
3450
|
-
return /*#__PURE__*/React.createElement("span", _extends({
|
|
3451
|
-
ref: elementRef
|
|
3452
|
-
}, rootProps), content, /*#__PURE__*/React.createElement(CalendarPanel, {
|
|
3453
|
-
hostName: "Calendar",
|
|
3454
|
-
ref: overlayRef,
|
|
3455
|
-
className: panelClassName,
|
|
3456
|
-
style: props.panelStyle,
|
|
3457
|
-
appendTo: props.appendTo,
|
|
3458
|
-
inline: props.inline,
|
|
3459
|
-
onClick: onPanelClick,
|
|
3460
|
-
onMouseUp: onPanelMouseUp,
|
|
3461
|
-
"in": visible,
|
|
3462
|
-
onEnter: onOverlayEnter,
|
|
3463
|
-
onEntered: onOverlayEntered,
|
|
3464
|
-
onExit: onOverlayExit,
|
|
3465
|
-
onExited: onOverlayExited,
|
|
3466
|
-
transitionOptions: props.transitionOptions,
|
|
3467
|
-
ptm: ptm,
|
|
3468
|
-
cx: cx
|
|
3469
|
-
}, datePicker, timePicker, monthPicker, yearPicker, buttonBar, footer));
|
|
3470
|
-
}));
|
|
3471
|
-
Calendar.displayName = 'Calendar';
|
|
3472
|
-
|
|
3473
|
-
export { Calendar };
|