@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.
Files changed (73) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/DatePicker.const.js +6 -3
  3. package/dist/DatePicker.d.ts +2 -2
  4. package/dist/DatePicker.js +61 -101
  5. package/dist/DatePicker.styles.d.ts +4 -4
  6. package/dist/DatePicker.styles.js +17 -14
  7. package/dist/DatePicker.types.d.ts +6 -6
  8. package/dist/DatePicker.types.js +1 -1
  9. package/dist/Elements/DayPicker/DayPicker.d.ts +3 -3
  10. package/dist/Elements/DayPicker/DayPicker.js +60 -60
  11. package/dist/Elements/DayPicker/DayPicker.styles.d.ts +6 -6
  12. package/dist/Elements/DayPicker/DayPicker.styles.js +18 -75
  13. package/dist/Elements/DayPicker/DayPicker.types.d.ts +4 -4
  14. package/dist/Elements/DayPicker/DayPicker.types.js +1 -1
  15. package/dist/Elements/DecadePicker/DecadePicker.d.ts +2 -2
  16. package/dist/Elements/DecadePicker/DecadePicker.js +85 -71
  17. package/dist/Elements/DecadePicker/DecadePicker.types.js +1 -1
  18. package/dist/Elements/Footer/Footer.d.ts +3 -3
  19. package/dist/Elements/Footer/Footer.js +39 -55
  20. package/dist/Elements/Footer/Footer.styles.d.ts +4 -4
  21. package/dist/Elements/Footer/Footer.styles.js +13 -7
  22. package/dist/Elements/Footer/Footer.types.d.ts +2 -2
  23. package/dist/Elements/Footer/Footer.types.js +1 -1
  24. package/dist/Elements/GridPicker/GridPicker.d.ts +2 -2
  25. package/dist/Elements/GridPicker/GridPicker.js +36 -44
  26. package/dist/Elements/GridPicker/GridPicker.styles.d.ts +2 -2
  27. package/dist/Elements/GridPicker/GridPicker.styles.js +9 -19
  28. package/dist/Elements/GridPicker/GridPicker.types.d.ts +1 -1
  29. package/dist/Elements/GridPicker/GridPicker.types.js +1 -1
  30. package/dist/Elements/MonthPicker/MonthPicker.d.ts +3 -3
  31. package/dist/Elements/MonthPicker/MonthPicker.js +85 -85
  32. package/dist/Elements/MonthPicker/MonthPicker.types.d.ts +1 -1
  33. package/dist/Elements/MonthPicker/MonthPicker.types.js +1 -1
  34. package/dist/Elements/Navbar/Navbar.d.ts +2 -2
  35. package/dist/Elements/Navbar/Navbar.js +31 -69
  36. package/dist/Elements/Navbar/Navbar.styles.d.ts +6 -6
  37. package/dist/Elements/Navbar/Navbar.styles.js +19 -19
  38. package/dist/Elements/Navbar/Navbar.types.d.ts +1 -1
  39. package/dist/Elements/Navbar/Navbar.types.js +1 -1
  40. package/dist/Elements/PickerInput/PickerInput.d.ts +5 -5
  41. package/dist/Elements/PickerInput/PickerInput.js +56 -80
  42. package/dist/Elements/PickerInput/PickerInput.styles.d.ts +8 -8
  43. package/dist/Elements/PickerInput/PickerInput.styles.js +35 -40
  44. package/dist/Elements/PickerInput/PickerInput.types.d.ts +5 -5
  45. package/dist/Elements/PickerInput/PickerInput.types.js +1 -1
  46. package/dist/Elements/QuickPicks/QuickPicks.d.ts +2 -2
  47. package/dist/Elements/QuickPicks/QuickPicks.js +48 -29
  48. package/dist/Elements/QuickPicks/QuickPicks.styles.d.ts +1 -1
  49. package/dist/Elements/QuickPicks/QuickPicks.styles.js +6 -5
  50. package/dist/Elements/TimePicker/TimePicker.d.ts +2 -2
  51. package/dist/Elements/TimePicker/TimePicker.js +32 -47
  52. package/dist/Elements/TimePicker/TimePicker.styles.d.ts +1 -1
  53. package/dist/Elements/TimePicker/TimePicker.styles.js +6 -3
  54. package/dist/Elements/TimePicker/TimePicker.types.js +1 -1
  55. package/dist/Elements/YearPicker/YearPicker.d.ts +2 -2
  56. package/dist/Elements/YearPicker/YearPicker.js +90 -83
  57. package/dist/Elements/YearPicker/YearPicker.types.js +1 -1
  58. package/dist/RawDatePicker/RawDatePicker.d.ts +4 -4
  59. package/dist/RawDatePicker/RawDatePicker.js +202 -222
  60. package/dist/RawDatePicker/RawDatePicker.types.d.ts +1 -1
  61. package/dist/RawDatePicker/RawDatePicker.types.js +1 -1
  62. package/dist/fns.d.ts +22 -22
  63. package/dist/fns.js +46 -44
  64. package/dist/format.js +38 -17
  65. package/dist/index.js +15 -7
  66. package/dist/localeUtils.d.ts +1 -1
  67. package/dist/localeUtils.js +34 -52
  68. package/dist/modules.d.js +1 -1
  69. package/dist/modules.d.ts +0 -0
  70. package/dist/utils/getDefaultTexts.d.ts +2 -2
  71. package/dist/utils/getDefaultTexts.js +17 -24
  72. package/dist/utils.js +44 -19
  73. package/package.json +12 -12
