@commercetools-uikit/date-input 12.2.9 → 13.0.0
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 +30 -16
- package/dist/commercetools-uikit-date-input.cjs.d.ts +2 -0
- package/dist/commercetools-uikit-date-input.cjs.dev.js +38 -93
- package/dist/commercetools-uikit-date-input.cjs.prod.js +22 -20
- package/dist/commercetools-uikit-date-input.esm.js +37 -92
- package/dist/declarations/src/date-input.d.ts +30 -0
- package/dist/declarations/src/index.d.ts +2 -0
- package/dist/declarations/src/messages.d.ts +8 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -45,22 +45,36 @@ export default Example;
|
|
|
45
45
|
|
|
46
46
|
## Properties
|
|
47
47
|
|
|
48
|
-
| Props | Type
|
|
49
|
-
| ---------------------- |
|
|
50
|
-
| `horizontalConstraint` | `
|
|
51
|
-
| `value` | `string`
|
|
52
|
-
| `onChange` | `
|
|
53
|
-
| `onFocus` | `
|
|
54
|
-
| `onBlur` | `
|
|
55
|
-
| `id` | `string`
|
|
56
|
-
| `name` | `string`
|
|
57
|
-
| `placeholder` | `string`
|
|
58
|
-
| `isDisabled` | `
|
|
59
|
-
| `isReadOnly` | `
|
|
60
|
-
| `hasError` | `
|
|
61
|
-
| `hasWarning` | `
|
|
62
|
-
| `minValue` | `string`
|
|
63
|
-
| `maxValue` | `string`
|
|
48
|
+
| Props | Type | Required | Default | Description |
|
|
49
|
+
| ---------------------- | -------------------------------------------------------------------------------------------- | :------: | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
50
|
+
| `horizontalConstraint` | `union`<br/>Possible values:<br/>`, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'` | | | Horizontal size limit of the input field. |
|
|
51
|
+
| `value` | `string` | ✅ | | The selected date, must either be an empty string or a date formatted as "YYYY-MM-DD". |
|
|
52
|
+
| `onChange` | `Function`<br/>[See signature.](#signature-onChange) | ✅ | | Called when the date changes. Called with an event containing either an empty string (no value) or a string in this format: "YYYY-MM-DD".
<br />
Signature: `(event) => void` |
|
|
53
|
+
| `onFocus` | `FocusEventHandler` | | | Called when the date input gains focus. |
|
|
54
|
+
| `onBlur` | `Function`<br/>[See signature.](#signature-onBlur) | | | Called when the date input loses focus. |
|
|
55
|
+
| `id` | `string` | | | Used as the HTML `id` attribute. |
|
|
56
|
+
| `name` | `string` | | | Used as the HTML `name` attribute. |
|
|
57
|
+
| `placeholder` | `string` | | | Placeholder value to show in the input field |
|
|
58
|
+
| `isDisabled` | `boolean` | | | Disables the date picker |
|
|
59
|
+
| `isReadOnly` | `boolean` | | | Disables the date picker menu and makes input field read-only |
|
|
60
|
+
| `hasError` | `boolean` | | | Indicates the input field has an error |
|
|
61
|
+
| `hasWarning` | `boolean` | | | Indicates the input field has a warning |
|
|
62
|
+
| `minValue` | `string` | | | A minimum selectable date. Must either be an empty string or a date formatted as "YYYY-MM-DD". |
|
|
63
|
+
| `maxValue` | `string` | | | A maximum selectable date. Must either be an empty string or a date formatted as "YYYY-MM-DD". |
|
|
64
|
+
|
|
65
|
+
## Signatures
|
|
66
|
+
|
|
67
|
+
### Signature `onChange`
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
(event: TEvent) => void
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Signature `onBlur`
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
(event: TEvent) => void
|
|
77
|
+
```
|
|
64
78
|
|
|
65
79
|
## Static methods
|
|
66
80
|
|
|
@@ -12,11 +12,11 @@ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/ob
|
|
|
12
12
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
13
13
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
14
14
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
15
|
+
var _pt = require('prop-types');
|
|
15
16
|
var _fillInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/fill');
|
|
16
17
|
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
17
18
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
18
19
|
var react = require('react');
|
|
19
|
-
var PropTypes = require('prop-types');
|
|
20
20
|
var Downshift = require('downshift');
|
|
21
21
|
var reactIntl = require('react-intl');
|
|
22
22
|
var Constraints = require('@commercetools-uikit/constraints');
|
|
@@ -34,10 +34,10 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
|
|
|
34
34
|
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
35
35
|
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
36
36
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
37
|
+
var _pt__default = /*#__PURE__*/_interopDefault(_pt);
|
|
37
38
|
var _fillInstanceProperty__default = /*#__PURE__*/_interopDefault(_fillInstanceProperty);
|
|
38
39
|
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
39
40
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
40
|
-
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
41
41
|
var Downshift__default = /*#__PURE__*/_interopDefault(Downshift);
|
|
42
42
|
var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
|
|
43
43
|
|
|
@@ -49,12 +49,11 @@ var messages = reactIntl.defineMessages({
|
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object);
|
|
52
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
53
53
|
|
|
54
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
54
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
55
55
|
|
|
56
56
|
var preventDownshiftDefault = function preventDownshiftDefault(event) {
|
|
57
|
-
// eslint-disable-next-line no-param-reassign
|
|
58
57
|
event.nativeEvent.preventDownshiftDefault = true;
|
|
59
58
|
};
|
|
60
59
|
|
|
@@ -76,7 +75,7 @@ var DateInput = function DateInput(props) {
|
|
|
76
75
|
highlightedIndex = _useState6[0],
|
|
77
76
|
setHighlightedIndex = _useState6[1];
|
|
78
77
|
|
|
79
|
-
var inputRef = react.useRef();
|
|
78
|
+
var inputRef = react.useRef(null);
|
|
80
79
|
var onChange = props.onChange;
|
|
81
80
|
var emit = react.useCallback(function (value) {
|
|
82
81
|
return onChange({
|
|
@@ -90,7 +89,9 @@ var DateInput = function DateInput(props) {
|
|
|
90
89
|
});
|
|
91
90
|
}, [onChange, props.id, props.name]);
|
|
92
91
|
var handleChange = react.useCallback(function (date) {
|
|
93
|
-
|
|
92
|
+
var _inputRef$current;
|
|
93
|
+
|
|
94
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.setSelectionRange(0, 100);
|
|
94
95
|
emit(date);
|
|
95
96
|
}, [inputRef, emit]);
|
|
96
97
|
var onBlur = props.onBlur;
|
|
@@ -104,10 +105,12 @@ var DateInput = function DateInput(props) {
|
|
|
104
105
|
}, [onBlur, props.id, props.name]);
|
|
105
106
|
|
|
106
107
|
var showToday = function showToday() {
|
|
108
|
+
var _inputRef$current2;
|
|
109
|
+
|
|
107
110
|
var today = calendarUtils.getToday();
|
|
108
111
|
setCalendarDate(today);
|
|
109
112
|
setHighlightedIndex(suggestedItems.length + calendarUtils.getDateInMonth(today) - 1);
|
|
110
|
-
inputRef.current.focus();
|
|
113
|
+
(_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus();
|
|
111
114
|
};
|
|
112
115
|
|
|
113
116
|
var jumpMonth = function jumpMonth(amount) {
|
|
@@ -126,7 +129,6 @@ var DateInput = function DateInput(props) {
|
|
|
126
129
|
highlightedIndex: highlightedIndex,
|
|
127
130
|
onChange: handleChange,
|
|
128
131
|
onStateChange: function onStateChange(changes) {
|
|
129
|
-
/* eslint-disable no-prototype-builtins */
|
|
130
132
|
if (changes.hasOwnProperty('inputValue')) {
|
|
131
133
|
// input changed because user typed
|
|
132
134
|
if (changes.type === Downshift__default["default"].stateChangeTypes.changeInput) {
|
|
@@ -154,8 +156,6 @@ var DateInput = function DateInput(props) {
|
|
|
154
156
|
if (changes.hasOwnProperty('highlightedIndex')) {
|
|
155
157
|
setHighlightedIndex(changes.highlightedIndex);
|
|
156
158
|
}
|
|
157
|
-
/* eslint-enable no-prototype-builtins */
|
|
158
|
-
|
|
159
159
|
},
|
|
160
160
|
children: function children(_ref) {
|
|
161
161
|
var _context;
|
|
@@ -171,10 +171,10 @@ var DateInput = function DateInput(props) {
|
|
|
171
171
|
selectedItem = _ref.selectedItem,
|
|
172
172
|
isOpen = _ref.isOpen,
|
|
173
173
|
inputValue = _ref.inputValue;
|
|
174
|
-
var calendarItems = calendarUtils.createCalendarItems(calendarDate
|
|
174
|
+
var calendarItems = calendarUtils.createCalendarItems(calendarDate);
|
|
175
175
|
var paddingDayCount = calendarUtils.getPaddingDayCount(calendarDate, intl.locale);
|
|
176
176
|
|
|
177
|
-
var paddingDays = _fillInstanceProperty__default["default"](_context = Array(paddingDayCount)).call(_context);
|
|
177
|
+
var paddingDays = _fillInstanceProperty__default["default"](_context = Array(paddingDayCount)).call(_context, undefined);
|
|
178
178
|
|
|
179
179
|
var weekdays = calendarUtils.getWeekdayNames(intl.locale);
|
|
180
180
|
var today = calendarUtils.getToday();
|
|
@@ -192,6 +192,7 @@ var DateInput = function DateInput(props) {
|
|
|
192
192
|
onMouseEnter: function onMouseEnter() {
|
|
193
193
|
// we remove the highlight so that the user can use the
|
|
194
194
|
// arrow keys to move the cursor when hovering
|
|
195
|
+
// @ts-ignore
|
|
195
196
|
if (isOpen) setDownshiftHighlightedIndex(null);
|
|
196
197
|
},
|
|
197
198
|
onKeyDown: function onKeyDown(event) {
|
|
@@ -200,13 +201,13 @@ var DateInput = function DateInput(props) {
|
|
|
200
201
|
return;
|
|
201
202
|
}
|
|
202
203
|
|
|
203
|
-
if (event.key === 'Enter' && _trimInstanceProperty__default["default"](inputValue).call(inputValue) === '') {
|
|
204
|
+
if (event.key === 'Enter' && (inputValue === null || inputValue === void 0 ? void 0 : _trimInstanceProperty__default["default"](inputValue).call(inputValue)) === '') {
|
|
204
205
|
clearSelection();
|
|
205
206
|
} // ArrowDown
|
|
206
207
|
|
|
207
208
|
|
|
208
209
|
if (event.keyCode === 40) {
|
|
209
|
-
var nextDayToHighlight = calendarUtils.getNextDay(calendarItems[highlightedIndex]);
|
|
210
|
+
var nextDayToHighlight = calendarUtils.getNextDay(calendarItems[Number(highlightedIndex)]);
|
|
210
211
|
|
|
211
212
|
if (!calendarUtils.getIsDateInRange(nextDayToHighlight, props.minValue, props.maxValue)) {
|
|
212
213
|
// if the date to highlight is disabled
|
|
@@ -215,7 +216,7 @@ var DateInput = function DateInput(props) {
|
|
|
215
216
|
return;
|
|
216
217
|
}
|
|
217
218
|
|
|
218
|
-
if (highlightedIndex + 1 >= calendarItems.length) {
|
|
219
|
+
if (Number(highlightedIndex) + 1 >= calendarItems.length) {
|
|
219
220
|
// if it's the end of the month
|
|
220
221
|
// then bypass normal arrow navigation
|
|
221
222
|
preventDownshiftDefault(event); // then jump to start of next month
|
|
@@ -226,7 +227,7 @@ var DateInput = function DateInput(props) {
|
|
|
226
227
|
|
|
227
228
|
|
|
228
229
|
if (event.keyCode === 38) {
|
|
229
|
-
var previousDay = calendarUtils.getPreviousDay(calendarItems[highlightedIndex]);
|
|
230
|
+
var previousDay = calendarUtils.getPreviousDay(calendarItems[Number(highlightedIndex)]);
|
|
230
231
|
|
|
231
232
|
if (!calendarUtils.getIsDateInRange(previousDay, props.minValue, props.maxValue)) {
|
|
232
233
|
// if the date to highlight is disabled
|
|
@@ -235,7 +236,7 @@ var DateInput = function DateInput(props) {
|
|
|
235
236
|
return;
|
|
236
237
|
}
|
|
237
238
|
|
|
238
|
-
if (highlightedIndex <= 0) {
|
|
239
|
+
if (Number(highlightedIndex) <= 0) {
|
|
239
240
|
// if it's the start of the month
|
|
240
241
|
// then bypass normal arrow navigation
|
|
241
242
|
preventDownshiftDefault(event);
|
|
@@ -282,7 +283,7 @@ var DateInput = function DateInput(props) {
|
|
|
282
283
|
type: "heading",
|
|
283
284
|
children: weekday
|
|
284
285
|
}, weekday);
|
|
285
|
-
}), _mapInstanceProperty__default["default"](paddingDays).call(paddingDays, function (
|
|
286
|
+
}), _mapInstanceProperty__default["default"](paddingDays).call(paddingDays, function (_, index) {
|
|
286
287
|
return jsxRuntime.jsx(calendarUtils.CalendarDay, {
|
|
287
288
|
type: "spacing"
|
|
288
289
|
}, index);
|
|
@@ -293,6 +294,7 @@ var DateInput = function DateInput(props) {
|
|
|
293
294
|
disabled: !calendarUtils.getIsDateInRange(item, props.minValue, props.maxValue),
|
|
294
295
|
item: item,
|
|
295
296
|
onMouseOut: function onMouseOut() {
|
|
297
|
+
// @ts-ignore
|
|
296
298
|
setDownshiftHighlightedIndex(null);
|
|
297
299
|
}
|
|
298
300
|
})), {}, {
|
|
@@ -309,89 +311,32 @@ var DateInput = function DateInput(props) {
|
|
|
309
311
|
});
|
|
310
312
|
};
|
|
311
313
|
|
|
314
|
+
DateInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
315
|
+
horizontalConstraint: _pt__default["default"].oneOf([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
316
|
+
value: _pt__default["default"].string.isRequired,
|
|
317
|
+
onChange: _pt__default["default"].func.isRequired,
|
|
318
|
+
onFocus: _pt__default["default"].func,
|
|
319
|
+
onBlur: _pt__default["default"].func,
|
|
320
|
+
id: _pt__default["default"].string,
|
|
321
|
+
name: _pt__default["default"].string,
|
|
322
|
+
placeholder: _pt__default["default"].string,
|
|
323
|
+
isDisabled: _pt__default["default"].bool,
|
|
324
|
+
isReadOnly: _pt__default["default"].bool,
|
|
325
|
+
hasError: _pt__default["default"].bool,
|
|
326
|
+
hasWarning: _pt__default["default"].bool,
|
|
327
|
+
minValue: _pt__default["default"].string,
|
|
328
|
+
maxValue: _pt__default["default"].string
|
|
329
|
+
} : {};
|
|
312
330
|
DateInput.displayName = 'DateInput';
|
|
313
331
|
|
|
314
332
|
DateInput.isEmpty = function (value) {
|
|
315
333
|
return value === '';
|
|
316
334
|
};
|
|
317
335
|
|
|
318
|
-
DateInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
319
|
-
/**
|
|
320
|
-
* Horizontal size limit of the input field.
|
|
321
|
-
*/
|
|
322
|
-
horizontalConstraint: PropTypes__default["default"].oneOf([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* The selected date, must either be an empty string or a date formatted as "YYYY-MM-DD".
|
|
326
|
-
*/
|
|
327
|
-
value: PropTypes__default["default"].string.isRequired,
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Called when the date changes. Called with an event containing either an empty string (no value) or a string in this format: "YYYY-MM-DD".
|
|
331
|
-
* <br />
|
|
332
|
-
* Signature: `(event) => void`
|
|
333
|
-
*/
|
|
334
|
-
onChange: PropTypes__default["default"].func.isRequired,
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Called when the date input gains focus.
|
|
338
|
-
*/
|
|
339
|
-
onFocus: PropTypes__default["default"].func,
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* Called when the date input loses focus.
|
|
343
|
-
*/
|
|
344
|
-
onBlur: PropTypes__default["default"].func,
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Used as the HTML `id` attribute.
|
|
348
|
-
*/
|
|
349
|
-
id: PropTypes__default["default"].string,
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* Used as the HTML `name` attribute.
|
|
353
|
-
*/
|
|
354
|
-
name: PropTypes__default["default"].string,
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* Placeholder value to show in the input field
|
|
358
|
-
*/
|
|
359
|
-
placeholder: PropTypes__default["default"].string,
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* Disables the date picker
|
|
363
|
-
*/
|
|
364
|
-
isDisabled: PropTypes__default["default"].bool,
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* Disables the date picker menu and makes input field read-only
|
|
368
|
-
*/
|
|
369
|
-
isReadOnly: PropTypes__default["default"].bool,
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Indicates the input field has an error
|
|
373
|
-
*/
|
|
374
|
-
hasError: PropTypes__default["default"].bool,
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Indicates the input field has a warning
|
|
378
|
-
*/
|
|
379
|
-
hasWarning: PropTypes__default["default"].bool,
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* A minimum selectable date. Must either be an empty string or a date formatted as "YYYY-MM-DD".
|
|
383
|
-
*/
|
|
384
|
-
minValue: PropTypes__default["default"].string,
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* A maximum selectable date. Must either be an empty string or a date formatted as "YYYY-MM-DD".
|
|
388
|
-
*/
|
|
389
|
-
maxValue: PropTypes__default["default"].string
|
|
390
|
-
} : {};
|
|
391
336
|
var DateInput$1 = DateInput;
|
|
392
337
|
|
|
393
338
|
// NOTE: This string will be replaced on build time with the package version.
|
|
394
|
-
var version = "
|
|
339
|
+
var version = "13.0.0";
|
|
395
340
|
|
|
396
341
|
exports["default"] = DateInput$1;
|
|
397
342
|
exports.version = version;
|
|
@@ -12,11 +12,11 @@ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/ob
|
|
|
12
12
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
13
13
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
14
14
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
15
|
+
require('prop-types');
|
|
15
16
|
var _fillInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/fill');
|
|
16
17
|
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
17
18
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
18
19
|
var react = require('react');
|
|
19
|
-
require('prop-types');
|
|
20
20
|
var Downshift = require('downshift');
|
|
21
21
|
var reactIntl = require('react-intl');
|
|
22
22
|
var Constraints = require('@commercetools-uikit/constraints');
|
|
@@ -48,12 +48,11 @@ var messages = reactIntl.defineMessages({
|
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object);
|
|
51
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
52
52
|
|
|
53
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
53
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
54
54
|
|
|
55
55
|
var preventDownshiftDefault = function preventDownshiftDefault(event) {
|
|
56
|
-
// eslint-disable-next-line no-param-reassign
|
|
57
56
|
event.nativeEvent.preventDownshiftDefault = true;
|
|
58
57
|
};
|
|
59
58
|
|
|
@@ -75,7 +74,7 @@ var DateInput = function DateInput(props) {
|
|
|
75
74
|
highlightedIndex = _useState6[0],
|
|
76
75
|
setHighlightedIndex = _useState6[1];
|
|
77
76
|
|
|
78
|
-
var inputRef = react.useRef();
|
|
77
|
+
var inputRef = react.useRef(null);
|
|
79
78
|
var onChange = props.onChange;
|
|
80
79
|
var emit = react.useCallback(function (value) {
|
|
81
80
|
return onChange({
|
|
@@ -89,7 +88,9 @@ var DateInput = function DateInput(props) {
|
|
|
89
88
|
});
|
|
90
89
|
}, [onChange, props.id, props.name]);
|
|
91
90
|
var handleChange = react.useCallback(function (date) {
|
|
92
|
-
|
|
91
|
+
var _inputRef$current;
|
|
92
|
+
|
|
93
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.setSelectionRange(0, 100);
|
|
93
94
|
emit(date);
|
|
94
95
|
}, [inputRef, emit]);
|
|
95
96
|
var onBlur = props.onBlur;
|
|
@@ -103,10 +104,12 @@ var DateInput = function DateInput(props) {
|
|
|
103
104
|
}, [onBlur, props.id, props.name]);
|
|
104
105
|
|
|
105
106
|
var showToday = function showToday() {
|
|
107
|
+
var _inputRef$current2;
|
|
108
|
+
|
|
106
109
|
var today = calendarUtils.getToday();
|
|
107
110
|
setCalendarDate(today);
|
|
108
111
|
setHighlightedIndex(suggestedItems.length + calendarUtils.getDateInMonth(today) - 1);
|
|
109
|
-
inputRef.current.focus();
|
|
112
|
+
(_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus();
|
|
110
113
|
};
|
|
111
114
|
|
|
112
115
|
var jumpMonth = function jumpMonth(amount) {
|
|
@@ -125,7 +128,6 @@ var DateInput = function DateInput(props) {
|
|
|
125
128
|
highlightedIndex: highlightedIndex,
|
|
126
129
|
onChange: handleChange,
|
|
127
130
|
onStateChange: function onStateChange(changes) {
|
|
128
|
-
/* eslint-disable no-prototype-builtins */
|
|
129
131
|
if (changes.hasOwnProperty('inputValue')) {
|
|
130
132
|
// input changed because user typed
|
|
131
133
|
if (changes.type === Downshift__default["default"].stateChangeTypes.changeInput) {
|
|
@@ -153,8 +155,6 @@ var DateInput = function DateInput(props) {
|
|
|
153
155
|
if (changes.hasOwnProperty('highlightedIndex')) {
|
|
154
156
|
setHighlightedIndex(changes.highlightedIndex);
|
|
155
157
|
}
|
|
156
|
-
/* eslint-enable no-prototype-builtins */
|
|
157
|
-
|
|
158
158
|
},
|
|
159
159
|
children: function children(_ref) {
|
|
160
160
|
var _context;
|
|
@@ -170,10 +170,10 @@ var DateInput = function DateInput(props) {
|
|
|
170
170
|
selectedItem = _ref.selectedItem,
|
|
171
171
|
isOpen = _ref.isOpen,
|
|
172
172
|
inputValue = _ref.inputValue;
|
|
173
|
-
var calendarItems = calendarUtils.createCalendarItems(calendarDate
|
|
173
|
+
var calendarItems = calendarUtils.createCalendarItems(calendarDate);
|
|
174
174
|
var paddingDayCount = calendarUtils.getPaddingDayCount(calendarDate, intl.locale);
|
|
175
175
|
|
|
176
|
-
var paddingDays = _fillInstanceProperty__default["default"](_context = Array(paddingDayCount)).call(_context);
|
|
176
|
+
var paddingDays = _fillInstanceProperty__default["default"](_context = Array(paddingDayCount)).call(_context, undefined);
|
|
177
177
|
|
|
178
178
|
var weekdays = calendarUtils.getWeekdayNames(intl.locale);
|
|
179
179
|
var today = calendarUtils.getToday();
|
|
@@ -191,6 +191,7 @@ var DateInput = function DateInput(props) {
|
|
|
191
191
|
onMouseEnter: function onMouseEnter() {
|
|
192
192
|
// we remove the highlight so that the user can use the
|
|
193
193
|
// arrow keys to move the cursor when hovering
|
|
194
|
+
// @ts-ignore
|
|
194
195
|
if (isOpen) setDownshiftHighlightedIndex(null);
|
|
195
196
|
},
|
|
196
197
|
onKeyDown: function onKeyDown(event) {
|
|
@@ -199,13 +200,13 @@ var DateInput = function DateInput(props) {
|
|
|
199
200
|
return;
|
|
200
201
|
}
|
|
201
202
|
|
|
202
|
-
if (event.key === 'Enter' && _trimInstanceProperty__default["default"](inputValue).call(inputValue) === '') {
|
|
203
|
+
if (event.key === 'Enter' && (inputValue === null || inputValue === void 0 ? void 0 : _trimInstanceProperty__default["default"](inputValue).call(inputValue)) === '') {
|
|
203
204
|
clearSelection();
|
|
204
205
|
} // ArrowDown
|
|
205
206
|
|
|
206
207
|
|
|
207
208
|
if (event.keyCode === 40) {
|
|
208
|
-
var nextDayToHighlight = calendarUtils.getNextDay(calendarItems[highlightedIndex]);
|
|
209
|
+
var nextDayToHighlight = calendarUtils.getNextDay(calendarItems[Number(highlightedIndex)]);
|
|
209
210
|
|
|
210
211
|
if (!calendarUtils.getIsDateInRange(nextDayToHighlight, props.minValue, props.maxValue)) {
|
|
211
212
|
// if the date to highlight is disabled
|
|
@@ -214,7 +215,7 @@ var DateInput = function DateInput(props) {
|
|
|
214
215
|
return;
|
|
215
216
|
}
|
|
216
217
|
|
|
217
|
-
if (highlightedIndex + 1 >= calendarItems.length) {
|
|
218
|
+
if (Number(highlightedIndex) + 1 >= calendarItems.length) {
|
|
218
219
|
// if it's the end of the month
|
|
219
220
|
// then bypass normal arrow navigation
|
|
220
221
|
preventDownshiftDefault(event); // then jump to start of next month
|
|
@@ -225,7 +226,7 @@ var DateInput = function DateInput(props) {
|
|
|
225
226
|
|
|
226
227
|
|
|
227
228
|
if (event.keyCode === 38) {
|
|
228
|
-
var previousDay = calendarUtils.getPreviousDay(calendarItems[highlightedIndex]);
|
|
229
|
+
var previousDay = calendarUtils.getPreviousDay(calendarItems[Number(highlightedIndex)]);
|
|
229
230
|
|
|
230
231
|
if (!calendarUtils.getIsDateInRange(previousDay, props.minValue, props.maxValue)) {
|
|
231
232
|
// if the date to highlight is disabled
|
|
@@ -234,7 +235,7 @@ var DateInput = function DateInput(props) {
|
|
|
234
235
|
return;
|
|
235
236
|
}
|
|
236
237
|
|
|
237
|
-
if (highlightedIndex <= 0) {
|
|
238
|
+
if (Number(highlightedIndex) <= 0) {
|
|
238
239
|
// if it's the start of the month
|
|
239
240
|
// then bypass normal arrow navigation
|
|
240
241
|
preventDownshiftDefault(event);
|
|
@@ -281,7 +282,7 @@ var DateInput = function DateInput(props) {
|
|
|
281
282
|
type: "heading",
|
|
282
283
|
children: weekday
|
|
283
284
|
}, weekday);
|
|
284
|
-
}), _mapInstanceProperty__default["default"](paddingDays).call(paddingDays, function (
|
|
285
|
+
}), _mapInstanceProperty__default["default"](paddingDays).call(paddingDays, function (_, index) {
|
|
285
286
|
return jsxRuntime.jsx(calendarUtils.CalendarDay, {
|
|
286
287
|
type: "spacing"
|
|
287
288
|
}, index);
|
|
@@ -292,6 +293,7 @@ var DateInput = function DateInput(props) {
|
|
|
292
293
|
disabled: !calendarUtils.getIsDateInRange(item, props.minValue, props.maxValue),
|
|
293
294
|
item: item,
|
|
294
295
|
onMouseOut: function onMouseOut() {
|
|
296
|
+
// @ts-ignore
|
|
295
297
|
setDownshiftHighlightedIndex(null);
|
|
296
298
|
}
|
|
297
299
|
})), {}, {
|
|
@@ -308,17 +310,17 @@ var DateInput = function DateInput(props) {
|
|
|
308
310
|
});
|
|
309
311
|
};
|
|
310
312
|
|
|
313
|
+
DateInput.propTypes = {};
|
|
311
314
|
DateInput.displayName = 'DateInput';
|
|
312
315
|
|
|
313
316
|
DateInput.isEmpty = function (value) {
|
|
314
317
|
return value === '';
|
|
315
318
|
};
|
|
316
319
|
|
|
317
|
-
DateInput.propTypes = {};
|
|
318
320
|
var DateInput$1 = DateInput;
|
|
319
321
|
|
|
320
322
|
// NOTE: This string will be replaced on build time with the package version.
|
|
321
|
-
var version = "
|
|
323
|
+
var version = "13.0.0";
|
|
322
324
|
|
|
323
325
|
exports["default"] = DateInput$1;
|
|
324
326
|
exports.version = version;
|
|
@@ -8,11 +8,11 @@ import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/obje
|
|
|
8
8
|
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
9
9
|
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
10
10
|
import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
11
|
+
import _pt from 'prop-types';
|
|
11
12
|
import _fillInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/fill';
|
|
12
13
|
import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/trim';
|
|
13
14
|
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
14
15
|
import { useState, useRef, useCallback } from 'react';
|
|
15
|
-
import PropTypes from 'prop-types';
|
|
16
16
|
import Downshift from 'downshift';
|
|
17
17
|
import { defineMessages, useIntl } from 'react-intl';
|
|
18
18
|
import Constraints from '@commercetools-uikit/constraints';
|
|
@@ -28,12 +28,11 @@ var messages = defineMessages({
|
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object);
|
|
31
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
32
32
|
|
|
33
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
33
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
34
34
|
|
|
35
35
|
var preventDownshiftDefault = function preventDownshiftDefault(event) {
|
|
36
|
-
// eslint-disable-next-line no-param-reassign
|
|
37
36
|
event.nativeEvent.preventDownshiftDefault = true;
|
|
38
37
|
};
|
|
39
38
|
|
|
@@ -55,7 +54,7 @@ var DateInput = function DateInput(props) {
|
|
|
55
54
|
highlightedIndex = _useState6[0],
|
|
56
55
|
setHighlightedIndex = _useState6[1];
|
|
57
56
|
|
|
58
|
-
var inputRef = useRef();
|
|
57
|
+
var inputRef = useRef(null);
|
|
59
58
|
var onChange = props.onChange;
|
|
60
59
|
var emit = useCallback(function (value) {
|
|
61
60
|
return onChange({
|
|
@@ -69,7 +68,9 @@ var DateInput = function DateInput(props) {
|
|
|
69
68
|
});
|
|
70
69
|
}, [onChange, props.id, props.name]);
|
|
71
70
|
var handleChange = useCallback(function (date) {
|
|
72
|
-
|
|
71
|
+
var _inputRef$current;
|
|
72
|
+
|
|
73
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.setSelectionRange(0, 100);
|
|
73
74
|
emit(date);
|
|
74
75
|
}, [inputRef, emit]);
|
|
75
76
|
var onBlur = props.onBlur;
|
|
@@ -83,10 +84,12 @@ var DateInput = function DateInput(props) {
|
|
|
83
84
|
}, [onBlur, props.id, props.name]);
|
|
84
85
|
|
|
85
86
|
var showToday = function showToday() {
|
|
87
|
+
var _inputRef$current2;
|
|
88
|
+
|
|
86
89
|
var today = getToday();
|
|
87
90
|
setCalendarDate(today);
|
|
88
91
|
setHighlightedIndex(suggestedItems.length + getDateInMonth(today) - 1);
|
|
89
|
-
inputRef.current.focus();
|
|
92
|
+
(_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus();
|
|
90
93
|
};
|
|
91
94
|
|
|
92
95
|
var jumpMonth = function jumpMonth(amount) {
|
|
@@ -105,7 +108,6 @@ var DateInput = function DateInput(props) {
|
|
|
105
108
|
highlightedIndex: highlightedIndex,
|
|
106
109
|
onChange: handleChange,
|
|
107
110
|
onStateChange: function onStateChange(changes) {
|
|
108
|
-
/* eslint-disable no-prototype-builtins */
|
|
109
111
|
if (changes.hasOwnProperty('inputValue')) {
|
|
110
112
|
// input changed because user typed
|
|
111
113
|
if (changes.type === Downshift.stateChangeTypes.changeInput) {
|
|
@@ -133,8 +135,6 @@ var DateInput = function DateInput(props) {
|
|
|
133
135
|
if (changes.hasOwnProperty('highlightedIndex')) {
|
|
134
136
|
setHighlightedIndex(changes.highlightedIndex);
|
|
135
137
|
}
|
|
136
|
-
/* eslint-enable no-prototype-builtins */
|
|
137
|
-
|
|
138
138
|
},
|
|
139
139
|
children: function children(_ref) {
|
|
140
140
|
var _context;
|
|
@@ -150,10 +150,10 @@ var DateInput = function DateInput(props) {
|
|
|
150
150
|
selectedItem = _ref.selectedItem,
|
|
151
151
|
isOpen = _ref.isOpen,
|
|
152
152
|
inputValue = _ref.inputValue;
|
|
153
|
-
var calendarItems = createCalendarItems(calendarDate
|
|
153
|
+
var calendarItems = createCalendarItems(calendarDate);
|
|
154
154
|
var paddingDayCount = getPaddingDayCount(calendarDate, intl.locale);
|
|
155
155
|
|
|
156
|
-
var paddingDays = _fillInstanceProperty(_context = Array(paddingDayCount)).call(_context);
|
|
156
|
+
var paddingDays = _fillInstanceProperty(_context = Array(paddingDayCount)).call(_context, undefined);
|
|
157
157
|
|
|
158
158
|
var weekdays = getWeekdayNames(intl.locale);
|
|
159
159
|
var today = getToday();
|
|
@@ -171,6 +171,7 @@ var DateInput = function DateInput(props) {
|
|
|
171
171
|
onMouseEnter: function onMouseEnter() {
|
|
172
172
|
// we remove the highlight so that the user can use the
|
|
173
173
|
// arrow keys to move the cursor when hovering
|
|
174
|
+
// @ts-ignore
|
|
174
175
|
if (isOpen) setDownshiftHighlightedIndex(null);
|
|
175
176
|
},
|
|
176
177
|
onKeyDown: function onKeyDown(event) {
|
|
@@ -179,13 +180,13 @@ var DateInput = function DateInput(props) {
|
|
|
179
180
|
return;
|
|
180
181
|
}
|
|
181
182
|
|
|
182
|
-
if (event.key === 'Enter' && _trimInstanceProperty(inputValue).call(inputValue) === '') {
|
|
183
|
+
if (event.key === 'Enter' && (inputValue === null || inputValue === void 0 ? void 0 : _trimInstanceProperty(inputValue).call(inputValue)) === '') {
|
|
183
184
|
clearSelection();
|
|
184
185
|
} // ArrowDown
|
|
185
186
|
|
|
186
187
|
|
|
187
188
|
if (event.keyCode === 40) {
|
|
188
|
-
var nextDayToHighlight = getNextDay(calendarItems[highlightedIndex]);
|
|
189
|
+
var nextDayToHighlight = getNextDay(calendarItems[Number(highlightedIndex)]);
|
|
189
190
|
|
|
190
191
|
if (!getIsDateInRange(nextDayToHighlight, props.minValue, props.maxValue)) {
|
|
191
192
|
// if the date to highlight is disabled
|
|
@@ -194,7 +195,7 @@ var DateInput = function DateInput(props) {
|
|
|
194
195
|
return;
|
|
195
196
|
}
|
|
196
197
|
|
|
197
|
-
if (highlightedIndex + 1 >= calendarItems.length) {
|
|
198
|
+
if (Number(highlightedIndex) + 1 >= calendarItems.length) {
|
|
198
199
|
// if it's the end of the month
|
|
199
200
|
// then bypass normal arrow navigation
|
|
200
201
|
preventDownshiftDefault(event); // then jump to start of next month
|
|
@@ -205,7 +206,7 @@ var DateInput = function DateInput(props) {
|
|
|
205
206
|
|
|
206
207
|
|
|
207
208
|
if (event.keyCode === 38) {
|
|
208
|
-
var previousDay = getPreviousDay(calendarItems[highlightedIndex]);
|
|
209
|
+
var previousDay = getPreviousDay(calendarItems[Number(highlightedIndex)]);
|
|
209
210
|
|
|
210
211
|
if (!getIsDateInRange(previousDay, props.minValue, props.maxValue)) {
|
|
211
212
|
// if the date to highlight is disabled
|
|
@@ -214,7 +215,7 @@ var DateInput = function DateInput(props) {
|
|
|
214
215
|
return;
|
|
215
216
|
}
|
|
216
217
|
|
|
217
|
-
if (highlightedIndex <= 0) {
|
|
218
|
+
if (Number(highlightedIndex) <= 0) {
|
|
218
219
|
// if it's the start of the month
|
|
219
220
|
// then bypass normal arrow navigation
|
|
220
221
|
preventDownshiftDefault(event);
|
|
@@ -261,7 +262,7 @@ var DateInput = function DateInput(props) {
|
|
|
261
262
|
type: "heading",
|
|
262
263
|
children: weekday
|
|
263
264
|
}, weekday);
|
|
264
|
-
}), _mapInstanceProperty(paddingDays).call(paddingDays, function (
|
|
265
|
+
}), _mapInstanceProperty(paddingDays).call(paddingDays, function (_, index) {
|
|
265
266
|
return jsx(CalendarDay, {
|
|
266
267
|
type: "spacing"
|
|
267
268
|
}, index);
|
|
@@ -272,6 +273,7 @@ var DateInput = function DateInput(props) {
|
|
|
272
273
|
disabled: !getIsDateInRange(item, props.minValue, props.maxValue),
|
|
273
274
|
item: item,
|
|
274
275
|
onMouseOut: function onMouseOut() {
|
|
276
|
+
// @ts-ignore
|
|
275
277
|
setDownshiftHighlightedIndex(null);
|
|
276
278
|
}
|
|
277
279
|
})), {}, {
|
|
@@ -288,88 +290,31 @@ var DateInput = function DateInput(props) {
|
|
|
288
290
|
});
|
|
289
291
|
};
|
|
290
292
|
|
|
293
|
+
DateInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
294
|
+
horizontalConstraint: _pt.oneOf([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
295
|
+
value: _pt.string.isRequired,
|
|
296
|
+
onChange: _pt.func.isRequired,
|
|
297
|
+
onFocus: _pt.func,
|
|
298
|
+
onBlur: _pt.func,
|
|
299
|
+
id: _pt.string,
|
|
300
|
+
name: _pt.string,
|
|
301
|
+
placeholder: _pt.string,
|
|
302
|
+
isDisabled: _pt.bool,
|
|
303
|
+
isReadOnly: _pt.bool,
|
|
304
|
+
hasError: _pt.bool,
|
|
305
|
+
hasWarning: _pt.bool,
|
|
306
|
+
minValue: _pt.string,
|
|
307
|
+
maxValue: _pt.string
|
|
308
|
+
} : {};
|
|
291
309
|
DateInput.displayName = 'DateInput';
|
|
292
310
|
|
|
293
311
|
DateInput.isEmpty = function (value) {
|
|
294
312
|
return value === '';
|
|
295
313
|
};
|
|
296
314
|
|
|
297
|
-
DateInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
298
|
-
/**
|
|
299
|
-
* Horizontal size limit of the input field.
|
|
300
|
-
*/
|
|
301
|
-
horizontalConstraint: PropTypes.oneOf([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* The selected date, must either be an empty string or a date formatted as "YYYY-MM-DD".
|
|
305
|
-
*/
|
|
306
|
-
value: PropTypes.string.isRequired,
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Called when the date changes. Called with an event containing either an empty string (no value) or a string in this format: "YYYY-MM-DD".
|
|
310
|
-
* <br />
|
|
311
|
-
* Signature: `(event) => void`
|
|
312
|
-
*/
|
|
313
|
-
onChange: PropTypes.func.isRequired,
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* Called when the date input gains focus.
|
|
317
|
-
*/
|
|
318
|
-
onFocus: PropTypes.func,
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Called when the date input loses focus.
|
|
322
|
-
*/
|
|
323
|
-
onBlur: PropTypes.func,
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* Used as the HTML `id` attribute.
|
|
327
|
-
*/
|
|
328
|
-
id: PropTypes.string,
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Used as the HTML `name` attribute.
|
|
332
|
-
*/
|
|
333
|
-
name: PropTypes.string,
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Placeholder value to show in the input field
|
|
337
|
-
*/
|
|
338
|
-
placeholder: PropTypes.string,
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Disables the date picker
|
|
342
|
-
*/
|
|
343
|
-
isDisabled: PropTypes.bool,
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Disables the date picker menu and makes input field read-only
|
|
347
|
-
*/
|
|
348
|
-
isReadOnly: PropTypes.bool,
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Indicates the input field has an error
|
|
352
|
-
*/
|
|
353
|
-
hasError: PropTypes.bool,
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* Indicates the input field has a warning
|
|
357
|
-
*/
|
|
358
|
-
hasWarning: PropTypes.bool,
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* A minimum selectable date. Must either be an empty string or a date formatted as "YYYY-MM-DD".
|
|
362
|
-
*/
|
|
363
|
-
minValue: PropTypes.string,
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* A maximum selectable date. Must either be an empty string or a date formatted as "YYYY-MM-DD".
|
|
367
|
-
*/
|
|
368
|
-
maxValue: PropTypes.string
|
|
369
|
-
} : {};
|
|
370
315
|
var DateInput$1 = DateInput;
|
|
371
316
|
|
|
372
317
|
// NOTE: This string will be replaced on build time with the package version.
|
|
373
|
-
var version = "
|
|
318
|
+
var version = "13.0.0";
|
|
374
319
|
|
|
375
320
|
export { DateInput$1 as default, version };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type FocusEventHandler } from 'react';
|
|
2
|
+
declare type TEvent = {
|
|
3
|
+
target: {
|
|
4
|
+
id?: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
declare type TDateInput = {
|
|
10
|
+
horizontalConstraint?: 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
|
|
11
|
+
value: string;
|
|
12
|
+
onChange: (event: TEvent) => void;
|
|
13
|
+
onFocus?: FocusEventHandler;
|
|
14
|
+
onBlur?: (event: TEvent) => void;
|
|
15
|
+
id?: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
isDisabled?: boolean;
|
|
19
|
+
isReadOnly?: boolean;
|
|
20
|
+
hasError?: boolean;
|
|
21
|
+
hasWarning?: boolean;
|
|
22
|
+
minValue?: string;
|
|
23
|
+
maxValue?: string;
|
|
24
|
+
};
|
|
25
|
+
declare const DateInput: {
|
|
26
|
+
(props: TDateInput): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
27
|
+
displayName: string;
|
|
28
|
+
isEmpty(value?: string | undefined): boolean;
|
|
29
|
+
};
|
|
30
|
+
export default DateInput;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/date-input",
|
|
3
3
|
"description": "The `DateInput` component allows the user to select a date. It formats the selected date depending on the users' locale.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "13.0.0",
|
|
5
5
|
"bugs": "https://github.com/commercetools/ui-kit/issues",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -19,25 +19,25 @@
|
|
|
19
19
|
"module": "dist/commercetools-uikit-date-input.esm.js",
|
|
20
20
|
"files": ["dist"],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@babel/runtime": "7.
|
|
23
|
-
"@babel/runtime-corejs3": "7.
|
|
24
|
-
"@commercetools-uikit/accessible-button": "
|
|
25
|
-
"@commercetools-uikit/calendar-utils": "
|
|
26
|
-
"@commercetools-uikit/constraints": "
|
|
27
|
-
"@commercetools-uikit/design-system": "
|
|
22
|
+
"@babel/runtime": "7.17.2",
|
|
23
|
+
"@babel/runtime-corejs3": "7.17.2",
|
|
24
|
+
"@commercetools-uikit/accessible-button": "13.0.0",
|
|
25
|
+
"@commercetools-uikit/calendar-utils": "13.0.0",
|
|
26
|
+
"@commercetools-uikit/constraints": "13.0.0",
|
|
27
|
+
"@commercetools-uikit/design-system": "13.0.0",
|
|
28
28
|
"@commercetools-uikit/hooks": "12.2.9",
|
|
29
|
-
"@commercetools-uikit/icons": "
|
|
30
|
-
"@commercetools-uikit/secondary-icon-button": "
|
|
31
|
-
"@commercetools-uikit/select-utils": "
|
|
32
|
-
"@commercetools-uikit/spacings-inline": "
|
|
33
|
-
"@commercetools-uikit/text": "
|
|
34
|
-
"@commercetools-uikit/tooltip": "
|
|
29
|
+
"@commercetools-uikit/icons": "13.0.0",
|
|
30
|
+
"@commercetools-uikit/secondary-icon-button": "13.0.0",
|
|
31
|
+
"@commercetools-uikit/select-utils": "13.0.0",
|
|
32
|
+
"@commercetools-uikit/spacings-inline": "13.0.0",
|
|
33
|
+
"@commercetools-uikit/text": "13.0.0",
|
|
34
|
+
"@commercetools-uikit/tooltip": "13.0.0",
|
|
35
35
|
"@commercetools-uikit/utils": "12.2.9",
|
|
36
36
|
"@emotion/react": "^11.4.0",
|
|
37
37
|
"@emotion/styled": "^11.3.0",
|
|
38
38
|
"common-tags": "1.8.2",
|
|
39
39
|
"downshift": "6.1.7",
|
|
40
|
-
"prop-types": "15.
|
|
40
|
+
"prop-types": "15.8.1",
|
|
41
41
|
"react-is": "17.0.2",
|
|
42
42
|
"react-required-if": "1.0.3",
|
|
43
43
|
"warning": "4.0.3"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"moment": "2.29.1",
|
|
47
47
|
"react": "17.0.2",
|
|
48
|
-
"react-intl": "5.
|
|
48
|
+
"react-intl": "5.24.6"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"moment": "2.x",
|