@synerise/ds-time-picker 0.8.8 → 0.8.9
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 +8 -0
- package/dist/TimePicker.d.ts +2 -2
- package/dist/TimePicker.js +4 -6
- package/dist/TimePicker.styles.d.ts +2 -14
- package/dist/Unit.d.ts +3 -4
- package/dist/Unit.js +20 -10
- package/dist/types/TimePicker.types.d.ts +3 -3
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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.8.9](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.8.8...@synerise/ds-time-picker@0.8.9) (2023-10-02)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-time-picker
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [0.8.8](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.8.7...@synerise/ds-time-picker@0.8.8) (2023-09-26)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @synerise/ds-time-picker
|
package/dist/TimePicker.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { TimePickerProps } from './types/TimePicker.types';
|
|
3
|
-
declare const _default: React.ForwardRefExoticComponent<
|
|
4
|
-
forwardedRef?:
|
|
3
|
+
declare const _default: React.ForwardRefExoticComponent<import("react-intl").Omit<TimePickerProps, "intl"> & {
|
|
4
|
+
forwardedRef?: React.Ref<any> | undefined;
|
|
5
5
|
} & React.RefAttributes<any>> & {
|
|
6
6
|
WrappedComponent: React.ComponentType<TimePickerProps>;
|
|
7
7
|
};
|
package/dist/TimePicker.js
CHANGED
|
@@ -99,12 +99,10 @@ var TimePicker = function TimePicker(_ref) {
|
|
|
99
99
|
disabled: disabledSeconds,
|
|
100
100
|
insertSeperator: is12HourClock
|
|
101
101
|
}];
|
|
102
|
-
var
|
|
103
|
-
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
});
|
|
107
|
-
}, [units, unitConfig]);
|
|
102
|
+
var availableUnits = units != null && units.length ? units : defaultUnits;
|
|
103
|
+
var unitsToRender = unitConfig.filter(function (u) {
|
|
104
|
+
return availableUnits && availableUnits.includes(u.unit);
|
|
105
|
+
});
|
|
108
106
|
|
|
109
107
|
var onVisibleChange = function onVisibleChange(visible) {
|
|
110
108
|
setOpen(visible);
|
|
@@ -8,21 +8,9 @@ export declare const Cell: import("styled-components").StyledComponent<"button",
|
|
|
8
8
|
active?: boolean | undefined;
|
|
9
9
|
}, never>;
|
|
10
10
|
export declare const ClearIcon: import("styled-components").StyledComponent<import("react").FC<import("@synerise/ds-icon").IconProps>, any, {}, never>;
|
|
11
|
-
export declare const TimePickerInput: import("styled-components").StyledComponent<
|
|
12
|
-
mask: string;
|
|
13
|
-
formatCharacters?: object | undefined;
|
|
14
|
-
placeholderChar?: string | undefined;
|
|
15
|
-
value?: string | undefined;
|
|
16
|
-
}) | (object & import("@synerise/ds-input").InputProps & import("antd/lib/input").TextAreaProps), any> & {
|
|
11
|
+
export declare const TimePickerInput: import("styled-components").StyledComponent<import("react").ComponentType<object & import("@synerise/ds-input").EnhancedProps> & {
|
|
17
12
|
displayName: string;
|
|
18
|
-
}
|
|
19
|
-
mask: string;
|
|
20
|
-
formatCharacters?: object | undefined;
|
|
21
|
-
placeholderChar?: string | undefined;
|
|
22
|
-
value?: string | undefined;
|
|
23
|
-
})> & {
|
|
24
|
-
displayName: string;
|
|
25
|
-
}), any, {}, never>;
|
|
13
|
+
}, any, {}, never>;
|
|
26
14
|
export declare const PlaceholderWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
27
15
|
export declare const Placeholder: import("styled-components").StyledComponent<"div", any, {
|
|
28
16
|
height: number;
|
package/dist/Unit.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import dayjs from 'dayjs';
|
|
3
|
-
export
|
|
2
|
+
export type UnitConfig = {
|
|
4
3
|
unit: dayjs.UnitType;
|
|
5
4
|
options: number[];
|
|
6
5
|
disabled?: number[];
|
|
7
6
|
insertSeperator?: boolean;
|
|
8
7
|
use12HourClock?: boolean | undefined;
|
|
9
8
|
};
|
|
10
|
-
export
|
|
9
|
+
export type UnitProps = UnitConfig & {
|
|
11
10
|
value?: Date;
|
|
12
11
|
onSelect: (value: number) => void;
|
|
13
12
|
};
|
|
14
|
-
declare const Unit:
|
|
13
|
+
declare const Unit: ({ options, disabled, value, unit, onSelect, use12HourClock }: UnitProps) => JSX.Element;
|
|
15
14
|
export default Unit;
|
package/dist/Unit.js
CHANGED
|
@@ -41,26 +41,36 @@ var Unit = function Unit(_ref) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}, [isFirstRender, unitContainerRef]);
|
|
44
|
-
|
|
44
|
+
|
|
45
|
+
var scrollHandler = function scrollHandler() {
|
|
45
46
|
if (!!unitContainerRef && !!unitContainerRef.current) {
|
|
46
47
|
var pixelsScrolled = unitContainerRef.current.scrollTop;
|
|
47
48
|
var isScrollBetweenTwoCells = pixelsScrolled % CELL_HEIGHT !== 0;
|
|
48
|
-
pixelsScrolled !== 0 && isScrollBetweenTwoCells && unitContainerRef.current.scrollTo({
|
|
49
|
+
pixelsScrolled !== 0 && isScrollBetweenTwoCells && typeof unitContainerRef.current.scrollTo === 'function' && unitContainerRef.current.scrollTo({
|
|
49
50
|
top: Math.round(pixelsScrolled / CELL_HEIGHT) * CELL_HEIGHT,
|
|
50
51
|
behavior: 'smooth'
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
|
-
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
var debouncedScrollHandler = debounce(scrollHandler, DEBOUNCE_DELAY);
|
|
57
|
+
React.useEffect(function () {
|
|
58
|
+
return function () {
|
|
59
|
+
debouncedScrollHandler.clear();
|
|
60
|
+
};
|
|
61
|
+
}, [debouncedScrollHandler]);
|
|
54
62
|
React.useEffect(function () {
|
|
55
63
|
if (selectedCellRef.current && unitContainerRef.current) {
|
|
56
|
-
var _unitContainerRef$cur, _unitContainerRef$cur2;
|
|
57
|
-
|
|
58
64
|
var offsetToParent = selectedCellRef.current.offsetTop - unitContainerRef.current.offsetTop;
|
|
59
65
|
var scrollBehaviour = isFirstRender || !containerHeight ? 'auto' : 'smooth';
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
|
|
67
|
+
if (typeof unitContainerRef.current.scrollTo === 'function') {
|
|
68
|
+
unitContainerRef.current.scrollTo({
|
|
69
|
+
top: offsetToParent,
|
|
70
|
+
behavior: scrollBehaviour
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
64
74
|
setContainerHeight(unitContainerRef.current.offsetHeight);
|
|
65
75
|
}
|
|
66
76
|
}, [selectedCellRef, unitContainerRef, isFirstRender, forceUpdate, containerHeight]);
|
|
@@ -68,7 +78,7 @@ var Unit = function Unit(_ref) {
|
|
|
68
78
|
"data-testid": "ds-time-picker-unit-" + unit
|
|
69
79
|
}, /*#__PURE__*/React.createElement(Scrollbar, {
|
|
70
80
|
ref: unitContainerRef,
|
|
71
|
-
onScroll:
|
|
81
|
+
onScroll: debouncedScrollHandler,
|
|
72
82
|
maxHeight: 192
|
|
73
83
|
}, options.map(function (option) {
|
|
74
84
|
var normalizedStringValue = option < 10 ? "0" + option : option.toString();
|
|
@@ -5,13 +5,13 @@ import { InputProps } from 'antd/es/input/Input';
|
|
|
5
5
|
import { DropdownProps } from '@synerise/ds-dropdown/dist/Dropdown';
|
|
6
6
|
import { DateToFormatOptions } from '@synerise/ds-data-format';
|
|
7
7
|
import { CLOCK_MODES } from '../constants/timePicker.constants';
|
|
8
|
-
export
|
|
9
|
-
export
|
|
8
|
+
export type ClockModes = typeof CLOCK_MODES[number];
|
|
9
|
+
export type TimePickerDisabledUnits = {
|
|
10
10
|
disabledSeconds?: number[];
|
|
11
11
|
disabledMinutes?: number[];
|
|
12
12
|
disabledHours?: number[];
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type TimePickerProps = TimePickerDisabledUnits & {
|
|
15
15
|
alwaysOpen?: boolean;
|
|
16
16
|
className?: string;
|
|
17
17
|
clearTooltip?: string | React.ReactNode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-time-picker",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.9",
|
|
4
4
|
"description": "TimePicker UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
],
|
|
33
33
|
"types": "dist/index.d.ts",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@synerise/ds-data-format": "^0.4.
|
|
36
|
-
"@synerise/ds-dropdown": "^0.17.
|
|
37
|
-
"@synerise/ds-icon": "^0.58.
|
|
38
|
-
"@synerise/ds-input": "^0.19.
|
|
39
|
-
"@synerise/ds-scrollbar": "^0.6.
|
|
40
|
-
"@synerise/ds-tooltip": "^0.14.
|
|
41
|
-
"@synerise/ds-typography": "^0.13.
|
|
42
|
-
"@synerise/ds-utils": "^0.24.
|
|
35
|
+
"@synerise/ds-data-format": "^0.4.3",
|
|
36
|
+
"@synerise/ds-dropdown": "^0.17.81",
|
|
37
|
+
"@synerise/ds-icon": "^0.58.3",
|
|
38
|
+
"@synerise/ds-input": "^0.19.3",
|
|
39
|
+
"@synerise/ds-scrollbar": "^0.6.8",
|
|
40
|
+
"@synerise/ds-tooltip": "^0.14.5",
|
|
41
|
+
"@synerise/ds-typography": "^0.13.1",
|
|
42
|
+
"@synerise/ds-utils": "^0.24.17",
|
|
43
43
|
"dayjs": "^1.8.19",
|
|
44
44
|
"debounce": "^1.2.0",
|
|
45
45
|
"lodash": "^4.17.19",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@testing-library/react": "10.0.1",
|
|
55
|
-
"@types/debounce": "^1.2.
|
|
55
|
+
"@types/debounce": "^1.2.1"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "1c1adf344f447e404a1d6320ad1d3f8486f29f67"
|
|
58
58
|
}
|