@@ -1,55 +1,50 @@
1
- import styled, { css } from 'styled-components';
2
- import { Input as DSInput } from '@synerise/ds-input';
3
- export var Prefixel = styled.div.withConfig({
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;"], function (props) {
7
- return props.theme.palette['grey-300'];
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;"], function (props) {
13
- return props.theme.palette['grey-300'];
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{", ";", "}}"], function (props) {
22
- return !props.autoResize && 'min-width: 150px';
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, function (props) {
30
- return props.theme.palette['grey-050'];
31
- }, function (props) {
32
- return props.prefixel && "\n " + Input + " input {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n }\n ";
33
- }, function (props) {
34
- return props.suffixel && "\n " + Input + " input {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n }\n ";
35
- });
36
- export var Container = styled.div.withConfig({
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
- export var ClearIconWrapper = styled.div.withConfig({
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:", ";}}"], function (props) {
44
- return props.theme.palette['red-600'];
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:", ";}}"], function (props) {
52
- return props.theme.palette['grey-400'];
53
- }, function (props) {
54
- return props.theme.palette['grey-600'];
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 { type SizeType } from 'antd/lib/config-provider/SizeContext';
2
- import type { CSSProperties, HTMLAttributes, ReactNode } from 'react';
3
- import type { DateToFormatOptions } from '@synerise/ds-core';
4
- import type { DataAttributes } from '@synerise/ds-utils';
5
- import type { DatePickerProps } from '../../DatePicker.types';
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
- export {};
1
+
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import type { QuickPick, Texts } from '../../DatePicker.types';
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 React from 'react';
2
- import { ButtonToggle } from '@synerise/ds-button';
3
- import { useDataFormat } from '@synerise/ds-core';
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) {
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
- 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
- };
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("styled-components").StyledComponent<"div", any, {}, never>;
1
+ export declare const QuickPicksWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
@@ -1,7 +1,8 @@
1
- import styled from 'styled-components';
2
- export var QuickPicksWrapper = styled.div.withConfig({
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 ", ";"], function (props) {
6
- return props.theme.palette['grey-200'];
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 { type TimePickerProps } from './TimePicker.types';
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
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React from 'react';
3
- import { getDefaultDataTimeOptions, useDataFormat } from '@synerise/ds-core';
4
- import DSTimePicker from '@synerise/ds-time-picker';
5
- import Navbar from '../Navbar/Navbar';
6
- import * as S from './TimePicker.styles';
7
- var TimePicker = function TimePicker(_ref) {
8
- var _ref$value = _ref.value,
9
- value = _ref$value === void 0 ? new Date() : _ref$value,
10
- _ref$disabledHours = _ref.disabledHours,
11
- disabledHours = _ref$disabledHours === void 0 ? [] : _ref$disabledHours,
12
- _ref$disabledMinutes = _ref.disabledMinutes,
13
- disabledMinutes = _ref$disabledMinutes === void 0 ? [] : _ref$disabledMinutes,
14
- _ref$disabledSeconds = _ref.disabledSeconds,
15
- disabledSeconds = _ref$disabledSeconds === void 0 ? [] : _ref$disabledSeconds,
16
- inactivePrev = _ref.inactivePrev,
17
- inactiveNext = _ref.inactiveNext,
18
- onChange = _ref.onChange,
19
- onShortNext = _ref.onShortNext,
20
- onShortPrev = _ref.onShortPrev;
21
- var _useDataFormat = useDataFormat(),
22
- is12HoursClock = _useDataFormat.is12HoursClock,
23
- formatValue = _useDataFormat.formatValue;
24
- var navbarDate = formatValue(value, _extends({}, getDefaultDataTimeOptions(), {
25
- targetFormat: 'date',
26
- month: 'short'
27
- }));
28
- return /*#__PURE__*/React.createElement(React.Fragment, null, !!value && /*#__PURE__*/React.createElement(Navbar, {
29
- title: navbarDate,
30
- key: "head",
31
- inactivePrev: inactivePrev,
32
- inactiveNext: inactiveNext,
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("styled-components").StyledComponent<"div", any, {}, never>;
1
+ export declare const Container: import('styled-components').StyledComponent<"div", any, {}, never>;
@@ -1,5 +1,8 @@
1
- import styled from 'styled-components';
2
- export var Container = styled.div.withConfig({
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
- export {};
1
+
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import { type YearPickerProps, type YearPickerState } from './YearPicker.types';
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
- function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }
2
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
3
- import React from 'react';
4
- import { legacyParse } from '@date-fns/upgrade/v2';
5
- import { fnsAddYears, fnsIsSameYear, fnsSetYear } from '../../fns';
6
- import fnsFormat from '../../format';
7
- import { getDecadeRange } from '../../utils';
8
- import DecadePicker from '../DecadePicker/DecadePicker';
9
- import GridPicker from '../GridPicker/GridPicker';
10
- import Navbar from '../Navbar/Navbar';
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
- var startYear = getDecadeRange(cursor)[0];
19
- return Array.from(Array(10)).map(function (_, index) {
20
- var date = fnsAddYears(fnsSetYear(cursor, startYear), index);
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, 'yyyy')
43
+ text: fnsFormat(date, "yyyy")
24
44
  };
25
45
  });
26
46
  }
27
- var YearPicker = /*#__PURE__*/function (_React$PureComponent) {
28
- function YearPicker() {
29
- var _this;
30
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
31
- args[_key] = arguments[_key];
32
- }
33
- _this = _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args)) || this;
34
- _this.state = getInitialState(_this.props);
35
- _this.handleLongPrev = function () {
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
- _this.handleLongNext = function () {
42
- var cursor = _this.state.cursor;
43
- _this.setState({
59
+ this.handleLongNext = () => {
60
+ const {
61
+ cursor
62
+ } = this.state;
63
+ this.setState({
44
64
  cursor: fnsAddYears(cursor, 10)
45
65
  });
46
66
  };
47
- _this.handleCellClick = function (isoDate) {
48
- var onChange = _this.props.onChange;
67
+ this.handleCellClick = (isoDate) => {
68
+ const {
69
+ onChange
70
+ } = this.props;
49
71
  if (isoDate === -1) {
50
- _this.handleLongPrev();
72
+ this.handleLongPrev();
51
73
  return;
52
74
  }
53
75
  if (isoDate === 1) {
54
- _this.handleLongNext();
76
+ this.handleLongNext();
55
77
  return;
56
78
  }
57
79
  onChange && onChange(new Date(isoDate));
58
80
  };
59
- return _this;
60
81
  }
61
- _inheritsLoose(YearPicker, _React$PureComponent);
62
- var _proto = YearPicker.prototype;
63
- _proto.getSnapshotBeforeUpdate = function getSnapshotBeforeUpdate(prevProps) {
64
- var value = this.props.value;
65
- if (value && (prevProps == null ? void 0 : prevProps.value) !== 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
- _proto.render = function render() {
71
- var _this2 = this;
72
- var _this$state = this.state,
73
- cursor = _this$state.cursor,
74
- decadeMode = _this$state.decadeMode;
75
- var value = this.props.value;
76
- var decadeRange = getDecadeRange(cursor);
77
- var cells = getCells(cursor);
78
- var valueCell = value ? cells.find(function (cell) {
79
- return fnsIsSameYear(value, legacyParse(cell.key));
80
- }) : null;
81
- var selectedKey = valueCell ? valueCell.key : null;
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
- }].concat(cells, [{
107
+ }, ...cells, {
87
108
  key: 1,
88
109
  text: decadeRange[1] + 1,
89
110
  outside: true
90
- }]);
111
+ }];
91
112
  if (decadeMode) {
92
- return /*#__PURE__*/React.createElement(DecadePicker, {
93
- value: cursor,
94
- onChange: function onChange(selectedDecade) {
95
- return _this2.setState({
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 /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Navbar, {
103
- onTitleClick: function onTitleClick() {
104
- return _this2.setState({
105
- decadeMode: true
106
- });
107
- },
108
- title: decadeRange.join('-'),
109
- onLongPrev: this.handleLongPrev,
110
- onLongNext: this.handleLongNext,
111
- key: "head"
112
- }), /*#__PURE__*/React.createElement(GridPicker, {
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
- export {};
1
+
@@ -1,7 +1,7 @@
1
- import React from 'react';
2
- import { type WrappedComponentProps } from 'react-intl';
3
- import { type RawDatePickerProps } from './RawDatePicker.types';
4
- declare const _default: React.FC<import("react-intl").WithIntlProps<RawDatePickerProps & WrappedComponentProps>> & {
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;