@synerise/ds-date-picker 0.11.5 → 0.11.7
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/CHANGELOG.md +19 -0
- package/dist/DatePicker.js +7 -3
- package/dist/DatePicker.types.d.ts +8 -8
- package/dist/Elements/TimePicker/TimePicker.types.d.ts +3 -3
- package/dist/RawDatePicker/RawDatePicker.d.ts +7 -30
- package/dist/RawDatePicker/RawDatePicker.js +5 -15
- package/dist/utils/getDefaultTexts.d.ts +3 -0
- package/dist/utils/getDefaultTexts.js +28 -0
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.11.7](https://github.com/Synerise/synerise-design/compare/@synerise/ds-date-picker@0.11.6...@synerise/ds-date-picker@0.11.7) (2024-07-15)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-date-picker
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.11.6](https://github.com/Synerise/synerise-design/compare/@synerise/ds-date-picker@0.11.5...@synerise/ds-date-picker@0.11.6) (2024-07-05)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **date-picker:** fixes of types ([1b09748](https://github.com/Synerise/synerise-design/commit/1b097484782a5dc37e71711d7308511eb8103a45))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [0.11.5](https://github.com/Synerise/synerise-design/compare/@synerise/ds-date-picker@0.11.4...@synerise/ds-date-picker@0.11.5) (2024-07-02)
|
|
7
26
|
|
|
8
27
|
|
package/dist/DatePicker.js
CHANGED
|
@@ -5,11 +5,13 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
5
5
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
6
|
|
|
7
7
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
8
|
+
import { useIntl } from 'react-intl';
|
|
8
9
|
import Dropdown from '@synerise/ds-dropdown';
|
|
9
10
|
import { useOnClickOutside } from '@synerise/ds-utils';
|
|
10
11
|
import RawDatePicker from './RawDatePicker/RawDatePicker';
|
|
11
12
|
import PickerInput from './Elements/PickerInput/PickerInput';
|
|
12
13
|
import * as S from './DatePicker.styles';
|
|
14
|
+
import { getDefaultTexts } from './utils/getDefaultTexts';
|
|
13
15
|
|
|
14
16
|
var DatePicker = function DatePicker(_ref) {
|
|
15
17
|
var autoFocus = _ref.autoFocus,
|
|
@@ -44,6 +46,8 @@ var DatePicker = function DatePicker(_ref) {
|
|
|
44
46
|
setSelectedDate = _useState2[1];
|
|
45
47
|
|
|
46
48
|
var ref = useRef(null);
|
|
49
|
+
var intl = useIntl();
|
|
50
|
+
var allTexts = getDefaultTexts(intl, texts);
|
|
47
51
|
useOnClickOutside(ref, function () {
|
|
48
52
|
!!dropVisible && setDropVisible(false);
|
|
49
53
|
});
|
|
@@ -74,10 +78,10 @@ var DatePicker = function DatePicker(_ref) {
|
|
|
74
78
|
format: format,
|
|
75
79
|
valueFormatOptions: valueFormatOptions,
|
|
76
80
|
onClear: handleClear,
|
|
77
|
-
placeholder:
|
|
81
|
+
placeholder: allTexts.inputPlaceholder,
|
|
78
82
|
prefixel: prefixel,
|
|
79
83
|
suffixel: suffixel,
|
|
80
|
-
clearTooltip:
|
|
84
|
+
clearTooltip: allTexts.clearTooltip,
|
|
81
85
|
highlight: !!dropVisible && !disabled,
|
|
82
86
|
error: error,
|
|
83
87
|
errorText: errorText,
|
|
@@ -88,7 +92,7 @@ var DatePicker = function DatePicker(_ref) {
|
|
|
88
92
|
ref: ref
|
|
89
93
|
}, /*#__PURE__*/React.createElement(RawDatePicker, _extends({}, rest, {
|
|
90
94
|
showTime: showTime,
|
|
91
|
-
texts:
|
|
95
|
+
texts: allTexts,
|
|
92
96
|
onApply: onApplyCallback,
|
|
93
97
|
onValueChange: onValueChangeCallback,
|
|
94
98
|
value: selectedDate,
|
|
@@ -7,17 +7,17 @@ export type DatePickerProps = {
|
|
|
7
7
|
autoFocus?: boolean;
|
|
8
8
|
disabled?: boolean;
|
|
9
9
|
disabledDates?: (date?: Date) => boolean;
|
|
10
|
-
disabledHours
|
|
11
|
-
disabledMinutes
|
|
12
|
-
disabledSeconds
|
|
10
|
+
disabledHours?: number[];
|
|
11
|
+
disabledMinutes?: number[];
|
|
12
|
+
disabledSeconds?: number[];
|
|
13
13
|
dropdownProps?: Partial<DropdownProps>;
|
|
14
14
|
/**
|
|
15
15
|
* @deprecated use `valueFormatOptions` instead
|
|
16
16
|
*/
|
|
17
17
|
format?: string;
|
|
18
18
|
valueFormatOptions?: DateToFormatOptions;
|
|
19
|
-
intl
|
|
20
|
-
onApply
|
|
19
|
+
intl: IntlShape;
|
|
20
|
+
onApply: (date?: Date) => void;
|
|
21
21
|
onClear?: () => void;
|
|
22
22
|
onDropdownVisibleChange?: (visible: boolean) => void;
|
|
23
23
|
onValueChange?: (date?: Date) => void;
|
|
@@ -27,7 +27,7 @@ export type DatePickerProps = {
|
|
|
27
27
|
prefixel?: ReactNode;
|
|
28
28
|
suffixel?: ReactNode;
|
|
29
29
|
showTime?: boolean;
|
|
30
|
-
texts
|
|
30
|
+
texts?: Partial<Texts>;
|
|
31
31
|
renderTrigger?: () => ReactElement;
|
|
32
32
|
value?: Date;
|
|
33
33
|
useStartOfDay?: boolean;
|
|
@@ -57,6 +57,6 @@ export type Modifier = {
|
|
|
57
57
|
export type Texts = {
|
|
58
58
|
apply: ReactNode;
|
|
59
59
|
now: ReactNode;
|
|
60
|
-
inputPlaceholder
|
|
61
|
-
clearTooltip
|
|
60
|
+
inputPlaceholder: string;
|
|
61
|
+
clearTooltip: ReactNode;
|
|
62
62
|
};
|
|
@@ -2,9 +2,9 @@ export type TimePickerProps = {
|
|
|
2
2
|
format?: string;
|
|
3
3
|
value?: Date;
|
|
4
4
|
onChange: (date?: Date | undefined) => void;
|
|
5
|
-
disabledHours
|
|
6
|
-
disabledMinutes
|
|
7
|
-
disabledSeconds
|
|
5
|
+
disabledHours?: number[];
|
|
6
|
+
disabledMinutes?: number[];
|
|
7
|
+
disabledSeconds?: number[];
|
|
8
8
|
inactivePrev?: boolean;
|
|
9
9
|
inactiveNext?: boolean;
|
|
10
10
|
onShortNext?: () => void;
|
|
@@ -1,30 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
disabledHours: never[];
|
|
9
|
-
disabledMinutes: never[];
|
|
10
|
-
disabledSeconds: never[];
|
|
11
|
-
};
|
|
12
|
-
constructor(props: Props);
|
|
13
|
-
getTexts(): Texts;
|
|
14
|
-
getSnapshotBeforeUpdate(prevProps: Readonly<Props>): null;
|
|
15
|
-
handleChange: (value: Date | undefined) => void;
|
|
16
|
-
handleDayMouseEnter: (day: Date) => void;
|
|
17
|
-
handleDayMouseLeave: () => void;
|
|
18
|
-
handleDayClick: (day: Date, modifiers: DayModifiers) => void;
|
|
19
|
-
handleModeSwitch: (mode: string) => void;
|
|
20
|
-
handleApply: (date: Date | undefined) => void;
|
|
21
|
-
handleMonthChange: (month: Date, mode: string) => void;
|
|
22
|
-
renderDay: (day: Date) => React.ReactNode;
|
|
23
|
-
renderYearPicker: () => React.ReactNode;
|
|
24
|
-
renderMonthPicker: () => React.ReactNode;
|
|
25
|
-
renderDayPicker: () => React.ReactNode;
|
|
26
|
-
handleDaySwitch: (day: Date) => void;
|
|
27
|
-
renderTimePicker: () => React.ReactNode;
|
|
28
|
-
render(): React.ReactNode;
|
|
29
|
-
}
|
|
30
|
-
export default RawDatePicker;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const _default: React.ForwardRefExoticComponent<import("react-intl").Omit<import("../DatePicker.types").DatePickerProps, "intl"> & {
|
|
3
|
+
forwardedRef?: React.Ref<any> | undefined;
|
|
4
|
+
} & React.RefAttributes<any>> & {
|
|
5
|
+
WrappedComponent: React.ComponentType<import("../DatePicker.types").DatePickerProps>;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
@@ -2,8 +2,8 @@ function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.crea
|
|
|
2
2
|
|
|
3
3
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { injectIntl } from 'react-intl';
|
|
7
7
|
import { legacyParse } from '@date-fns/upgrade/v2';
|
|
8
8
|
import Footer from '../Elements/Footer/Footer';
|
|
9
9
|
import * as S from '../DatePicker.styles';
|
|
@@ -15,6 +15,7 @@ import TimePicker from '../Elements/TimePicker/TimePicker';
|
|
|
15
15
|
import { DayBackground, DayText, DayForeground } from '../Elements/DayPicker/DayPicker.styles';
|
|
16
16
|
import { fnsStartOfMonth, fnsSetYear, fnsSetMonth, fnsSetDate, fnsStartOfDay, fnsEndOfDay, fnsAddDays } from '../fns';
|
|
17
17
|
import { changeDayWithHoursPreserved } from '../utils';
|
|
18
|
+
import { getDefaultTexts } from '../utils/getDefaultTexts';
|
|
18
19
|
|
|
19
20
|
var RawDatePicker = /*#__PURE__*/function (_React$Component) {
|
|
20
21
|
function RawDatePicker(props) {
|
|
@@ -236,18 +237,7 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
236
237
|
var _this$props3 = this.props,
|
|
237
238
|
texts = _this$props3.texts,
|
|
238
239
|
intl = _this$props3.intl;
|
|
239
|
-
|
|
240
|
-
apply: (texts == null ? void 0 : texts.apply) || /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
241
|
-
id: "DS.DATE-PICKER.APPLY"
|
|
242
|
-
}),
|
|
243
|
-
now: (texts == null ? void 0 : texts.now) || /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
244
|
-
id: "DS.DATE-PICKER.NOW"
|
|
245
|
-
}),
|
|
246
|
-
inputPlaceholder: (texts == null ? void 0 : texts.inputPlaceholder) || (intl == null ? void 0 : intl.formatMessage({
|
|
247
|
-
id: 'DS.DATE-PICKER.SELECT-DATE'
|
|
248
|
-
})) || ''
|
|
249
|
-
};
|
|
250
|
-
return updatedTexts;
|
|
240
|
+
return getDefaultTexts(intl, texts);
|
|
251
241
|
};
|
|
252
242
|
|
|
253
243
|
_proto.getSnapshotBeforeUpdate = function getSnapshotBeforeUpdate(prevProps) {
|
|
@@ -326,4 +316,4 @@ _defineProperty(RawDatePicker, "defaultProps", {
|
|
|
326
316
|
disabledSeconds: []
|
|
327
317
|
});
|
|
328
318
|
|
|
329
|
-
export default RawDatePicker;
|
|
319
|
+
export default injectIntl(RawDatePicker);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { FormattedMessage } from 'react-intl';
|
|
9
|
+
export var getDefaultTexts = function getDefaultTexts(intl, texts) {
|
|
10
|
+
var defaultTexts = {
|
|
11
|
+
apply: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
12
|
+
id: "DS.DATE-PICKER.APPLY",
|
|
13
|
+
defaultMessage: "Apply"
|
|
14
|
+
}),
|
|
15
|
+
now: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
16
|
+
id: "DS.DATE-PICKER.NOW",
|
|
17
|
+
defaultMessage: "Now"
|
|
18
|
+
}),
|
|
19
|
+
inputPlaceholder: intl.formatMessage({
|
|
20
|
+
id: 'DS.DATE-PICKER.SELECT-DATE'
|
|
21
|
+
}),
|
|
22
|
+
clearTooltip: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
23
|
+
id: "DS.DATE-PICKER.CLEAR-TOOLTIP",
|
|
24
|
+
defaultMessage: "Clear"
|
|
25
|
+
})
|
|
26
|
+
};
|
|
27
|
+
return texts ? _objectSpread({}, defaultTexts, {}, texts) : defaultTexts;
|
|
28
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-date-picker",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.7",
|
|
4
4
|
"description": "DatePicker UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"types": "dist/index.d.ts",
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@date-fns/upgrade": "^1.0.3",
|
|
37
|
-
"@synerise/ds-button": "^0.21.
|
|
38
|
-
"@synerise/ds-data-format": "^0.5.
|
|
39
|
-
"@synerise/ds-dropdown": "^0.18.
|
|
40
|
-
"@synerise/ds-icon": "^0.
|
|
41
|
-
"@synerise/ds-input": "^0.23.
|
|
42
|
-
"@synerise/ds-time-picker": "^0.10.
|
|
43
|
-
"@synerise/ds-tooltip": "^0.14.
|
|
44
|
-
"@synerise/ds-utils": "^0.
|
|
37
|
+
"@synerise/ds-button": "^0.21.3",
|
|
38
|
+
"@synerise/ds-data-format": "^0.5.1",
|
|
39
|
+
"@synerise/ds-dropdown": "^0.18.5",
|
|
40
|
+
"@synerise/ds-icon": "^0.64.1",
|
|
41
|
+
"@synerise/ds-input": "^0.23.2",
|
|
42
|
+
"@synerise/ds-time-picker": "^0.10.15",
|
|
43
|
+
"@synerise/ds-tooltip": "^0.14.33",
|
|
44
|
+
"@synerise/ds-utils": "^0.28.0",
|
|
45
45
|
"classnames": "2.3.2",
|
|
46
46
|
"date-fns": "2.16.1",
|
|
47
47
|
"lodash": "^4.17.20",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@synerise/ds-core": "*",
|
|
54
54
|
"antd": "4.7.0",
|
|
55
|
-
"react": ">=16.9.0
|
|
55
|
+
"react": ">=16.9.0 <= 17.0.2",
|
|
56
56
|
"styled-components": "5.0.1"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "6f4996380356c1e5cb9a9d8b553069ad9cea7c27"
|
|
59
59
|
}
|