@synerise/ds-date-picker 1.4.1 → 1.4.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 +4 -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,55 +1,50 @@
|
|
|
1
|
-
import styled, { css } from
|
|
2
|
-
import { Input as
|
|
3
|
-
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import { Input as Input$1 } from "@synerise/ds-input";
|
|
3
|
+
const Prefixel = /* @__PURE__ */ styled.div.withConfig({
|
|
4
4
|
displayName: "PickerInputstyles__Prefixel",
|
|
5
5
|
componentId: "sc-168pcz5-0"
|
|
6
|
-
})(["border:1px solid ", ";border-radius:3px 0 0 3px;border-right-width:0;"],
|
|
7
|
-
|
|
8
|
-
});
|
|
9
|
-
export var Suffixel = styled.div.withConfig({
|
|
6
|
+
})(["border:1px solid ", ";border-radius:3px 0 0 3px;border-right-width:0;"], (props) => props.theme.palette["grey-300"]);
|
|
7
|
+
const Suffixel = /* @__PURE__ */ styled.div.withConfig({
|
|
10
8
|
displayName: "PickerInputstyles__Suffixel",
|
|
11
9
|
componentId: "sc-168pcz5-1"
|
|
12
|
-
})(["border:1px solid ", ";border-radius:0 3px 3px 0;border-left-width:0;"],
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var activeStyle = function activeStyle(props) {
|
|
16
|
-
return css(["box-shadow:inset 0 0 0 1px ", ";border-color:", ";background:", ";"], props.theme.palette['blue-600'], props.theme.palette['blue-600'], props.theme.palette['blue-050']);
|
|
17
|
-
};
|
|
18
|
-
export var Input = styled(DSInput).withConfig({
|
|
10
|
+
})(["border:1px solid ", ";border-radius:0 3px 3px 0;border-left-width:0;"], (props) => props.theme.palette["grey-300"]);
|
|
11
|
+
const activeStyle = (props) => css(["box-shadow:inset 0 0 0 1px ", ";border-color:", ";background:", ";"], props.theme.palette["blue-600"], props.theme.palette["blue-600"], props.theme.palette["blue-050"]);
|
|
12
|
+
const Input = /* @__PURE__ */ styled(Input$1).withConfig({
|
|
19
13
|
displayName: "PickerInputstyles__Input",
|
|
20
14
|
componentId: "sc-168pcz5-2"
|
|
21
|
-
})(["&{.ant-input{", ";", "}}"],
|
|
22
|
-
|
|
23
|
-
}, function (props) {
|
|
24
|
-
return !!props.active && activeStyle(props);
|
|
25
|
-
});
|
|
26
|
-
export var PickerInputWrapper = styled.div.withConfig({
|
|
15
|
+
})(["&{.ant-input{", ";", "}}"], (props) => !props.autoResize && "min-width: 150px", (props) => !!props.active && activeStyle(props));
|
|
16
|
+
const PickerInputWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
27
17
|
displayName: "PickerInputstyles__PickerInputWrapper",
|
|
28
18
|
componentId: "sc-168pcz5-3"
|
|
29
|
-
})(["display:flex;align-items:center;", ",", "{background:", ";display:flex;align-items:center;align-self:stretch;padding:0 12px;}", " ", ""], Prefixel, Suffixel,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
19
|
+
})(["display:flex;align-items:center;", ",", "{background:", ";display:flex;align-items:center;align-self:stretch;padding:0 12px;}", " ", ""], Prefixel, Suffixel, (props) => props.theme.palette["grey-050"], (props) => props.prefixel && `
|
|
20
|
+
${Input} input {
|
|
21
|
+
border-top-left-radius: 0;
|
|
22
|
+
border-bottom-left-radius: 0;
|
|
23
|
+
}
|
|
24
|
+
`, (props) => props.suffixel && `
|
|
25
|
+
${Input} input {
|
|
26
|
+
border-top-right-radius: 0;
|
|
27
|
+
border-bottom-right-radius: 0;
|
|
28
|
+
}
|
|
29
|
+
`);
|
|
30
|
+
const Container = /* @__PURE__ */ styled.div.withConfig({
|
|
37
31
|
displayName: "PickerInputstyles__Container",
|
|
38
32
|
componentId: "sc-168pcz5-4"
|
|
39
33
|
})(["width:100%;"]);
|
|
40
|
-
|
|
34
|
+
const ClearIconWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
41
35
|
displayName: "PickerInputstyles__ClearIconWrapper",
|
|
42
36
|
componentId: "sc-168pcz5-5"
|
|
43
|
-
})([".ds-icon svg{fill:", ";}&&:hover{.ds-icon svg{fill:", ";}}"],
|
|
44
|
-
|
|
45
|
-
}, function (props) {
|
|
46
|
-
return props.theme.palette['red-600'];
|
|
47
|
-
});
|
|
48
|
-
export var DefaultIconWrapper = styled.div.withConfig({
|
|
37
|
+
})([".ds-icon svg{fill:", ";}&&:hover{.ds-icon svg{fill:", ";}}"], (props) => props.theme.palette["red-600"], (props) => props.theme.palette["red-600"]);
|
|
38
|
+
const DefaultIconWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
49
39
|
displayName: "PickerInputstyles__DefaultIconWrapper",
|
|
50
40
|
componentId: "sc-168pcz5-6"
|
|
51
|
-
})([".ds-icon svg{fill:", ";}&&:hover{.ds-icon svg{fill:", ";}}"],
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
})([".ds-icon svg{fill:", ";}&&:hover{.ds-icon svg{fill:", ";}}"], (props) => props.theme.palette["grey-400"], (props) => props.theme.palette["grey-600"]);
|
|
42
|
+
export {
|
|
43
|
+
ClearIconWrapper,
|
|
44
|
+
Container,
|
|
45
|
+
DefaultIconWrapper,
|
|
46
|
+
Input,
|
|
47
|
+
PickerInputWrapper,
|
|
48
|
+
Prefixel,
|
|
49
|
+
Suffixel
|
|
50
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import { SizeType } from 'antd/lib/config-provider/SizeContext';
|
|
2
|
+
import { CSSProperties, HTMLAttributes, ReactNode } from 'react';
|
|
3
|
+
import { DateToFormatOptions } from '@synerise/ds-core';
|
|
4
|
+
import { DataAttributes } from '@synerise/ds-utils';
|
|
5
|
+
import { DatePickerProps } from '../../DatePicker.types';
|
|
6
6
|
type InputProps = DatePickerProps['inputProps'];
|
|
7
7
|
export type Props = InputProps & {
|
|
8
8
|
autoFocus?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { QuickPick, Texts } from '../../DatePicker.types';
|
|
3
3
|
type QuickPicksProps = {
|
|
4
4
|
value?: Date;
|
|
5
5
|
onChange: (item: QuickPick) => void;
|
|
@@ -1,31 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ButtonToggle } from
|
|
3
|
-
import { useDataFormat } from
|
|
4
|
-
import { Title } from
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { ButtonToggle } from "@synerise/ds-button";
|
|
3
|
+
import { useDataFormat } from "@synerise/ds-core";
|
|
4
|
+
import { Title } from "@synerise/ds-typography";
|
|
5
|
+
import "date-fns/addDays";
|
|
6
|
+
import "date-fns/addMonths";
|
|
7
|
+
import "date-fns/addSeconds";
|
|
8
|
+
import "date-fns/addYears";
|
|
9
|
+
import "date-fns/differenceInSeconds";
|
|
10
|
+
import "date-fns/differenceInYears";
|
|
11
|
+
import "date-fns/endOfDay";
|
|
12
|
+
import "date-fns/endOfMonth";
|
|
13
|
+
import "date-fns/format";
|
|
14
|
+
import "date-fns/getSeconds";
|
|
15
|
+
import "date-fns/getYear";
|
|
16
|
+
import "date-fns/isAfter";
|
|
17
|
+
import "date-fns/isBefore";
|
|
18
|
+
import "date-fns/isEqual";
|
|
19
|
+
import fnsIsSameDay from "date-fns/isSameDay";
|
|
20
|
+
import "date-fns/isSameMonth";
|
|
21
|
+
import "date-fns/isSameYear";
|
|
22
|
+
import "date-fns/setDate";
|
|
23
|
+
import "date-fns/setMonth";
|
|
24
|
+
import "date-fns/setYear";
|
|
25
|
+
import "date-fns/startOfDay";
|
|
26
|
+
import "date-fns/startOfMonth";
|
|
27
|
+
import { QuickPicksWrapper } from "./QuickPicks.styles.js";
|
|
28
|
+
const quickPickMatchesValue = (item, value) => {
|
|
8
29
|
return value ? fnsIsSameDay(item.value, value) : false;
|
|
9
30
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}));
|
|
31
|
-
};
|
|
31
|
+
const QuickPicks = ({
|
|
32
|
+
value,
|
|
33
|
+
items,
|
|
34
|
+
texts,
|
|
35
|
+
onChange
|
|
36
|
+
}) => {
|
|
37
|
+
const {
|
|
38
|
+
formatValue
|
|
39
|
+
} = useDataFormat();
|
|
40
|
+
return /* @__PURE__ */ jsxs(QuickPicksWrapper, { children: [
|
|
41
|
+
/* @__PURE__ */ jsx(Title, { level: 6, children: texts.quickPicks }),
|
|
42
|
+
items.map((item) => /* @__PURE__ */ jsx(ButtonToggle, { type: "ghost", activated: quickPickMatchesValue(item, value), onClick: () => onChange(item), tooltipProps: {
|
|
43
|
+
title: /* @__PURE__ */ jsx(Fragment, { children: formatValue(item.value) })
|
|
44
|
+
}, children: item.label }))
|
|
45
|
+
] });
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
QuickPicks,
|
|
49
|
+
quickPickMatchesValue
|
|
50
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const QuickPicksWrapper: import(
|
|
1
|
+
export declare const QuickPicksWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import styled from
|
|
2
|
-
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
const QuickPicksWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
3
3
|
displayName: "QuickPicksstyles__QuickPicksWrapper",
|
|
4
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 ", ";"],
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
})(["display:flex;flex-direction:column;margin-top:47px;align-items:flex-start;gap:8px;padding:16px 16px 16px 24px;border-top:1px solid ", ";"], (props) => props.theme.palette["grey-200"]);
|
|
6
|
+
export {
|
|
7
|
+
QuickPicksWrapper
|
|
8
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { TimePickerProps } from './TimePicker.types';
|
|
3
3
|
declare const TimePicker: ({ value, disabledHours, disabledMinutes, disabledSeconds, inactivePrev, inactiveNext, onChange, onShortNext, onShortPrev, }: TimePickerProps) => React.JSX.Element;
|
|
4
4
|
export default TimePicker;
|
|
@@ -1,48 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
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
|
-
|
|
33
|
-
onShortNext: onShortNext,
|
|
34
|
-
onShortPrev: onShortPrev
|
|
35
|
-
}), /*#__PURE__*/React.createElement(S.Container, {
|
|
36
|
-
key: "ds-time-picker-body",
|
|
37
|
-
className: "ds-time-picker"
|
|
38
|
-
}, /*#__PURE__*/React.createElement(DSTimePicker, {
|
|
39
|
-
value: value,
|
|
40
|
-
onChange: onChange,
|
|
41
|
-
disabledHours: disabledHours,
|
|
42
|
-
disabledMinutes: disabledMinutes,
|
|
43
|
-
disabledSeconds: disabledSeconds,
|
|
44
|
-
use12HourClock: is12HoursClock,
|
|
45
|
-
raw: true
|
|
46
|
-
})));
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useDataFormat, getDefaultDataTimeOptions } from "@synerise/ds-core";
|
|
3
|
+
import DSTimePicker from "@synerise/ds-time-picker";
|
|
4
|
+
import Navbar from "../Navbar/Navbar.js";
|
|
5
|
+
import { Container } from "./TimePicker.styles.js";
|
|
6
|
+
const TimePicker = ({
|
|
7
|
+
value = /* @__PURE__ */ new Date(),
|
|
8
|
+
disabledHours = [],
|
|
9
|
+
disabledMinutes = [],
|
|
10
|
+
disabledSeconds = [],
|
|
11
|
+
inactivePrev,
|
|
12
|
+
inactiveNext,
|
|
13
|
+
onChange,
|
|
14
|
+
onShortNext,
|
|
15
|
+
onShortPrev
|
|
16
|
+
}) => {
|
|
17
|
+
const {
|
|
18
|
+
is12HoursClock,
|
|
19
|
+
formatValue
|
|
20
|
+
} = useDataFormat();
|
|
21
|
+
const navbarDate = formatValue(value, {
|
|
22
|
+
...getDefaultDataTimeOptions(),
|
|
23
|
+
targetFormat: "date",
|
|
24
|
+
month: "short"
|
|
25
|
+
});
|
|
26
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
27
|
+
!!value && /* @__PURE__ */ jsx(Navbar, { title: navbarDate, inactivePrev, inactiveNext, onShortNext, onShortPrev }, "head"),
|
|
28
|
+
/* @__PURE__ */ jsx(Container, { className: "ds-time-picker", children: /* @__PURE__ */ jsx(DSTimePicker, { value, onChange, disabledHours, disabledMinutes, disabledSeconds, use12HourClock: is12HoursClock, raw: true }) }, "ds-time-picker-body")
|
|
29
|
+
] });
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
TimePicker as default
|
|
47
33
|
};
|
|
48
|
-
export default TimePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const Container: import(
|
|
1
|
+
export declare const Container: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import styled from
|
|
2
|
-
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
const Container = /* @__PURE__ */ styled.div.withConfig({
|
|
3
3
|
displayName: "TimePickerstyles__Container",
|
|
4
4
|
componentId: "sc-js4ktp-0"
|
|
5
|
-
})(["display:grid;grid-auto-columns:1fr;> *{grid-row:1;}&&{& > div > div{height:calc(100% - 18px);}}padding:16px 24px 0 24px;"]);
|
|
5
|
+
})(["display:grid;grid-auto-columns:1fr;> *{grid-row:1;}&&{& > div > div{height:calc(100% - 18px);}}padding:16px 24px 0 24px;"]);
|
|
6
|
+
export {
|
|
7
|
+
Container
|
|
8
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { YearPickerProps, YearPickerState } from './YearPicker.types';
|
|
3
3
|
export default class YearPicker extends React.PureComponent<YearPickerProps, YearPickerState> {
|
|
4
4
|
state: YearPickerState;
|
|
5
5
|
getSnapshotBeforeUpdate(prevProps: Readonly<YearPickerProps>): null;
|
|
@@ -1,121 +1,128 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { legacyParse } from "@date-fns/upgrade/v2";
|
|
4
|
+
import "date-fns/addDays";
|
|
5
|
+
import "date-fns/addMonths";
|
|
6
|
+
import "date-fns/addSeconds";
|
|
7
|
+
import fnsAddYears from "date-fns/addYears";
|
|
8
|
+
import "date-fns/differenceInSeconds";
|
|
9
|
+
import "date-fns/differenceInYears";
|
|
10
|
+
import "date-fns/endOfDay";
|
|
11
|
+
import "date-fns/endOfMonth";
|
|
12
|
+
import "date-fns/format";
|
|
13
|
+
import "date-fns/getSeconds";
|
|
14
|
+
import "date-fns/getYear";
|
|
15
|
+
import "date-fns/isAfter";
|
|
16
|
+
import "date-fns/isBefore";
|
|
17
|
+
import "date-fns/isEqual";
|
|
18
|
+
import "date-fns/isSameDay";
|
|
19
|
+
import "date-fns/isSameMonth";
|
|
20
|
+
import fnsIsSameYear from "date-fns/isSameYear";
|
|
21
|
+
import "date-fns/setDate";
|
|
22
|
+
import "date-fns/setMonth";
|
|
23
|
+
import fnsSetYear from "date-fns/setYear";
|
|
24
|
+
import "date-fns/startOfDay";
|
|
25
|
+
import "date-fns/startOfMonth";
|
|
26
|
+
import fnsFormat from "../../format.js";
|
|
27
|
+
import { getDecadeRange } from "../../utils.js";
|
|
28
|
+
import DecadePicker from "../DecadePicker/DecadePicker.js";
|
|
29
|
+
import GridPicker from "../GridPicker/GridPicker.js";
|
|
30
|
+
import Navbar from "../Navbar/Navbar.js";
|
|
11
31
|
function getInitialState(props) {
|
|
12
32
|
return {
|
|
13
|
-
cursor: props.value || new Date(),
|
|
33
|
+
cursor: props.value || /* @__PURE__ */ new Date(),
|
|
14
34
|
decadeMode: false
|
|
15
35
|
};
|
|
16
36
|
}
|
|
17
37
|
function getCells(cursor) {
|
|
18
|
-
|
|
19
|
-
return Array.from(Array(10)).map(
|
|
20
|
-
|
|
38
|
+
const startYear = getDecadeRange(cursor)[0];
|
|
39
|
+
return Array.from(Array(10)).map((_, index) => {
|
|
40
|
+
const date = fnsAddYears(fnsSetYear(cursor, startYear), index);
|
|
21
41
|
return {
|
|
22
42
|
key: date.toISOString(),
|
|
23
|
-
text: fnsFormat(date,
|
|
43
|
+
text: fnsFormat(date, "yyyy")
|
|
24
44
|
};
|
|
25
45
|
});
|
|
26
46
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var cursor = _this.state.cursor;
|
|
37
|
-
_this.setState({
|
|
47
|
+
class YearPicker extends React.PureComponent {
|
|
48
|
+
constructor() {
|
|
49
|
+
super(...arguments);
|
|
50
|
+
this.state = getInitialState(this.props);
|
|
51
|
+
this.handleLongPrev = () => {
|
|
52
|
+
const {
|
|
53
|
+
cursor
|
|
54
|
+
} = this.state;
|
|
55
|
+
this.setState({
|
|
38
56
|
cursor: fnsAddYears(cursor, -10)
|
|
39
57
|
});
|
|
40
58
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
59
|
+
this.handleLongNext = () => {
|
|
60
|
+
const {
|
|
61
|
+
cursor
|
|
62
|
+
} = this.state;
|
|
63
|
+
this.setState({
|
|
44
64
|
cursor: fnsAddYears(cursor, 10)
|
|
45
65
|
});
|
|
46
66
|
};
|
|
47
|
-
|
|
48
|
-
|
|
67
|
+
this.handleCellClick = (isoDate) => {
|
|
68
|
+
const {
|
|
69
|
+
onChange
|
|
70
|
+
} = this.props;
|
|
49
71
|
if (isoDate === -1) {
|
|
50
|
-
|
|
72
|
+
this.handleLongPrev();
|
|
51
73
|
return;
|
|
52
74
|
}
|
|
53
75
|
if (isoDate === 1) {
|
|
54
|
-
|
|
76
|
+
this.handleLongNext();
|
|
55
77
|
return;
|
|
56
78
|
}
|
|
57
79
|
onChange && onChange(new Date(isoDate));
|
|
58
80
|
};
|
|
59
|
-
return _this;
|
|
60
81
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (value &&
|
|
82
|
+
getSnapshotBeforeUpdate(prevProps) {
|
|
83
|
+
const {
|
|
84
|
+
value
|
|
85
|
+
} = this.props;
|
|
86
|
+
if (value && prevProps?.value !== value) {
|
|
66
87
|
this.setState(getInitialState(this.props));
|
|
67
88
|
}
|
|
68
89
|
return null;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
90
|
+
}
|
|
91
|
+
render() {
|
|
92
|
+
const {
|
|
93
|
+
cursor,
|
|
94
|
+
decadeMode
|
|
95
|
+
} = this.state;
|
|
96
|
+
const {
|
|
97
|
+
value
|
|
98
|
+
} = this.props;
|
|
99
|
+
const decadeRange = getDecadeRange(cursor);
|
|
100
|
+
let cells = getCells(cursor);
|
|
101
|
+
const valueCell = value ? cells.find((cell) => fnsIsSameYear(value, legacyParse(cell.key))) : null;
|
|
102
|
+
const selectedKey = valueCell ? valueCell.key : null;
|
|
82
103
|
cells = [{
|
|
83
104
|
key: -1,
|
|
84
105
|
text: decadeRange[0] - 1,
|
|
85
106
|
outside: true
|
|
86
|
-
}
|
|
107
|
+
}, ...cells, {
|
|
87
108
|
key: 1,
|
|
88
109
|
text: decadeRange[1] + 1,
|
|
89
110
|
outside: true
|
|
90
|
-
}]
|
|
111
|
+
}];
|
|
91
112
|
if (decadeMode) {
|
|
92
|
-
return
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
cursor: selectedDecade,
|
|
97
|
-
decadeMode: false
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
});
|
|
113
|
+
return /* @__PURE__ */ jsx(DecadePicker, { value: cursor, onChange: (selectedDecade) => this.setState({
|
|
114
|
+
cursor: selectedDecade,
|
|
115
|
+
decadeMode: false
|
|
116
|
+
}) });
|
|
101
117
|
}
|
|
102
|
-
return
|
|
103
|
-
onTitleClick:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
selectedKey: selectedKey,
|
|
114
|
-
cells: cells,
|
|
115
|
-
onCellClick: this.handleCellClick,
|
|
116
|
-
key: "body"
|
|
117
|
-
}));
|
|
118
|
-
};
|
|
119
|
-
return YearPicker;
|
|
120
|
-
}(React.PureComponent);
|
|
121
|
-
export { YearPicker as default };
|
|
118
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
119
|
+
/* @__PURE__ */ jsx(Navbar, { onTitleClick: () => this.setState({
|
|
120
|
+
decadeMode: true
|
|
121
|
+
}), title: decadeRange.join("-"), onLongPrev: this.handleLongPrev, onLongNext: this.handleLongNext }, "head"),
|
|
122
|
+
/* @__PURE__ */ jsx(GridPicker, { selectedKey, cells, onCellClick: this.handleCellClick }, "body")
|
|
123
|
+
] });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export {
|
|
127
|
+
YearPicker as default
|
|
128
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
declare const _default: React.FC<import(
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { WrappedComponentProps } from 'react-intl';
|
|
3
|
+
import { RawDatePickerProps } from './RawDatePicker.types';
|
|
4
|
+
declare const _default: React.FC<import('react-intl').WithIntlProps<RawDatePickerProps & WrappedComponentProps>> & {
|
|
5
5
|
WrappedComponent: React.ComponentType<RawDatePickerProps & WrappedComponentProps>;
|
|
6
6
|
};
|
|
7
7
|
export default _default;
|