@chayns-components/date 5.0.0-beta.919 → 5.0.0-beta.921
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/lib/cjs/components/calendar/Calendar.js +17 -17
- package/lib/cjs/components/calendar/Calendar.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.js +1 -0
- package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/Month.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js +19 -21
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.js +3 -3
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js +9 -11
- package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js.map +1 -1
- package/lib/cjs/components/calendar/month-year-pickers/MonthYearPickers.js +2 -2
- package/lib/cjs/components/calendar/month-year-pickers/MonthYearPickers.js.map +1 -1
- package/lib/cjs/components/date-info/DateInfo.js.map +1 -1
- package/lib/cjs/hooks/useDateInfo.js +27 -72
- package/lib/cjs/hooks/useDateInfo.js.map +1 -1
- package/lib/cjs/index.js +130 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/types/dateinfo.js +2 -0
- package/lib/cjs/types/dateinfo.js.map +1 -0
- package/lib/cjs/utils/calendar.js +12 -9
- package/lib/cjs/utils/calendar.js.map +1 -1
- package/lib/cjs/utils/date.js +114 -0
- package/lib/cjs/utils/date.js.map +1 -0
- package/lib/cjs/utils/dateInfo.js +99 -344
- package/lib/cjs/utils/dateInfo.js.map +1 -1
- package/lib/esm/components/calendar/Calendar.js +4 -4
- package/lib/esm/components/calendar/Calendar.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js +1 -0
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/Month.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js +2 -4
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.js +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js +8 -10
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js.map +1 -1
- package/lib/esm/components/calendar/month-year-pickers/MonthYearPickers.js +1 -1
- package/lib/esm/components/calendar/month-year-pickers/MonthYearPickers.js.map +1 -1
- package/lib/esm/components/date-info/DateInfo.js.map +1 -1
- package/lib/esm/hooks/useDateInfo.js +28 -73
- package/lib/esm/hooks/useDateInfo.js.map +1 -1
- package/lib/esm/index.js +10 -2
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/types/dateinfo.js +2 -0
- package/lib/esm/types/dateinfo.js.map +1 -0
- package/lib/esm/utils/calendar.js +4 -3
- package/lib/esm/utils/calendar.js.map +1 -1
- package/lib/esm/utils/date.js +89 -0
- package/lib/esm/utils/date.js.map +1 -0
- package/lib/esm/utils/dateInfo.js +98 -339
- package/lib/esm/utils/dateInfo.js.map +1 -1
- package/lib/types/components/calendar/Calendar.d.ts +2 -2
- package/lib/types/components/calendar/month-wrapper/MonthWrapper.d.ts +2 -2
- package/lib/types/components/calendar/month-wrapper/MonthWrapper.styles.d.ts +1 -1
- package/lib/types/components/calendar/month-wrapper/month/Month.d.ts +2 -2
- package/lib/types/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.d.ts +2 -2
- package/lib/types/components/calendar/month-year-pickers/MonthYearPickers.d.ts +2 -2
- package/lib/types/components/date-info/DateInfo.d.ts +1 -1
- package/lib/types/components/opening-times/opening-inputs/OpeningInputs.styles.d.ts +1 -1
- package/lib/types/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.d.ts +1 -1
- package/lib/types/hooks/useDateInfo.d.ts +1 -34
- package/lib/types/index.d.ts +6 -4
- package/lib/types/types/dateinfo.d.ts +34 -0
- package/lib/types/utils/calendar.d.ts +2 -2
- package/lib/types/utils/date.d.ts +27 -0
- package/lib/types/utils/dateInfo.d.ts +10 -51
- package/package.json +3 -4
- package/lib/cjs/constants/dateInfo.js +0 -639
- package/lib/cjs/constants/dateInfo.js.map +0 -1
- package/lib/esm/constants/dateInfo.js +0 -633
- package/lib/esm/constants/dateInfo.js.map +0 -1
- package/lib/types/constants/dateInfo.d.ts +0 -23
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Day.js","names":["
|
|
1
|
+
{"version":3,"file":"Day.js","names":["_react","_interopRequireWildcard","require","_Category","_interopRequireDefault","_Day","_date","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Day","date","highlightedDates","categories","isSameMonth","isSelected","onClick","isDisabled","isIntervalStart","isIntervalEnd","customThumbColors","isWithinIntervalSelection","shouldShowHighlightsInMonthOverlay","setHoveringDay","dayRef","useRef","styles","useMemo","_highlightedDates$fin","undefined","find","highlightedDate","dates","some","highlighted","isSameDay","style","categoryElements","flatMap","category","filter","day","map","createElement","key","getTime","Math","random","color","StyledDay","ref","$isSameMonth","$isDisabled","$backgroundColor","backgroundColor","$textColor","textColor","onMouseEnter","onMouseLeave","StyledDayNumber","$customThumbColors","$isSelected","$isIntervalStart","$isIntervalEnd","$isWithinIntervalSelection","getDate","StyledDayCategoryWrapper","displayName","_default","exports"],"sources":["../../../../../../../../src/components/calendar/month-wrapper/month/day-wrapper/day/Day.tsx"],"sourcesContent":["import React, { FC, useMemo, useRef } from 'react';\nimport {\n Categories, CustomThumbColors,\n HighlightedDates,\n HighlightedDateStyles,\n} from '../../../../../../types/calendar';\nimport Category from './category/Category';\nimport { StyledDay, StyledDayCategoryWrapper, StyledDayNumber } from './Day.styles';\nimport {isSameDay} from \"../../../../../../utils/date\";\n\nexport type DayProps = {\n date: Date;\n isSameMonth: boolean;\n isSelected: boolean;\n onClick: (date: Date, shouldFireEvent: boolean) => void;\n highlightedDates?: HighlightedDates[];\n categories?: Categories[];\n isDisabled: boolean;\n isIntervalStart: boolean;\n isIntervalEnd: boolean;\n isWithinIntervalSelection: boolean;\n setHoveringDay: (date: Date | null) => void;\n shouldShowHighlightsInMonthOverlay: boolean;\n customThumbColors?: CustomThumbColors;\n};\n\nconst Day: FC<DayProps> = ({\n date,\n highlightedDates,\n categories,\n isSameMonth,\n isSelected,\n onClick,\n isDisabled,\n isIntervalStart,\n isIntervalEnd,customThumbColors,\n isWithinIntervalSelection,\n shouldShowHighlightsInMonthOverlay,\n setHoveringDay,\n}) => {\n const dayRef = useRef<HTMLDivElement>(null);\n\n const styles: HighlightedDateStyles | undefined = useMemo(() => {\n if (!highlightedDates || (!shouldShowHighlightsInMonthOverlay && !isSameMonth)) {\n return undefined;\n }\n\n return highlightedDates.find((highlightedDate) =>\n highlightedDate.dates.some((highlighted) => isSameDay(highlighted, date)),\n )?.style;\n }, [date, highlightedDates, isSameMonth, shouldShowHighlightsInMonthOverlay]);\n\n const categoryElements = useMemo(() => {\n if (!categories || (!shouldShowHighlightsInMonthOverlay && !isSameMonth)) return [];\n\n return categories.flatMap((category) =>\n category.dates\n .filter((day) => isSameDay(day, date))\n .map((day) => (\n <Category key={day.getTime() * Math.random()} color={category.color} />\n )),\n );\n }, [categories, date, isSameMonth, shouldShowHighlightsInMonthOverlay]);\n\n return (\n <StyledDay\n ref={dayRef}\n onClick={() => onClick(date, isSameMonth && !isDisabled)}\n $isSameMonth={isSameMonth}\n $isDisabled={isDisabled}\n $backgroundColor={styles?.backgroundColor}\n $textColor={styles?.textColor}\n onMouseEnter={() => setHoveringDay(date)}\n onMouseLeave={() => setHoveringDay(null)}\n >\n <StyledDayNumber\n $customThumbColors={customThumbColors}\n $isSelected={\n shouldShowHighlightsInMonthOverlay ? isSelected : isSelected && isSameMonth\n }\n $isIntervalStart={\n shouldShowHighlightsInMonthOverlay\n ? isIntervalStart\n : isIntervalStart && isSameMonth\n }\n $isIntervalEnd={\n shouldShowHighlightsInMonthOverlay\n ? isIntervalEnd\n : isIntervalEnd && isSameMonth\n }\n $isWithinIntervalSelection={\n shouldShowHighlightsInMonthOverlay\n ? isWithinIntervalSelection\n : isWithinIntervalSelection && isSameMonth\n }\n >\n {date.getDate()}\n </StyledDayNumber>\n {categoryElements && (\n <StyledDayCategoryWrapper>{categoryElements}</StyledDayCategoryWrapper>\n )}\n </StyledDay>\n );\n};\n\nDay.displayName = 'Day';\n\nexport default Day;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAMA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAAuD,SAAAE,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GA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8B,SAAU;IAC9BC,YAAY,EAAEA,CAAA,KAAMlC,cAAc,CAACZ,IAAI,CAAE;IACzC+C,YAAY,EAAEA,CAAA,KAAMnC,cAAc,CAAC,IAAI;EAAE,gBAEzCxC,MAAA,CAAAS,OAAA,CAAAmD,aAAA,CAACvD,IAAA,CAAAuE,eAAe;IACZC,kBAAkB,EAAExC,iBAAkB;IACtCyC,WAAW,EACPvC,kCAAkC,GAAGP,UAAU,GAAGA,UAAU,IAAID,WACnE;IACDgD,gBAAgB,EACZxC,kCAAkC,GAC5BJ,eAAe,GACfA,eAAe,IAAIJ,WAC5B;IACDiD,cAAc,EACVzC,kCAAkC,GAC5BH,aAAa,GACbA,aAAa,IAAIL,WAC1B;IACDkD,0BAA0B,EACtB1C,kCAAkC,GAC5BD,yBAAyB,GACzBA,yBAAyB,IAAIP;EACtC,GAEAH,IAAI,CAACsD,OAAO,CAAC,CACD,CAAC,EACjB5B,gBAAgB,iBACbtD,MAAA,CAAAS,OAAA,CAAAmD,aAAA,CAACvD,IAAA,CAAA8E,wBAAwB,QAAE7B,gBAA2C,CAEnE,CAAC;AAEpB,CAAC;AAED3B,GAAG,CAACyD,WAAW,GAAG,KAAK;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA7E,OAAA,GAETkB,GAAG","ignoreList":[]}
|
|
@@ -5,31 +5,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _dateFns = require("date-fns");
|
|
9
8
|
var _WeekdayWrapper = require("./WeekdayWrapper.styles");
|
|
10
9
|
var _Weekday = _interopRequireDefault(require("./weekday/Weekday"));
|
|
10
|
+
var _date = require("../../../../../utils/date");
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
13
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
14
|
const WeekdayWrapper = ({
|
|
15
15
|
locale
|
|
16
16
|
}) => {
|
|
17
|
-
const monday = (0,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const sunday = (0, _dateFns.endOfWeek)(new Date(), {
|
|
21
|
-
weekStartsOn: 1
|
|
22
|
-
});
|
|
23
|
-
const weekdays = (0, _dateFns.eachDayOfInterval)({
|
|
17
|
+
const monday = (0, _date.startOfWeek)(new Date());
|
|
18
|
+
const sunday = (0, _date.endOfWeek)(new Date());
|
|
19
|
+
const weekdays = (0, _date.eachDayOfInterval)({
|
|
24
20
|
start: monday,
|
|
25
21
|
end: sunday
|
|
26
22
|
});
|
|
27
23
|
const weekdayElements = (0, _react.useMemo)(() => {
|
|
28
24
|
const items = [];
|
|
29
25
|
weekdays.forEach(day => {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
}
|
|
26
|
+
const options = {
|
|
27
|
+
weekday: 'short'
|
|
28
|
+
};
|
|
29
|
+
const formatter = new Intl.DateTimeFormat(locale, options);
|
|
30
|
+
const formattedDay = formatter.format(day);
|
|
33
31
|
items.push(/*#__PURE__*/_react.default.createElement(_Weekday.default, {
|
|
34
32
|
key: `weekday-${formattedDay}`,
|
|
35
33
|
name: formattedDay
|
package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WeekdayWrapper.js","names":["_react","_interopRequireWildcard","require","
|
|
1
|
+
{"version":3,"file":"WeekdayWrapper.js","names":["_react","_interopRequireWildcard","require","_WeekdayWrapper","_Weekday","_interopRequireDefault","_date","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","WeekdayWrapper","locale","monday","startOfWeek","Date","sunday","endOfWeek","weekdays","eachDayOfInterval","start","end","weekdayElements","useMemo","items","forEach","day","options","weekday","formatter","Intl","DateTimeFormat","formattedDay","format","push","createElement","key","name","StyledWeekdayWrapper","displayName","_default","exports"],"sources":["../../../../../../../src/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.tsx"],"sourcesContent":["import React, { FC, type ReactElement, useMemo } from 'react';\nimport { StyledWeekdayWrapper } from './WeekdayWrapper.styles';\nimport Weekday from './weekday/Weekday';\nimport {Language} from \"chayns-api\";\nimport {eachDayOfInterval, endOfWeek, startOfWeek} from \"../../../../../utils/date\";\n\nexport type WeekdayWrapperProps = {\n locale?: Language;\n};\n\nconst WeekdayWrapper: FC<WeekdayWrapperProps> = ({ locale }) => {\n const monday = startOfWeek(new Date());\n const sunday = endOfWeek(new Date());\n const weekdays = eachDayOfInterval({ start: monday, end: sunday });\n\n const weekdayElements = useMemo(() => {\n const items: ReactElement[] = [];\n\n weekdays.forEach((day) => {\n const options: Intl.DateTimeFormatOptions = { weekday: 'short' };\n const formatter = new Intl.DateTimeFormat(locale, options);\n const formattedDay = formatter.format(day);\n\n items.push(<Weekday key={`weekday-${formattedDay}`} name={formattedDay} />);\n });\n\n return items;\n }, [locale, weekdays]);\n\n return <StyledWeekdayWrapper>{weekdayElements}</StyledWeekdayWrapper>;\n};\n\nWeekdayWrapper.displayName = 'WeekdayWrapper';\n\nexport default WeekdayWrapper;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC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}
|
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.MonthYearPickerType = void 0;
|
|
7
7
|
var _core = require("@chayns-components/core");
|
|
8
|
-
var _dateFns = require("date-fns");
|
|
9
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
9
|
var _calendar = require("../../../utils/calendar");
|
|
11
10
|
var _Month = require("../month-wrapper/month/Month.styles");
|
|
11
|
+
var _date = require("../../../utils/date");
|
|
12
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
13
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
14
|
let MonthYearPickerType = exports.MonthYearPickerType = /*#__PURE__*/function (MonthYearPickerType) {
|
|
@@ -34,7 +34,7 @@ const MonthYearPickers = ({
|
|
|
34
34
|
}),
|
|
35
35
|
value: tempMonth
|
|
36
36
|
})), [locale]);
|
|
37
|
-
const hasMultipleMonths = (0, _react.useMemo)(() => (0,
|
|
37
|
+
const hasMultipleMonths = (0, _react.useMemo)(() => (0, _date.differenceInCalendarMonths)(maxDate, minDate) > 0, [minDate, maxDate]);
|
|
38
38
|
const years = (0, _react.useMemo)(() => (0, _calendar.getYearsBetween)(minDate, maxDate).map(tempYear => ({
|
|
39
39
|
text: tempYear.toString(),
|
|
40
40
|
value: tempYear
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MonthYearPickers.js","names":["_core","require","
|
|
1
|
+
{"version":3,"file":"MonthYearPickers.js","names":["_core","require","_react","_interopRequireWildcard","_calendar","_Month","_date","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","MonthYearPickerType","exports","MonthYearPickers","month","year","locale","minDate","maxDate","setCurrentDate","displayIndex","showMonthYearPickers","currentYear","useState","Date","getFullYear","months","useMemo","map","tempMonth","text","formatMonth","value","hasMultipleMonths","differenceInCalendarMonths","years","getYearsBetween","tempYear","toString","hasMultipleYears","length","createElement","Fragment","ComboBox","onSelect","selectedItem","tempSelectedDate","isDateInRange","currentDate","lists","list","placeholder","StyledMonthName","_default"],"sources":["../../../../../src/components/calendar/month-year-pickers/MonthYearPickers.tsx"],"sourcesContent":["import { ComboBox } from '@chayns-components/core';\nimport React, { FC, useMemo, useState } from 'react';\nimport { EMonth } from '../../../types/calendar';\nimport { formatMonth, getYearsBetween, isDateInRange } from '../../../utils/calendar';\nimport { StyledMonthName } from '../month-wrapper/month/Month.styles';\nimport {Language} from \"chayns-api\";\nimport {differenceInCalendarMonths} from \"../../../utils/date\";\n\nexport enum MonthYearPickerType {\n Month = 'month',\n Year = 'year',\n}\n\ntype MonthYearPickerProps = {\n month: EMonth;\n year: number;\n locale: Language;\n minDate: Date;\n maxDate: Date;\n setCurrentDate: (date: Date) => void;\n displayIndex?: number;\n showMonthYearPickers: boolean;\n};\n\nconst MonthYearPickers: FC<MonthYearPickerProps> = ({\n month,\n year,\n locale,\n minDate,\n maxDate,\n setCurrentDate,\n displayIndex = 0,\n showMonthYearPickers,\n}) => {\n const [currentYear] = useState(new Date().getFullYear());\n\n const months = useMemo(\n () =>\n [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].map((tempMonth) => ({\n text: formatMonth({ month: tempMonth, locale }),\n value: tempMonth,\n })),\n [locale],\n );\n\n const hasMultipleMonths = useMemo(\n () => differenceInCalendarMonths(maxDate, minDate) > 0,\n [minDate, maxDate],\n );\n\n const years = useMemo(\n () =>\n getYearsBetween(minDate, maxDate).map((tempYear) => ({\n text: tempYear.toString(),\n value: tempYear,\n })),\n [minDate, maxDate],\n );\n\n const hasMultipleYears = useMemo(() => years.length > 1, [years]);\n\n return (\n <>\n {showMonthYearPickers && hasMultipleMonths ? (\n <ComboBox\n onSelect={(selectedItem) => {\n const tempSelectedDate = isDateInRange({\n minDate,\n maxDate,\n currentDate: new Date(\n year,\n (selectedItem.value as number) - 1 - displayIndex,\n 1,\n ),\n });\n\n setCurrentDate(tempSelectedDate);\n }}\n lists={[\n {\n list: months,\n },\n ]}\n selectedItem={{\n text: formatMonth({ month, locale }),\n value: month,\n }}\n placeholder=\"\"\n />\n ) : (\n <StyledMonthName>{formatMonth({ locale, month })}</StyledMonthName>\n )}\n {showMonthYearPickers && hasMultipleYears ? (\n <ComboBox\n onSelect={(selectedItem) => {\n const tempSelectedDate = isDateInRange({\n minDate,\n maxDate,\n currentDate: new Date(\n selectedItem.value as number,\n month - 1 - displayIndex,\n 1,\n ),\n });\n\n setCurrentDate(tempSelectedDate);\n }}\n lists={[\n {\n list: years,\n },\n ]}\n selectedItem={{\n text: year.toString(),\n value: year,\n }}\n placeholder=\"\"\n />\n ) : (\n <StyledMonthName>{currentYear !== year ? year : ''}</StyledMonthName>\n )}\n </>\n );\n};\n\nexport default MonthYearPickers;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,IAAAK,KAAA,GAAAL,OAAA;AAA+D,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CA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B,CAAC,gBAEFjE,MAAA,CAAAW,OAAA,CAAA4C,aAAA,CAACpD,MAAA,CAAA+D,eAAe,QAAE9B,WAAW,KAAKP,IAAI,GAAGA,IAAI,GAAG,EAAoB,CAE1E,CAAC;AAEX,CAAC;AAAC,IAAAsC,QAAA,GAAAzC,OAAA,CAAAf,OAAA,GAEagB,gBAAgB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInfo.js","names":["_react","_interopRequireWildcard","require","_useDateInfo","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DateInfo","date","preText","shouldShowYear","shouldShowTime","shouldShowRelativeDayOfWeek","shouldUseShortText","shouldShowDayOfWeek","shouldShowDateToNowDifference","formattedDate","useDateInfo","useMemo","createElement","displayName","_default","exports"],"sources":["../../../../src/components/date-info/DateInfo.tsx"],"sourcesContent":["import React, { FC, useMemo } from 'react';\nimport { useDateInfo
|
|
1
|
+
{"version":3,"file":"DateInfo.js","names":["_react","_interopRequireWildcard","require","_useDateInfo","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DateInfo","date","preText","shouldShowYear","shouldShowTime","shouldShowRelativeDayOfWeek","shouldUseShortText","shouldShowDayOfWeek","shouldShowDateToNowDifference","formattedDate","useDateInfo","useMemo","createElement","displayName","_default","exports"],"sources":["../../../../src/components/date-info/DateInfo.tsx"],"sourcesContent":["import React, { FC, useMemo } from 'react';\nimport { useDateInfo } from '../../hooks/useDateInfo';\nimport { UseDateInfoOptions } from '../../types/dateinfo';\n\nexport type DateInfoProps = UseDateInfoOptions;\n\nconst DateInfo: FC<DateInfoProps> = ({\n date,\n preText = '',\n shouldShowYear,\n shouldShowTime,\n shouldShowRelativeDayOfWeek,\n shouldUseShortText,\n shouldShowDayOfWeek,\n shouldShowDateToNowDifference,\n}) => {\n const formattedDate = useDateInfo({\n date,\n preText,\n shouldShowYear,\n shouldShowTime,\n shouldUseShortText,\n shouldShowDayOfWeek,\n shouldShowRelativeDayOfWeek,\n shouldShowDateToNowDifference,\n });\n\n return useMemo(() => <span>{formattedDate}</span>, [formattedDate]);\n};\n\nDateInfo.displayName = 'DateInfo';\n\nexport default DateInfo;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAsD,SAAAE,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAe,GAAA,CAAAlB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAKtD,MAAMW,QAA2B,GAAGA,CAAC;EACjCC,IAAI;EACJC,OAAO,GAAG,EAAE;EACZC,cAAc;EACdC,cAAc;EACdC,2BAA2B;EAC3BC,kBAAkB;EAClBC,mBAAmB;EACnBC;AACJ,CAAC,KAAK;EACF,MAAMC,aAAa,GAAG,IAAAC,wBAAW,EAAC;IAC9BT,IAAI;IACJC,OAAO;IACPC,cAAc;IACdC,cAAc;IACdE,kBAAkB;IAClBC,mBAAmB;IACnBF,2BAA2B;IAC3BG;EACJ,CAAC,CAAC;EAEF,OAAO,IAAAG,cAAO,EAAC,mBAAMnC,MAAA,CAAAU,OAAA,CAAA0B,aAAA,eAAOH,aAAoB,CAAC,EAAE,CAACA,aAAa,CAAC,CAAC;AACvE,CAAC;AAEDT,QAAQ,CAACa,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA7B,OAAA,GAEnBc,QAAQ","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useDateInfo = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _chaynsApi = require("chayns-api");
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _dateInfo = require("../utils/dateInfo");
|
|
10
10
|
const useDateInfo = ({
|
|
@@ -17,92 +17,47 @@ const useDateInfo = ({
|
|
|
17
17
|
shouldShowYear,
|
|
18
18
|
preText
|
|
19
19
|
}) => {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
20
|
+
const {
|
|
21
|
+
active: language
|
|
22
|
+
} = (0, _chaynsApi.getLanguage)();
|
|
23
|
+
const [formattedDate, setFormattedDate] = (0, _react.useState)(date.toLocaleDateString());
|
|
24
|
+
const [currentDate, setCurrentDate] = (0, _react.useState)(new Date());
|
|
24
25
|
(0, _react.useEffect)(() => {
|
|
25
|
-
// This useEffect is used for normal date formation
|
|
26
26
|
if (shouldShowDateToNowDifference) {
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
shouldUseShortText,
|
|
33
|
-
date: formattedDate,
|
|
34
|
-
language
|
|
35
|
-
});
|
|
36
|
-
if (!isDateNearToday || !shouldShowRelativeDayOfWeek || !shouldShowTime) {
|
|
37
|
-
let formatString = 'dd. ';
|
|
38
|
-
formatString += `${(0, _dateInfo.getMonthFormat)({
|
|
39
|
-
shouldUseShortText
|
|
40
|
-
})}`;
|
|
41
|
-
formatString += `${(0, _dateInfo.getYearFormat)({
|
|
42
|
-
date: formattedDate,
|
|
43
|
-
shouldShowYear
|
|
44
|
-
})}`;
|
|
45
|
-
newFormattedDateString += (0, _dateFns.format)(formattedDate, formatString, {
|
|
46
|
-
locale: language
|
|
47
|
-
});
|
|
48
|
-
} else {
|
|
49
|
-
newFormattedDateString = newFormattedDateString.replace(', ', '');
|
|
50
|
-
}
|
|
51
|
-
newFormattedDateString += (0, _dateInfo.getFormattedTime)({
|
|
52
|
-
date: formattedDate,
|
|
29
|
+
setFormattedDate((0, _dateInfo.getDateInfo)({
|
|
30
|
+
date,
|
|
31
|
+
shouldShowYear,
|
|
53
32
|
shouldShowTime,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// Calculate remaining time till next minute to update time according to time left
|
|
60
|
-
const [currentDate, setCurrentDate] = (0, _react.useState)(new Date());
|
|
33
|
+
shouldUseShortText,
|
|
34
|
+
shouldShowDayOfWeek,
|
|
35
|
+
shouldShowRelativeDayOfWeek
|
|
36
|
+
}));
|
|
37
|
+
}, [date, shouldShowDateToNowDifference, shouldShowDayOfWeek, shouldShowRelativeDayOfWeek, shouldShowTime, shouldShowYear, shouldUseShortText]);
|
|
61
38
|
(0, _react.useEffect)(() => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (timeoutTime < 0) {
|
|
70
|
-
timeoutTime = 60 - new Date().getSeconds() + formattedDate.getSeconds();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// initialized with remaining time
|
|
74
|
-
let timeDiffInMs = formattedDate.getTime() - currentDate.getTime();
|
|
75
|
-
|
|
76
|
-
// set to elapsed time
|
|
77
|
-
if ((0, _dateFns.isPast)(formattedDate)) {
|
|
78
|
-
timeDiffInMs = currentDate.getTime() - formattedDate.getTime();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// time difference is less than a minute, time should be updated every second
|
|
82
|
-
if (timeDiffInMs < 60000) {
|
|
83
|
-
timeoutTime = 1;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Set timeoutTime to at least 1000ms
|
|
87
|
-
timeoutTime = Math.max(timeoutTime * 1000, 1000);
|
|
88
|
-
const timeout = setTimeout(() => {
|
|
89
|
-
setCurrentDate(new Date());
|
|
90
|
-
}, timeoutTime);
|
|
39
|
+
if (!shouldShowDateToNowDifference) return () => {};
|
|
40
|
+
const updateCurrentDate = () => setCurrentDate(new Date());
|
|
41
|
+
const now = new Date();
|
|
42
|
+
const timeDiffInMs = Math.abs(date.getTime() - now.getTime());
|
|
43
|
+
const updateInterval = timeDiffInMs < 60000 ? 1000 : 60000 - now.getSeconds() * 1000;
|
|
44
|
+
const intervalId = setInterval(updateCurrentDate, 1000);
|
|
45
|
+
const timeout = setTimeout(updateCurrentDate, updateInterval);
|
|
91
46
|
return () => {
|
|
92
47
|
clearTimeout(timeout);
|
|
48
|
+
clearInterval(intervalId);
|
|
93
49
|
};
|
|
94
|
-
}, [
|
|
50
|
+
}, [date, shouldShowDateToNowDifference]);
|
|
95
51
|
(0, _react.useEffect)(() => {
|
|
96
|
-
// This useEffect is for showing the difference of the date to now
|
|
97
52
|
if (shouldShowDateToNowDifference) {
|
|
98
|
-
|
|
99
|
-
date
|
|
53
|
+
setFormattedDate((0, _dateInfo.getTimeTillNow)({
|
|
54
|
+
date,
|
|
100
55
|
currentDate,
|
|
101
56
|
language
|
|
102
57
|
}));
|
|
103
58
|
}
|
|
104
|
-
}, [
|
|
105
|
-
return (0, _react.useMemo)(() => `${preText ? `${preText.trim()} ` : ''}${
|
|
59
|
+
}, [date, currentDate, language, shouldShowDateToNowDifference]);
|
|
60
|
+
return (0, _react.useMemo)(() => `${preText ? `${preText.trim()} ` : ''}${formattedDate}`, [formattedDate, preText]);
|
|
106
61
|
};
|
|
107
62
|
exports.useDateInfo = useDateInfo;
|
|
108
63
|
//# sourceMappingURL=useDateInfo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDateInfo.js","names":["
|
|
1
|
+
{"version":3,"file":"useDateInfo.js","names":["_chaynsApi","require","_react","_dateInfo","useDateInfo","date","shouldShowDateToNowDifference","shouldShowRelativeDayOfWeek","shouldShowDayOfWeek","shouldShowTime","shouldUseShortText","shouldShowYear","preText","active","language","getLanguage","formattedDate","setFormattedDate","useState","toLocaleDateString","currentDate","setCurrentDate","Date","useEffect","getDateInfo","updateCurrentDate","now","timeDiffInMs","Math","abs","getTime","updateInterval","getSeconds","intervalId","setInterval","timeout","setTimeout","clearTimeout","clearInterval","getTimeTillNow","useMemo","trim","exports"],"sources":["../../../src/hooks/useDateInfo.ts"],"sourcesContent":["import { getLanguage } from 'chayns-api';\nimport { useEffect, useMemo, useState } from 'react';\nimport { UseDateInfoOptions } from '../types/dateinfo';\nimport { getDateInfo, getTimeTillNow } from '../utils/dateInfo';\n\nexport const useDateInfo = ({\n date,\n shouldShowDateToNowDifference,\n shouldShowRelativeDayOfWeek,\n shouldShowDayOfWeek,\n shouldShowTime,\n shouldUseShortText,\n shouldShowYear,\n preText,\n}: UseDateInfoOptions) => {\n const { active: language } = getLanguage();\n\n const [formattedDate, setFormattedDate] = useState(date.toLocaleDateString());\n const [currentDate, setCurrentDate] = useState(new Date());\n\n useEffect(() => {\n if (shouldShowDateToNowDifference) {\n return;\n }\n\n setFormattedDate(\n getDateInfo({\n date,\n shouldShowYear,\n shouldShowTime,\n shouldUseShortText,\n shouldShowDayOfWeek,\n shouldShowRelativeDayOfWeek,\n }),\n );\n }, [\n date,\n shouldShowDateToNowDifference,\n shouldShowDayOfWeek,\n shouldShowRelativeDayOfWeek,\n shouldShowTime,\n shouldShowYear,\n shouldUseShortText,\n ]);\n\n useEffect(() => {\n if (!shouldShowDateToNowDifference) return () => {};\n\n const updateCurrentDate = () => setCurrentDate(new Date());\n const now = new Date();\n const timeDiffInMs = Math.abs(date.getTime() - now.getTime());\n\n const updateInterval = timeDiffInMs < 60000 ? 1000 : 60000 - now.getSeconds() * 1000;\n\n const intervalId = setInterval(updateCurrentDate, 1000);\n const timeout = setTimeout(updateCurrentDate, updateInterval);\n\n return () => {\n clearTimeout(timeout);\n clearInterval(intervalId);\n };\n }, [date, shouldShowDateToNowDifference]);\n\n useEffect(() => {\n if (shouldShowDateToNowDifference) {\n setFormattedDate(getTimeTillNow({ date, currentDate, language }));\n }\n }, [date, currentDate, language, shouldShowDateToNowDifference]);\n\n return useMemo(\n () => `${preText ? `${preText.trim()} ` : ''}${formattedDate}`,\n [formattedDate, preText],\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAEO,MAAMG,WAAW,GAAGA,CAAC;EACxBC,IAAI;EACJC,6BAA6B;EAC7BC,2BAA2B;EAC3BC,mBAAmB;EACnBC,cAAc;EACdC,kBAAkB;EAClBC,cAAc;EACdC;AACgB,CAAC,KAAK;EACtB,MAAM;IAAEC,MAAM,EAAEC;EA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ACTM,YAAY,CAACF,OAAO,CAAC;MACrBG,aAAa,CAACL,UAAU,CAAC;IAC7B,CAAC;EACL,CAAC,EAAE,CAAC5B,IAAI,EAAEC,6BAA6B,CAAC,CAAC;EAEzC,IAAAiB,gBAAS,EAAC,MAAM;IACZ,IAAIjB,6BAA6B,EAAE;MAC/BW,gBAAgB,CAAC,IAAAsB,wBAAc,EAAC;QAAElC,IAAI;QAAEe,WAAW;QAAEN;MAAS,CAAC,CAAC,CAAC;IACrE;EACJ,CAAC,EAAE,CAACT,IAAI,EAAEe,WAAW,EAAEN,QAAQ,EAAER,6BAA6B,CAAC,CAAC;EAEhE,OAAO,IAAAkC,cAAO,EACV,MAAM,GAAG5B,OAAO,GAAG,GAAGA,OAAO,CAAC6B,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,GAAGzB,aAAa,EAAE,EAC9D,CAACA,aAAa,EAAEJ,OAAO,CAC3B,CAAC;AACL,CAAC;AAAC8B,OAAA,CAAAtC,WAAA,GAAAA,WAAA","ignoreList":[]}
|
package/lib/cjs/index.js
CHANGED
|
@@ -33,6 +33,132 @@ Object.defineProperty(exports, "OpeningTimes", {
|
|
|
33
33
|
return _OpeningTimes.default;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
+
Object.defineProperty(exports, "addDays", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _date.addDays;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "addYears", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _date.addYears;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "differenceInCalendarMonths", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _date.differenceInCalendarMonths;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "eachDayOfInterval", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _date.eachDayOfInterval;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "endOfWeek", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _date.endOfWeek;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "getDateInfo", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _dateInfo.getDateInfo;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "getIsDateNearToday", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () {
|
|
75
|
+
return _date.getIsDateNearToday;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "getTimeTillNow", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () {
|
|
81
|
+
return _dateInfo.getTimeTillNow;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "isAfter", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () {
|
|
87
|
+
return _date.isAfter;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(exports, "isBefore", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function () {
|
|
93
|
+
return _date.isBefore;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(exports, "isCurrentYear", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function () {
|
|
99
|
+
return _date.isCurrentYear;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
Object.defineProperty(exports, "isMorning", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function () {
|
|
105
|
+
return _date.isMorning;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(exports, "isSameDay", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function () {
|
|
111
|
+
return _date.isSameDay;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
Object.defineProperty(exports, "isSameMonth", {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function () {
|
|
117
|
+
return _date.isSameMonth;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
Object.defineProperty(exports, "isToday", {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () {
|
|
123
|
+
return _date.isToday;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
Object.defineProperty(exports, "isTomorrow", {
|
|
127
|
+
enumerable: true,
|
|
128
|
+
get: function () {
|
|
129
|
+
return _date.isTomorrow;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
Object.defineProperty(exports, "isWithinInterval", {
|
|
133
|
+
enumerable: true,
|
|
134
|
+
get: function () {
|
|
135
|
+
return _date.isWithinInterval;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
Object.defineProperty(exports, "isYesterday", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
get: function () {
|
|
141
|
+
return _date.isYesterday;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(exports, "startOfMonth", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function () {
|
|
147
|
+
return _date.startOfMonth;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
Object.defineProperty(exports, "startOfWeek", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function () {
|
|
153
|
+
return _date.startOfWeek;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(exports, "subYears", {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function () {
|
|
159
|
+
return _date.subYears;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
36
162
|
Object.defineProperty(exports, "useDateInfo", {
|
|
37
163
|
enumerable: true,
|
|
38
164
|
get: function () {
|
|
@@ -40,10 +166,12 @@ Object.defineProperty(exports, "useDateInfo", {
|
|
|
40
166
|
}
|
|
41
167
|
});
|
|
42
168
|
var _Calendar = _interopRequireDefault(require("./components/calendar/Calendar"));
|
|
43
|
-
var
|
|
169
|
+
var _calendar = require("./types/calendar");
|
|
44
170
|
var _OpeningInputs = _interopRequireDefault(require("./components/opening-times/opening-inputs/OpeningInputs"));
|
|
45
171
|
var _OpeningTimes = _interopRequireDefault(require("./components/opening-times/OpeningTimes"));
|
|
172
|
+
var _DateInfo = _interopRequireDefault(require("./components/date-info/DateInfo"));
|
|
46
173
|
var _useDateInfo = require("./hooks/useDateInfo");
|
|
47
|
-
var
|
|
174
|
+
var _dateInfo = require("./utils/dateInfo");
|
|
175
|
+
var _date = require("./utils/date");
|
|
48
176
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
49
177
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_Calendar","_interopRequireDefault","require","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Calendar","_interopRequireDefault","require","_calendar","_OpeningInputs","_OpeningTimes","_DateInfo","_useDateInfo","_dateInfo","_date","e","__esModule","default"],"sources":["../../src/index.ts"],"sourcesContent":["// Calendar\nexport {default as Calendar} from './components/calendar/Calendar';\nexport type {Categories, HighlightedDates, HighlightedDateStyles, DateInterval, CustomThumbColors} from './types/calendar';\nexport {CalendarType} from './types/calendar';\n\n// OpeningTimes\nexport {default as OpeningInputs} from './components/opening-times/opening-inputs/OpeningInputs';\nexport {default as OpeningTimes} from './components/opening-times/OpeningTimes';\nexport type {HintTextPosition, OpeningTime, Time, Weekday} from './types/openingTimes';\n\n// DateInfo\nexport {default as DateInfo} from './components/date-info/DateInfo';\nexport {useDateInfo} from './hooks/useDateInfo';\nexport {getDateInfo, getTimeTillNow} from './utils/dateInfo'\n\n// Utils\nexport {\n isToday,\n getIsDateNearToday,\n isTomorrow,\n isYesterday,\n isMorning,\n isCurrentYear,\n addYears,\n addDays,\n isSameDay,\n eachDayOfInterval,\n isWithinInterval,\n subYears,\n endOfWeek,\n startOfWeek,\n isSameMonth,\n differenceInCalendarMonths,\n startOfMonth,\n isAfter,\n isBefore\n} from './utils/date'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AAGA,IAAAE,cAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,aAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAIA,IAAAI,SAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAGA,IAAAO,KAAA,GAAAP,OAAA;AAoBqB,SAAAD,uBAAAS,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateinfo.js","names":[],"sources":["../../../src/types/dateinfo.ts"],"sourcesContent":["export interface UseDateInfoOptions {\n /**\n * The date, that should be displayed\n */\n date: Date;\n /**\n * Additional text for \"shouldShowDateToNowDifference\" prop. Writes a text before the calculated time\n */\n preText?: string;\n /**\n * Adds the current year to the display\n */\n shouldShowYear?: boolean;\n /**\n * Adds the time to the display.\n */\n shouldShowTime?: boolean;\n /**\n * Whether the relative day of week to today should be shown (today, yesterday or tomorrow).\n */\n shouldShowRelativeDayOfWeek?: boolean;\n /**\n * Shortens the day and month text to maximum three digits\n */\n shouldUseShortText?: boolean;\n /**\n * Adds the day of week to the display\n */\n shouldShowDayOfWeek?: boolean;\n /**\n * Shows the difference from the date to now. The component handles updates itself.\n */\n shouldShowDateToNowDifference?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isDateInRange = exports.getYearsBetween = exports.getNewDate = exports.getMonthAndYear = exports.formatMonth = exports.findNextDate = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _date = require("./date");
|
|
8
8
|
const getMonthAndYear = date => {
|
|
9
9
|
const month = date.getMonth() + 1;
|
|
10
10
|
const year = date.getFullYear();
|
|
@@ -19,13 +19,13 @@ const isDateInRange = ({
|
|
|
19
19
|
maxDate,
|
|
20
20
|
currentDate
|
|
21
21
|
}) => {
|
|
22
|
-
const monthStartOfCurrentDate = (0,
|
|
23
|
-
const monthStartOfMaxDate = (0,
|
|
24
|
-
const monthStartOfMinDate = (0,
|
|
22
|
+
const monthStartOfCurrentDate = (0, _date.startOfMonth)(currentDate);
|
|
23
|
+
const monthStartOfMaxDate = (0, _date.startOfMonth)(maxDate);
|
|
24
|
+
const monthStartOfMinDate = (0, _date.startOfMonth)(minDate);
|
|
25
25
|
switch (true) {
|
|
26
|
-
case (0,
|
|
26
|
+
case (0, _date.isAfter)(monthStartOfCurrentDate, monthStartOfMaxDate):
|
|
27
27
|
return monthStartOfMaxDate;
|
|
28
|
-
case (0,
|
|
28
|
+
case (0, _date.isBefore)(monthStartOfCurrentDate, monthStartOfMinDate):
|
|
29
29
|
return monthStartOfMinDate;
|
|
30
30
|
default:
|
|
31
31
|
return monthStartOfCurrentDate;
|
|
@@ -47,9 +47,12 @@ exports.getNewDate = getNewDate;
|
|
|
47
47
|
const formatMonth = ({
|
|
48
48
|
month,
|
|
49
49
|
locale
|
|
50
|
-
}) =>
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
}) => {
|
|
51
|
+
const date = new Date(2022, month - 1, 1);
|
|
52
|
+
return date.toLocaleString(locale, {
|
|
53
|
+
month: 'long'
|
|
54
|
+
});
|
|
55
|
+
};
|
|
53
56
|
exports.formatMonth = formatMonth;
|
|
54
57
|
const findNextDate = (date, dateArray) => {
|
|
55
58
|
const futureDates = dateArray.filter(d => d > date);
|