@synerise/ds-date-picker 1.4.1 → 1.4.3
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 +8 -0
- package/dist/DatePicker.const.js +6 -3
- package/dist/DatePicker.d.ts +2 -2
- package/dist/DatePicker.js +61 -101
- package/dist/DatePicker.styles.d.ts +4 -4
- package/dist/DatePicker.styles.js +17 -14
- package/dist/DatePicker.types.d.ts +6 -6
- package/dist/DatePicker.types.js +1 -1
- package/dist/Elements/DayPicker/DayPicker.d.ts +3 -3
- package/dist/Elements/DayPicker/DayPicker.js +60 -60
- package/dist/Elements/DayPicker/DayPicker.styles.d.ts +6 -6
- package/dist/Elements/DayPicker/DayPicker.styles.js +18 -75
- package/dist/Elements/DayPicker/DayPicker.types.d.ts +4 -4
- package/dist/Elements/DayPicker/DayPicker.types.js +1 -1
- package/dist/Elements/DecadePicker/DecadePicker.d.ts +2 -2
- package/dist/Elements/DecadePicker/DecadePicker.js +85 -71
- package/dist/Elements/DecadePicker/DecadePicker.types.js +1 -1
- package/dist/Elements/Footer/Footer.d.ts +3 -3
- package/dist/Elements/Footer/Footer.js +39 -55
- package/dist/Elements/Footer/Footer.styles.d.ts +4 -4
- package/dist/Elements/Footer/Footer.styles.js +13 -7
- package/dist/Elements/Footer/Footer.types.d.ts +2 -2
- package/dist/Elements/Footer/Footer.types.js +1 -1
- package/dist/Elements/GridPicker/GridPicker.d.ts +2 -2
- package/dist/Elements/GridPicker/GridPicker.js +36 -44
- package/dist/Elements/GridPicker/GridPicker.styles.d.ts +2 -2
- package/dist/Elements/GridPicker/GridPicker.styles.js +9 -19
- package/dist/Elements/GridPicker/GridPicker.types.d.ts +1 -1
- package/dist/Elements/GridPicker/GridPicker.types.js +1 -1
- package/dist/Elements/MonthPicker/MonthPicker.d.ts +3 -3
- package/dist/Elements/MonthPicker/MonthPicker.js +85 -85
- package/dist/Elements/MonthPicker/MonthPicker.types.d.ts +1 -1
- package/dist/Elements/MonthPicker/MonthPicker.types.js +1 -1
- package/dist/Elements/Navbar/Navbar.d.ts +2 -2
- package/dist/Elements/Navbar/Navbar.js +31 -69
- package/dist/Elements/Navbar/Navbar.styles.d.ts +6 -6
- package/dist/Elements/Navbar/Navbar.styles.js +19 -19
- package/dist/Elements/Navbar/Navbar.types.d.ts +1 -1
- package/dist/Elements/Navbar/Navbar.types.js +1 -1
- package/dist/Elements/PickerInput/PickerInput.d.ts +5 -5
- package/dist/Elements/PickerInput/PickerInput.js +56 -80
- package/dist/Elements/PickerInput/PickerInput.styles.d.ts +8 -8
- package/dist/Elements/PickerInput/PickerInput.styles.js +35 -40
- package/dist/Elements/PickerInput/PickerInput.types.d.ts +5 -5
- package/dist/Elements/PickerInput/PickerInput.types.js +1 -1
- package/dist/Elements/QuickPicks/QuickPicks.d.ts +2 -2
- package/dist/Elements/QuickPicks/QuickPicks.js +48 -29
- package/dist/Elements/QuickPicks/QuickPicks.styles.d.ts +1 -1
- package/dist/Elements/QuickPicks/QuickPicks.styles.js +6 -5
- package/dist/Elements/TimePicker/TimePicker.d.ts +2 -2
- package/dist/Elements/TimePicker/TimePicker.js +32 -47
- package/dist/Elements/TimePicker/TimePicker.styles.d.ts +1 -1
- package/dist/Elements/TimePicker/TimePicker.styles.js +6 -3
- package/dist/Elements/TimePicker/TimePicker.types.js +1 -1
- package/dist/Elements/YearPicker/YearPicker.d.ts +2 -2
- package/dist/Elements/YearPicker/YearPicker.js +90 -83
- package/dist/Elements/YearPicker/YearPicker.types.js +1 -1
- package/dist/RawDatePicker/RawDatePicker.d.ts +4 -4
- package/dist/RawDatePicker/RawDatePicker.js +202 -222
- package/dist/RawDatePicker/RawDatePicker.types.d.ts +1 -1
- package/dist/RawDatePicker/RawDatePicker.types.js +1 -1
- package/dist/fns.d.ts +22 -22
- package/dist/fns.js +46 -44
- package/dist/format.js +38 -17
- package/dist/index.js +15 -7
- package/dist/localeUtils.d.ts +1 -1
- package/dist/localeUtils.js +34 -52
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/dist/utils/getDefaultTexts.d.ts +2 -2
- package/dist/utils/getDefaultTexts.js +17 -24
- package/dist/utils.js +44 -19
- package/package.json +12 -12
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import range from "lodash.range";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { injectIntl } from "react-intl";
|
|
5
|
+
import { legacyParse } from "@date-fns/upgrade/v2";
|
|
6
|
+
import "date-fns/addDays";
|
|
7
|
+
import "date-fns/addMonths";
|
|
8
|
+
import "date-fns/addSeconds";
|
|
9
|
+
import fnsAddYears from "date-fns/addYears";
|
|
10
|
+
import "date-fns/differenceInSeconds";
|
|
11
|
+
import "date-fns/differenceInYears";
|
|
12
|
+
import "date-fns/endOfDay";
|
|
13
|
+
import fnsEndOfMonth from "date-fns/endOfMonth";
|
|
14
|
+
import "date-fns/format";
|
|
15
|
+
import "date-fns/getSeconds";
|
|
16
|
+
import "date-fns/getYear";
|
|
17
|
+
import fnsIsAfter from "date-fns/isAfter";
|
|
18
|
+
import fnsIsBefore from "date-fns/isBefore";
|
|
19
|
+
import "date-fns/isEqual";
|
|
20
|
+
import "date-fns/isSameDay";
|
|
21
|
+
import fnsIsSameMonth from "date-fns/isSameMonth";
|
|
22
|
+
import "date-fns/isSameYear";
|
|
23
|
+
import "date-fns/setDate";
|
|
24
|
+
import fnsSetMonth from "date-fns/setMonth";
|
|
25
|
+
import "date-fns/setYear";
|
|
26
|
+
import "date-fns/startOfDay";
|
|
27
|
+
import fnsStartOfMonth from "date-fns/startOfMonth";
|
|
28
|
+
import fnsFormat from "../../format.js";
|
|
29
|
+
import GridPicker from "../GridPicker/GridPicker.js";
|
|
30
|
+
import Navbar from "../Navbar/Navbar.js";
|
|
31
|
+
import YearPicker from "../YearPicker/YearPicker.js";
|
|
12
32
|
function getInitialState(props) {
|
|
13
33
|
return {
|
|
14
|
-
cursor: props.value || new Date(),
|
|
34
|
+
cursor: props.value || /* @__PURE__ */ new Date(),
|
|
15
35
|
yearMode: false
|
|
16
36
|
};
|
|
17
37
|
}
|
|
18
38
|
function getCells(cursor, min, max, locale) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return range(0, 12).map(
|
|
22
|
-
|
|
39
|
+
const minDate = min ? fnsStartOfMonth(min) : fnsSetMonth(cursor, 0);
|
|
40
|
+
const maxDate = max ? fnsEndOfMonth(max) : fnsSetMonth(cursor, 12);
|
|
41
|
+
return range(0, 12).map((index) => {
|
|
42
|
+
const date = fnsSetMonth(cursor, index);
|
|
23
43
|
return {
|
|
24
44
|
key: date.toISOString(),
|
|
25
|
-
text: fnsFormat(date,
|
|
45
|
+
text: fnsFormat(date, "MMM", locale),
|
|
26
46
|
disabled: fnsIsAfter(date, maxDate) || fnsIsBefore(date, minDate)
|
|
27
47
|
};
|
|
28
48
|
});
|
|
29
49
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var cursor = _this.state.cursor;
|
|
40
|
-
_this.setState({
|
|
50
|
+
class MonthPicker extends React.PureComponent {
|
|
51
|
+
constructor() {
|
|
52
|
+
super(...arguments);
|
|
53
|
+
this.state = getInitialState(this.props);
|
|
54
|
+
this.handleLongPrev = () => {
|
|
55
|
+
const {
|
|
56
|
+
cursor
|
|
57
|
+
} = this.state;
|
|
58
|
+
this.setState({
|
|
41
59
|
cursor: fnsAddYears(cursor, -1)
|
|
42
60
|
});
|
|
43
61
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
62
|
+
this.handleLongNext = () => {
|
|
63
|
+
const {
|
|
64
|
+
cursor
|
|
65
|
+
} = this.state;
|
|
66
|
+
this.setState({
|
|
47
67
|
cursor: fnsAddYears(cursor, 1)
|
|
48
68
|
});
|
|
49
69
|
};
|
|
50
|
-
return _this;
|
|
51
70
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (
|
|
71
|
+
getSnapshotBeforeUpdate(prevProps) {
|
|
72
|
+
const {
|
|
73
|
+
value
|
|
74
|
+
} = this.props;
|
|
75
|
+
if (prevProps?.value !== value) {
|
|
57
76
|
this.setState(getInitialState(this.props));
|
|
58
77
|
}
|
|
59
78
|
return null;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
min
|
|
68
|
-
max
|
|
69
|
-
value
|
|
70
|
-
intl
|
|
71
|
-
onChange
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
var selectedKey = valueCell ? valueCell.key : null;
|
|
79
|
+
}
|
|
80
|
+
render() {
|
|
81
|
+
const {
|
|
82
|
+
cursor,
|
|
83
|
+
yearMode
|
|
84
|
+
} = this.state;
|
|
85
|
+
const {
|
|
86
|
+
min,
|
|
87
|
+
max,
|
|
88
|
+
value,
|
|
89
|
+
intl,
|
|
90
|
+
onChange
|
|
91
|
+
} = this.props;
|
|
92
|
+
const cells = getCells(cursor, min, max, intl?.locale);
|
|
93
|
+
const valueCell = value ? cells.find((cell) => fnsIsSameMonth(value, legacyParse(cell.key))) : null;
|
|
94
|
+
const selectedKey = valueCell ? valueCell.key : null;
|
|
77
95
|
if (yearMode) {
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
cursor: changedDate,
|
|
83
|
-
yearMode: false
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
});
|
|
96
|
+
return /* @__PURE__ */ jsx(YearPicker, { value: cursor, onChange: (changedDate) => this.setState({
|
|
97
|
+
cursor: changedDate,
|
|
98
|
+
yearMode: false
|
|
99
|
+
}) });
|
|
87
100
|
}
|
|
88
|
-
return [
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
key: "head"
|
|
98
|
-
}), /*#__PURE__*/React.createElement(GridPicker, {
|
|
99
|
-
selectedKey: selectedKey,
|
|
100
|
-
cells: cells,
|
|
101
|
-
onCellClick: function onCellClick(isoDate) {
|
|
102
|
-
return onChange(new Date(isoDate));
|
|
103
|
-
},
|
|
104
|
-
key: "body"
|
|
105
|
-
})];
|
|
106
|
-
};
|
|
107
|
-
return MonthPicker;
|
|
108
|
-
}(React.PureComponent);
|
|
109
|
-
export default injectIntl(MonthPicker);
|
|
101
|
+
return [/* @__PURE__ */ jsx(Navbar, { onTitleClick: () => this.setState({
|
|
102
|
+
yearMode: true
|
|
103
|
+
}), title: fnsFormat(cursor, "yyyy"), onLongPrev: this.handleLongPrev, onLongNext: this.handleLongNext }, "head"), /* @__PURE__ */ jsx(GridPicker, { selectedKey, cells, onCellClick: (isoDate) => onChange(new Date(isoDate)) }, "body")];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const MonthPicker$1 = injectIntl(MonthPicker);
|
|
107
|
+
export {
|
|
108
|
+
MonthPicker$1 as default
|
|
109
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,70 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { v4
|
|
3
|
-
import Icon, { AngleLeftS, AngleRightS,
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
disabled: inactivePrev,
|
|
33
|
-
key: uuid(),
|
|
34
|
-
mode: "single-icon",
|
|
35
|
-
role: "button",
|
|
36
|
-
type: "ghost",
|
|
37
|
-
onClick: onShortPrev
|
|
38
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
39
|
-
component: /*#__PURE__*/React.createElement(AngleLeftS, null)
|
|
40
|
-
})) : /*#__PURE__*/React.createElement(S.ArrowPlaceholder, {
|
|
41
|
-
className: "arrow-placeholder short-prev"
|
|
42
|
-
})), /*#__PURE__*/React.createElement(S.Text, null, onTitleClick ? /*#__PURE__*/React.createElement(S.Link, {
|
|
43
|
-
onClick: onTitleClick
|
|
44
|
-
}, title) : title), /*#__PURE__*/React.createElement(S.ArrowContainer, null, onShortNext && !hideNext ? /*#__PURE__*/React.createElement(S.NavButton, {
|
|
45
|
-
"data-testid": "datapicker-short-next",
|
|
46
|
-
disabled: inactiveNext,
|
|
47
|
-
key: uuid(),
|
|
48
|
-
mode: "single-icon",
|
|
49
|
-
role: "button",
|
|
50
|
-
type: "ghost",
|
|
51
|
-
onClick: onShortNext
|
|
52
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
53
|
-
component: /*#__PURE__*/React.createElement(AngleRightS, null)
|
|
54
|
-
})) : /*#__PURE__*/React.createElement(S.ArrowPlaceholder, {
|
|
55
|
-
className: "arrow-placeholder short-next"
|
|
56
|
-
}), onLongNext && !hideNext ? /*#__PURE__*/React.createElement(S.NavButton, {
|
|
57
|
-
"data-testid": "datapicker-long-next",
|
|
58
|
-
disabled: inactiveNext,
|
|
59
|
-
key: uuid(),
|
|
60
|
-
mode: "single-icon",
|
|
61
|
-
role: "button",
|
|
62
|
-
type: "ghost",
|
|
63
|
-
onClick: onLongNext
|
|
64
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
65
|
-
component: /*#__PURE__*/React.createElement(DoubleAngleRightS, null)
|
|
66
|
-
})) : /*#__PURE__*/React.createElement(S.ArrowPlaceholder, {
|
|
67
|
-
className: "arrow-placeholder long-next"
|
|
68
|
-
})));
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { v4 } from "uuid";
|
|
3
|
+
import Icon, { DoubleAngleLeftS, AngleLeftS, AngleRightS, DoubleAngleRightS } from "@synerise/ds-icon";
|
|
4
|
+
import { Container, ArrowContainer, NavButton, ArrowPlaceholder, Text, Link } from "./Navbar.styles.js";
|
|
5
|
+
const Navbar = (props) => {
|
|
6
|
+
const {
|
|
7
|
+
title,
|
|
8
|
+
onTitleClick,
|
|
9
|
+
hidePrev,
|
|
10
|
+
hideNext,
|
|
11
|
+
onLongPrev,
|
|
12
|
+
onLongNext,
|
|
13
|
+
onShortPrev,
|
|
14
|
+
onShortNext,
|
|
15
|
+
inactivePrev,
|
|
16
|
+
inactiveNext
|
|
17
|
+
} = props;
|
|
18
|
+
return /* @__PURE__ */ jsxs(Container, { className: "ds-date-picker-nav", children: [
|
|
19
|
+
/* @__PURE__ */ jsxs(ArrowContainer, { children: [
|
|
20
|
+
onLongPrev && !hidePrev ? /* @__PURE__ */ jsx(NavButton, { "data-testid": "datapicker-long-prev", disabled: inactivePrev, mode: "single-icon", role: "button", type: "ghost", onClick: onLongPrev, children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(DoubleAngleLeftS, {}) }) }, v4()) : /* @__PURE__ */ jsx(ArrowPlaceholder, { className: "arrow-placeholder long-prev" }),
|
|
21
|
+
onShortPrev && !hidePrev ? /* @__PURE__ */ jsx(NavButton, { "data-testid": "datapicker-short-prev", disabled: inactivePrev, mode: "single-icon", role: "button", type: "ghost", onClick: onShortPrev, children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(AngleLeftS, {}) }) }, v4()) : /* @__PURE__ */ jsx(ArrowPlaceholder, { className: "arrow-placeholder short-prev" })
|
|
22
|
+
] }),
|
|
23
|
+
/* @__PURE__ */ jsx(Text, { children: onTitleClick ? /* @__PURE__ */ jsx(Link, { onClick: onTitleClick, children: title }) : title }),
|
|
24
|
+
/* @__PURE__ */ jsxs(ArrowContainer, { children: [
|
|
25
|
+
onShortNext && !hideNext ? /* @__PURE__ */ jsx(NavButton, { "data-testid": "datapicker-short-next", disabled: inactiveNext, mode: "single-icon", role: "button", type: "ghost", onClick: onShortNext, children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(AngleRightS, {}) }) }, v4()) : /* @__PURE__ */ jsx(ArrowPlaceholder, { className: "arrow-placeholder short-next" }),
|
|
26
|
+
onLongNext && !hideNext ? /* @__PURE__ */ jsx(NavButton, { "data-testid": "datapicker-long-next", disabled: inactiveNext, mode: "single-icon", role: "button", type: "ghost", onClick: onLongNext, children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(DoubleAngleRightS, {}) }) }, v4()) : /* @__PURE__ */ jsx(ArrowPlaceholder, { className: "arrow-placeholder long-next" })
|
|
27
|
+
] })
|
|
28
|
+
] });
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
Navbar as default
|
|
69
32
|
};
|
|
70
|
-
export default Navbar;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StyledButton } from '@synerise/ds-button';
|
|
2
2
|
export declare const NavButton: StyledButton;
|
|
3
|
-
export declare const ArrowPlaceholder: import(
|
|
4
|
-
export declare const ArrowContainer: import(
|
|
5
|
-
export declare const Text: import(
|
|
6
|
-
export declare const Container: import(
|
|
7
|
-
export declare const Link: import(
|
|
3
|
+
export declare const ArrowPlaceholder: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
4
|
+
export declare const ArrowContainer: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
5
|
+
export declare const Text: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
6
|
+
export declare const Container: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
7
|
+
export declare const Link: import('styled-components').StyledComponent<"span", any, {}, never>;
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import styled from
|
|
2
|
-
import Button from
|
|
3
|
-
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import Button from "@synerise/ds-button";
|
|
3
|
+
const NavButton = /* @__PURE__ */ styled(Button).withConfig({
|
|
4
4
|
displayName: "Navbarstyles__NavButton",
|
|
5
5
|
componentId: "sc-105m0p0-0"
|
|
6
|
-
})([".ds-icon > svg{fill:", ";}"],
|
|
7
|
-
|
|
8
|
-
});
|
|
9
|
-
export var ArrowPlaceholder = styled.div.withConfig({
|
|
6
|
+
})([".ds-icon > svg{fill:", ";}"], (props) => props.theme.palette["grey-600"]);
|
|
7
|
+
const ArrowPlaceholder = /* @__PURE__ */ styled.div.withConfig({
|
|
10
8
|
displayName: "Navbarstyles__ArrowPlaceholder",
|
|
11
9
|
componentId: "sc-105m0p0-1"
|
|
12
10
|
})(["width:32px;height:32px;"]);
|
|
13
|
-
|
|
11
|
+
const ArrowContainer = /* @__PURE__ */ styled.div.withConfig({
|
|
14
12
|
displayName: "Navbarstyles__ArrowContainer",
|
|
15
13
|
componentId: "sc-105m0p0-2"
|
|
16
14
|
})(["display:flex;align-items:center;"]);
|
|
17
|
-
|
|
15
|
+
const Text = /* @__PURE__ */ styled.div.withConfig({
|
|
18
16
|
displayName: "Navbarstyles__Text",
|
|
19
17
|
componentId: "sc-105m0p0-3"
|
|
20
18
|
})(["flex:1;text-align:center;font-weight:500;font-size:13px;"]);
|
|
21
|
-
|
|
19
|
+
const Container = /* @__PURE__ */ styled.div.withConfig({
|
|
22
20
|
displayName: "Navbarstyles__Container",
|
|
23
21
|
componentId: "sc-105m0p0-4"
|
|
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;}}"],
|
|
25
|
-
|
|
26
|
-
}, ArrowContainer, NavButton, ArrowPlaceholder, ArrowContainer, NavButton, ArrowPlaceholder);
|
|
27
|
-
export var Link = styled.span.withConfig({
|
|
22
|
+
})(["display:flex;align-items:center;padding:0 24px;border-bottom:1px solid ", ";", ":first-of-type{", ",", "{margin-right:8px;}}", ":last-of-type{", ",", "{margin-left:8px;}}"], (props) => props.theme.palette["grey-200"], ArrowContainer, NavButton, ArrowPlaceholder, ArrowContainer, NavButton, ArrowPlaceholder);
|
|
23
|
+
const Link = /* @__PURE__ */ styled.span.withConfig({
|
|
28
24
|
displayName: "Navbarstyles__Link",
|
|
29
25
|
componentId: "sc-105m0p0-5"
|
|
30
|
-
})(["cursor:pointer;transition:0.3s;&:hover{color:", ";}&:active{color:", ";}"],
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
})(["cursor:pointer;transition:0.3s;&:hover{color:", ";}&:active{color:", ";}"], (props) => props.theme.palette["blue-600"], (props) => props.theme.palette["blue-600"]);
|
|
27
|
+
export {
|
|
28
|
+
ArrowContainer,
|
|
29
|
+
ArrowPlaceholder,
|
|
30
|
+
Container,
|
|
31
|
+
Link,
|
|
32
|
+
NavButton,
|
|
33
|
+
Text
|
|
34
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
declare const PickerInput: React.ForwardRefExoticComponent<Pick<import(
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
declare const PickerInput: React.ForwardRefExoticComponent<Pick<import('@synerise/ds-input').InputProps, "autoResize"> & {
|
|
3
3
|
autoFocus?: boolean;
|
|
4
|
-
size?: import(
|
|
4
|
+
size?: import('antd/lib/button').ButtonSize;
|
|
5
5
|
format?: string;
|
|
6
|
-
valueFormatOptions?: import(
|
|
6
|
+
valueFormatOptions?: import('@synerise/ds-core').DateToFormatOptions;
|
|
7
7
|
showTime?: boolean;
|
|
8
8
|
allowClear?: boolean;
|
|
9
9
|
value?: Date | string;
|
|
@@ -20,6 +20,6 @@ declare const PickerInput: React.ForwardRefExoticComponent<Pick<import("@syneris
|
|
|
20
20
|
errorText?: React.ReactNode;
|
|
21
21
|
prefixel?: React.ReactNode;
|
|
22
22
|
suffixel?: React.ReactNode;
|
|
23
|
-
triggerHTMLAttributes?: React.HTMLAttributes<HTMLDivElement> & import(
|
|
23
|
+
triggerHTMLAttributes?: React.HTMLAttributes<HTMLDivElement> & import('@synerise/ds-utils').DataAttributes;
|
|
24
24
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
25
25
|
export default PickerInput;
|
|
@@ -1,99 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
hovered = _useState[0],
|
|
34
|
-
setHovered = _useState[1];
|
|
35
|
-
var getText = useCallback(function () {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState, useCallback, useMemo } from "react";
|
|
3
|
+
import { legacyParse } from "@date-fns/upgrade/v2";
|
|
4
|
+
import { useDataFormat, useTheme, getDefaultDataTimeOptions } from "@synerise/ds-core";
|
|
5
|
+
import Icon, { Close3S, CalendarM } from "@synerise/ds-icon";
|
|
6
|
+
import Tooltip from "@synerise/ds-tooltip";
|
|
7
|
+
import fnsFormat from "../../format.js";
|
|
8
|
+
import { ClearIconWrapper, DefaultIconWrapper, PickerInputWrapper, Prefixel, Container, Input, Suffixel } from "./PickerInput.styles.js";
|
|
9
|
+
const PickerInput = forwardRef(({
|
|
10
|
+
disabled,
|
|
11
|
+
readOnly,
|
|
12
|
+
value,
|
|
13
|
+
format: dateFormat,
|
|
14
|
+
valueFormatOptions,
|
|
15
|
+
onChange,
|
|
16
|
+
showTime,
|
|
17
|
+
onClear,
|
|
18
|
+
onClick,
|
|
19
|
+
clearTooltip,
|
|
20
|
+
highlight,
|
|
21
|
+
prefixel,
|
|
22
|
+
suffixel,
|
|
23
|
+
allowClear,
|
|
24
|
+
triggerHTMLAttributes,
|
|
25
|
+
...rest
|
|
26
|
+
}, ref) => {
|
|
27
|
+
const {
|
|
28
|
+
formatValue
|
|
29
|
+
} = useDataFormat();
|
|
30
|
+
const theme = useTheme();
|
|
31
|
+
const [hovered, setHovered] = useState(false);
|
|
32
|
+
const getText = useCallback(() => {
|
|
36
33
|
if (!value) {
|
|
37
|
-
return
|
|
34
|
+
return "";
|
|
38
35
|
}
|
|
39
36
|
if (dateFormat) {
|
|
40
|
-
return
|
|
37
|
+
return fnsFormat(legacyParse(value), dateFormat);
|
|
41
38
|
}
|
|
42
|
-
if (typeof value ===
|
|
43
|
-
return
|
|
39
|
+
if (typeof value === "string") {
|
|
40
|
+
return fnsFormat(legacyParse(value), dateFormat || showTime ? "MMM d, yyyy, HH:mm" : "MMM d, yyyy");
|
|
44
41
|
}
|
|
45
|
-
return formatValue(value,
|
|
42
|
+
return formatValue(value, {
|
|
43
|
+
...getDefaultDataTimeOptions(showTime),
|
|
44
|
+
...valueFormatOptions
|
|
45
|
+
});
|
|
46
46
|
}, [value, dateFormat, showTime, formatValue, valueFormatOptions]);
|
|
47
|
-
|
|
47
|
+
const handleApply = useCallback((date) => {
|
|
48
48
|
if (!onChange) {
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
onChange(date, getText());
|
|
52
52
|
}, [onChange, getText]);
|
|
53
|
-
|
|
53
|
+
const handleIconClick = useCallback((event) => {
|
|
54
54
|
event.stopPropagation();
|
|
55
55
|
onClear && onClear();
|
|
56
56
|
handleApply(null);
|
|
57
57
|
}, [onClear, handleApply]);
|
|
58
|
-
|
|
58
|
+
const handleInputClick = useCallback((event) => {
|
|
59
59
|
event.stopPropagation();
|
|
60
60
|
onClick && onClick();
|
|
61
61
|
}, [onClick]);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}, [hovered, highlight, allowClear, readOnly, value, theme, clearTooltip, handleIconClick]);
|
|
73
|
-
var _ref2 = triggerHTMLAttributes != null ? triggerHTMLAttributes : {},
|
|
74
|
-
className = _ref2.className,
|
|
75
|
-
restAttributes = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
76
|
-
return /*#__PURE__*/React.createElement(S.PickerInputWrapper, _extends({
|
|
77
|
-
ref: ref,
|
|
78
|
-
prefixel: !!prefixel,
|
|
79
|
-
suffixel: !!suffixel,
|
|
80
|
-
className: "ds-date-input " + (className || '')
|
|
81
|
-
}, restAttributes), !!prefixel && /*#__PURE__*/React.createElement(S.Prefixel, null, prefixel), /*#__PURE__*/React.createElement(S.Container, {
|
|
82
|
-
onMouseEnter: !disabled ? function () {
|
|
83
|
-
return setHovered(true);
|
|
84
|
-
} : undefined,
|
|
85
|
-
onMouseLeave: !disabled ? function () {
|
|
86
|
-
return setHovered(false);
|
|
87
|
-
} : undefined,
|
|
88
|
-
onClick: !disabled ? handleInputClick : undefined
|
|
89
|
-
}, /*#__PURE__*/React.createElement(S.Input, _extends({
|
|
90
|
-
active: !!highlight,
|
|
91
|
-
resetMargin: true,
|
|
92
|
-
type: "text",
|
|
93
|
-
value: getText(),
|
|
94
|
-
icon1: iconInput,
|
|
95
|
-
readOnly: readOnly,
|
|
96
|
-
disabled: disabled
|
|
97
|
-
}, rest))), !!suffixel && /*#__PURE__*/React.createElement(S.Suffixel, null, suffixel));
|
|
62
|
+
const iconInput = useMemo(() => (hovered || highlight) && allowClear && !readOnly && !!value ? /* @__PURE__ */ jsx(ClearIconWrapper, { children: /* @__PURE__ */ jsx(Tooltip, { title: clearTooltip, children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(Close3S, {}), onClick: handleIconClick }) }) }) : /* @__PURE__ */ jsx(DefaultIconWrapper, { children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(CalendarM, {}), color: theme.palette["grey-400"] }) }), [hovered, highlight, allowClear, readOnly, value, theme, clearTooltip, handleIconClick]);
|
|
63
|
+
const {
|
|
64
|
+
className,
|
|
65
|
+
...restAttributes
|
|
66
|
+
} = triggerHTMLAttributes ?? {};
|
|
67
|
+
return /* @__PURE__ */ jsxs(PickerInputWrapper, { ref, prefixel: !!prefixel, suffixel: !!suffixel, className: `ds-date-input ${className || ""}`, ...restAttributes, children: [
|
|
68
|
+
!!prefixel && /* @__PURE__ */ jsx(Prefixel, { children: prefixel }),
|
|
69
|
+
/* @__PURE__ */ jsx(Container, { onMouseEnter: !disabled ? () => setHovered(true) : void 0, onMouseLeave: !disabled ? () => setHovered(false) : void 0, onClick: !disabled ? handleInputClick : void 0, children: /* @__PURE__ */ jsx(Input, { active: !!highlight, resetMargin: true, type: "text", value: getText(), icon1: iconInput, readOnly, disabled, ...rest }) }),
|
|
70
|
+
!!suffixel && /* @__PURE__ */ jsx(Suffixel, { children: suffixel })
|
|
71
|
+
] });
|
|
98
72
|
});
|
|
99
|
-
export
|
|
73
|
+
export {
|
|
74
|
+
PickerInput as default
|
|
75
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare const Prefixel: import(
|
|
4
|
-
export declare const Suffixel: import(
|
|
1
|
+
import { ThemeProps } from '@synerise/ds-core';
|
|
2
|
+
import { StyledInput } from '@synerise/ds-input';
|
|
3
|
+
export declare const Prefixel: import('styled-components').StyledComponent<"div", any, ThemeProps, never>;
|
|
4
|
+
export declare const Suffixel: import('styled-components').StyledComponent<"div", any, ThemeProps, never>;
|
|
5
5
|
export declare const Input: StyledInput<{
|
|
6
6
|
active: boolean;
|
|
7
7
|
}>;
|
|
8
|
-
export declare const PickerInputWrapper: import(
|
|
8
|
+
export declare const PickerInputWrapper: import('styled-components').StyledComponent<"div", any, {
|
|
9
9
|
prefixel: boolean;
|
|
10
10
|
suffixel: boolean;
|
|
11
11
|
}, never>;
|
|
12
|
-
export declare const Container: import(
|
|
13
|
-
export declare const ClearIconWrapper: import(
|
|
14
|
-
export declare const DefaultIconWrapper: import(
|
|
12
|
+
export declare const Container: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
13
|
+
export declare const ClearIconWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
14
|
+
export declare const DefaultIconWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|