@synerise/ds-completed-within 0.3.14 → 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 +33 -0
- package/README.md +9 -6
- package/dist/CompletedWithin.js +28 -11
- package/dist/CompletedWithin.types.d.ts +3 -0
- package/dist/Settings/Settings.js +4 -2
- package/dist/Settings/Settings.types.d.ts +2 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,39 @@
|
|
|
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
|
+
|
|
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)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* **completed-within:** adds placeholder nad tooltip props ([22976de](https://github.com/Synerise/synerise-design/commit/22976deac9012e1654b86ad745da7207e664ad88))
|
|
25
|
+
* **completed-within:** adds placeholder prop ([6aa6e91](https://github.com/Synerise/synerise-design/commit/6aa6e91cb9fae233d6c2e1cf447fd91082c67686))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## [0.3.15](https://github.com/Synerise/synerise-design/compare/@synerise/ds-completed-within@0.3.14...@synerise/ds-completed-within@0.3.15) (2022-03-30)
|
|
32
|
+
|
|
33
|
+
**Note:** Version bump only for package @synerise/ds-completed-within
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
6
39
|
## [0.3.14](https://github.com/Synerise/synerise-design/compare/@synerise/ds-completed-within@0.3.13...@synerise/ds-completed-within@0.3.14) (2022-03-24)
|
|
7
40
|
|
|
8
41
|
**Note:** Version bump only for package @synerise/ds-completed-within
|
package/README.md
CHANGED
|
@@ -29,12 +29,15 @@ import CompletedWithin from '@synerise/ds-completed-within'
|
|
|
29
29
|
|
|
30
30
|
## API
|
|
31
31
|
|
|
32
|
-
| Property
|
|
33
|
-
| ---
|
|
34
|
-
| text
|
|
35
|
-
| value
|
|
36
|
-
|
|
|
37
|
-
|
|
|
32
|
+
| Property | Description | Type | Default |
|
|
33
|
+
| --- | --- | --- | --- |
|
|
34
|
+
| text | Custom labels and tooltips | CompletedWithinTexts | - |
|
|
35
|
+
| value | Selected value | PeriodValue | { value: undefined, period: 'YEARS'} |
|
|
36
|
+
| maxValue | Max value | PeriodValue[value] | Number.MAX_SAFE_INTEGER |
|
|
37
|
+
| onSetValue | Function called when user has closed the settings with set value, and period | (value: PeriodValue) => void | - |
|
|
38
|
+
| periods | Custom list of periods | CustomPeriod[] | - |
|
|
39
|
+
| placeholder | Trigger button label | string | - |
|
|
40
|
+
| tooltip | Content of tooltip | string | - |
|
|
38
41
|
|
|
39
42
|
### CompletedWithinTexts
|
|
40
43
|
|
package/dist/CompletedWithin.js
CHANGED
|
@@ -12,13 +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
|
-
periods = _ref.periods
|
|
21
|
+
periods = _ref.periods,
|
|
22
|
+
placeholder = _ref.placeholder,
|
|
23
|
+
tooltip = _ref.tooltip;
|
|
22
24
|
var intl = useIntl();
|
|
23
25
|
var texts = React.useMemo(function () {
|
|
24
26
|
return _objectSpread({
|
|
@@ -60,10 +62,14 @@ var CompletedWithin = function CompletedWithin(_ref) {
|
|
|
60
62
|
innerValue = _React$useState[0],
|
|
61
63
|
setInnerValue = _React$useState[1];
|
|
62
64
|
|
|
63
|
-
var _React$useState2 = React.useState(value.period
|
|
65
|
+
var _React$useState2 = React.useState(value.period),
|
|
64
66
|
innerPeriod = _React$useState2[0],
|
|
65
67
|
setInnerPeriod = _React$useState2[1];
|
|
66
68
|
|
|
69
|
+
var _React$useState3 = React.useState(false),
|
|
70
|
+
tooltipVisible = _React$useState3[0],
|
|
71
|
+
setTooltipVisible = _React$useState3[1];
|
|
72
|
+
|
|
67
73
|
var hasValue = React.useMemo(function () {
|
|
68
74
|
return value.value !== undefined && value.value > 0;
|
|
69
75
|
}, [value]);
|
|
@@ -74,6 +80,10 @@ var CompletedWithin = function CompletedWithin(_ref) {
|
|
|
74
80
|
period: innerPeriod
|
|
75
81
|
});
|
|
76
82
|
}
|
|
83
|
+
|
|
84
|
+
if (visible) {
|
|
85
|
+
setTooltipVisible(false);
|
|
86
|
+
}
|
|
77
87
|
}, [innerPeriod, innerValue, onSetValue]);
|
|
78
88
|
var handleClear = React.useCallback(function () {
|
|
79
89
|
setInnerPeriod(undefined);
|
|
@@ -84,24 +94,25 @@ var CompletedWithin = function CompletedWithin(_ref) {
|
|
|
84
94
|
});
|
|
85
95
|
}, [onSetValue]);
|
|
86
96
|
var triggerMode = React.useMemo(function () {
|
|
87
|
-
if (
|
|
88
|
-
return 'icon
|
|
89
|
-
}, [hasValue]);
|
|
97
|
+
if (hasValue || placeholder) return 'icon-label';
|
|
98
|
+
return 'single-icon';
|
|
99
|
+
}, [hasValue, placeholder]);
|
|
90
100
|
var triggerLabel = React.useMemo(function () {
|
|
91
101
|
var _getPeriods$find;
|
|
92
102
|
|
|
93
|
-
return hasValue
|
|
103
|
+
return hasValue ? texts.completedLabel + " " + value.value + " " + ((_getPeriods$find = getPeriods.find(function (singlePeriod) {
|
|
94
104
|
return singlePeriod.value === value.period;
|
|
95
|
-
})) == null ? void 0 : _getPeriods$find.label);
|
|
96
|
-
}, [getPeriods, hasValue, texts, value]);
|
|
105
|
+
})) == null ? void 0 : _getPeriods$find.label) : placeholder;
|
|
106
|
+
}, [getPeriods, hasValue, texts, value, placeholder]);
|
|
97
107
|
return /*#__PURE__*/React.createElement(S.CompletedWithinWrapper, {
|
|
98
108
|
withValue: hasValue
|
|
99
109
|
}, /*#__PURE__*/React.createElement(Dropdown, {
|
|
100
110
|
overlay: /*#__PURE__*/React.createElement(Settings, {
|
|
101
111
|
value: {
|
|
102
|
-
value: Number(innerValue),
|
|
112
|
+
value: innerValue !== undefined ? Number(innerValue) : undefined,
|
|
103
113
|
period: innerPeriod
|
|
104
114
|
},
|
|
115
|
+
maxValue: maxValue,
|
|
105
116
|
onValueChange: setInnerValue,
|
|
106
117
|
onPeriodChange: setInnerPeriod,
|
|
107
118
|
text: texts,
|
|
@@ -110,13 +121,19 @@ var CompletedWithin = function CompletedWithin(_ref) {
|
|
|
110
121
|
trigger: ['click'],
|
|
111
122
|
onVisibleChange: handleVisibleChange,
|
|
112
123
|
placement: "topLeft"
|
|
124
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
125
|
+
type: "largeSimple",
|
|
126
|
+
description: tooltip,
|
|
127
|
+
trigger: ['hover'],
|
|
128
|
+
onVisibleChange: setTooltipVisible,
|
|
129
|
+
visible: tooltipVisible
|
|
113
130
|
}, /*#__PURE__*/React.createElement(S.TriggerButton, {
|
|
114
131
|
className: "ds-completed-within",
|
|
115
132
|
type: "tertiary",
|
|
116
133
|
mode: triggerMode
|
|
117
134
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
118
135
|
component: /*#__PURE__*/React.createElement(ClockM, null)
|
|
119
|
-
}), triggerLabel)), hasValue && /*#__PURE__*/React.createElement(Tooltip, {
|
|
136
|
+
}), triggerLabel))), hasValue && /*#__PURE__*/React.createElement(Tooltip, {
|
|
120
137
|
title: texts.clear
|
|
121
138
|
}, /*#__PURE__*/React.createElement(S.ClearButton, {
|
|
122
139
|
mode: "single-icon",
|
|
@@ -17,6 +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[];
|
|
23
|
+
placeholder?: string | undefined;
|
|
24
|
+
tooltip?: string;
|
|
22
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",
|
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
],
|
|
33
33
|
"types": "dist/index.d.ts",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@synerise/ds-button": "^0.17.
|
|
36
|
-
"@synerise/ds-dropdown": "^0.17.
|
|
37
|
-
"@synerise/ds-icon": "^0.
|
|
35
|
+
"@synerise/ds-button": "^0.17.2",
|
|
36
|
+
"@synerise/ds-dropdown": "^0.17.17",
|
|
37
|
+
"@synerise/ds-icon": "^0.49.0",
|
|
38
38
|
"@synerise/ds-input-number": "^0.3.45",
|
|
39
|
-
"@synerise/ds-select": "^0.14.
|
|
40
|
-
"@synerise/ds-tooltip": "^0.11.
|
|
39
|
+
"@synerise/ds-select": "^0.14.11",
|
|
40
|
+
"@synerise/ds-tooltip": "^0.11.9"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@synerise/ds-core": "*",
|
|
44
44
|
"react": ">=16.9.0 < 17.0.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "4a658911645846d1e329609ba9db06a7bc64962b"
|
|
47
47
|
}
|