@gpa-gemstone/react-forms 1.1.59 → 1.1.61

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.
Files changed (47) hide show
  1. package/lib/ArrayCheckBoxes.d.ts +33 -11
  2. package/lib/ArrayCheckBoxes.js +81 -79
  3. package/lib/ArrayMultiSelect.d.ts +47 -13
  4. package/lib/ArrayMultiSelect.js +49 -47
  5. package/lib/CheckBox.d.ts +37 -11
  6. package/lib/CheckBox.js +62 -60
  7. package/lib/ColorPicker.d.ts +59 -15
  8. package/lib/ColorPicker.js +114 -114
  9. package/lib/DatePicker.d.ts +23 -21
  10. package/lib/DatePicker.js +221 -214
  11. package/lib/DateRangePicker.d.ts +64 -13
  12. package/lib/DateRangePicker.js +143 -132
  13. package/lib/DateTimeUI/Calender.d.ts +7 -8
  14. package/lib/DateTimeUI/Calender.js +180 -180
  15. package/lib/DateTimeUI/Clock.d.ts +9 -10
  16. package/lib/DateTimeUI/Clock.js +153 -153
  17. package/lib/DateTimeUI/DateTimePopup.d.ts +16 -17
  18. package/lib/DateTimeUI/DateTimePopup.js +59 -59
  19. package/lib/DoubleInput.d.ts +58 -12
  20. package/lib/DoubleInput.js +55 -51
  21. package/lib/EnumCheckBoxes.d.ts +41 -9
  22. package/lib/EnumCheckBoxes.js +65 -58
  23. package/lib/HelperMessage.d.ts +37 -10
  24. package/lib/HelperMessage.js +93 -83
  25. package/lib/Input.d.ts +80 -18
  26. package/lib/Input.js +111 -106
  27. package/lib/InputWithButton.d.ts +109 -23
  28. package/lib/InputWithButton.js +107 -107
  29. package/lib/MutliCheckBoxSelect.d.ts +42 -18
  30. package/lib/MutliCheckBoxSelect.js +110 -104
  31. package/lib/RadioButtons.d.ts +15 -0
  32. package/lib/RadioButtons.js +62 -0
  33. package/lib/SearchableSelect.d.ts +60 -18
  34. package/lib/SearchableSelect.js +84 -85
  35. package/lib/Select.d.ts +57 -17
  36. package/lib/Select.js +84 -80
  37. package/lib/StylableSelect.d.ts +53 -17
  38. package/lib/StylableSelect.js +106 -100
  39. package/lib/TextArea.d.ts +54 -14
  40. package/lib/TextArea.js +76 -72
  41. package/lib/TimePicker.d.ts +50 -11
  42. package/lib/TimePicker.js +60 -51
  43. package/lib/ToggleSwitch.d.ts +44 -12
  44. package/lib/ToggleSwitch.js +57 -61
  45. package/lib/index.d.ts +19 -18
  46. package/lib/index.js +61 -59
  47. package/package.json +4 -3
