@synerise/ds-time-picker 0.7.4 → 0.7.6

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 CHANGED
@@ -3,6 +3,26 @@
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.6](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.7.5...@synerise/ds-time-picker@0.7.6) (2023-04-19)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-time-picker
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.7.5](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.7.4...@synerise/ds-time-picker@0.7.5) (2023-04-14)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **date-range-picker:** date range picker us notation fixes ([c17afe0](https://github.com/Synerise/synerise-design/commit/c17afe052c3c0226ab4ed2f7c25655a0d2e89a75))
20
+ * **time-picker:** disabing AM fix ([f02f384](https://github.com/Synerise/synerise-design/commit/f02f384937565b084f1cf9b927bcc09ea9633a28))
21
+
22
+
23
+
24
+
25
+
6
26
  ## [0.7.4](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.7.3...@synerise/ds-time-picker@0.7.4) (2023-04-05)
7
27
 
8
28
  **Note:** Version bump only for package @synerise/ds-time-picker
@@ -7,6 +7,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
7
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
8
 
9
9
  import * as React from 'react';
10
+ import { useCallback } from 'react';
10
11
  import { FormattedMessage, injectIntl } from 'react-intl';
11
12
  import { range } from 'lodash';
12
13
  import dayjs from 'dayjs';
@@ -18,7 +19,7 @@ import { useDataFormat } from '@synerise/ds-data-format';
18
19
  import Unit from './Unit';
19
20
  import * as S from './TimePicker.styles';
20
21
  import { handleTimeChange } from './utils/timePicker.utils';
21
- import { AM, CLOCK_MODES, HOUR, HOUR_12, MINUTE, PM, SECOND } from './constants/timePicker.constants';
22
+ import { AM, CLOCK_MODES, HOUR, HOUR_12, MINUTE, PM, SECOND, DISABLE_CLOCK_MODE_HOUR } from './constants/timePicker.constants';
22
23
  dayjs.extend(customParseFormatPlugin);
23
24
  var defaultUnits = [HOUR, MINUTE, SECOND];
24
25
 
@@ -129,6 +130,29 @@ var TimePicker = function TimePicker(_ref) {
129
130
  React.useEffect(function () {
130
131
  handleChange(undefined, undefined, true); // eslint-disable-next-line react-hooks/exhaustive-deps
131
132
  }, [clockMode]);
133
+ var isAmOrPmModeDisabled = useCallback(function (mode) {
134
+ if (!is12HourClock) {
135
+ return false;
136
+ }
137
+
138
+ if (mode === AM && clockMode === AM) {
139
+ return false;
140
+ }
141
+
142
+ if (mode === PM && clockMode === PM) {
143
+ return false;
144
+ }
145
+
146
+ if (mode === AM && (disabledHours != null && disabledHours.includes(HOUR_12) || disabledHours != null && disabledHours.includes(DISABLE_CLOCK_MODE_HOUR))) {
147
+ return true;
148
+ }
149
+
150
+ if (mode === PM && disabledHours != null && disabledHours.includes(DISABLE_CLOCK_MODE_HOUR)) {
151
+ return true;
152
+ }
153
+
154
+ return false;
155
+ }, [clockMode, disabledHours, is12HourClock]);
132
156
 
133
157
  var renderClockSwitch = function renderClockSwitch() {
134
158
  return /*#__PURE__*/React.createElement(S.Unit, null, Object.values(CLOCK_MODES).map(function (mode) {
@@ -138,7 +162,8 @@ var TimePicker = function TimePicker(_ref) {
138
162
  onClick: function onClick() {
139
163
  setClockMode(mode);
140
164
  onClockModeChange && onClockModeChange(mode);
141
- }
165
+ },
166
+ disabled: isAmOrPmModeDisabled(mode)
142
167
  }, /*#__PURE__*/React.createElement(S.CellText, null, mode));
143
168
  }));
144
169
  };
@@ -7,6 +7,7 @@ export declare const CLOCK_MODES: readonly ["AM", "PM"];
7
7
  export declare const PM: ClockModes;
8
8
  export declare const AM: ClockModes;
9
9
  export declare const HOUR_12 = 12;
10
+ export declare const DISABLE_CLOCK_MODE_HOUR = -1;
10
11
  export declare const MAP_12_AM_TO_24_HOUR: {
11
12
  0: number;
12
13
  1: number;
@@ -5,6 +5,7 @@ export var CLOCK_MODES = ['AM', 'PM'];
5
5
  export var PM = 'PM';
6
6
  export var AM = 'AM';
7
7
  export var HOUR_12 = 12;
8
+ export var DISABLE_CLOCK_MODE_HOUR = -1;
8
9
  export var MAP_12_AM_TO_24_HOUR = {
9
10
  0: 12,
10
11
  1: 1,
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { default } from './TimePicker';
2
- export { AM, PM, HOUR_12, HOUR, CLOCK_MODES, MAP_12_AM_TO_24_HOUR, MAP_12_PM_TO_24_HOUR, MAP_24_HOUR_TO_12, } from './constants/timePicker.constants';
2
+ export { AM, PM, HOUR_12, HOUR, CLOCK_MODES, MAP_12_AM_TO_24_HOUR, MAP_12_PM_TO_24_HOUR, MAP_24_HOUR_TO_12, DISABLE_CLOCK_MODE_HOUR, } from './constants/timePicker.constants';
3
3
  export type { ClockModes, TimePickerProps } from './types/TimePicker.types';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export { default } from './TimePicker';
2
- export { AM, PM, HOUR_12, HOUR, CLOCK_MODES, MAP_12_AM_TO_24_HOUR, MAP_12_PM_TO_24_HOUR, MAP_24_HOUR_TO_12 } from './constants/timePicker.constants';
2
+ export { AM, PM, HOUR_12, HOUR, CLOCK_MODES, MAP_12_AM_TO_24_HOUR, MAP_12_PM_TO_24_HOUR, MAP_24_HOUR_TO_12, DISABLE_CLOCK_MODE_HOUR } from './constants/timePicker.constants';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-time-picker",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "description": "TimePicker UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -32,10 +32,10 @@
32
32
  ],
33
33
  "types": "dist/index.d.ts",
34
34
  "dependencies": {
35
- "@synerise/ds-dropdown": "^0.17.60",
36
- "@synerise/ds-icon": "^0.54.0",
37
- "@synerise/ds-input": "^0.18.37",
38
- "@synerise/ds-search-bar": "^0.6.27",
35
+ "@synerise/ds-dropdown": "^0.17.62",
36
+ "@synerise/ds-icon": "^0.55.0",
37
+ "@synerise/ds-input": "^0.18.38",
38
+ "@synerise/ds-search-bar": "^0.6.28",
39
39
  "@synerise/ds-typography": "^0.12.7",
40
40
  "dayjs": "^1.8.19",
41
41
  "debounce": "^1.2.0"
@@ -47,5 +47,5 @@
47
47
  "devDependencies": {
48
48
  "@types/debounce": "^1.2.0"
49
49
  },
50
- "gitHead": "42bda32506d121cbc207c73efca09f300a749120"
50
+ "gitHead": "3b8c3b1437ecbdda775a790ac3c27d6b1b6cbf26"
51
51
  }