@drivy/cobalt 0.37.2 → 0.37.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Calendar/CalendarView/CalendarViewMonth.js +5 -3
- package/components/Calendar/CalendarView/CalendarViewMonth.js.map +1 -1
- package/components/Calendar/CalendarView/index.js +1 -1
- package/components/Calendar/CalendarView/index.js.map +1 -1
- package/package.json +15 -15
- package/types/components/Calendar/CalendarView/CalendarViewMonth.d.ts +1 -1
- package/types/components/Calendar/CalendarView/index.d.ts +2 -1
- package/types/components/Calendar/CalendarView/types.d.ts +1 -0
|
@@ -2,13 +2,15 @@ import React, { useMemo } from 'react';
|
|
|
2
2
|
import { getDaysInMonth, differenceInCalendarWeeks, endOfMonth, getISODay, setDate, isPast, isToday, format } from 'date-fns';
|
|
3
3
|
import cx from 'classnames';
|
|
4
4
|
|
|
5
|
-
const CalendarViewMonth = ({ monthName, monthStart, statusByDate = {}, }) => {
|
|
5
|
+
const CalendarViewMonth = ({ monthName, monthStart, statusByDate = {}, isSundayFirstDayOfWeek = false, }) => {
|
|
6
6
|
const getMonthByWeek = () => {
|
|
7
7
|
const daysInMonth = getDaysInMonth(monthStart);
|
|
8
8
|
const weeksInMonth = differenceInCalendarWeeks(endOfMonth(monthStart), monthStart, {
|
|
9
|
-
weekStartsOn: 1,
|
|
9
|
+
weekStartsOn: isSundayFirstDayOfWeek ? 0 : 1,
|
|
10
10
|
}) + 1;
|
|
11
|
-
const weekDay =
|
|
11
|
+
const weekDay = isSundayFirstDayOfWeek
|
|
12
|
+
? (getISODay(monthStart) % 7) + 1
|
|
13
|
+
: getISODay(monthStart);
|
|
12
14
|
const month = [];
|
|
13
15
|
let cursor = 0;
|
|
14
16
|
let date = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalendarViewMonth.js","sources":["../../../../src/components/Calendar/CalendarView/CalendarViewMonth.tsx"],"sourcesContent":["import React, { useMemo } from \"react\"\nimport {\n setDate,\n getISODay,\n getDaysInMonth,\n endOfMonth,\n differenceInCalendarWeeks,\n isPast,\n isToday,\n format,\n} from \"date-fns\"\nimport cx from \"classnames\"\nimport {\n CalendarViewMonthType,\n MonthType,\n CalendarViewDateType,\n DateType,\n} from \"./types\"\n\ntype Props = MonthType\n\nconst CalendarViewMonth = ({\n monthName,\n monthStart,\n statusByDate = {},\n}: Props) => {\n const getMonthByWeek = (): CalendarViewMonthType => {\n const daysInMonth = getDaysInMonth(monthStart)\n const weeksInMonth =\n differenceInCalendarWeeks(endOfMonth(monthStart), monthStart, {\n weekStartsOn: 1,\n }) + 1\n const weekDay = getISODay(monthStart)\n const month: CalendarViewDateType[][] = []\n let cursor = 0\n let date = 0\n\n for (let week = 0; week < weeksInMonth; week++) {\n month[week] = []\n for (let day = 0; day < 7; day++) {\n month[week][day] = { date: null }\n\n if (cursor >= weekDay - 1 && date < daysInMonth) {\n month[week][day].date = ++date as DateType\n\n const currentDate = setDate(monthStart, date)\n\n month[week][day].status =\n isPast(currentDate) && !isToday(currentDate)\n ? \"past\"\n : statusByDate[format(currentDate, \"yyyy-MM-dd\")]\n }\n cursor++\n }\n }\n return month\n }\n\n const monthByWeek = useMemo(() => getMonthByWeek(), [])\n\n return (\n <div className=\"cobalt-CalendarView__month\">\n <div className=\"cobalt-CalendarView__monthName\">{monthName}</div>\n {monthByWeek.map((week, weekIndex) => (\n <div key={weekIndex} className=\"cobalt-CalendarView__week\">\n {week.map((day, dayIndex) => (\n <div\n key={weekIndex + 1 * dayIndex + 1}\n className={cx(\"cobalt-CalendarView__day\", {\n [`cobalt-CalendarView__day--${day.status}`]: day.status,\n })}\n >\n {day.date}\n </div>\n ))}\n </div>\n ))}\n </div>\n )\n}\n\nCalendarViewMonth.displayName = \"CalendarViewMonth\"\n\nexport default CalendarViewMonth\n"],"names":[],"mappings":";;;;AAqBA,MAAM,iBAAiB,GAAG,CAAC,EACzB,SAAS,EACT,UAAU,EACV,YAAY,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"CalendarViewMonth.js","sources":["../../../../src/components/Calendar/CalendarView/CalendarViewMonth.tsx"],"sourcesContent":["import React, { useMemo } from \"react\"\nimport {\n setDate,\n getISODay,\n getDaysInMonth,\n endOfMonth,\n differenceInCalendarWeeks,\n isPast,\n isToday,\n format,\n} from \"date-fns\"\nimport cx from \"classnames\"\nimport {\n CalendarViewMonthType,\n MonthType,\n CalendarViewDateType,\n DateType,\n} from \"./types\"\n\ntype Props = MonthType\n\nconst CalendarViewMonth = ({\n monthName,\n monthStart,\n statusByDate = {},\n isSundayFirstDayOfWeek = false,\n}: Props) => {\n const getMonthByWeek = (): CalendarViewMonthType => {\n const daysInMonth = getDaysInMonth(monthStart)\n const weeksInMonth =\n differenceInCalendarWeeks(endOfMonth(monthStart), monthStart, {\n weekStartsOn: isSundayFirstDayOfWeek ? 0 : 1,\n }) + 1\n const weekDay = isSundayFirstDayOfWeek\n ? (getISODay(monthStart) % 7) + 1\n : getISODay(monthStart)\n const month: CalendarViewDateType[][] = []\n let cursor = 0\n let date = 0\n\n for (let week = 0; week < weeksInMonth; week++) {\n month[week] = []\n for (let day = 0; day < 7; day++) {\n month[week][day] = { date: null }\n\n if (cursor >= weekDay - 1 && date < daysInMonth) {\n month[week][day].date = ++date as DateType\n\n const currentDate = setDate(monthStart, date)\n\n month[week][day].status =\n isPast(currentDate) && !isToday(currentDate)\n ? \"past\"\n : statusByDate[format(currentDate, \"yyyy-MM-dd\")]\n }\n cursor++\n }\n }\n return month\n }\n\n const monthByWeek = useMemo(() => getMonthByWeek(), [])\n\n return (\n <div className=\"cobalt-CalendarView__month\">\n <div className=\"cobalt-CalendarView__monthName\">{monthName}</div>\n {monthByWeek.map((week, weekIndex) => (\n <div key={weekIndex} className=\"cobalt-CalendarView__week\">\n {week.map((day, dayIndex) => (\n <div\n key={weekIndex + 1 * dayIndex + 1}\n className={cx(\"cobalt-CalendarView__day\", {\n [`cobalt-CalendarView__day--${day.status}`]: day.status,\n })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1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import CalendarViewMonth from './CalendarViewMonth.js';
|
|
3
3
|
|
|
4
|
-
const CalendarView = ({ months }) => (React.createElement("div", { className: "cobalt-CalendarView" }, months.map((month) => (React.createElement(CalendarViewMonth, { key: month.monthStart, ...month })))));
|
|
4
|
+
const CalendarView = ({ months, isSundayFirstDayOfWeek }) => (React.createElement("div", { className: "cobalt-CalendarView" }, months.map((month) => (React.createElement(CalendarViewMonth, { key: month.monthStart, isSundayFirstDayOfWeek: isSundayFirstDayOfWeek, ...month })))));
|
|
5
5
|
CalendarView.displayName = "CalendarView";
|
|
6
6
|
|
|
7
7
|
export { CalendarView };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/Calendar/CalendarView/index.tsx"],"sourcesContent":["import React from \"react\"\nimport Month from \"./CalendarViewMonth\"\nimport { MonthType } from \"./types\"\n\ntype Props = {\n months: MonthType[]\n}\n\nconst CalendarView = ({ months }: Props) => (\n <div className=\"cobalt-CalendarView\">\n {months.map((month) => (\n <Month
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/Calendar/CalendarView/index.tsx"],"sourcesContent":["import React from \"react\"\nimport Month from \"./CalendarViewMonth\"\nimport { MonthType } from \"./types\"\n\ntype Props = {\n months: MonthType[]\n isSundayFirstDayOfWeek?: boolean\n}\n\nconst CalendarView = ({ months, isSundayFirstDayOfWeek }: Props) => (\n <div className=\"cobalt-CalendarView\">\n {months.map((month) => (\n <Month\n key={month.monthStart}\n isSundayFirstDayOfWeek={isSundayFirstDayOfWeek}\n {...month}\n />\n ))}\n </div>\n)\n\nCalendarView.displayName = \"CalendarView\"\n\nexport { CalendarView }\n"],"names":["Month"],"mappings":";;;AASM,MAAA,YAAY,GAAG,CAAC,EAAE,MAAM,EAAE,sBAAsB,EAAS,MAC7D,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,qBAAqB,IACjC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,MAChB,KAAC,CAAA,aAAA,CAAAA,iBAAK,IACJ,GAAG,EAAE,KAAK,CAAC,UAAU,EACrB,sBAAsB,EAAE,sBAAsB,EAC1C,GAAA,KAAK,GACT,CACH,CAAC,CACE,EACP;AAED,YAAY,CAAC,WAAW,GAAG,cAAc;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drivy/cobalt",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.3",
|
|
4
4
|
"description": "Opinionated design system for Drivy's projects.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"@getaround-eu/stylelint-config": "3.0.0",
|
|
51
51
|
"@getaround-eu/ts-config": "2.2.0",
|
|
52
52
|
"@percy/storybook": "4.3.6",
|
|
53
|
-
"@rollup/plugin-json": "6.0.
|
|
54
|
-
"@rushstack/eslint-patch": "1.
|
|
55
|
-
"@storybook/addon-essentials": "7.4.
|
|
56
|
-
"@storybook/addons": "7.4.
|
|
57
|
-
"@storybook/blocks": "7.4.
|
|
58
|
-
"@storybook/react": "7.4.
|
|
59
|
-
"@storybook/react-webpack5": "7.4.
|
|
53
|
+
"@rollup/plugin-json": "6.0.1",
|
|
54
|
+
"@rushstack/eslint-patch": "1.5.1",
|
|
55
|
+
"@storybook/addon-essentials": "7.4.6",
|
|
56
|
+
"@storybook/addons": "7.4.6",
|
|
57
|
+
"@storybook/blocks": "7.4.6",
|
|
58
|
+
"@storybook/react": "7.4.6",
|
|
59
|
+
"@storybook/react-webpack5": "7.4.6",
|
|
60
60
|
"@svgr/cli": "7.0.0",
|
|
61
61
|
"@testing-library/jest-dom": "5.17.0",
|
|
62
62
|
"@testing-library/react": "14.0.0",
|
|
@@ -66,12 +66,12 @@
|
|
|
66
66
|
"@types/lodash.throttle": "4.1.7",
|
|
67
67
|
"@types/media-typer": "1.1.1",
|
|
68
68
|
"@types/prettier": "3.0.0",
|
|
69
|
-
"@types/react-dom": "18.2.
|
|
69
|
+
"@types/react-dom": "18.2.11",
|
|
70
70
|
"autoprefixer": "10.4.16",
|
|
71
|
-
"core-js": "3.
|
|
71
|
+
"core-js": "3.33.0",
|
|
72
72
|
"css-loader": "6.8.1",
|
|
73
|
-
"eslint": "8.
|
|
74
|
-
"eslint-plugin-storybook": "^0.6.
|
|
73
|
+
"eslint": "8.51.0",
|
|
74
|
+
"eslint-plugin-storybook": "^0.6.15",
|
|
75
75
|
"file-loader": "6.2.0",
|
|
76
76
|
"jest": "29.7.0",
|
|
77
77
|
"jest-environment-jsdom": "29.7.0",
|
|
@@ -91,12 +91,12 @@
|
|
|
91
91
|
"rollup-plugin-copy": "3.5.0",
|
|
92
92
|
"rollup-plugin-postcss": "4.0.2",
|
|
93
93
|
"rollup-plugin-svgo": "2.0.0",
|
|
94
|
-
"rollup-plugin-typescript2": "0.
|
|
95
|
-
"sass": "1.
|
|
94
|
+
"rollup-plugin-typescript2": "0.36.0",
|
|
95
|
+
"sass": "1.69.0",
|
|
96
96
|
"sass-loader": "13.3.2",
|
|
97
97
|
"sharp": "0.32.6",
|
|
98
98
|
"sharp-cli": "4.1.1",
|
|
99
|
-
"storybook": "7.4.
|
|
99
|
+
"storybook": "7.4.6",
|
|
100
100
|
"style-loader": "3.3.3",
|
|
101
101
|
"stylelint": "15.10.3",
|
|
102
102
|
"svg2vectordrawable": "2.9.1",
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { MonthType } from "./types";
|
|
3
3
|
type Props = MonthType;
|
|
4
4
|
declare const CalendarViewMonth: {
|
|
5
|
-
({ monthName, monthStart, statusByDate, }: Props): React.JSX.Element;
|
|
5
|
+
({ monthName, monthStart, statusByDate, isSundayFirstDayOfWeek, }: Props): React.JSX.Element;
|
|
6
6
|
displayName: string;
|
|
7
7
|
};
|
|
8
8
|
export default CalendarViewMonth;
|
|
@@ -2,9 +2,10 @@ import React from "react";
|
|
|
2
2
|
import { MonthType } from "./types";
|
|
3
3
|
type Props = {
|
|
4
4
|
months: MonthType[];
|
|
5
|
+
isSundayFirstDayOfWeek?: boolean;
|
|
5
6
|
};
|
|
6
7
|
declare const CalendarView: {
|
|
7
|
-
({ months }: Props): React.JSX.Element;
|
|
8
|
+
({ months, isSundayFirstDayOfWeek }: Props): React.JSX.Element;
|
|
8
9
|
displayName: string;
|
|
9
10
|
};
|
|
10
11
|
export { CalendarView };
|
|
@@ -6,6 +6,7 @@ export type MonthType = {
|
|
|
6
6
|
monthName: string;
|
|
7
7
|
monthStart: number;
|
|
8
8
|
statusByDate?: StatusByDateType;
|
|
9
|
+
isSundayFirstDayOfWeek?: boolean;
|
|
9
10
|
};
|
|
10
11
|
export type DateType = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31;
|
|
11
12
|
export type CalendarViewDateType = {
|