@synerise/ds-time-picker 0.7.0 → 0.7.2
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 +25 -0
- package/dist/TimePicker.d.ts +1 -1
- package/dist/TimePicker.js +35 -12
- package/dist/TimePicker.styles.js +1 -1
- package/dist/Unit.d.ts +1 -1
- package/dist/types/TimePicker.types.d.ts +8 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,31 @@
|
|
|
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.7.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.7.1...@synerise/ds-time-picker@0.7.2) (2023-03-24)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **date-range-picker:** data format in date range picker usage fix ([0f17e68](https://github.com/Synerise/synerise-design/commit/0f17e68dbdf1d324e939e2dc45f5c5a454dc20f7))
|
|
12
|
+
* **time-picker:** test fix ([ca3dd75](https://github.com/Synerise/synerise-design/commit/ca3dd75d9b39bc49ca571872528673945ead6a60))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [0.7.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.7.0...@synerise/ds-time-picker@0.7.1) (2023-03-21)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* **data-format:** after review changes ([60ca685](https://github.com/Synerise/synerise-design/commit/60ca68551cf3724aebe4c5787bc0d02bb58ac1bf))
|
|
24
|
+
* **data-format:** data format usage fixes ([fef43fc](https://github.com/Synerise/synerise-design/commit/fef43fce8a04a28caddbb7b4dbd68126013ee58d))
|
|
25
|
+
* **time-picker:** time picker data format usage fix ([538edd2](https://github.com/Synerise/synerise-design/commit/538edd231839bc4e9d5259302a385189b492c48f))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
6
31
|
# [0.7.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.6.58...@synerise/ds-time-picker@0.7.0) (2023-03-20)
|
|
7
32
|
|
|
8
33
|
|
package/dist/TimePicker.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { TimePickerProps } from './types/TimePicker.types';
|
|
3
|
-
declare const _default: React.ForwardRefExoticComponent<Pick<TimePickerProps, "className" | "onChange" | "placeholder" | "disabled" | "value" | "trigger" | "placement" | "overlayClassName" | "use12HourClock" | "units" | "defaultOpen" | "containerStyle" | "timeFormat" | "alwaysOpen" | "dropdownProps" | "inputProps" | "disabledHours" | "disabledMinutes" | "disabledSeconds" | "clearTooltip" | "raw" | "onClockModeChange"> & {
|
|
3
|
+
declare const _default: React.ForwardRefExoticComponent<Pick<TimePickerProps, "className" | "onChange" | "placeholder" | "disabled" | "value" | "trigger" | "placement" | "overlayClassName" | "use12HourClock" | "units" | "defaultOpen" | "containerStyle" | "timeFormat" | "valueFormatOptions" | "alwaysOpen" | "dropdownProps" | "inputProps" | "disabledHours" | "disabledMinutes" | "disabledSeconds" | "clearTooltip" | "raw" | "onClockModeChange"> & {
|
|
4
4
|
forwardedRef?: ((instance: any) => void) | React.RefObject<any> | null | undefined;
|
|
5
5
|
} & React.RefAttributes<any>> & {
|
|
6
6
|
WrappedComponent: React.ComponentType<TimePickerProps>;
|
package/dist/TimePicker.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
|
+
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; }
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
7
|
+
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; }
|
|
8
|
+
|
|
3
9
|
import * as React from 'react';
|
|
4
10
|
import { FormattedMessage, injectIntl } from 'react-intl';
|
|
5
11
|
import { range } from 'lodash';
|
|
@@ -8,6 +14,7 @@ import customParseFormatPlugin from 'dayjs/plugin/customParseFormat';
|
|
|
8
14
|
import Icon, { ClockM, Close3S } from '@synerise/ds-icon';
|
|
9
15
|
import Dropdown from '@synerise/ds-dropdown';
|
|
10
16
|
import Tooltip from '@synerise/ds-tooltip/dist/Tooltip';
|
|
17
|
+
import { useDataFormat } from '@synerise/ds-data-format';
|
|
11
18
|
import Unit from './Unit';
|
|
12
19
|
import * as S from './TimePicker.styles';
|
|
13
20
|
import { handleTimeChange } from './utils/timePicker.utils';
|
|
@@ -26,6 +33,7 @@ var TimePicker = function TimePicker(_ref) {
|
|
|
26
33
|
_ref$containerStyle = _ref.containerStyle,
|
|
27
34
|
containerStyle = _ref$containerStyle === void 0 ? {} : _ref$containerStyle,
|
|
28
35
|
timeFormat = _ref.timeFormat,
|
|
36
|
+
valueFormatOptions = _ref.valueFormatOptions,
|
|
29
37
|
use12HourClock = _ref.use12HourClock,
|
|
30
38
|
alwaysOpen = _ref.alwaysOpen,
|
|
31
39
|
_ref$dropdownProps = _ref.dropdownProps,
|
|
@@ -47,6 +55,10 @@ var TimePicker = function TimePicker(_ref) {
|
|
|
47
55
|
onClockModeChange = _ref.onClockModeChange,
|
|
48
56
|
intl = _ref.intl;
|
|
49
57
|
|
|
58
|
+
var _useDataFormat = useDataFormat(),
|
|
59
|
+
formatValue = _useDataFormat.formatValue,
|
|
60
|
+
is12HoursClockFromDataFormat = _useDataFormat.is12HoursClock;
|
|
61
|
+
|
|
50
62
|
var _React$useState = React.useState(defaultOpen || false),
|
|
51
63
|
open = _React$useState[0],
|
|
52
64
|
setOpen = _React$useState[1];
|
|
@@ -59,16 +71,27 @@ var TimePicker = function TimePicker(_ref) {
|
|
|
59
71
|
clockMode = _React$useState2[0],
|
|
60
72
|
setClockMode = _React$useState2[1];
|
|
61
73
|
|
|
74
|
+
var is12HourClock = React.useMemo(function () {
|
|
75
|
+
if (use12HourClock === undefined) return is12HoursClockFromDataFormat;
|
|
76
|
+
return use12HourClock;
|
|
77
|
+
}, [is12HoursClockFromDataFormat, use12HourClock]);
|
|
62
78
|
var timeFormatByClockMode = React.useMemo(function () {
|
|
63
|
-
return timeFormat != null ? timeFormat :
|
|
64
|
-
}, [timeFormat,
|
|
79
|
+
return timeFormat != null ? timeFormat : is12HourClock ? 'hh:mm:ss A' : 'HH:mm:ss';
|
|
80
|
+
}, [timeFormat, is12HourClock]);
|
|
65
81
|
var getTimeString = React.useCallback(function (date) {
|
|
66
|
-
|
|
82
|
+
if (timeFormat) {
|
|
83
|
+
return dayjs(date).format(timeFormatByClockMode);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return formatValue(date, _objectSpread({
|
|
87
|
+
targetFormat: 'time',
|
|
88
|
+
second: 'numeric'
|
|
89
|
+
}, valueFormatOptions));
|
|
67
90
|
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
68
|
-
[timeFormat, timeFormatByClockMode]);
|
|
91
|
+
[timeFormat, timeFormatByClockMode, formatValue]);
|
|
69
92
|
var unitConfig = [{
|
|
70
93
|
unit: HOUR,
|
|
71
|
-
options:
|
|
94
|
+
options: is12HourClock ? range(1, 13) : range(24),
|
|
72
95
|
disabled: disabledHours,
|
|
73
96
|
insertSeperator: true
|
|
74
97
|
}, {
|
|
@@ -80,7 +103,7 @@ var TimePicker = function TimePicker(_ref) {
|
|
|
80
103
|
unit: SECOND,
|
|
81
104
|
options: range(60),
|
|
82
105
|
disabled: disabledSeconds,
|
|
83
|
-
insertSeperator:
|
|
106
|
+
insertSeperator: is12HourClock
|
|
84
107
|
}];
|
|
85
108
|
var unitsToRender = React.useMemo(function () {
|
|
86
109
|
var availableUnits = units != null && units.length ? units : defaultUnits;
|
|
@@ -99,7 +122,7 @@ var TimePicker = function TimePicker(_ref) {
|
|
|
99
122
|
clockModeChanged = false;
|
|
100
123
|
}
|
|
101
124
|
|
|
102
|
-
var newDate = handleTimeChange(value, unit, newValue, clockModeChanged,
|
|
125
|
+
var newDate = handleTimeChange(value, unit, newValue, clockModeChanged, is12HourClock, clockMode, unitConfig);
|
|
103
126
|
onChange && onChange(newDate, getTimeString(newDate));
|
|
104
127
|
};
|
|
105
128
|
|
|
@@ -131,9 +154,9 @@ var TimePicker = function TimePicker(_ref) {
|
|
|
131
154
|
onSelect: function onSelect(newValue) {
|
|
132
155
|
return handleChange(u.unit, newValue);
|
|
133
156
|
},
|
|
134
|
-
use12HourClock:
|
|
135
|
-
})), (index !== unitsToRender.length - 1 ||
|
|
136
|
-
}),
|
|
157
|
+
use12HourClock: is12HourClock
|
|
158
|
+
})), (index !== unitsToRender.length - 1 || is12HourClock) && /*#__PURE__*/React.createElement(S.UnitSeperator, null));
|
|
159
|
+
}), is12HourClock && renderClockSwitch());
|
|
137
160
|
var localValue = value;
|
|
138
161
|
var dateString = localValue && getTimeString(localValue);
|
|
139
162
|
var clear = React.useCallback(function () {
|
|
@@ -156,13 +179,13 @@ var TimePicker = function TimePicker(_ref) {
|
|
|
156
179
|
}, [open, dateString, clear, clearTooltip, alwaysOpen, disabled]);
|
|
157
180
|
var placeholderValue = React.useMemo(function () {
|
|
158
181
|
if (value) {
|
|
159
|
-
return
|
|
182
|
+
return getTimeString(value);
|
|
160
183
|
}
|
|
161
184
|
|
|
162
185
|
return placeholder || intl.formatMessage({
|
|
163
186
|
id: 'DS.TIME-PICKER.PLACEHOLDER'
|
|
164
187
|
});
|
|
165
|
-
}, [placeholder, intl, value,
|
|
188
|
+
}, [placeholder, intl, value, getTimeString]);
|
|
166
189
|
|
|
167
190
|
if (raw) {
|
|
168
191
|
return overlay;
|
|
@@ -25,7 +25,7 @@ export var UnitSeperator = styled.div.withConfig({
|
|
|
25
25
|
export var CellText = styled(Label).withConfig({
|
|
26
26
|
displayName: "TimePickerstyles__CellText",
|
|
27
27
|
componentId: "yk19n0-4"
|
|
28
|
-
})(["&&{width:
|
|
28
|
+
})(["&&{width:22px;height:18px;text-align:center;color:", ";transition:color 0.3s;}"], function (props) {
|
|
29
29
|
return props.theme.palette['grey-600'];
|
|
30
30
|
});
|
|
31
31
|
export var Cell = styled.button.withConfig({
|
package/dist/Unit.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import dayjs from 'dayjs';
|
|
|
3
3
|
import { IntlShape } from 'react-intl';
|
|
4
4
|
import { InputProps } from 'antd/es/input/Input';
|
|
5
5
|
import { DropdownProps } from '@synerise/ds-dropdown/dist/Dropdown';
|
|
6
|
+
import { DateToFormatOptions } from '@synerise/ds-data-format';
|
|
6
7
|
import { CLOCK_MODES } from '../constants/timePicker.constants';
|
|
7
8
|
export declare type ClockModes = typeof CLOCK_MODES[number];
|
|
8
9
|
export declare type TimePickerDisabledUnits = {
|
|
@@ -26,9 +27,16 @@ export declare type TimePickerProps = TimePickerDisabledUnits & {
|
|
|
26
27
|
placeholder?: string;
|
|
27
28
|
placement?: 'topLeft' | 'topCenter' | 'topRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight';
|
|
28
29
|
raw?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated use `valueFormatOptions` instead
|
|
32
|
+
*/
|
|
29
33
|
timeFormat?: string;
|
|
30
34
|
trigger?: ('click' | 'hover' | 'contextMenu')[];
|
|
31
35
|
units?: dayjs.UnitType[];
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated use DSProvider::dataFormatConfig instead
|
|
38
|
+
*/
|
|
32
39
|
use12HourClock?: boolean;
|
|
40
|
+
valueFormatOptions?: DateToFormatOptions;
|
|
33
41
|
value?: Date;
|
|
34
42
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-time-picker",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "TimePicker UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
],
|
|
33
33
|
"types": "dist/index.d.ts",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@synerise/ds-dropdown": "^0.17.
|
|
35
|
+
"@synerise/ds-dropdown": "^0.17.58",
|
|
36
36
|
"@synerise/ds-icon": "^0.54.0",
|
|
37
37
|
"@synerise/ds-input": "^0.18.36",
|
|
38
38
|
"@synerise/ds-search-bar": "^0.6.26",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/debounce": "^1.2.0"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "f6617e99a823599ee63f3d094b81cdbec3a979ea"
|
|
51
51
|
}
|