@semcore/date-picker 2.5.5 → 2.7.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 +12 -0
- package/lib/cjs/DatePicker.js +8 -4
- package/lib/cjs/DatePicker.js.map +1 -1
- package/lib/cjs/DateRangePicker.js +2 -2
- package/lib/cjs/DateRangePicker.js.map +1 -1
- package/lib/cjs/MonthPicker.js +2 -2
- package/lib/cjs/MonthPicker.js.map +1 -1
- package/lib/cjs/MonthRangePicker.js +2 -2
- package/lib/cjs/MonthRangePicker.js.map +1 -1
- package/lib/cjs/components/ButtonTrigger.js +7 -12
- package/lib/cjs/components/ButtonTrigger.js.map +1 -1
- package/lib/cjs/components/Calendar.js +29 -22
- package/lib/cjs/components/Calendar.js.map +1 -1
- package/lib/cjs/components/PickerAbstract.js +6 -6
- package/lib/cjs/components/PickerAbstract.js.map +1 -1
- package/lib/cjs/components/RangePickerAbstract.js +10 -6
- package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
- package/lib/cjs/components/index.js +16 -13
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/index.js +5 -1
- package/lib/cjs/utils/cronTabScheduler.js +1 -1
- package/lib/cjs/utils/cronTabScheduler.js.map +1 -1
- package/lib/cjs/utils/includesDate.js.map +1 -1
- package/lib/cjs/utils/shortDateRangeFormat.js +5 -2
- package/lib/cjs/utils/shortDateRangeFormat.js.map +1 -1
- package/lib/es6/DatePicker.js +2 -2
- package/lib/es6/DatePicker.js.map +1 -1
- package/lib/es6/DateRangePicker.js +2 -2
- package/lib/es6/DateRangePicker.js.map +1 -1
- package/lib/es6/MonthPicker.js +2 -2
- package/lib/es6/MonthPicker.js.map +1 -1
- package/lib/es6/MonthRangePicker.js +2 -2
- package/lib/es6/MonthRangePicker.js.map +1 -1
- package/lib/es6/components/ButtonTrigger.js +2 -9
- package/lib/es6/components/ButtonTrigger.js.map +1 -1
- package/lib/es6/components/Calendar.js +20 -19
- package/lib/es6/components/Calendar.js.map +1 -1
- package/lib/es6/components/PickerAbstract.js +6 -6
- package/lib/es6/components/PickerAbstract.js.map +1 -1
- package/lib/es6/components/RangePickerAbstract.js +10 -6
- package/lib/es6/components/RangePickerAbstract.js.map +1 -1
- package/lib/es6/components/index.js +8 -7
- package/lib/es6/components/index.js.map +1 -1
- package/lib/es6/utils/cronTabScheduler.js.map +1 -1
- package/lib/es6/utils/includesDate.js.map +1 -1
- package/lib/es6/utils/shortDateRangeFormat.js +4 -2
- package/lib/es6/utils/shortDateRangeFormat.js.map +1 -1
- package/package.json +4 -4
- package/src/DatePicker.js +1 -3
- package/src/DateRangePicker.js +5 -30
- package/src/MonthPicker.js +1 -3
- package/src/MonthRangePicker.js +9 -32
- package/src/components/ButtonTrigger.js +2 -10
- package/src/components/Calendar.js +1 -3
- package/src/components/PickerAbstract.js +3 -9
- package/src/components/RangePickerAbstract.js +6 -18
- package/src/components/index.js +2 -2
|
@@ -14,6 +14,7 @@ import { assignProps as _assignProps4 } from "@semcore/core";
|
|
|
14
14
|
import { assignProps as _assignProps3 } from "@semcore/core";
|
|
15
15
|
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
16
16
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
17
|
+
var _excluded = ["value", "onClick", "onMouseEnter", "onMouseLeave"];
|
|
17
18
|
|
|
18
19
|
var _this = this;
|
|
19
20
|
|
|
@@ -21,9 +22,9 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
21
22
|
|
|
22
23
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
23
24
|
|
|
24
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
25
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
26
|
|
|
26
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
27
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
28
|
|
|
28
29
|
import React from 'react';
|
|
29
30
|
import dayjs from 'dayjs';
|
|
@@ -31,8 +32,8 @@ import { Component, Root, sstyled } from '@semcore/core';
|
|
|
31
32
|
import Dropdown from '@semcore/dropdown';
|
|
32
33
|
import { Box } from '@semcore/flex-box';
|
|
33
34
|
import Button from '@semcore/button';
|
|
34
|
-
import ChevronLeft from '@semcore/icon/
|
|
35
|
-
import ChevronRight from '@semcore/icon/
|
|
35
|
+
import ChevronLeft from '@semcore/icon/ChevronLeft/m';
|
|
36
|
+
import ChevronRight from '@semcore/icon/ChevronRight/m';
|
|
36
37
|
import { callAllEventHandlers } from '@semcore/utils/lib/assignProps';
|
|
37
38
|
import ButtonTrigger from './ButtonTrigger';
|
|
38
39
|
export function Trigger() {
|
|
@@ -100,12 +101,12 @@ var stylesBtn = (
|
|
|
100
101
|
/*__reshadow_css_start__*/
|
|
101
102
|
sstyled.insert(
|
|
102
103
|
/*__inner_css_start__*/
|
|
103
|
-
".
|
|
104
|
+
".___SInner_135s4_gg_{justify-content:flex-start}"
|
|
104
105
|
/*__inner_css_end__*/
|
|
105
106
|
, "rfgf9b_gg_")
|
|
106
107
|
/*__reshadow_css_end__*/
|
|
107
108
|
, {
|
|
108
|
-
"__SInner": "
|
|
109
|
+
"__SInner": "___SInner_135s4_gg_"
|
|
109
110
|
});
|
|
110
111
|
export var Period = /*#__PURE__*/function (_Component) {
|
|
111
112
|
_inherits(Period, _Component);
|
|
@@ -164,7 +165,7 @@ export var Period = /*#__PURE__*/function (_Component) {
|
|
|
164
165
|
onClick = _ref13.onClick,
|
|
165
166
|
onMouseEnter = _ref13.onMouseEnter,
|
|
166
167
|
onMouseLeave = _ref13.onMouseLeave,
|
|
167
|
-
other = _objectWithoutProperties(_ref13,
|
|
168
|
+
other = _objectWithoutProperties(_ref13, _excluded);
|
|
168
169
|
|
|
169
170
|
return /*#__PURE__*/React.createElement(Button, _extends({
|
|
170
171
|
use: "tertiary",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/index.js"],"names":["React","dayjs","Component","Root","sstyled","Dropdown","Box","Button","ChevronLeft","ChevronRight","callAllEventHandlers","ButtonTrigger","Trigger","Popper","props","SPopper","styles","Header","SHeader","Title","Children","STitle","Prev","defaultProps","children","Next","stylesBtn","Period","period","value","compareMonth","monthOne","monthTwo","isSame","Array","isArray","length","SPeriod","asProps","onChange","periods","onHighlightedChange","onDisplayedPeriodChange","map","i","onClick","onMouseEnter","onMouseLeave","other","getActiveControl","toDate","Date"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/index.js"],"names":["React","dayjs","Component","Root","sstyled","Dropdown","Box","Button","ChevronLeft","ChevronRight","callAllEventHandlers","ButtonTrigger","Trigger","Popper","props","SPopper","styles","Header","SHeader","Title","Children","STitle","Prev","defaultProps","children","Next","stylesBtn","Period","period","value","compareMonth","monthOne","monthTwo","isSame","Array","isArray","length","SPeriod","asProps","onChange","periods","onHighlightedChange","onDisplayedPeriodChange","map","i","onClick","onMouseEnter","onMouseLeave","other","getActiveControl","toDate","Date"],"mappings":";;;;;;;;;;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B,MAAM,CAAC,CAAD,CAAP,CAAL,CAAiBsB,MAAjB,EAAD,CAAvB;AACD,WAHiC,CAPpC;AAWE,UAAA,YAAY,EAAExC,oBAAoB,CAACqC,YAAD,EAAe,YAAM;AACrDN,YAAAA,mBAAmB,CAAC,EAAD,CAAnB;AACAC,YAAAA,uBAAuB,CAACb,KAAK,CAAC,CAAD,CAAL,GAAW5B,KAAK,CAAC4B,KAAK,CAAC,CAAD,CAAN,CAAL,CAAgBqB,MAAhB,EAAX,GAAsC,IAAIC,IAAJ,EAAvC,CAAvB;AACD,WAHiC;AAXpC,WAeMH,KAfN,EADW;AAAA,OAAZ,CADH,CADF;AAuBD;AAjDH;;AAAA;AAAA,EAA4B9C,SAA5B","sourcesContent":["import React from 'react';\nimport dayjs from 'dayjs';\nimport { Component, Root, sstyled } from '@semcore/core';\nimport Dropdown from '@semcore/dropdown';\nimport { Box } from '@semcore/flex-box';\nimport Button from '@semcore/button';\nimport ChevronLeft from '@semcore/icon/ChevronLeft/m';\nimport ChevronRight from '@semcore/icon/ChevronRight/m';\nimport { callAllEventHandlers } from '@semcore/utils/lib/assignProps';\nimport ButtonTrigger from './ButtonTrigger';\n\nexport function Trigger() {\n return <Root render={Dropdown.Trigger} tag={ButtonTrigger} />;\n}\n\nexport function Popper(props) {\n const SPopper = Root;\n return sstyled(props.styles)(\n <SPopper render={Dropdown.Popper} role=\"region\" aria-label=\"calendar-container\" />,\n );\n}\n\nexport function Header(props) {\n const SHeader = Root;\n return sstyled(props.styles)(<SHeader render={Box} />);\n}\n\nexport const Title = ({ Children, styles }) => {\n const STitle = Root;\n return sstyled(styles)(\n <STitle render={Box}>\n <Children />\n </STitle>,\n );\n};\n\nexport function Prev() {\n return (\n <Root\n render={Button}\n use=\"tertiary\"\n theme=\"muted\"\n size=\"l\"\n tabIndex={-1}\n aria-label=\"Prev period\"\n />\n );\n}\n\nPrev.defaultProps = {\n children: <ChevronLeft />,\n};\n\nexport function Next() {\n return (\n <Root\n render={Button}\n use=\"tertiary\"\n theme=\"muted\"\n size=\"l\"\n tabIndex={-1}\n aria-label=\"Next period\"\n />\n );\n}\n\nNext.defaultProps = {\n children: <ChevronRight />,\n};\n\nconst stylesBtn = sstyled.css`\n SInner {\n justify-content: flex-start;\n }\n`;\n\nexport class Period extends Component {\n getActiveControl = (period = [], value) => {\n function compareMonth(monthOne, monthTwo) {\n return dayjs(monthOne).isSame(dayjs(monthTwo), 'date');\n }\n\n if (!period || !value) return false;\n if (Array.isArray(value) && period.length !== value.length) return false;\n if (Array.isArray(value)) {\n return compareMonth(period[0], value[0]) && compareMonth(period[1], value[1]);\n }\n\n return compareMonth(period[0], value);\n };\n\n render() {\n const SPeriod = Root;\n const {\n styles,\n value,\n onChange,\n periods,\n onHighlightedChange,\n onDisplayedPeriodChange,\n } = this.asProps;\n\n return sstyled(styles)(\n <SPeriod render={Box}>\n {periods.map(({ value: period, onClick, onMouseEnter, onMouseLeave, ...other }, i) => (\n <Button\n use=\"tertiary\"\n theme=\"muted\"\n styles={stylesBtn}\n key={i}\n active={this.getActiveControl(period, value)}\n onClick={callAllEventHandlers(onClick, () => onChange(period))}\n onMouseEnter={callAllEventHandlers(onMouseEnter, () => {\n onHighlightedChange(period);\n onDisplayedPeriodChange(dayjs(period[0]).toDate());\n })}\n onMouseLeave={callAllEventHandlers(onMouseLeave, () => {\n onHighlightedChange([]);\n onDisplayedPeriodChange(value[0] ? dayjs(value[0]).toDate() : new Date());\n })}\n {...other}\n />\n ))}\n </SPeriod>,\n );\n }\n}\n"],"file":"index.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/cronTabScheduler.js"],"names":["cronUnitToArray","unit","includes","split","start","end","Array","from","length","parseInt","_","idx","isValidSchedule","pattern","isValidUnit","min","max","unitValues","CRON_REG","every","item","intItem","test","isValidMonth","month","isValidWeekDay","weekDay","isValidMonthDay","monthDay","validate","validateFn","msg","console","warn","patternArr","isInPeriod","date","period","dateMethod","monthInPeriod","monthDayInPeriod","weekDayInPeriod","units","testFn","some"],"mappings":";;AAAA,SAASA,eAAT,CAAyBC,IAAzB,EAA+B;AAC7B,MAAIA,IAAI,CAACC,QAAL,CAAc,GAAd,CAAJ,EAAwB;
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/cronTabScheduler.js"],"names":["cronUnitToArray","unit","includes","split","start","end","Array","from","length","parseInt","_","idx","isValidSchedule","pattern","isValidUnit","min","max","unitValues","CRON_REG","every","item","intItem","test","isValidMonth","month","isValidWeekDay","weekDay","isValidMonthDay","monthDay","validate","validateFn","msg","console","warn","patternArr","isInPeriod","date","period","dateMethod","monthInPeriod","monthDayInPeriod","weekDayInPeriod","units","testFn","some"],"mappings":";;AAAA,SAASA,eAAT,CAAyBC,IAAzB,EAA+B;AAC7B,MAAIA,IAAI,CAACC,QAAL,CAAc,GAAd,CAAJ,EAAwB;AACtB,sBAAqBD,IAAI,CAACE,KAAL,CAAW,GAAX,CAArB;AAAA;AAAA,QAAOC,KAAP;AAAA,QAAcC,GAAd;;AACA,WAAOC,KAAK,CAACC,IAAN,CACL;AAAEC,MAAAA,MAAM,EAAEC,QAAQ,CAACJ,GAAD,EAAM,EAAN,CAAR,GAAoBI,QAAQ,CAACL,KAAD,EAAQ,EAAR,CAA5B,GAA0C;AAApD,KADK,EAEL,UAACM,CAAD,EAAIC,GAAJ;AAAA,aAAYF,QAAQ,CAACL,KAAD,EAAQ,EAAR,CAAR,GAAsBO,GAAlC;AAAA,KAFK,CAAP;AAID;;AACD,SAAOV,IAAI,CAACE,KAAL,CAAW,OAAX,CAAP;AACD;;AAED,OAAO,SAASS,eAAT,CAAyBC,OAAzB,EAAkC;AACvC,MAAI,OAAOA,OAAP,KAAmB,QAAvB,EAAiC,OAAO,KAAP;;AAEjC,WAASC,WAAT,CAAqBb,IAArB,EAA2Bc,GAA3B,EAAgCC,GAAhC,EAAqC;AACnC,QAAMC,UAAU,GAAGjB,eAAe,CAACC,IAAD,CAAlC;AACA,QAAMiB,QA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AAlC;;AACA,YAAQU,GAAR;AACE,WAAK,CAAL;AACE,eAAOW,IAAI,CAACL,UAAD,EAAamB,IAAb,EAAmBI,gBAAnB,CAAX;;AACF,WAAK,CAAL;AACE,eAAOlB,IAAI,CAACL,UAAD,EAAamB,IAAb,EAAmBG,aAAnB,CAAX;;AACF,WAAK,CAAL;AACE,eAAOjB,IAAI,CAACL,UAAD,EAAamB,IAAb,EAAmBK,eAAnB,CAAX;;AACF;AACE,eAAO,KAAP;AARJ;AAUD,GAZM,CAAP;AAaD","sourcesContent":["function cronUnitToArray(unit) {\n if (unit.includes('-')) {\n const [start, end] = unit.split('-');\n return Array.from(\n { length: parseInt(end, 10) - parseInt(start, 10) + 1 },\n (_, idx) => parseInt(start, 10) + idx,\n );\n }\n return unit.split(/[,\\/]/);\n}\n\nexport function isValidSchedule(pattern) {\n if (typeof pattern !== 'string') return false;\n\n function isValidUnit(unit, min, max) {\n const unitValues = cronUnitToArray(unit);\n const CRON_REG = /^\\d+$|^\\*$|^\\*\\/\\d+$/;\n return unitValues.every((item) => {\n const intItem = parseInt(item, 10);\n return !(intItem < min || intItem > max || !CRON_REG.test(item));\n });\n }\n\n function isValidMonth(month) {\n return isValidUnit(month, 1, 12);\n }\n\n function isValidWeekDay(weekDay) {\n return isValidUnit(weekDay, 1, 7);\n }\n\n function isValidMonthDay(monthDay) {\n return isValidUnit(monthDay, 1, 31);\n }\n\n function validate(pattern, validateFn, msg) {\n if (validateFn(pattern)) return true;\n // eslint-disable-next-line no-console\n console.warn(`DatePicker disabledSchedule: ${msg} format is invalid`);\n return false;\n }\n\n const patternArr = pattern.split(' ');\n\n if (patternArr.length < 3) return false;\n\n return patternArr.every((pattern, idx) => {\n switch (idx) {\n case 0:\n return validate(pattern, isValidMonthDay, 'day of month');\n case 1:\n return validate(pattern, isValidMonth, 'month');\n case 2:\n return validate(pattern, isValidWeekDay, 'day of week');\n default:\n return false;\n }\n });\n}\n\nexport function isInPeriod(pattern, date) {\n const patternArr = pattern.split(' ');\n\n function isInPeriod(date, period, dateMethod) {\n if (period === '*') return true;\n return date[dateMethod]() === parseInt(period, 10);\n }\n\n function monthInPeriod(date, period) {\n return isInPeriod(date, period, 'getMonth');\n }\n\n function monthDayInPeriod(date, period) {\n return isInPeriod(date, period, 'getDate');\n }\n\n function weekDayInPeriod(date, period) {\n if (period == 7) period = 0;\n return isInPeriod(date, period, 'getDay');\n }\n\n function test(units, date, testFn) {\n return units.some((unit) => testFn(date, unit));\n }\n\n return patternArr.every((unit, idx) => {\n const unitValues = cronUnitToArray(unit);\n switch (idx) {\n case 0:\n return test(unitValues, date, monthDayInPeriod);\n case 1:\n return test(unitValues, date, monthInPeriod);\n case 2:\n return test(unitValues, date, weekDayInPeriod);\n default:\n return false;\n }\n });\n}\n"],"file":"cronTabScheduler.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/includesDate.js"],"names":["isInPeriod","isValidSchedule","date","unit","disabled_day","Array","isArray","MAX_DATE_TIMESTAMP","start","end","isBetween","toDate","isSame"],"mappings":";AAAA,SAASA,UAAT,EAAqBC,eAArB,QAA4C,oBAA5C;AAEA,gBAAe,UAACC,IAAD,EAAOC,IAAP;AAAA,SAAgB,UAACC,YAAD,EAAkB;AAC/C,QAAIC,KAAK,CAACC,OAAN,CAAcF,YAAd,CAAJ,EAAiC;AAC/B,UAAMG,kBAAkB,GAAG,gBAA3B;;
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/includesDate.js"],"names":["isInPeriod","isValidSchedule","date","unit","disabled_day","Array","isArray","MAX_DATE_TIMESTAMP","start","end","isBetween","toDate","isSame"],"mappings":";AAAA,SAASA,UAAT,EAAqBC,eAArB,QAA4C,oBAA5C;AAEA,gBAAe,UAACC,IAAD,EAAOC,IAAP;AAAA,SAAgB,UAACC,YAAD,EAAkB;AAC/C,QAAIC,KAAK,CAACC,OAAN,CAAcF,YAAd,CAAJ,EAAiC;AAC/B,UAAMG,kBAAkB,GAAG,gBAA3B;;AACA,yCAAqBH,YAArB;AAAA,UAAOI,KAAP;AAAA,UAAcC,GAAd;;AACA,aAAOP,IAAI,CAACQ,SAAL,CAAeF,KAAK,IAAI,CAACD,kBAAzB,EAA6CE,GAAG,IAAIF,kBAApD,EAAwEJ,IAAxE,EAA8E,IAA9E,CAAP;AACD;;AACD,QAAIF,eAAe,CAACG,YAAD,CAAnB,EAAmC;AACjC,aAAOJ,UAAU,CAACI,YAAD,EAAeF,IAAI,CAACS,MAAL,EAAf,CAAjB;AACD;;AACD,WAAOT,IAAI,CAACU,MAAL,CAAYR,YAAZ,EAA0B,MAA1B,CAAP;AACD,GAVc;AAAA,CAAf","sourcesContent":["import { isInPeriod, isValidSchedule } from './cronTabScheduler';\n\nexport default (date, unit) => (disabled_day) => {\n if (Array.isArray(disabled_day)) {\n const MAX_DATE_TIMESTAMP = 8640000000000000;\n const [start, end] = disabled_day;\n return date.isBetween(start || -MAX_DATE_TIMESTAMP, end || MAX_DATE_TIMESTAMP, unit, '[]');\n }\n if (isValidSchedule(disabled_day)) {\n return isInPeriod(disabled_day, date.toDate());\n }\n return date.isSame(disabled_day, 'date');\n};\n"],"file":"includesDate.js"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
+
var _excluded = ["locale"],
|
|
3
|
+
_excluded2 = ["year"];
|
|
2
4
|
import dayjs from 'dayjs';
|
|
3
5
|
|
|
4
6
|
function getDayJSLocale(locale) {
|
|
@@ -12,7 +14,7 @@ function getDayJSLocale(locale) {
|
|
|
12
14
|
export default function shortDateRangeFormat(dates, _ref) {
|
|
13
15
|
var _ref$locale = _ref.locale,
|
|
14
16
|
locale = _ref$locale === void 0 ? 'en-US' : _ref$locale,
|
|
15
|
-
options = _objectWithoutProperties(_ref,
|
|
17
|
+
options = _objectWithoutProperties(_ref, _excluded);
|
|
16
18
|
|
|
17
19
|
var _Intl$DateTimeFormat = new Intl.DateTimeFormat(locale, options),
|
|
18
20
|
format = _Intl$DateTimeFormat.format;
|
|
@@ -59,7 +61,7 @@ export default function shortDateRangeFormat(dates, _ref) {
|
|
|
59
61
|
|
|
60
62
|
if (isSimilarYear) {
|
|
61
63
|
var year = options.year,
|
|
62
|
-
newOptions = _objectWithoutProperties(options,
|
|
64
|
+
newOptions = _objectWithoutProperties(options, _excluded2);
|
|
63
65
|
|
|
64
66
|
if (getDayJSLocale(locale) === 'en') {
|
|
65
67
|
return "".concat(new Intl.DateTimeFormat(locale, newOptions).format(normalizeDates[0]), " - ").concat(new Intl.DateTimeFormat(locale, newOptions).format(normalizeDates[1]), ", ").concat(normalizeDates[0].getFullYear());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/shortDateRangeFormat.js"],"names":["dayjs","getDayJSLocale","locale","includes","shortDateRangeFormat","dates","options","Intl","DateTimeFormat","format","normalizeDates","map","date","toDate","monthsYears","month","year","length","isSimilarDay","isSimilarMonth","isSimilarYear","day","getDate","getFullYear","newOptions"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/shortDateRangeFormat.js"],"names":["dayjs","getDayJSLocale","locale","includes","shortDateRangeFormat","dates","options","Intl","DateTimeFormat","format","normalizeDates","map","date","toDate","monthsYears","month","year","length","isSimilarDay","isSimilarMonth","isSimilarYear","day","getDate","getFullYear","newOptions"],"mappings":";;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;;AAEA,SAASC,cAAT,CAAwBC,MAAxB,EAAgC;AAC9B,MAAIA,MAAM,CAACC,QAAP,CAAgB,IAAhB,KAAyBD,MAAM,CAACC,QAAP,CAAgB,IAAhB,CAA7B,EAAoD;AAClD,WAAO,IAAP;AACD;;AACD,SAAO,IAAP;AACD;;AAED,eAAe,SAASC,oBAAT,CAA8BC,KAA9B,QAAuE;AAAA,yBAAhCH,MAAgC;AAAA,MAAhCA,MAAgC,4BAAvB,OAAuB;AAAA,MAAXI,OAAW;;AACpF,6BAAmB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jB,UAAQJ,IAAR,GAAgCV,OAAhC,CAAQU,IAAR;AAAA,UAAiBQ,UAAjB,4BAAgClB,OAAhC;;AACA,UAAIL,cAAc,CAACC,MAAD,CAAd,KAA2B,IAA/B,EAAqC;AACnC,yBAAU,IAAIK,IAAI,CAACC,cAAT,CAAwBN,MAAxB,EAAgCsB,UAAhC,EAA4Cf,MAA5C,CACRC,cAAc,CAAC,CAAD,CADN,CAAV,gBAEO,IAAIH,IAAI,CAACC,cAAT,CAAwBN,MAAxB,EAAgCsB,UAAhC,EAA4Cf,MAA5C,CACLC,cAAc,CAAC,CAAD,CADT,CAFP,eAIMA,cAAc,CAAC,CAAD,CAAd,CAAkBa,WAAlB,EAJN;AAKD;;AACD,uBAAU,IAAIhB,IAAI,CAACC,cAAT,CAAwBN,MAAxB,EAAgCsB,UAAhC,EAA4Cf,MAA5C,CACRC,cAAc,CAAC,CAAD,CADN,CAAV,gBAEO,IAAIH,IAAI,CAACC,cAAT,CAAwBN,MAAxB,EAAgCsB,UAAhC,EAA4Cf,MAA5C,CACLC,cAAc,CAAC,CAAD,CADT,CAFP,cAIKA,cAAc,CAAC,CAAD,CAAd,CAAkBa,WAAlB,EAJL;AAKD;;AAED,qBAAUd,MAAM,CAACC,cAAc,CAAC,CAAD,CAAf,CAAhB,gBAAyCD,MAAM,CAACC,cAAc,CAAC,CAAD,CAAf,CAA/C;AACD;;AAED,SAAOD,MAAM,CAACC,cAAc,CAAC,CAAD,CAAf,CAAb;AACD","sourcesContent":["import dayjs from 'dayjs';\n\nfunction getDayJSLocale(locale) {\n if (locale.includes('en') || locale.includes('ja')) {\n return 'en';\n }\n return 'ru';\n}\n\nexport default function shortDateRangeFormat(dates, { locale = 'en-US', ...options }) {\n const { format } = new Intl.DateTimeFormat(locale, options);\n const normalizeDates = dates.map((date) => dayjs(date).toDate());\n const monthsYears = dates.map((date) => [\n dayjs(date).date(),\n dayjs(date).month(),\n dayjs(date).year(),\n ]);\n\n if (monthsYears.length > 1) {\n const isSimilarDay = monthsYears[0][0] === monthsYears[1][0];\n const isSimilarMonth = monthsYears[0][1] === monthsYears[1][1];\n const isSimilarYear = monthsYears[0][2] === monthsYears[1][2];\n\n if (isSimilarMonth && isSimilarYear && !options.day) {\n return format(normalizeDates[0]);\n }\n if (isSimilarMonth && isSimilarYear) {\n if (getDayJSLocale(locale) === 'en') {\n if (isSimilarDay) {\n return `${new Intl.DateTimeFormat(locale, { month: options.month }).format(\n normalizeDates[0],\n )} ${normalizeDates[0].getDate()}, ${normalizeDates[0].getFullYear()}`;\n }\n return `${new Intl.DateTimeFormat(locale, { month: options.month }).format(\n normalizeDates[0],\n )} ${normalizeDates[0].getDate()} - ${normalizeDates[1].getDate()}, ${normalizeDates[0].getFullYear()}`;\n }\n if (isSimilarDay) {\n return `${normalizeDates[0].getDate()} ${new Intl.DateTimeFormat(locale, {\n month: options.month,\n }).format(normalizeDates[0])} ${normalizeDates[0].getFullYear()}`;\n }\n return `${normalizeDates[0].getDate()} - ${normalizeDates[1].getDate()} ${new Intl.DateTimeFormat(\n locale,\n { month: options.month },\n ).format(normalizeDates[0])} ${normalizeDates[0].getFullYear()}`;\n }\n\n if (isSimilarYear) {\n const { year, ...newOptions } = options;\n if (getDayJSLocale(locale) === 'en') {\n return `${new Intl.DateTimeFormat(locale, newOptions).format(\n normalizeDates[0],\n )} - ${new Intl.DateTimeFormat(locale, newOptions).format(\n normalizeDates[1],\n )}, ${normalizeDates[0].getFullYear()}`;\n }\n return `${new Intl.DateTimeFormat(locale, newOptions).format(\n normalizeDates[0],\n )} - ${new Intl.DateTimeFormat(locale, newOptions).format(\n normalizeDates[1],\n )} ${normalizeDates[0].getFullYear()}`;\n }\n\n return `${format(normalizeDates[0])} - ${format(normalizeDates[1])}`;\n }\n\n return format(normalizeDates[0]);\n}\n"],"file":"shortDateRangeFormat.js"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/date-picker",
|
|
3
3
|
"description": "SEMRush DatePicker Component",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.7.0",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"@semcore/utils": "^3.27",
|
|
17
17
|
"@semcore/base-trigger": "^2",
|
|
18
18
|
"@semcore/flex-box": "^4",
|
|
19
|
-
"@semcore/button": "^3",
|
|
19
|
+
"@semcore/button": "^3.3.3-0",
|
|
20
20
|
"@semcore/divider": "^2",
|
|
21
|
-
"@semcore/icon": "^2",
|
|
21
|
+
"@semcore/icon": "^2.16",
|
|
22
22
|
"@semcore/dropdown": "^2",
|
|
23
23
|
"@semcore/typography": "^3",
|
|
24
24
|
"dayjs": "^1.8"
|
|
@@ -28,6 +28,6 @@
|
|
|
28
28
|
"react": "16.8 - 17"
|
|
29
29
|
},
|
|
30
30
|
"jest": {
|
|
31
|
-
"preset": "jest-preset-ui"
|
|
31
|
+
"preset": "@semcore/jest-preset-ui"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/DatePicker.js
CHANGED
|
@@ -64,9 +64,7 @@ export class DatePickerRoot extends PickerAbstract {
|
|
|
64
64
|
return {
|
|
65
65
|
...super.getTitleProps(),
|
|
66
66
|
children: new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }).format(
|
|
67
|
-
dayjs(displayedPeriod)
|
|
68
|
-
.startOf('month')
|
|
69
|
-
.toDate(),
|
|
67
|
+
dayjs(displayedPeriod).startOf('month').toDate(),
|
|
70
68
|
),
|
|
71
69
|
};
|
|
72
70
|
}
|
package/src/DateRangePicker.js
CHANGED
|
@@ -35,48 +35,23 @@ class DateRangePickerRoot extends RangePickerAbstract {
|
|
|
35
35
|
return [
|
|
36
36
|
{
|
|
37
37
|
children: getI18nText('last2Days'),
|
|
38
|
-
value: [
|
|
39
|
-
dayjs(today)
|
|
40
|
-
.subtract(1, 'day')
|
|
41
|
-
.toDate(),
|
|
42
|
-
today,
|
|
43
|
-
],
|
|
38
|
+
value: [dayjs(today).subtract(1, 'day').toDate(), today],
|
|
44
39
|
},
|
|
45
40
|
{
|
|
46
41
|
children: getI18nText('lastWeek'),
|
|
47
|
-
value: [
|
|
48
|
-
dayjs(today)
|
|
49
|
-
.subtract(6, 'day')
|
|
50
|
-
.toDate(),
|
|
51
|
-
today,
|
|
52
|
-
],
|
|
42
|
+
value: [dayjs(today).subtract(6, 'day').toDate(), today],
|
|
53
43
|
},
|
|
54
44
|
{
|
|
55
45
|
children: getI18nText('last2Weeks'),
|
|
56
|
-
value: [
|
|
57
|
-
dayjs(today)
|
|
58
|
-
.subtract(13, 'day')
|
|
59
|
-
.toDate(),
|
|
60
|
-
today,
|
|
61
|
-
],
|
|
46
|
+
value: [dayjs(today).subtract(13, 'day').toDate(), today],
|
|
62
47
|
},
|
|
63
48
|
{
|
|
64
49
|
children: getI18nText('lastMonth'),
|
|
65
|
-
value: [
|
|
66
|
-
dayjs(today)
|
|
67
|
-
.subtract(1, 'month')
|
|
68
|
-
.toDate(),
|
|
69
|
-
today,
|
|
70
|
-
],
|
|
50
|
+
value: [dayjs(today).subtract(1, 'month').toDate(), today],
|
|
71
51
|
},
|
|
72
52
|
{
|
|
73
53
|
children: getI18nText('last2Months'),
|
|
74
|
-
value: [
|
|
75
|
-
dayjs(today)
|
|
76
|
-
.subtract(2, 'month')
|
|
77
|
-
.toDate(),
|
|
78
|
-
today,
|
|
79
|
-
],
|
|
54
|
+
value: [dayjs(today).subtract(2, 'month').toDate(), today],
|
|
80
55
|
},
|
|
81
56
|
];
|
|
82
57
|
}
|
package/src/MonthPicker.js
CHANGED
|
@@ -46,9 +46,7 @@ class MonthPickerRoot extends PickerAbstract {
|
|
|
46
46
|
return {
|
|
47
47
|
...super.getTitleProps(),
|
|
48
48
|
children: new Intl.DateTimeFormat(locale, { year: 'numeric' }).format(
|
|
49
|
-
dayjs(displayedPeriod)
|
|
50
|
-
.startOf('year')
|
|
51
|
-
.toDate(),
|
|
49
|
+
dayjs(displayedPeriod).startOf('year').toDate(),
|
|
52
50
|
),
|
|
53
51
|
};
|
|
54
52
|
}
|
package/src/MonthRangePicker.js
CHANGED
|
@@ -36,49 +36,29 @@ class MonthRangePickerRoot extends RangePickerAbstract {
|
|
|
36
36
|
{
|
|
37
37
|
children: getI18nText('lastMonth'),
|
|
38
38
|
value: [
|
|
39
|
-
dayjs(today)
|
|
40
|
-
|
|
41
|
-
.startOf('month')
|
|
42
|
-
.toDate(),
|
|
43
|
-
dayjs(today)
|
|
44
|
-
.startOf('month')
|
|
45
|
-
.toDate(),
|
|
39
|
+
dayjs(today).subtract(1, 'month').startOf('month').toDate(),
|
|
40
|
+
dayjs(today).startOf('month').toDate(),
|
|
46
41
|
],
|
|
47
42
|
},
|
|
48
43
|
{
|
|
49
44
|
children: getI18nText('last3Months'),
|
|
50
45
|
value: [
|
|
51
|
-
dayjs(today)
|
|
52
|
-
|
|
53
|
-
.startOf('month')
|
|
54
|
-
.toDate(),
|
|
55
|
-
dayjs(today)
|
|
56
|
-
.startOf('month')
|
|
57
|
-
.toDate(),
|
|
46
|
+
dayjs(today).subtract(2, 'month').startOf('month').toDate(),
|
|
47
|
+
dayjs(today).startOf('month').toDate(),
|
|
58
48
|
],
|
|
59
49
|
},
|
|
60
50
|
{
|
|
61
51
|
children: getI18nText('last6Months'),
|
|
62
52
|
value: [
|
|
63
|
-
dayjs(today)
|
|
64
|
-
|
|
65
|
-
.startOf('month')
|
|
66
|
-
.toDate(),
|
|
67
|
-
dayjs(today)
|
|
68
|
-
.startOf('month')
|
|
69
|
-
.toDate(),
|
|
53
|
+
dayjs(today).subtract(5, 'month').startOf('month').toDate(),
|
|
54
|
+
dayjs(today).startOf('month').toDate(),
|
|
70
55
|
],
|
|
71
56
|
},
|
|
72
57
|
{
|
|
73
58
|
children: getI18nText('last12Months'),
|
|
74
59
|
value: [
|
|
75
|
-
dayjs(today)
|
|
76
|
-
|
|
77
|
-
.startOf('month')
|
|
78
|
-
.toDate(),
|
|
79
|
-
dayjs(today)
|
|
80
|
-
.startOf('month')
|
|
81
|
-
.toDate(),
|
|
60
|
+
dayjs(today).subtract(11, 'month').startOf('month').toDate(),
|
|
61
|
+
dayjs(today).startOf('month').toDate(),
|
|
82
62
|
],
|
|
83
63
|
},
|
|
84
64
|
];
|
|
@@ -102,10 +82,7 @@ class MonthRangePickerRoot extends RangePickerAbstract {
|
|
|
102
82
|
return {
|
|
103
83
|
...super.getTitleProps(props, index),
|
|
104
84
|
children: new Intl.DateTimeFormat(locale, { year: 'numeric' }).format(
|
|
105
|
-
dayjs(displayedPeriod)
|
|
106
|
-
.add(index, this.navigateStep)
|
|
107
|
-
.startOf(this.navigateStep)
|
|
108
|
-
.toDate(),
|
|
85
|
+
dayjs(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate(),
|
|
109
86
|
),
|
|
110
87
|
};
|
|
111
88
|
}
|
|
@@ -2,21 +2,13 @@ import React, { ComponentProps } from 'react';
|
|
|
2
2
|
import BaseTrigger from '@semcore/base-trigger';
|
|
3
3
|
import { Box } from '@semcore/flex-box';
|
|
4
4
|
import addonTextChildren from '@semcore/utils/lib/addonTextChildren';
|
|
5
|
-
import
|
|
6
|
-
import CalendarS from '@semcore/icon/lib/Calendar/s';
|
|
5
|
+
import Calendar from '@semcore/icon/Calendar/m';
|
|
7
6
|
import createComponent, { Root } from '@semcore/core';
|
|
8
7
|
|
|
9
|
-
const MAP_SIZE_TO_CALENDAR_SIZE = {
|
|
10
|
-
m: CalendarXS,
|
|
11
|
-
l: CalendarS,
|
|
12
|
-
xl: CalendarS,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
8
|
const ButtonTriggerRoot = ({ Children, size }) => {
|
|
16
|
-
const Icon = MAP_SIZE_TO_CALENDAR_SIZE[size || 'm'];
|
|
17
9
|
return (
|
|
18
10
|
<Root render={BaseTrigger}>
|
|
19
|
-
<ButtonTrigger.Addon tag={
|
|
11
|
+
<ButtonTrigger.Addon tag={Calendar} />
|
|
20
12
|
{addonTextChildren(Children, ButtonTrigger.Text, ButtonTrigger.Addon)}
|
|
21
13
|
</Root>
|
|
22
14
|
);
|
|
@@ -37,9 +37,7 @@ class CalendarWeekDaysRoot extends Component {
|
|
|
37
37
|
getDaysByWeek() {
|
|
38
38
|
const { locale } = this.asProps;
|
|
39
39
|
|
|
40
|
-
let date = dayjs()
|
|
41
|
-
.locale(locale, getDayJSLocaleParams(locale))
|
|
42
|
-
.startOf('week');
|
|
40
|
+
let date = dayjs().locale(locale, getDayJSLocaleParams(locale)).startOf('week');
|
|
43
41
|
return range(7, () => {
|
|
44
42
|
const weekday = new Intl.DateTimeFormat(locale, { weekday: 'short' }).format(date.valueOf());
|
|
45
43
|
date = date.add(1, 'day');
|
|
@@ -42,15 +42,11 @@ class PickerAbstract extends Component {
|
|
|
42
42
|
static enhance = [i18nEnhance()];
|
|
43
43
|
|
|
44
44
|
static add = (date, amount, unit) => {
|
|
45
|
-
return dayjs(date)
|
|
46
|
-
.add(amount, unit)
|
|
47
|
-
.toDate();
|
|
45
|
+
return dayjs(date).add(amount, unit).toDate();
|
|
48
46
|
};
|
|
49
47
|
|
|
50
48
|
static subtract = (date, amount, unit) => {
|
|
51
|
-
return dayjs(date)
|
|
52
|
-
.subtract(amount, unit)
|
|
53
|
-
.toDate();
|
|
49
|
+
return dayjs(date).subtract(amount, unit).toDate();
|
|
54
50
|
};
|
|
55
51
|
|
|
56
52
|
navigateStep;
|
|
@@ -84,9 +80,7 @@ class PickerAbstract extends Component {
|
|
|
84
80
|
navigateView = (direction) => {
|
|
85
81
|
const { displayedPeriod } = this.asProps;
|
|
86
82
|
const action = direction >= 1 ? 'add' : 'subtract';
|
|
87
|
-
const date = dayjs(displayedPeriod)
|
|
88
|
-
[action](1, this.navigateStep)
|
|
89
|
-
.toDate();
|
|
83
|
+
const date = dayjs(displayedPeriod)[action](1, this.navigateStep).toDate();
|
|
90
84
|
this.handlers.displayedPeriod(date);
|
|
91
85
|
};
|
|
92
86
|
|
|
@@ -51,15 +51,11 @@ class RangePickerAbstract extends Component {
|
|
|
51
51
|
static enhance = [i18nEnhance()];
|
|
52
52
|
|
|
53
53
|
static add = (date, amount, unit) => {
|
|
54
|
-
return dayjs(date)
|
|
55
|
-
.add(amount, unit)
|
|
56
|
-
.toDate();
|
|
54
|
+
return dayjs(date).add(amount, unit).toDate();
|
|
57
55
|
};
|
|
58
56
|
|
|
59
57
|
static subtract = (date, amount, unit) => {
|
|
60
|
-
return dayjs(date)
|
|
61
|
-
.subtract(amount, unit)
|
|
62
|
-
.toDate();
|
|
58
|
+
return dayjs(date).subtract(amount, unit).toDate();
|
|
63
59
|
};
|
|
64
60
|
|
|
65
61
|
navigateStep;
|
|
@@ -78,6 +74,7 @@ class RangePickerAbstract extends Component {
|
|
|
78
74
|
(visible) => {
|
|
79
75
|
if (!visible) {
|
|
80
76
|
this.handlers.highlighted([]);
|
|
77
|
+
this.setState({ dirtyValue: [] });
|
|
81
78
|
this.handlers.displayedPeriod(
|
|
82
79
|
getEndDate(this.asProps.value) || this.props.defaultDisplayedPeriod,
|
|
83
80
|
);
|
|
@@ -99,9 +96,7 @@ class RangePickerAbstract extends Component {
|
|
|
99
96
|
navigateView = (direction) => {
|
|
100
97
|
const { displayedPeriod } = this.asProps;
|
|
101
98
|
const action = direction >= 1 ? 'add' : 'subtract';
|
|
102
|
-
const date = dayjs(displayedPeriod)
|
|
103
|
-
[action](1, this.navigateStep)
|
|
104
|
-
.toDate();
|
|
99
|
+
const date = dayjs(displayedPeriod)[action](1, this.navigateStep).toDate();
|
|
105
100
|
this.handlers.displayedPeriod(date);
|
|
106
101
|
};
|
|
107
102
|
|
|
@@ -144,11 +139,7 @@ class RangePickerAbstract extends Component {
|
|
|
144
139
|
.toDate(),
|
|
145
140
|
];
|
|
146
141
|
} else {
|
|
147
|
-
next_highlighted = [
|
|
148
|
-
dayjs(highlighted[0])
|
|
149
|
-
.add(day, this.keyStep)
|
|
150
|
-
.toDate(),
|
|
151
|
-
];
|
|
142
|
+
next_highlighted = [dayjs(highlighted[0]).add(day, this.keyStep).toDate()];
|
|
152
143
|
}
|
|
153
144
|
this.handlers.highlighted(next_highlighted);
|
|
154
145
|
this.handlers.displayedPeriod(setNextDisplayedPeriod(next_highlighted));
|
|
@@ -283,10 +274,7 @@ class RangePickerAbstract extends Component {
|
|
|
283
274
|
const { locale, displayedPeriod } = this.asProps;
|
|
284
275
|
return {
|
|
285
276
|
children: new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }).format(
|
|
286
|
-
dayjs(displayedPeriod)
|
|
287
|
-
.add(index, this.navigateStep)
|
|
288
|
-
.startOf(this.navigateStep)
|
|
289
|
-
.toDate(),
|
|
277
|
+
dayjs(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate(),
|
|
290
278
|
),
|
|
291
279
|
};
|
|
292
280
|
}
|
package/src/components/index.js
CHANGED
|
@@ -4,8 +4,8 @@ import { Component, Root, sstyled } from '@semcore/core';
|
|
|
4
4
|
import Dropdown from '@semcore/dropdown';
|
|
5
5
|
import { Box } from '@semcore/flex-box';
|
|
6
6
|
import Button from '@semcore/button';
|
|
7
|
-
import ChevronLeft from '@semcore/icon/
|
|
8
|
-
import ChevronRight from '@semcore/icon/
|
|
7
|
+
import ChevronLeft from '@semcore/icon/ChevronLeft/m';
|
|
8
|
+
import ChevronRight from '@semcore/icon/ChevronRight/m';
|
|
9
9
|
import { callAllEventHandlers } from '@semcore/utils/lib/assignProps';
|
|
10
10
|
import ButtonTrigger from './ButtonTrigger';
|
|
11
11
|
|