@synerise/ds-date-picker 1.1.11 → 1.2.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 +19 -0
- package/README.md +26 -18
- package/dist/DatePicker.styles.d.ts +2 -0
- package/dist/DatePicker.styles.js +10 -2
- package/dist/DatePicker.types.d.ts +6 -0
- package/dist/Elements/Navbar/Navbar.styles.js +3 -1
- package/dist/Elements/QuickPicks/QuickPicks.d.ts +11 -0
- package/dist/Elements/QuickPicks/QuickPicks.js +31 -0
- package/dist/Elements/QuickPicks/QuickPicks.styles.d.ts +1 -0
- package/dist/Elements/QuickPicks/QuickPicks.styles.js +7 -0
- package/dist/RawDatePicker/RawDatePicker.js +12 -2
- package/dist/fns.d.ts +4 -0
- package/dist/fns.js +5 -1
- package/dist/utils/getDefaultTexts.js +4 -0
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
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
|
+
# [1.2.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-date-picker@1.1.12...@synerise/ds-date-picker@1.2.0) (2025-07-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **date-picker:** quick picks ([0df17cf](https://github.com/Synerise/synerise-design/commit/0df17cff8b8695cf005970b96c82fffd9b8c8b00))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [1.1.12](https://github.com/Synerise/synerise-design/compare/@synerise/ds-date-picker@1.1.11...@synerise/ds-date-picker@1.1.12) (2025-07-08)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @synerise/ds-date-picker
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [1.1.11](https://github.com/Synerise/synerise-design/compare/@synerise/ds-date-picker@1.1.10...@synerise/ds-date-picker@1.1.11) (2025-07-01)
|
|
7
26
|
|
|
8
27
|
|
package/README.md
CHANGED
|
@@ -28,24 +28,32 @@ import DatePicker from '@synerise/ds-date-picker'
|
|
|
28
28
|
|
|
29
29
|
## API
|
|
30
30
|
|
|
31
|
-
| Property | Description
|
|
32
|
-
|
|
33
|
-
| autoFocus | Boolean value to force focus of an input
|
|
34
|
-
| showTime | Boolean value to enable user to choose particular hour
|
|
35
|
-
| value | Value of the picker
|
|
36
|
-
| onApply | Callback executed after applying changes
|
|
37
|
-
| disabled | Boolean value to set disabled state of an input
|
|
38
|
-
| disabledDates | Function to specify if particular dates are disabled or not
|
|
39
|
-
| disabledHours | Disabled hours for time picker
|
|
40
|
-
| disabledMinutes | Disabled minutes for time picker
|
|
41
|
-
| disabledSeconds | Disabled seconds for time picker
|
|
42
|
-
| useStartOfDay | Boolean value to set hours to the start of the day
|
|
43
|
-
| useEndOfDay | Boolean value to set hours to the start of the day
|
|
44
|
-
| texts | Object containing texts
|
|
45
|
-
| prefixel | String or ReactNode to set prefix
|
|
46
|
-
| suffixel | String or ReactNode to set suffix
|
|
47
|
-
| hideNow | Hide now button
|
|
48
|
-
| renderTrigger | Function for rendering a custom trigger element
|
|
31
|
+
| Property | Description | Type | Default |
|
|
32
|
+
|-----------------|---------------------------------------------------------------|------------------------------|------------|
|
|
33
|
+
| autoFocus | Boolean value to force focus of an input | boolean | `false` |
|
|
34
|
+
| showTime | Boolean value to enable user to choose particular hour | boolean | `false` |
|
|
35
|
+
| value | Value of the picker | Date | new Date() |
|
|
36
|
+
| onApply | Callback executed after applying changes | (date:Date)=>void | - |
|
|
37
|
+
| disabled | Boolean value to set disabled state of an input | boolean | `false` |
|
|
38
|
+
| disabledDates | Function to specify if particular dates are disabled or not | (date:Date)=>boolean | - |
|
|
39
|
+
| disabledHours | Disabled hours for time picker | number[] | [] |
|
|
40
|
+
| disabledMinutes | Disabled minutes for time picker | number[] | [] |
|
|
41
|
+
| disabledSeconds | Disabled seconds for time picker | number[] | [] |
|
|
42
|
+
| useStartOfDay | Boolean value to set hours to the start of the day | boolean | `false` |
|
|
43
|
+
| useEndOfDay | Boolean value to set hours to the start of the day | boolean | `false` |
|
|
44
|
+
| texts | Object containing texts | object | {} |
|
|
45
|
+
| prefixel | String or ReactNode to set prefix | string / ReactNode | - |
|
|
46
|
+
| suffixel | String or ReactNode to set suffix | string / ReactNode | - |
|
|
47
|
+
| hideNow | Hide now button | boolean / undefined | - |
|
|
48
|
+
| renderTrigger | Function for rendering a custom trigger element | ()=>ReactElement / undefined | - |
|
|
49
|
+
| quickPicks | render buttons for preset dates in left column next to picker | QuickPick[] | - |
|
|
50
|
+
|
|
51
|
+
### QuickPick
|
|
52
|
+
|
|
53
|
+
| Property | Description | Type | Default |
|
|
54
|
+
|----------|------------------|-----------|---------|
|
|
55
|
+
| label | Text for button | ReactNode | - |
|
|
56
|
+
| value | value for button | Date | - |
|
|
49
57
|
|
|
50
58
|
### Texts
|
|
51
59
|
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export declare const Container: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const ContentWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const PickerWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
4
|
export declare const OverlayContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -2,12 +2,20 @@ import styled from 'styled-components';
|
|
|
2
2
|
export var Container = styled.div.withConfig({
|
|
3
3
|
displayName: "DatePickerstyles__Container",
|
|
4
4
|
componentId: "sc-1kprsne-0"
|
|
5
|
-
})(["background-color:", ";user-select:none;
|
|
5
|
+
})(["background-color:", ";user-select:none;padding-top:12px;> *:not(:last-child){border-bottom:1px solid ", ";}.ds-date-picker-nav{.long-prev,.long-next{display:none;}}"], function (props) {
|
|
6
6
|
return props.theme.palette.white;
|
|
7
7
|
}, function (props) {
|
|
8
8
|
return props.theme.palette['grey-200'];
|
|
9
9
|
});
|
|
10
|
+
export var ContentWrapper = styled.div.withConfig({
|
|
11
|
+
displayName: "DatePickerstyles__ContentWrapper",
|
|
12
|
+
componentId: "sc-1kprsne-1"
|
|
13
|
+
})(["display:flex;"]);
|
|
14
|
+
export var PickerWrapper = styled.div.withConfig({
|
|
15
|
+
displayName: "DatePickerstyles__PickerWrapper",
|
|
16
|
+
componentId: "sc-1kprsne-2"
|
|
17
|
+
})(["display:grid;min-width:318px;align-items:stretch;justify-content:stretch;grid-template-rows:48px 300px 1fr;"]);
|
|
10
18
|
export var OverlayContainer = styled.div.withConfig({
|
|
11
19
|
displayName: "DatePickerstyles__OverlayContainer",
|
|
12
|
-
componentId: "sc-1kprsne-
|
|
20
|
+
componentId: "sc-1kprsne-3"
|
|
13
21
|
})(["overflow:visible;"]);
|
|
@@ -4,6 +4,10 @@ import type { DateToFormatOptions } from '@synerise/ds-data-format';
|
|
|
4
4
|
import type { DropdownProps } from '@synerise/ds-dropdown';
|
|
5
5
|
import type { InputProps } from '@synerise/ds-input';
|
|
6
6
|
import type { DataAttributes } from '@synerise/ds-utils';
|
|
7
|
+
export type QuickPick = {
|
|
8
|
+
label: ReactNode;
|
|
9
|
+
value: Date;
|
|
10
|
+
};
|
|
7
11
|
export type DatePickerProps = {
|
|
8
12
|
autoFocus?: boolean;
|
|
9
13
|
disabled?: boolean;
|
|
@@ -38,6 +42,7 @@ export type DatePickerProps = {
|
|
|
38
42
|
useStartOfDay?: boolean;
|
|
39
43
|
useEndOfDay?: boolean;
|
|
40
44
|
hideNow?: boolean;
|
|
45
|
+
quickPicks?: QuickPick[];
|
|
41
46
|
readOnly?: boolean;
|
|
42
47
|
inputProps?: Pick<InputProps, 'autoResize'>;
|
|
43
48
|
overlayHTMLAttributes?: HTMLAttributes<HTMLDivElement> & DataAttributes;
|
|
@@ -66,4 +71,5 @@ export type Texts = {
|
|
|
66
71
|
now: ReactNode;
|
|
67
72
|
inputPlaceholder: string;
|
|
68
73
|
clearTooltip: ReactNode;
|
|
74
|
+
quickPicks: ReactNode;
|
|
69
75
|
};
|
|
@@ -21,7 +21,9 @@ export var Text = styled.div.withConfig({
|
|
|
21
21
|
export var Container = styled.div.withConfig({
|
|
22
22
|
displayName: "Navbarstyles__Container",
|
|
23
23
|
componentId: "sc-105m0p0-4"
|
|
24
|
-
})(["display:flex;align-items:center;
|
|
24
|
+
})(["display:flex;align-items:center;padding:0 24px;border-bottom:1px solid ", ";", ":first-of-type{", ",", "{margin-right:8px;}}", ":last-of-type{", ",", "{margin-left:8px;}}"], function (props) {
|
|
25
|
+
return props.theme.palette['grey-200'];
|
|
26
|
+
}, ArrowContainer, NavButton, ArrowPlaceholder, ArrowContainer, NavButton, ArrowPlaceholder);
|
|
25
27
|
export var Link = styled.span.withConfig({
|
|
26
28
|
displayName: "Navbarstyles__Link",
|
|
27
29
|
componentId: "sc-105m0p0-5"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { QuickPick, Texts } from '../../DatePicker.types';
|
|
3
|
+
type QuickPicksProps = {
|
|
4
|
+
value?: Date;
|
|
5
|
+
onChange: (item: QuickPick) => void;
|
|
6
|
+
items: QuickPick[];
|
|
7
|
+
texts: Texts;
|
|
8
|
+
};
|
|
9
|
+
export declare const quickPickMatchesValue: (item: QuickPick, value?: Date) => boolean;
|
|
10
|
+
export declare const QuickPicks: ({ value, items, texts, onChange, }: QuickPicksProps) => React.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ButtonToggle } from '@synerise/ds-button';
|
|
3
|
+
import { useDataFormat } from '@synerise/ds-data-format';
|
|
4
|
+
import { Title } from '@synerise/ds-typography';
|
|
5
|
+
import { fnsIsSameDay } from '../../fns';
|
|
6
|
+
import * as S from './QuickPicks.styles';
|
|
7
|
+
export var quickPickMatchesValue = function quickPickMatchesValue(item, value) {
|
|
8
|
+
return value ? fnsIsSameDay(item.value, value) : false;
|
|
9
|
+
};
|
|
10
|
+
export var QuickPicks = function QuickPicks(_ref) {
|
|
11
|
+
var value = _ref.value,
|
|
12
|
+
items = _ref.items,
|
|
13
|
+
texts = _ref.texts,
|
|
14
|
+
onChange = _ref.onChange;
|
|
15
|
+
var _useDataFormat = useDataFormat(),
|
|
16
|
+
formatValue = _useDataFormat.formatValue;
|
|
17
|
+
return /*#__PURE__*/React.createElement(S.QuickPicksWrapper, null, /*#__PURE__*/React.createElement(Title, {
|
|
18
|
+
level: 6
|
|
19
|
+
}, texts.quickPicks), items.map(function (item) {
|
|
20
|
+
return /*#__PURE__*/React.createElement(ButtonToggle, {
|
|
21
|
+
type: "ghost",
|
|
22
|
+
activated: quickPickMatchesValue(item, value),
|
|
23
|
+
onClick: function onClick() {
|
|
24
|
+
return onChange(item);
|
|
25
|
+
},
|
|
26
|
+
tooltipProps: {
|
|
27
|
+
title: /*#__PURE__*/React.createElement(React.Fragment, null, formatValue(item.value))
|
|
28
|
+
}
|
|
29
|
+
}, item.label);
|
|
30
|
+
}));
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const QuickPicksWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
export var QuickPicksWrapper = styled.div.withConfig({
|
|
3
|
+
displayName: "QuickPicksstyles__QuickPicksWrapper",
|
|
4
|
+
componentId: "sc-apfn0i-0"
|
|
5
|
+
})(["display:flex;flex-direction:column;margin-top:47px;align-items:flex-start;gap:8px;padding:16px 16px 16px 24px;border-top:1px solid ", ";"], function (props) {
|
|
6
|
+
return props.theme.palette['grey-200'];
|
|
7
|
+
});
|
|
@@ -8,6 +8,7 @@ import DayPicker from '../Elements/DayPicker/DayPicker';
|
|
|
8
8
|
import { DayBackground, DayForeground, DayText } from '../Elements/DayPicker/DayPicker.styles';
|
|
9
9
|
import Footer from '../Elements/Footer/Footer';
|
|
10
10
|
import MonthPicker from '../Elements/MonthPicker/MonthPicker';
|
|
11
|
+
import { QuickPicks } from '../Elements/QuickPicks/QuickPicks';
|
|
11
12
|
import TimePicker from '../Elements/TimePicker/TimePicker';
|
|
12
13
|
import YearPicker from '../Elements/YearPicker/YearPicker';
|
|
13
14
|
import { fnsAddDays, fnsEndOfDay, fnsSetDate, fnsSetMonth, fnsSetYear, fnsStartOfDay, fnsStartOfMonth } from '../fns';
|
|
@@ -238,7 +239,8 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
238
239
|
texts = _this$state4.texts;
|
|
239
240
|
var _this$props4 = this.props,
|
|
240
241
|
showTime = _this$props4.showTime,
|
|
241
|
-
hideNow = _this$props4.hideNow
|
|
242
|
+
hideNow = _this$props4.hideNow,
|
|
243
|
+
quickPicks = _this$props4.quickPicks;
|
|
242
244
|
var isValid = !!value;
|
|
243
245
|
var picker;
|
|
244
246
|
switch (mode) {
|
|
@@ -258,7 +260,15 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
258
260
|
picker = null;
|
|
259
261
|
break;
|
|
260
262
|
}
|
|
261
|
-
return /*#__PURE__*/React.createElement(S.Container, null,
|
|
263
|
+
return /*#__PURE__*/React.createElement(S.Container, null, /*#__PURE__*/React.createElement(S.ContentWrapper, null, (quickPicks == null ? void 0 : quickPicks.length) && /*#__PURE__*/React.createElement(QuickPicks, {
|
|
264
|
+
value: value,
|
|
265
|
+
onChange: function onChange(item) {
|
|
266
|
+
_this2.handleMonthChange(item.value, 'date');
|
|
267
|
+
_this2.handleChange(item.value);
|
|
268
|
+
},
|
|
269
|
+
items: quickPicks,
|
|
270
|
+
texts: texts
|
|
271
|
+
}), /*#__PURE__*/React.createElement(S.PickerWrapper, null, picker)), /*#__PURE__*/React.createElement(Footer, {
|
|
262
272
|
canApply: isValid && changed,
|
|
263
273
|
onApply: this.handleApply,
|
|
264
274
|
dateOnly: !showTime,
|
package/dist/fns.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ import fnsGetSeconds from 'date-fns/getSeconds';
|
|
|
11
11
|
import fnsGetYear from 'date-fns/getYear';
|
|
12
12
|
import fnsIsAfter from 'date-fns/isAfter';
|
|
13
13
|
import fnsIsBefore from 'date-fns/isBefore';
|
|
14
|
+
import fnsIsEqual from 'date-fns/isEqual';
|
|
15
|
+
import fnsIsSameDay from 'date-fns/isSameDay';
|
|
14
16
|
import fnsIsSameMonth from 'date-fns/isSameMonth';
|
|
15
17
|
import fnsIsSameYear from 'date-fns/isSameYear';
|
|
16
18
|
import fnsSetDate from 'date-fns/setDate';
|
|
@@ -38,3 +40,5 @@ export { fnsGetYear };
|
|
|
38
40
|
export { fnsAddDays };
|
|
39
41
|
export { fnsAddSeconds };
|
|
40
42
|
export { fnsDifferenceInYears };
|
|
43
|
+
export { fnsIsEqual };
|
|
44
|
+
export { fnsIsSameDay };
|
package/dist/fns.js
CHANGED
|
@@ -11,6 +11,8 @@ import fnsGetSeconds from 'date-fns/getSeconds';
|
|
|
11
11
|
import fnsGetYear from 'date-fns/getYear';
|
|
12
12
|
import fnsIsAfter from 'date-fns/isAfter';
|
|
13
13
|
import fnsIsBefore from 'date-fns/isBefore';
|
|
14
|
+
import fnsIsEqual from 'date-fns/isEqual';
|
|
15
|
+
import fnsIsSameDay from 'date-fns/isSameDay';
|
|
14
16
|
import fnsIsSameMonth from 'date-fns/isSameMonth';
|
|
15
17
|
import fnsIsSameYear from 'date-fns/isSameYear';
|
|
16
18
|
import fnsSetDate from 'date-fns/setDate';
|
|
@@ -37,4 +39,6 @@ export { fnsIsSameYear };
|
|
|
37
39
|
export { fnsGetYear };
|
|
38
40
|
export { fnsAddDays };
|
|
39
41
|
export { fnsAddSeconds };
|
|
40
|
-
export { fnsDifferenceInYears };
|
|
42
|
+
export { fnsDifferenceInYears };
|
|
43
|
+
export { fnsIsEqual };
|
|
44
|
+
export { fnsIsSameDay };
|
|
@@ -11,6 +11,10 @@ export var getDefaultTexts = function getDefaultTexts(intl, texts) {
|
|
|
11
11
|
id: "DS.DATE-PICKER.NOW",
|
|
12
12
|
defaultMessage: "Now"
|
|
13
13
|
}),
|
|
14
|
+
quickPicks: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
15
|
+
id: "DS.DATE-PICKER.QUICK-PICKS",
|
|
16
|
+
defaultMessage: "Quick picks"
|
|
17
|
+
}),
|
|
14
18
|
inputPlaceholder: intl.formatMessage({
|
|
15
19
|
id: 'DS.DATE-PICKER.SELECT-DATE'
|
|
16
20
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-date-picker",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "DatePicker UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
"types": "dist/index.d.ts",
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@date-fns/upgrade": "^1.0.3",
|
|
38
|
-
"@synerise/ds-button": "^1.4.
|
|
38
|
+
"@synerise/ds-button": "^1.4.4",
|
|
39
39
|
"@synerise/ds-data-format": "^1.0.1",
|
|
40
|
-
"@synerise/ds-dropdown": "^1.0.
|
|
41
|
-
"@synerise/ds-icon": "^1.
|
|
42
|
-
"@synerise/ds-input": "^1.3.
|
|
43
|
-
"@synerise/ds-time-picker": "^1.1.
|
|
44
|
-
"@synerise/ds-tooltip": "^1.1.
|
|
40
|
+
"@synerise/ds-dropdown": "^1.0.17",
|
|
41
|
+
"@synerise/ds-icon": "^1.6.0",
|
|
42
|
+
"@synerise/ds-input": "^1.3.4",
|
|
43
|
+
"@synerise/ds-time-picker": "^1.1.12",
|
|
44
|
+
"@synerise/ds-tooltip": "^1.1.13",
|
|
45
45
|
"@synerise/ds-utils": "^1.3.1",
|
|
46
|
-
"classnames": "2.
|
|
46
|
+
"classnames": "^2.5.1",
|
|
47
47
|
"date-fns": "2.16.1",
|
|
48
48
|
"lodash": "^4.17.21",
|
|
49
49
|
"react-day-picker": "^7.4.8",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"react-intl": ">=3.12.0 <= 6.8",
|
|
57
57
|
"styled-components": "^5.3.3"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "f7c362a4f370d86b51df9aba9e91ac8f7fe4ed8f"
|
|
60
60
|
}
|