@@ -1,180 +1,180 @@
1
- "use strict";
2
- // ******************************************************************************************************
3
- // Calender.tsx - Gbtc
4
- //
5
- // Copyright © 2020, Grid Protection Alliance. All Rights Reserved.
6
- //
7
- // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
8
- // the NOTICE file distributed with this work for additional information regarding copyright ownership.
9
- // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
10
- // file except in compliance with the License. You may obtain a copy of the License at:
11
- //
12
- // http://opensource.org/licenses/MIT
13
- //
14
- // Unless agreed to in writing, the subject software distributed under the License is distributed on an
15
- // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
16
- // License for the specific language governing permissions and limitations.
17
- //
18
- // Code Modification History:
19
- // ----------------------------------------------------------------------------------------------------
20
- // 05/15/2023 - C. Lackner
21
- // Generated original version of source code.
22
- //
23
- // ******************************************************************************************************
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- var React = require("react");
26
- var moment = require("moment");
27
- function Calender(props) {
28
- var _a, _b, _c, _d;
29
- var _e = React.useState([]), weeks = _e[0], setWeeks = _e[1];
30
- var _f = React.useState((_b = (_a = props.DateTime) === null || _a === void 0 ? void 0 : _a.month()) !== null && _b !== void 0 ? _b : 0), month = _f[0], setMonth = _f[1];
31
- var _g = React.useState((_d = (_c = props.DateTime) === null || _c === void 0 ? void 0 : _c.year()) !== null && _d !== void 0 ? _d : moment.utc().year()), year = _g[0], setYear = _g[1];
32
- var _h = React.useState('month'), mode = _h[0], setMode = _h[1];
33
- var _j = React.useState('None'), hover = _j[0], setHover = _j[1];
34
- React.useEffect(function () {
35
- var _a, _b, _c, _d, _e, _f, _g, _h;
36
- setMonth(isNaN((_b = (_a = props.DateTime) === null || _a === void 0 ? void 0 : _a.month()) !== null && _b !== void 0 ? _b : NaN) ? 0 : ((_d = (_c = props.DateTime) === null || _c === void 0 ? void 0 : _c.month()) !== null && _d !== void 0 ? _d : 0));
37
- setYear(isNaN((_f = (_e = props.DateTime) === null || _e === void 0 ? void 0 : _e.year()) !== null && _f !== void 0 ? _f : NaN) ? moment.utc().year() : ((_h = (_g = props.DateTime) === null || _g === void 0 ? void 0 : _g.year()) !== null && _h !== void 0 ? _h : moment.utc().year()));
38
- }, [props.DateTime]);
39
- React.useEffect(function () {
40
- var d1 = moment([year, month, 1]).startOf('week');
41
- var w = [];
42
- while ((d1.month() <= month && d1.year() === year) || (d1.year() < year)) {
43
- w.push({
44
- sunday: moment(d1),
45
- monday: moment(d1).add(1, 'day'),
46
- tuesday: moment(d1).add(2, 'day'),
47
- wednesday: moment(d1).add(3, 'day'),
48
- thursday: moment(d1).add(4, 'day'),
49
- friday: moment(d1).add(5, 'day'),
50
- saturday: moment(d1).add(6, 'day')
51
- });
52
- d1.add(1, 'week');
53
- d1 = moment(d1).startOf('week');
54
- }
55
- setWeeks(w);
56
- }, [month, year]);
57
- function toNext() {
58
- if (mode === 'month' && month === 11) {
59
- setMonth(0);
60
- setYear(function (y) { return y + 1; });
61
- }
62
- else if (mode === 'month') {
63
- setMonth(function (m) { return m + 1; });
64
- }
65
- else if (mode === 'year') {
66
- setYear(function (y) { return y + 1; });
67
- }
68
- else {
69
- setYear(function (y) { return y + 12; });
70
- }
71
- }
72
- function toPrev() {
73
- if (mode === 'month' && month === 0) {
74
- setMonth(11);
75
- setYear(function (y) { return y - 1; });
76
- }
77
- else if (mode === 'month') {
78
- setMonth(function (m) { return m - 1; });
79
- }
80
- else if (mode === 'year') {
81
- setYear(function (y) { return y - 1; });
82
- }
83
- else {
84
- setYear(function (y) { return y - 12; });
85
- }
86
- }
87
- function setDate(d) {
88
- var ud = moment(props.DateTime);
89
- if (!ud.isValid())
90
- ud = moment.utc().startOf('d');
91
- ud.year(d.year()).month(d.month()).date(d.date());
92
- props.Setter(ud);
93
- }
94
- var headerWidth = (mode === 'month' ? 5 : 2);
95
- return (React.createElement("div", { style: { background: '#f0f0f0', opacity: 1 } },
96
- React.createElement("table", { style: { textAlign: 'center' } },
97
- React.createElement("thead", { style: { verticalAlign: 'middle', fontWeight: 'bold' } },
98
- React.createElement("tr", { style: { height: 20, lineHeight: '20px' } },
99
- React.createElement("th", { style: { width: 20, padding: 5, cursor: 'pointer' }, onMouseEnter: function () { return setHover('Previous'); }, onMouseLeave: function () { return setHover('None'); }, onClick: toPrev }, '<'),
100
- React.createElement("th", { style: { width: 145, padding: 5, cursor: 'pointer' }, colSpan: headerWidth, onClick: function (evt) {
101
- evt.stopPropagation();
102
- if (mode === 'month')
103
- setMode('year');
104
- }, onMouseEnter: function () { return setHover('Center'); }, onMouseLeave: function () { return setHover('None'); } },
105
- mode === 'month' ? moment([year, month, 1]).format('MMMM YYYY') : '',
106
- mode === 'year' ? year : '',
107
- mode === 'dozenYear' ? year - 6 + "-" + (year + 5) : ''),
108
- React.createElement("th", { style: { width: 20, padding: 5, cursor: 'pointer' }, onClick: toNext, onMouseEnter: function () { return setHover('Next'); }, onMouseLeave: function () { return setHover('None'); } }, '>')),
109
- mode === 'month' ? React.createElement("tr", { style: { height: 20, lineHeight: '20px' } },
110
- React.createElement("td", { style: { width: 20, padding: 5 } }, "SU"),
111
- React.createElement("td", { style: { width: 20, padding: 5 } }, "MO"),
112
- React.createElement("td", { style: { width: 20, padding: 5 } }, "TU"),
113
- React.createElement("td", { style: { width: 20, padding: 5 } }, "WE"),
114
- React.createElement("td", { style: { width: 20, padding: 5 } }, "TH"),
115
- React.createElement("td", { style: { width: 20, padding: 5 } }, "FR"),
116
- React.createElement("td", { style: { width: 20, padding: 5 } }, "SA")) : null),
117
- React.createElement("tbody", null,
118
- mode === 'month' ? weeks.map(function (w) {
119
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
120
- return React.createElement("tr", { key: w.sunday.isoWeek(), style: { height: 20, lineHeight: '20px' } },
121
- React.createElement(DayCell, { date: w.sunday, month: month, day: (_b = (_a = props.DateTime) === null || _a === void 0 ? void 0 : _a.date()) !== null && _b !== void 0 ? _b : -1, onClick: function (evt) { evt.stopPropagation(); setDate(w.sunday); } }),
122
- React.createElement(DayCell, { date: w.monday, month: month, day: (_d = (_c = props.DateTime) === null || _c === void 0 ? void 0 : _c.date()) !== null && _d !== void 0 ? _d : -1, onClick: function (evt) { evt.stopPropagation(); setDate(w.monday); } }),
123
- React.createElement(DayCell, { date: w.tuesday, month: month, day: (_f = (_e = props.DateTime) === null || _e === void 0 ? void 0 : _e.date()) !== null && _f !== void 0 ? _f : -1, onClick: function (evt) { evt.stopPropagation(); setDate(w.tuesday); } }),
124
- React.createElement(DayCell, { date: w.wednesday, month: month, day: (_h = (_g = props.DateTime) === null || _g === void 0 ? void 0 : _g.date()) !== null && _h !== void 0 ? _h : -1, onClick: function (evt) { evt.stopPropagation(); setDate(w.wednesday); } }),
125
- React.createElement(DayCell, { date: w.thursday, month: month, day: (_k = (_j = props.DateTime) === null || _j === void 0 ? void 0 : _j.date()) !== null && _k !== void 0 ? _k : -1, onClick: function (evt) { evt.stopPropagation(); setDate(w.thursday); } }),
126
- React.createElement(DayCell, { date: w.friday, month: month, day: (_m = (_l = props.DateTime) === null || _l === void 0 ? void 0 : _l.date()) !== null && _m !== void 0 ? _m : -1, onClick: function (evt) { evt.stopPropagation(); setDate(w.friday); } }),
127
- React.createElement(DayCell, { date: w.saturday, month: month, day: (_p = (_o = props.DateTime) === null || _o === void 0 ? void 0 : _o.date()) !== null && _p !== void 0 ? _p : -1, onClick: function (evt) { evt.stopPropagation(); setDate(w.saturday); } }));
128
- }) : null,
129
- mode === 'year' ? React.createElement(React.Fragment, null,
130
- React.createElement("tr", { style: { height: 54, lineHeight: '54px' } },
131
- React.createElement(MonthCell, { date: moment([year, 0, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(0); } }),
132
- React.createElement(MonthCell, { date: moment([year, 1, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(1); } }),
133
- React.createElement(MonthCell, { date: moment([year, 2, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(2); } }),
134
- React.createElement(MonthCell, { date: moment([year, 3, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(3); } })),
135
- React.createElement("tr", { style: { height: 54, lineHeight: '54px' } },
136
- React.createElement(MonthCell, { date: moment([year, 4, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(4); } }),
137
- React.createElement(MonthCell, { date: moment([year, 5, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(5); } }),
138
- React.createElement(MonthCell, { date: moment([year, 6, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(6); } }),
139
- React.createElement(MonthCell, { date: moment([year, 7, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(7); } })),
140
- React.createElement("tr", { style: { height: 54, lineHeight: '54px' } },
141
- React.createElement(MonthCell, { date: moment([year, 8, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(8); } }),
142
- React.createElement(MonthCell, { date: moment([year, 9, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(9); } }),
143
- React.createElement(MonthCell, { date: moment([year, 10, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(10); } }),
144
- React.createElement(MonthCell, { date: moment([year, 11, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(11); } }))) : null))));
145
- }
146
- exports.default = Calender;
147
- var DayCell = function (props) {
148
- var _a = React.useState(false), active = _a[0], setActive = _a[1];
149
- var _b = React.useState(false), hover = _b[0], setHover = _b[1];
150
- var _c = React.useState(false), disabled = _c[0], setDisabled = _c[1];
151
- React.useEffect(function () {
152
- setActive(props.date.date() === props.day && props.month === props.date.month());
153
- setDisabled(props.date.month() !== props.month);
154
- }, [props.month, props.date, props.day]);
155
- var color = (disabled ? '#777' : (active ? '#fff' : undefined));
156
- var bg = (active ? '#337ab7' : hover ? '#d3d3d3' : undefined);
157
- return React.createElement("td", { style: {
158
- width: 20,
159
- padding: 5,
160
- color: color,
161
- backgroundColor: bg,
162
- cursor: (!active ? 'pointer' : 'default')
163
- }, onClick: props.onClick, onMouseEnter: function () { return setHover(true); }, onMouseLeave: function () { return setHover(false); } }, props.date.format("DD"));
164
- };
165
- var MonthCell = function (props) {
166
- var _a = React.useState(false), active = _a[0], setActive = _a[1];
167
- var _b = React.useState(false), hover = _b[0], setHover = _b[1];
168
- React.useEffect(function () {
169
- setActive(props.date.month() === props.month);
170
- }, [props.month, props.date]);
171
- var color = (active ? '#fff' : undefined);
172
- var bg = (active ? '#337ab7' : hover ? '#d3d3d3' : undefined);
173
- return React.createElement("td", { style: {
174
- width: 54,
175
- padding: 5,
176
- color: color,
177
- backgroundColor: bg,
178
- cursor: (!active ? 'pointer' : 'default')
179
- }, onMouseEnter: function () { return setHover(true); }, onMouseLeave: function () { return setHover(false); }, onClick: props.onClick }, props.date.format("MMM"));
180
- };
1
+ "use strict";
2
+ // ******************************************************************************************************
3
+ // Calender.tsx - Gbtc
4
+ //
5
+ // Copyright © 2020, Grid Protection Alliance. All Rights Reserved.
6
+ //
7
+ // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
8
+ // the NOTICE file distributed with this work for additional information regarding copyright ownership.
9
+ // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
10
+ // file except in compliance with the License. You may obtain a copy of the License at:
11
+ //
12
+ // http://opensource.org/licenses/MIT
13
+ //
14
+ // Unless agreed to in writing, the subject software distributed under the License is distributed on an
15
+ // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
16
+ // License for the specific language governing permissions and limitations.
17
+ //
18
+ // Code Modification History:
19
+ // ----------------------------------------------------------------------------------------------------
20
+ // 05/15/2023 - C. Lackner
21
+ // Generated original version of source code.
22
+ //
23
+ // ******************************************************************************************************
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.default = Calender;
26
+ var React = require("react");
27
+ var moment = require("moment");
28
+ function Calender(props) {
29
+ var _a, _b, _c, _d;
30
+ var _e = React.useState([]), weeks = _e[0], setWeeks = _e[1];
31
+ var _f = React.useState((_b = (_a = props.DateTime) === null || _a === void 0 ? void 0 : _a.month()) !== null && _b !== void 0 ? _b : 0), month = _f[0], setMonth = _f[1];
32
+ var _g = React.useState((_d = (_c = props.DateTime) === null || _c === void 0 ? void 0 : _c.year()) !== null && _d !== void 0 ? _d : moment.utc().year()), year = _g[0], setYear = _g[1];
33
+ var _h = React.useState('month'), mode = _h[0], setMode = _h[1];
34
+ var _j = React.useState('None'), hover = _j[0], setHover = _j[1];
35
+ React.useEffect(function () {
36
+ var _a, _b, _c, _d, _e, _f, _g, _h;
37
+ setMonth(isNaN((_b = (_a = props.DateTime) === null || _a === void 0 ? void 0 : _a.month()) !== null && _b !== void 0 ? _b : NaN) ? 0 : ((_d = (_c = props.DateTime) === null || _c === void 0 ? void 0 : _c.month()) !== null && _d !== void 0 ? _d : 0));
38
+ setYear(isNaN((_f = (_e = props.DateTime) === null || _e === void 0 ? void 0 : _e.year()) !== null && _f !== void 0 ? _f : NaN) ? moment.utc().year() : ((_h = (_g = props.DateTime) === null || _g === void 0 ? void 0 : _g.year()) !== null && _h !== void 0 ? _h : moment.utc().year()));
39
+ }, [props.DateTime]);
40
+ React.useEffect(function () {
41
+ var d1 = moment([year, month, 1]).startOf('week');
42
+ var w = [];
43
+ while ((d1.month() <= month && d1.year() === year) || (d1.year() < year)) {
44
+ w.push({
45
+ sunday: moment(d1),
46
+ monday: moment(d1).add(1, 'day'),
47
+ tuesday: moment(d1).add(2, 'day'),
48
+ wednesday: moment(d1).add(3, 'day'),
49
+ thursday: moment(d1).add(4, 'day'),
50
+ friday: moment(d1).add(5, 'day'),
51
+ saturday: moment(d1).add(6, 'day')
52
+ });
53
+ d1.add(1, 'week');
54
+ d1 = moment(d1).startOf('week');
55
+ }
56
+ setWeeks(w);
57
+ }, [month, year]);
58
+ function toNext() {
59
+ if (mode === 'month' && month === 11) {
60
+ setMonth(0);
61
+ setYear(function (y) { return y + 1; });
62
+ }
63
+ else if (mode === 'month') {
64
+ setMonth(function (m) { return m + 1; });
65
+ }
66
+ else if (mode === 'year') {
67
+ setYear(function (y) { return y + 1; });
68
+ }
69
+ else {
70
+ setYear(function (y) { return y + 12; });
71
+ }
72
+ }
73
+ function toPrev() {
74
+ if (mode === 'month' && month === 0) {
75
+ setMonth(11);
76
+ setYear(function (y) { return y - 1; });
77
+ }
78
+ else if (mode === 'month') {
79
+ setMonth(function (m) { return m - 1; });
80
+ }
81
+ else if (mode === 'year') {
82
+ setYear(function (y) { return y - 1; });
83
+ }
84
+ else {
85
+ setYear(function (y) { return y - 12; });
86
+ }
87
+ }
88
+ function setDate(d) {
89
+ var ud = moment(props.DateTime);
90
+ if (!ud.isValid())
91
+ ud = moment.utc().startOf('d');
92
+ ud.year(d.year()).month(d.month()).date(d.date());
93
+ props.Setter(ud);
94
+ }
95
+ var headerWidth = (mode === 'month' ? 5 : 2);
96
+ return (React.createElement("div", { style: { background: '#f0f0f0', opacity: 1 } },
97
+ React.createElement("table", { style: { textAlign: 'center' } },
98
+ React.createElement("thead", { style: { verticalAlign: 'middle', fontWeight: 'bold' } },
99
+ React.createElement("tr", { style: { height: 20, lineHeight: '20px' } },
100
+ React.createElement("th", { style: { width: 20, padding: 5, cursor: 'pointer' }, onMouseEnter: function () { return setHover('Previous'); }, onMouseLeave: function () { return setHover('None'); }, onClick: toPrev }, '<'),
101
+ React.createElement("th", { style: { width: 145, padding: 5, cursor: 'pointer' }, colSpan: headerWidth, onClick: function (evt) {
102
+ evt.stopPropagation();
103
+ if (mode === 'month')
104
+ setMode('year');
105
+ }, onMouseEnter: function () { return setHover('Center'); }, onMouseLeave: function () { return setHover('None'); } },
106
+ mode === 'month' ? moment([year, month, 1]).format('MMMM YYYY') : '',
107
+ mode === 'year' ? year : '',
108
+ mode === 'dozenYear' ? "".concat(year - 6, "-").concat(year + 5) : ''),
109
+ React.createElement("th", { style: { width: 20, padding: 5, cursor: 'pointer' }, onClick: toNext, onMouseEnter: function () { return setHover('Next'); }, onMouseLeave: function () { return setHover('None'); } }, '>')),
110
+ mode === 'month' ? React.createElement("tr", { style: { height: 20, lineHeight: '20px' } },
111
+ React.createElement("td", { style: { width: 20, padding: 5 } }, "SU"),
112
+ React.createElement("td", { style: { width: 20, padding: 5 } }, "MO"),
113
+ React.createElement("td", { style: { width: 20, padding: 5 } }, "TU"),
114
+ React.createElement("td", { style: { width: 20, padding: 5 } }, "WE"),
115
+ React.createElement("td", { style: { width: 20, padding: 5 } }, "TH"),
116
+ React.createElement("td", { style: { width: 20, padding: 5 } }, "FR"),
117
+ React.createElement("td", { style: { width: 20, padding: 5 } }, "SA")) : null),
118
+ React.createElement("tbody", null,
119
+ mode === 'month' ? weeks.map(function (w) {
120
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
121
+ return React.createElement("tr", { key: w.sunday.isoWeek(), style: { height: 20, lineHeight: '20px' } },
122
+ React.createElement(DayCell, { date: w.sunday, month: month, day: (_b = (_a = props.DateTime) === null || _a === void 0 ? void 0 : _a.date()) !== null && _b !== void 0 ? _b : -1, onClick: function (evt) { evt.stopPropagation(); setDate(w.sunday); } }),
123
+ React.createElement(DayCell, { date: w.monday, month: month, day: (_d = (_c = props.DateTime) === null || _c === void 0 ? void 0 : _c.date()) !== null && _d !== void 0 ? _d : -1, onClick: function (evt) { evt.stopPropagation(); setDate(w.monday); } }),
124
+ React.createElement(DayCell, { date: w.tuesday, month: month, day: (_f = (_e = props.DateTime) === null || _e === void 0 ? void 0 : _e.date()) !== null && _f !== void 0 ? _f : -1, onClick: function (evt) { evt.stopPropagation(); setDate(w.tuesday); } }),
125
+ React.createElement(DayCell, { date: w.wednesday, month: month, day: (_h = (_g = props.DateTime) === null || _g === void 0 ? void 0 : _g.date()) !== null && _h !== void 0 ? _h : -1, onClick: function (evt) { evt.stopPropagation(); setDate(w.wednesday); } }),
126
+ React.createElement(DayCell, { date: w.thursday, month: month, day: (_k = (_j = props.DateTime) === null || _j === void 0 ? void 0 : _j.date()) !== null && _k !== void 0 ? _k : -1, onClick: function (evt) { evt.stopPropagation(); setDate(w.thursday); } }),
127
+ React.createElement(DayCell, { date: w.friday, month: month, day: (_m = (_l = props.DateTime) === null || _l === void 0 ? void 0 : _l.date()) !== null && _m !== void 0 ? _m : -1, onClick: function (evt) { evt.stopPropagation(); setDate(w.friday); } }),
128
+ React.createElement(DayCell, { date: w.saturday, month: month, day: (_p = (_o = props.DateTime) === null || _o === void 0 ? void 0 : _o.date()) !== null && _p !== void 0 ? _p : -1, onClick: function (evt) { evt.stopPropagation(); setDate(w.saturday); } }));
129
+ }) : null,
130
+ mode === 'year' ? React.createElement(React.Fragment, null,
131
+ React.createElement("tr", { style: { height: 54, lineHeight: '54px' } },
132
+ React.createElement(MonthCell, { date: moment([year, 0, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(0); } }),
133
+ React.createElement(MonthCell, { date: moment([year, 1, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(1); } }),
134
+ React.createElement(MonthCell, { date: moment([year, 2, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(2); } }),
135
+ React.createElement(MonthCell, { date: moment([year, 3, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(3); } })),
136
+ React.createElement("tr", { style: { height: 54, lineHeight: '54px' } },
137
+ React.createElement(MonthCell, { date: moment([year, 4, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(4); } }),
138
+ React.createElement(MonthCell, { date: moment([year, 5, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(5); } }),
139
+ React.createElement(MonthCell, { date: moment([year, 6, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(6); } }),
140
+ React.createElement(MonthCell, { date: moment([year, 7, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(7); } })),
141
+ React.createElement("tr", { style: { height: 54, lineHeight: '54px' } },
142
+ React.createElement(MonthCell, { date: moment([year, 8, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(8); } }),
143
+ React.createElement(MonthCell, { date: moment([year, 9, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(9); } }),
144
+ React.createElement(MonthCell, { date: moment([year, 10, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(10); } }),
145
+ React.createElement(MonthCell, { date: moment([year, 11, 1]), month: month, onClick: function (evt) { evt.stopPropagation(); setMode('month'); setMonth(11); } }))) : null))));
146
+ }
147
+ var DayCell = function (props) {
148
+ var _a = React.useState(false), active = _a[0], setActive = _a[1];
149
+ var _b = React.useState(false), hover = _b[0], setHover = _b[1];
150
+ var _c = React.useState(false), disabled = _c[0], setDisabled = _c[1];
151
+ React.useEffect(function () {
152
+ setActive(props.date.date() === props.day && props.month === props.date.month());
153
+ setDisabled(props.date.month() !== props.month);
154
+ }, [props.month, props.date, props.day]);
155
+ var color = (disabled ? '#777' : (active ? '#fff' : undefined));
156
+ var bg = (active ? '#337ab7' : hover ? '#d3d3d3' : undefined);
157
+ return React.createElement("td", { style: {
158
+ width: 20,
159
+ padding: 5,
160
+ color: color,
161
+ backgroundColor: bg,
162
+ cursor: (!active ? 'pointer' : 'default')
163
+ }, onClick: props.onClick, onMouseEnter: function () { return setHover(true); }, onMouseLeave: function () { return setHover(false); } }, props.date.format("DD"));
164
+ };
165
+ var MonthCell = function (props) {
166
+ var _a = React.useState(false), active = _a[0], setActive = _a[1];
167
+ var _b = React.useState(false), hover = _b[0], setHover = _b[1];
168
+ React.useEffect(function () {
169
+ setActive(props.date.month() === props.month);
170
+ }, [props.month, props.date]);
171
+ var color = (active ? '#fff' : undefined);
172
+ var bg = (active ? '#337ab7' : hover ? '#d3d3d3' : undefined);
173
+ return React.createElement("td", { style: {
174
+ width: 54,
175
+ padding: 5,
176
+ color: color,
177
+ backgroundColor: bg,
178
+ cursor: (!active ? 'pointer' : 'default')
179
+ }, onMouseEnter: function () { return setHover(true); }, onMouseLeave: function () { return setHover(false); }, onClick: props.onClick }, props.date.format("MMM"));
180
+ };
@@ -1,10 +1,9 @@
1
- /// <reference types="react" />
2
- import * as moment from 'moment';
3
- interface IProps {
4
- DateTime: moment.Moment | undefined;
5
- Setter: (record: moment.Moment) => void;
6
- Accuracy?: Accuracy;
7
- }
8
- export declare type Accuracy = ('minute' | 'second' | 'millisecond');
9
- export default function Clock(props: IProps): JSX.Element;
10
- export {};
1
+ import * as moment from 'moment';
2
+ interface IProps {
3
+ DateTime: moment.Moment | undefined;
4
+ Setter: (record: moment.Moment) => void;
5
+ Accuracy?: Accuracy;
6
+ }
7
+ export type Accuracy = ('minute' | 'second' | 'millisecond');
8
+ export default function Clock(props: IProps): JSX.Element;
9
+ export {};