@synerise/ds-completed-within 0.4.0 → 0.5.0
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,19 @@
|
|
|
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.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)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **completed-within:** adds maxValue prop ([cc20e27](https://github.com/Synerise/synerise-design/commit/cc20e2788e2840a9d78bd51cb43a1928fb64e958))
|
|
12
|
+
* **completed-within:** adds tooltip for trigger button ([694812e](https://github.com/Synerise/synerise-design/commit/694812e9179e79c8f8fa4d12054d2704d7abcab3))
|
|
13
|
+
* **completed-within:** replace || by ?? in maxValue ([d36c970](https://github.com/Synerise/synerise-design/commit/d36c970832fcc835881a15a0d013b5c5225c4c72))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
6
19
|
# [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
20
|
|
|
8
21
|
|
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,10 +62,14 @@ 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
|
+
|
|
68
73
|
var hasValue = React.useMemo(function () {
|
|
69
74
|
return value.value !== undefined && value.value > 0;
|
|
70
75
|
}, [value]);
|
|
@@ -75,6 +80,10 @@ var CompletedWithin = function CompletedWithin(_ref) {
|
|
|
75
80
|
period: innerPeriod
|
|
76
81
|
});
|
|
77
82
|
}
|
|
83
|
+
|
|
84
|
+
if (visible) {
|
|
85
|
+
setTooltipVisible(false);
|
|
86
|
+
}
|
|
78
87
|
}, [innerPeriod, innerValue, onSetValue]);
|
|
79
88
|
var handleClear = React.useCallback(function () {
|
|
80
89
|
setInnerPeriod(undefined);
|
|
@@ -100,9 +109,10 @@ var CompletedWithin = function CompletedWithin(_ref) {
|
|
|
100
109
|
}, /*#__PURE__*/React.createElement(Dropdown, {
|
|
101
110
|
overlay: /*#__PURE__*/React.createElement(Settings, {
|
|
102
111
|
value: {
|
|
103
|
-
value: innerValue !== undefined ? Number(innerValue) :
|
|
112
|
+
value: innerValue !== undefined ? Number(innerValue) : undefined,
|
|
104
113
|
period: innerPeriod
|
|
105
114
|
},
|
|
115
|
+
maxValue: maxValue,
|
|
106
116
|
onValueChange: setInnerValue,
|
|
107
117
|
onPeriodChange: setInnerPeriod,
|
|
108
118
|
text: texts,
|
|
@@ -111,13 +121,19 @@ var CompletedWithin = function CompletedWithin(_ref) {
|
|
|
111
121
|
trigger: ['click'],
|
|
112
122
|
onVisibleChange: handleVisibleChange,
|
|
113
123
|
placement: "topLeft"
|
|
124
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
125
|
+
type: "largeSimple",
|
|
126
|
+
description: tooltip,
|
|
127
|
+
trigger: ['hover'],
|
|
128
|
+
onVisibleChange: setTooltipVisible,
|
|
129
|
+
visible: tooltipVisible
|
|
114
130
|
}, /*#__PURE__*/React.createElement(S.TriggerButton, {
|
|
115
131
|
className: "ds-completed-within",
|
|
116
132
|
type: "tertiary",
|
|
117
133
|
mode: triggerMode
|
|
118
134
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
119
135
|
component: /*#__PURE__*/React.createElement(ClockM, null)
|
|
120
|
-
}), triggerLabel)), hasValue && /*#__PURE__*/React.createElement(Tooltip, {
|
|
136
|
+
}), triggerLabel))), hasValue && /*#__PURE__*/React.createElement(Tooltip, {
|
|
121
137
|
title: texts.clear
|
|
122
138
|
}, /*#__PURE__*/React.createElement(S.ClearButton, {
|
|
123
139
|
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.0",
|
|
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": "4a658911645846d1e329609ba9db06a7bc64962b"
|
|
47
47
|
}
|