@synerise/ds-completed-within 0.4.0 → 0.5.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
CHANGED
|
@@ -3,6 +3,42 @@
|
|
|
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.5.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-completed-within@0.5.1...@synerise/ds-completed-within@0.5.2) (2022-05-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **completed-within:** set max width of dropdown ([49c881e](https://github.com/Synerise/synerise-design/commit/49c881e27b8a2cb22c1770645d987a55d03a05cb))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [0.5.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-completed-within@0.5.0...@synerise/ds-completed-within@0.5.1) (2022-05-13)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **completed-within:** fixes clearing tooltip ([b9e0520](https://github.com/Synerise/synerise-design/commit/b9e05208d75069b03e9671981ea061f0e6183c99))
|
|
23
|
+
* **completed-within:** fixes maxValues in btn label ([46c73ad](https://github.com/Synerise/synerise-design/commit/46c73ad326737bd355ba949fcfeceb58b0035d3e))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# [0.5.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-completed-within@0.4.0...@synerise/ds-completed-within@0.5.0) (2022-04-29)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Features
|
|
33
|
+
|
|
34
|
+
* **completed-within:** adds maxValue prop ([cc20e27](https://github.com/Synerise/synerise-design/commit/cc20e2788e2840a9d78bd51cb43a1928fb64e958))
|
|
35
|
+
* **completed-within:** adds tooltip for trigger button ([694812e](https://github.com/Synerise/synerise-design/commit/694812e9179e79c8f8fa4d12054d2704d7abcab3))
|
|
36
|
+
* **completed-within:** replace || by ?? in maxValue ([d36c970](https://github.com/Synerise/synerise-design/commit/d36c970832fcc835881a15a0d013b5c5225c4c72))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
6
42
|
# [0.4.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-completed-within@0.3.15...@synerise/ds-completed-within@0.4.0) (2022-04-05)
|
|
7
43
|
|
|
8
44
|
|
package/README.md
CHANGED
|
@@ -33,9 +33,11 @@ import CompletedWithin from '@synerise/ds-completed-within'
|
|
|
33
33
|
| --- | --- | --- | --- |
|
|
34
34
|
| text | Custom labels and tooltips | CompletedWithinTexts | - |
|
|
35
35
|
| value | Selected value | PeriodValue | { value: undefined, period: 'YEARS'} |
|
|
36
|
+
| maxValue | Max value | PeriodValue[value] | Number.MAX_SAFE_INTEGER |
|
|
36
37
|
| onSetValue | Function called when user has closed the settings with set value, and period | (value: PeriodValue) => void | - |
|
|
37
38
|
| periods | Custom list of periods | CustomPeriod[] | - |
|
|
38
39
|
| placeholder | Trigger button label | string | - |
|
|
40
|
+
| tooltip | Content of tooltip | string | - |
|
|
39
41
|
|
|
40
42
|
### CompletedWithinTexts
|
|
41
43
|
|
package/dist/CompletedWithin.js
CHANGED
|
@@ -12,14 +12,15 @@ import Tooltip from '@synerise/ds-tooltip';
|
|
|
12
12
|
import Settings from './Settings/Settings';
|
|
13
13
|
import * as S from './CompleteWithin.styles';
|
|
14
14
|
export var DEFAULT_PERIODS = ['SECONDS', 'MINUTES', 'HOURS', 'DAYS', 'MONTHS', 'YEARS'];
|
|
15
|
-
var DEFAULT_PERIOD = 'DAYS';
|
|
16
15
|
|
|
17
16
|
var CompletedWithin = function CompletedWithin(_ref) {
|
|
18
17
|
var value = _ref.value,
|
|
18
|
+
maxValue = _ref.maxValue,
|
|
19
19
|
onSetValue = _ref.onSetValue,
|
|
20
20
|
text = _ref.text,
|
|
21
21
|
periods = _ref.periods,
|
|
22
|
-
placeholder = _ref.placeholder
|
|
22
|
+
placeholder = _ref.placeholder,
|
|
23
|
+
tooltip = _ref.tooltip;
|
|
23
24
|
var intl = useIntl();
|
|
24
25
|
var texts = React.useMemo(function () {
|
|
25
26
|
return _objectSpread({
|
|
@@ -61,21 +62,33 @@ var CompletedWithin = function CompletedWithin(_ref) {
|
|
|
61
62
|
innerValue = _React$useState[0],
|
|
62
63
|
setInnerValue = _React$useState[1];
|
|
63
64
|
|
|
64
|
-
var _React$useState2 = React.useState(value.period
|
|
65
|
+
var _React$useState2 = React.useState(value.period),
|
|
65
66
|
innerPeriod = _React$useState2[0],
|
|
66
67
|
setInnerPeriod = _React$useState2[1];
|
|
67
68
|
|
|
69
|
+
var _React$useState3 = React.useState(false),
|
|
70
|
+
tooltipVisible = _React$useState3[0],
|
|
71
|
+
setTooltipVisible = _React$useState3[1];
|
|
72
|
+
|
|
73
|
+
var _React$useState4 = React.useState(false),
|
|
74
|
+
settingsVisible = _React$useState4[0],
|
|
75
|
+
setSettingsVisible = _React$useState4[1];
|
|
76
|
+
|
|
68
77
|
var hasValue = React.useMemo(function () {
|
|
69
78
|
return value.value !== undefined && value.value > 0;
|
|
70
79
|
}, [value]);
|
|
71
80
|
var handleVisibleChange = React.useCallback(function (visible) {
|
|
81
|
+
setSettingsVisible(visible);
|
|
82
|
+
setTooltipVisible(false);
|
|
83
|
+
|
|
72
84
|
if (!visible && innerValue && innerPeriod) {
|
|
85
|
+
var newValue = maxValue && maxValue < innerValue ? maxValue : innerValue;
|
|
73
86
|
onSetValue({
|
|
74
|
-
value: Number(
|
|
87
|
+
value: Number(newValue),
|
|
75
88
|
period: innerPeriod
|
|
76
89
|
});
|
|
77
90
|
}
|
|
78
|
-
}, [innerPeriod, innerValue, onSetValue]);
|
|
91
|
+
}, [innerPeriod, innerValue, maxValue, onSetValue]);
|
|
79
92
|
var handleClear = React.useCallback(function () {
|
|
80
93
|
setInnerPeriod(undefined);
|
|
81
94
|
setInnerValue(undefined);
|
|
@@ -100,9 +113,10 @@ var CompletedWithin = function CompletedWithin(_ref) {
|
|
|
100
113
|
}, /*#__PURE__*/React.createElement(Dropdown, {
|
|
101
114
|
overlay: /*#__PURE__*/React.createElement(Settings, {
|
|
102
115
|
value: {
|
|
103
|
-
value: innerValue !== undefined ? Number(innerValue) :
|
|
116
|
+
value: innerValue !== undefined ? Number(innerValue) : undefined,
|
|
104
117
|
period: innerPeriod
|
|
105
118
|
},
|
|
119
|
+
maxValue: maxValue,
|
|
106
120
|
onValueChange: setInnerValue,
|
|
107
121
|
onPeriodChange: setInnerPeriod,
|
|
108
122
|
text: texts,
|
|
@@ -110,14 +124,24 @@ var CompletedWithin = function CompletedWithin(_ref) {
|
|
|
110
124
|
}),
|
|
111
125
|
trigger: ['click'],
|
|
112
126
|
onVisibleChange: handleVisibleChange,
|
|
113
|
-
placement: "topLeft"
|
|
127
|
+
placement: "topLeft",
|
|
128
|
+
overlayStyle: {
|
|
129
|
+
maxWidth: '238px',
|
|
130
|
+
minWidth: '238px'
|
|
131
|
+
}
|
|
132
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
133
|
+
type: "largeSimple",
|
|
134
|
+
description: tooltip,
|
|
135
|
+
trigger: ['hover'],
|
|
136
|
+
onVisibleChange: setTooltipVisible,
|
|
137
|
+
visible: !settingsVisible && tooltipVisible
|
|
114
138
|
}, /*#__PURE__*/React.createElement(S.TriggerButton, {
|
|
115
139
|
className: "ds-completed-within",
|
|
116
140
|
type: "tertiary",
|
|
117
141
|
mode: triggerMode
|
|
118
142
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
119
143
|
component: /*#__PURE__*/React.createElement(ClockM, null)
|
|
120
|
-
}), triggerLabel)), hasValue && /*#__PURE__*/React.createElement(Tooltip, {
|
|
144
|
+
}), triggerLabel))), hasValue && /*#__PURE__*/React.createElement(Tooltip, {
|
|
121
145
|
title: texts.clear
|
|
122
146
|
}, /*#__PURE__*/React.createElement(S.ClearButton, {
|
|
123
147
|
mode: "single-icon",
|
|
@@ -17,7 +17,9 @@ export declare type PeriodValue = {
|
|
|
17
17
|
export declare type CompletedWithinProps = {
|
|
18
18
|
text?: CompletedWithinTexts;
|
|
19
19
|
value: PeriodValue;
|
|
20
|
+
maxValue?: PeriodValue['value'];
|
|
20
21
|
onSetValue: (value: PeriodValue) => void;
|
|
21
22
|
periods?: CustomPeriod[];
|
|
22
23
|
placeholder?: string | undefined;
|
|
24
|
+
tooltip?: string;
|
|
23
25
|
};
|
|
@@ -9,7 +9,8 @@ var Settings = function Settings(_ref) {
|
|
|
9
9
|
text = _ref.text,
|
|
10
10
|
onPeriodChange = _ref.onPeriodChange,
|
|
11
11
|
onValueChange = _ref.onValueChange,
|
|
12
|
-
periods = _ref.periods
|
|
12
|
+
periods = _ref.periods,
|
|
13
|
+
maxValue = _ref.maxValue;
|
|
13
14
|
return /*#__PURE__*/React.createElement(S.Settings, null, /*#__PURE__*/React.createElement(InputGroup, {
|
|
14
15
|
size: "default",
|
|
15
16
|
label: text.header,
|
|
@@ -20,7 +21,8 @@ var Settings = function Settings(_ref) {
|
|
|
20
21
|
raw: true,
|
|
21
22
|
value: value.value,
|
|
22
23
|
onChange: onValueChange,
|
|
23
|
-
min: 0
|
|
24
|
+
min: 0,
|
|
25
|
+
max: maxValue != null ? maxValue : Number.MAX_SAFE_INTEGER
|
|
24
26
|
}), /*#__PURE__*/React.createElement(Select, {
|
|
25
27
|
size: 'default',
|
|
26
28
|
value: value.period,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import InputNumber from '@synerise/ds-input-number';
|
|
3
|
-
import { CompletedWithinProps, CompletedWithinTexts, CustomPeriod, Period } from '../CompletedWithin.types';
|
|
3
|
+
import { CompletedWithinProps, CompletedWithinTexts, CustomPeriod, Period, PeriodValue } from '../CompletedWithin.types';
|
|
4
4
|
declare type InputProps = React.ComponentProps<typeof InputNumber>;
|
|
5
5
|
export declare type SettingsProps = Omit<CompletedWithinProps, 'onClear' | 'onSetValue' | 'periods' | 'text'> & {
|
|
6
6
|
onValueChange: InputProps['onChange'];
|
|
7
7
|
onPeriodChange: (period: Period) => void;
|
|
8
8
|
periods: CustomPeriod[];
|
|
9
9
|
text: CompletedWithinTexts;
|
|
10
|
+
maxValue: PeriodValue['value'];
|
|
10
11
|
};
|
|
11
12
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-completed-within",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "CompletedWithin UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"types": "dist/index.d.ts",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@synerise/ds-button": "^0.17.2",
|
|
36
|
-
"@synerise/ds-dropdown": "^0.17.
|
|
36
|
+
"@synerise/ds-dropdown": "^0.17.17",
|
|
37
37
|
"@synerise/ds-icon": "^0.49.0",
|
|
38
38
|
"@synerise/ds-input-number": "^0.3.45",
|
|
39
39
|
"@synerise/ds-select": "^0.14.11",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"@synerise/ds-core": "*",
|
|
44
44
|
"react": ">=16.9.0 < 17.0.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "8f33e32ba9432243d34d588baab19d394596bbaa"
|
|
47
47
|
}
|