@gpa-gemstone/react-forms 1.1.60 → 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 -101
  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
package/lib/DatePicker.js CHANGED
@@ -1,214 +1,221 @@
1
- "use strict";
2
- // ******************************************************************************************************
3
- // DatePicker.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
- // 02/05/2020 - Billy Ernest
21
- // Generated original version of source code.
22
- //
23
- // ******************************************************************************************************
24
- var __assign = (this && this.__assign) || function () {
25
- __assign = Object.assign || function(t) {
26
- for (var s, i = 1, n = arguments.length; i < n; i++) {
27
- s = arguments[i];
28
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
29
- t[p] = s[p];
30
- }
31
- return t;
32
- };
33
- return __assign.apply(this, arguments);
34
- };
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- var React = require("react");
37
- var moment = require("moment");
38
- var DateTimePopup_1 = require("./DateTimeUI/DateTimePopup");
39
- var helper_functions_1 = require("@gpa-gemstone/helper-functions");
40
- var HelperMessage_1 = require("./HelperMessage");
41
- function DateTimePicker(props) {
42
- // Formats that will be used for dateBoxes
43
- var boxFormat = getBoxFormat(props.Type, props.Accuracy);
44
- var recordFormat = props.Format !== undefined ? props.Format : "YYYY-MM-DD" + (props.Type === undefined || props.Type === 'date' ? "" : "[T]HH:mm:ss.SSS[Z]");
45
- var parse = function (r) { return moment(props.Record[props.Field], recordFormat); };
46
- var divRef = React.useRef(null);
47
- var _a = React.useState(""), guid = _a[0], setGuid = _a[1];
48
- var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
49
- // Adds a buffer between the outside props and what the box is reading to prevent box overwriting every render with a keystroke
50
- var _c = React.useState(parse(props.Record).format(boxFormat)), boxRecord = _c[0], setBoxRecord = _c[1];
51
- var _d = React.useState(parse(props.Record)), pickerRecord = _d[0], setPickerRecord = _d[1];
52
- var _e = React.useState(""), feedbackMessage = _e[0], setFeedbackMessage = _e[1];
53
- var _f = React.useState(false), showOverlay = _f[0], setShowOverlay = _f[1];
54
- var _g = React.useState(0), top = _g[0], setTop = _g[1];
55
- var _h = React.useState(0), left = _h[0], setLeft = _h[1];
56
- React.useEffect(function () {
57
- setGuid((0, helper_functions_1.CreateGuid)());
58
- }, []);
59
- React.useEffect(function () {
60
- if (props.Record[props.Field] !== null) {
61
- setPickerRecord(parse(props.Record));
62
- setBoxRecord(parse(props.Record).format(boxFormat));
63
- }
64
- else {
65
- setPickerRecord(undefined);
66
- setBoxRecord('');
67
- }
68
- }, [props.Record]);
69
- React.useLayoutEffect(function () {
70
- var node = (divRef.current !== null ? (0, helper_functions_1.GetNodeSize)(divRef.current) : { top: top, left: left, height: 0, width: 0 });
71
- if (node.height === 0 && node.width === 0) {
72
- setLeft(0);
73
- setTop(-9999);
74
- return;
75
- }
76
- setLeft(node.left + 0.5 * node.width);
77
- setTop(node.top + node.height + 10);
78
- });
79
- React.useEffect(function () {
80
- window.addEventListener('click', onWindowClick);
81
- return function () { window.removeEventListener('click', onWindowClick); };
82
- }, [props.Record, props.Field, boxFormat]);
83
- function setPickerAndRecord(arg) {
84
- var _a, _b;
85
- var _c;
86
- setPickerRecord(arg);
87
- if (((_c = props.AllowEmpty) !== null && _c !== void 0 ? _c : false) && arg === undefined && props.Record[props.Field] !== null)
88
- props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = null, _a)));
89
- var valid = arg != undefined && validateDate(arg);
90
- if (valid && props.Record[props.Field].toString() !== arg.format(recordFormat))
91
- props.Setter(__assign(__assign({}, props.Record), (_b = {}, _b[props.Field] = arg.format(recordFormat), _b)));
92
- }
93
- function onWindowClick(evt) {
94
- if (evt.target.closest(".gpa-gemstone-datetime") == null) {
95
- setShowOverlay(false);
96
- if (props.Record[props.Field] !== null) {
97
- setPickerAndRecord(parse(props.Record));
98
- setBoxRecord(parse(props.Record).format(boxFormat));
99
- }
100
- else {
101
- setPickerAndRecord(undefined);
102
- setBoxRecord('');
103
- }
104
- }
105
- }
106
- function getBoxFormat(type, accuracy) {
107
- var dateTime = type !== null && type !== void 0 ? type : 'date';
108
- var timeUnit = accuracy !== null && accuracy !== void 0 ? accuracy : 'second';
109
- if (dateTime === 'time') {
110
- if (timeUnit === 'minute') {
111
- return "HH:mm";
112
- }
113
- else if (timeUnit === 'second') {
114
- return "HH:mm:ss";
115
- }
116
- else {
117
- return "HH:mm:ss.SSS";
118
- }
119
- }
120
- else if (dateTime === 'datetime-local') {
121
- if (timeUnit === 'minute') {
122
- return "YYYY-MM-DD[T]HH:mm";
123
- }
124
- else if (timeUnit === 'second') {
125
- return "YYYY-MM-DD[T]HH:mm:ss";
126
- }
127
- else {
128
- return "YYYY-MM-DD[T]HH:mm:ss.SSS";
129
- }
130
- }
131
- else {
132
- return "YYYY-MM-DD";
133
- }
134
- }
135
- function getFeedbackMessage() {
136
- if (feedbackMessage.length != 0) {
137
- return feedbackMessage;
138
- }
139
- else if (props.Feedback == null || props.Feedback.length == 0) {
140
- return props.Field.toString() + " is a required field.";
141
- }
142
- else {
143
- return props.Feedback;
144
- }
145
- }
146
- function validateDate(date) {
147
- var minStartDate = props.MinDate != null ? props.MinDate.startOf('day') : moment("1753-01-01", "YYYY-MM-DD").startOf('day');
148
- if (!date.isValid()) {
149
- setFeedbackMessage("Please enter a valid date.");
150
- return false;
151
- }
152
- else if (date.startOf('day').isBefore(minStartDate)) {
153
- setFeedbackMessage("Date must be on or after " + minStartDate.format("MM-DD-YYYY"));
154
- return false;
155
- }
156
- else {
157
- setFeedbackMessage("");
158
- return true;
159
- }
160
- }
161
- var showLabel = props.Label !== "";
162
- var showHelpIcon = props.Help !== undefined;
163
- var label = props.Label === undefined ? props.Field : props.Label;
164
- var step = props.Accuracy === 'millisecond' ? '0.001' : (props.Accuracy === 'minute' ? '60' : '1');
165
- var IsValid = function () {
166
- if (feedbackMessage.length > 0)
167
- return false;
168
- return props.Valid(props.Field);
169
- };
170
- function valueChange(value) {
171
- var _a, _b;
172
- var allowNull = props.AllowEmpty === undefined ? false : props.AllowEmpty;
173
- var date = moment(value, boxFormat);
174
- if (allowNull && value === '') {
175
- props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = null, _a)));
176
- setPickerAndRecord(undefined);
177
- }
178
- else if (validateDate(date)) {
179
- props.Setter(__assign(__assign({}, props.Record), (_b = {}, _b[props.Field] = moment(value, boxFormat).format(recordFormat), _b)));
180
- setPickerAndRecord(moment(value, boxFormat));
181
- }
182
- else {
183
- setPickerAndRecord(undefined);
184
- }
185
- setBoxRecord(value);
186
- }
187
- return (React.createElement("div", { className: "form-group", ref: divRef },
188
- showHelpIcon || showLabel ?
189
- React.createElement("label", null,
190
- showLabel ? label : '',
191
- showHelpIcon ? React.createElement("div", { style: {
192
- width: 20,
193
- height: 20,
194
- borderRadius: '50%',
195
- display: 'inline-block',
196
- background: '#0D6EFD',
197
- marginLeft: 10,
198
- textAlign: 'center',
199
- fontWeight: 'bold'
200
- }, onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); } }, " ? ") : null) : null,
201
- showHelpIcon ?
202
- React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid }, props.Help)
203
- : null,
204
- React.createElement("input", { "data-help": guid, className: "gpa-gemstone-datetime form-control " + (IsValid() ? '' : 'is-invalid'), type: props.Type === undefined ? 'date' : props.Type, onChange: function (evt) {
205
- valueChange(evt.target.value);
206
- }, onFocus: function () { setShowOverlay(true); }, value: boxRecord, disabled: props.Disabled === undefined ? false : props.Disabled, onClick: function (e) { e.preventDefault(); }, step: step }),
207
- React.createElement("div", { className: "invalid-feedback" }, getFeedbackMessage()),
208
- React.createElement(DateTimePopup_1.default, { Setter: function (d) {
209
- setPickerAndRecord(d);
210
- if (props.Type === 'date')
211
- setShowOverlay(false);
212
- }, Show: showOverlay, DateTime: pickerRecord, Valid: props.Valid(props.Field), Top: top, Center: left, Type: props.Type === undefined ? 'date' : props.Type, Accuracy: props.Accuracy })));
213
- }
214
- exports.default = DateTimePicker;
1
+ "use strict";
2
+ // ******************************************************************************************************
3
+ // DatePicker.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
+ // 02/05/2020 - Billy Ernest
21
+ // Generated original version of source code.
22
+ //
23
+ // ******************************************************************************************************
24
+ var __assign = (this && this.__assign) || function () {
25
+ __assign = Object.assign || function(t) {
26
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
27
+ s = arguments[i];
28
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
29
+ t[p] = s[p];
30
+ }
31
+ return t;
32
+ };
33
+ return __assign.apply(this, arguments);
34
+ };
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.default = DateTimePicker;
37
+ var React = require("react");
38
+ var moment = require("moment");
39
+ var DateTimePopup_1 = require("./DateTimeUI/DateTimePopup");
40
+ var helper_functions_1 = require("@gpa-gemstone/helper-functions");
41
+ var HelperMessage_1 = require("./HelperMessage");
42
+ /**
43
+ * Component that allows a user to pick a date or datetime.
44
+ */
45
+ function DateTimePicker(props) {
46
+ // Formats for displaying dates in the input box and storing in the record.
47
+ var boxFormat = getBoxFormat(props.Type, props.Accuracy);
48
+ var recordFormat = props.Format !== undefined ? props.Format : "YYYY-MM-DD" + (props.Type === undefined || props.Type === 'date' ? "" : "[T]HH:mm:ss.SSS[Z]");
49
+ // Parse the date from the record.
50
+ var parse = function (r) { return moment(props.Record[props.Field], recordFormat); };
51
+ // State and ref declarations.
52
+ var divRef = React.useRef(null);
53
+ var _a = React.useState(""), guid = _a[0], setGuid = _a[1];
54
+ var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
55
+ // Adds a buffer between the outside props and what the box is reading to prevent box overwriting every render with a keystroke
56
+ var _c = React.useState(parse(props.Record).format(boxFormat)), boxRecord = _c[0], setBoxRecord = _c[1];
57
+ var _d = React.useState(parse(props.Record)), pickerRecord = _d[0], setPickerRecord = _d[1];
58
+ var _e = React.useState(""), feedbackMessage = _e[0], setFeedbackMessage = _e[1];
59
+ var _f = React.useState(false), showOverlay = _f[0], setShowOverlay = _f[1];
60
+ var _g = React.useState(0), top = _g[0], setTop = _g[1];
61
+ var _h = React.useState(0), left = _h[0], setLeft = _h[1];
62
+ React.useEffect(function () {
63
+ setGuid((0, helper_functions_1.CreateGuid)());
64
+ }, []);
65
+ React.useEffect(function () {
66
+ if (props.Record[props.Field] !== null) {
67
+ setPickerRecord(parse(props.Record));
68
+ setBoxRecord(parse(props.Record).format(boxFormat));
69
+ }
70
+ else {
71
+ setPickerRecord(undefined);
72
+ setBoxRecord('');
73
+ }
74
+ }, [props.Record]);
75
+ React.useLayoutEffect(function () {
76
+ var node = (divRef.current !== null ? (0, helper_functions_1.GetNodeSize)(divRef.current) : { top: top, left: left, height: 0, width: 0 });
77
+ if (node.height === 0 && node.width === 0) {
78
+ setLeft(0);
79
+ setTop(-9999);
80
+ return;
81
+ }
82
+ setLeft(node.left + 0.5 * node.width);
83
+ setTop(node.top + node.height + 10);
84
+ });
85
+ React.useEffect(function () {
86
+ window.addEventListener('click', onWindowClick);
87
+ return function () { window.removeEventListener('click', onWindowClick); };
88
+ }, [props.Record, props.Field, boxFormat]);
89
+ function setPickerAndRecord(arg) {
90
+ var _a, _b;
91
+ var _c;
92
+ setPickerRecord(arg);
93
+ if (((_c = props.AllowEmpty) !== null && _c !== void 0 ? _c : false) && arg === undefined && props.Record[props.Field] !== null)
94
+ props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = null, _a)));
95
+ var valid = arg != undefined && validateDate(arg);
96
+ if (valid && props.Record[props.Field].toString() !== arg.format(recordFormat))
97
+ props.Setter(__assign(__assign({}, props.Record), (_b = {}, _b[props.Field] = arg.format(recordFormat), _b)));
98
+ }
99
+ // Handle clicks outside the component.
100
+ function onWindowClick(evt) {
101
+ if (evt.target.closest(".gpa-gemstone-datetime") == null) {
102
+ setShowOverlay(false);
103
+ if (props.Record[props.Field] !== null) {
104
+ setPickerAndRecord(parse(props.Record));
105
+ setBoxRecord(parse(props.Record).format(boxFormat));
106
+ }
107
+ else {
108
+ setPickerAndRecord(undefined);
109
+ setBoxRecord('');
110
+ }
111
+ }
112
+ }
113
+ function getBoxFormat(type, accuracy) {
114
+ var dateTime = type !== null && type !== void 0 ? type : 'date';
115
+ var timeUnit = accuracy !== null && accuracy !== void 0 ? accuracy : 'second';
116
+ if (dateTime === 'time') {
117
+ if (timeUnit === 'minute') {
118
+ return "HH:mm";
119
+ }
120
+ else if (timeUnit === 'second') {
121
+ return "HH:mm:ss";
122
+ }
123
+ else {
124
+ return "HH:mm:ss.SSS";
125
+ }
126
+ }
127
+ else if (dateTime === 'datetime-local') {
128
+ if (timeUnit === 'minute') {
129
+ return "YYYY-MM-DD[T]HH:mm";
130
+ }
131
+ else if (timeUnit === 'second') {
132
+ return "YYYY-MM-DD[T]HH:mm:ss";
133
+ }
134
+ else {
135
+ return "YYYY-MM-DD[T]HH:mm:ss.SSS";
136
+ }
137
+ }
138
+ else {
139
+ return "YYYY-MM-DD";
140
+ }
141
+ }
142
+ function getFeedbackMessage() {
143
+ if (feedbackMessage.length != 0) {
144
+ return feedbackMessage;
145
+ }
146
+ else if (props.Feedback == null || props.Feedback.length == 0) {
147
+ return "".concat(props.Field.toString(), " is a required field.");
148
+ }
149
+ else {
150
+ return props.Feedback;
151
+ }
152
+ }
153
+ function validateDate(date) {
154
+ var minStartDate = props.MinDate != null ? props.MinDate.startOf('day') : moment("1753-01-01", "YYYY-MM-DD").startOf('day');
155
+ if (!date.isValid()) {
156
+ setFeedbackMessage("Please enter a valid date.");
157
+ return false;
158
+ }
159
+ else if (date.startOf('day').isBefore(minStartDate)) {
160
+ setFeedbackMessage("Date must be on or after ".concat(minStartDate.format("MM-DD-YYYY")));
161
+ return false;
162
+ }
163
+ else {
164
+ setFeedbackMessage("");
165
+ return true;
166
+ }
167
+ }
168
+ // Variables for rendering labels and help icons.
169
+ var showLabel = props.Label !== "";
170
+ var showHelpIcon = props.Help !== undefined;
171
+ var label = props.Label === undefined ? props.Field : props.Label;
172
+ var step = props.Accuracy === 'millisecond' ? '0.001' : (props.Accuracy === 'minute' ? '60' : '1');
173
+ var IsValid = function () {
174
+ if (feedbackMessage.length > 0)
175
+ return false;
176
+ return props.Valid(props.Field);
177
+ };
178
+ function valueChange(value) {
179
+ var _a, _b;
180
+ var allowNull = props.AllowEmpty === undefined ? false : props.AllowEmpty;
181
+ var date = moment(value, boxFormat);
182
+ if (allowNull && value === '') {
183
+ props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = null, _a)));
184
+ setPickerAndRecord(undefined);
185
+ }
186
+ else if (validateDate(date)) {
187
+ props.Setter(__assign(__assign({}, props.Record), (_b = {}, _b[props.Field] = moment(value, boxFormat).format(recordFormat), _b)));
188
+ setPickerAndRecord(moment(value, boxFormat));
189
+ }
190
+ else {
191
+ setPickerAndRecord(undefined);
192
+ }
193
+ setBoxRecord(value);
194
+ }
195
+ return (React.createElement("div", { className: "form-group", ref: divRef },
196
+ showHelpIcon || showLabel ?
197
+ React.createElement("label", null,
198
+ showLabel ? label : '',
199
+ showHelpIcon ? React.createElement("div", { style: {
200
+ width: 20,
201
+ height: 20,
202
+ borderRadius: '50%',
203
+ display: 'inline-block',
204
+ background: '#0D6EFD',
205
+ marginLeft: 10,
206
+ textAlign: 'center',
207
+ fontWeight: 'bold'
208
+ }, onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); } }, " ? ") : null) : null,
209
+ showHelpIcon ?
210
+ React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid }, props.Help)
211
+ : null,
212
+ React.createElement("input", { "data-help": guid, className: "gpa-gemstone-datetime form-control ".concat(IsValid() ? '' : 'is-invalid'), type: props.Type === undefined ? 'date' : props.Type, onChange: function (evt) {
213
+ valueChange(evt.target.value);
214
+ }, onFocus: function () { setShowOverlay(true); }, value: boxRecord, disabled: props.Disabled === undefined ? false : props.Disabled, onClick: function (e) { e.preventDefault(); }, step: step }),
215
+ React.createElement("div", { className: "invalid-feedback" }, getFeedbackMessage()),
216
+ React.createElement(DateTimePopup_1.default, { Setter: function (d) {
217
+ setPickerAndRecord(d);
218
+ if (props.Type === 'date')
219
+ setShowOverlay(false);
220
+ }, Show: showOverlay, DateTime: pickerRecord, Valid: props.Valid(props.Field), Top: top, Center: left, Type: props.Type === undefined ? 'date' : props.Type, Accuracy: props.Accuracy })));
221
+ }
@@ -1,13 +1,64 @@
1
- /// <reference types="react" />
2
- export default function DateRangePicker<T>(props: {
3
- Record: T;
4
- FromField: keyof T;
5
- ToField: keyof T;
6
- Setter: (record: T) => void;
7
- Label: string;
8
- Valid: (fieldFrom: keyof T, fieldTo: keyof T) => boolean;
9
- Disabled?: boolean;
10
- Feedback?: string;
11
- Format?: string;
12
- Type?: ('datetime-local' | 'date');
13
- }): JSX.Element;
1
+ interface IProps<T> {
2
+ /**
3
+ * Record to be used in form
4
+ * @type {T}
5
+ */
6
+ Record: T;
7
+ /**
8
+ * Field representing the start date in the record
9
+ * @type {keyof T}
10
+ */
11
+ FromField: keyof T;
12
+ /**
13
+ * Field representing the end date in the record
14
+ * @type {keyof T}
15
+ */
16
+ ToField: keyof T;
17
+ /**
18
+ * Setter function to update the Record
19
+ * @param record - Updated Record
20
+ */
21
+ Setter: (record: T) => void;
22
+ /**
23
+ * Label to display for the form, defaults to the Field prop
24
+ * @type {string}
25
+ * @optional
26
+ */
27
+ Label: string;
28
+ /**
29
+ * Function to determine the validity of a field
30
+ * @param field - Field of the record to check
31
+ * @returns {boolean}
32
+ */
33
+ Valid: (fieldFrom: keyof T, fieldTo: keyof T) => boolean;
34
+ /**
35
+ * Flag to disable the input field
36
+ * @type {boolean}
37
+ * @optional
38
+ */
39
+ Disabled?: boolean;
40
+ /**
41
+ * Feedback message to show when input is invalid
42
+ * @type {string}
43
+ * @optional
44
+ */
45
+ Feedback?: string;
46
+ /**
47
+ * Date format to use for the input fields
48
+ * @type {string}
49
+ * @optional
50
+ */
51
+ Format?: string;
52
+ /**
53
+ * Value for the type attribute in input element, either 'datetime-local' or the default 'date'
54
+ * @type {'datetime-local' | 'date'}
55
+ * @optional
56
+ */
57
+ Type?: ('datetime-local' | 'date');
58
+ }
59
+ /**
60
+ * DateRangePicker Component.
61
+ * Allows users to select a date range either by choosing predefined durations or by specifying custom dates.
62
+ */
63
+ export default function DateRangePicker<T>(props: IProps<T>): JSX.Element;
64
+ export {};