@panneau/list-calendar 4.0.1 → 4.0.4

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 (2) hide show
  1. package/es/index.js +87 -76
  2. package/package.json +8 -8
package/es/index.js CHANGED
@@ -3,10 +3,11 @@ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
3
3
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
4
  import classNames from 'classnames';
5
5
  import { parseISO, toDate, startOfWeek, addWeeks, addMonths, endOfWeek, addDays, compareAsc, compareDesc, format } from 'date-fns';
6
- import React, { useState, useMemo, useCallback, useEffect } from 'react';
6
+ import { useState, useMemo, useCallback, useEffect } from 'react';
7
7
  import { useIntl, FormattedDate } from 'react-intl';
8
8
  import Button from '@panneau/element-button';
9
9
  import Icon from '@panneau/element-icon';
10
+ import { jsx, jsxs } from 'react/jsx-runtime';
10
11
 
11
12
  var styles = {"container":"panneau-list-calendar-container","inner":"panneau-list-calendar-inner","calendarHeader":"panneau-list-calendar-calendarHeader","activePeriod":"panneau-list-calendar-activePeriod","activePeriodWithDates":"panneau-list-calendar-activePeriodWithDates","arrow":"panneau-list-calendar-arrow","calendarGrid":"panneau-list-calendar-calendarGrid","calendarBox":"panneau-list-calendar-calendarBox","headerBox":"panneau-list-calendar-headerBox","day":"panneau-list-calendar-day","isToday":"panneau-list-calendar-isToday","isPast":"panneau-list-calendar-isPast","dayButton":"panneau-list-calendar-dayButton","active":"panneau-list-calendar-active"};
12
13
 
@@ -105,7 +106,6 @@ function CalendarList(_ref) {
105
106
  }, [intl]);
106
107
  var datesArray = [];
107
108
  if (mode === 'weekly') {
108
- // eslint-disable-next-line no-plusplus
109
109
  for (var i = 0; i < 7; i++) {
110
110
  var dte = addDays(activeWeekStart, i);
111
111
  datesArray.push(dte);
@@ -114,7 +114,6 @@ function CalendarList(_ref) {
114
114
  var firstDayOfActualMonth = new Date(activeYear, activeMonth, 1).getDay();
115
115
  var dayBeforeDiff = firstDayOfActualMonth === 0 ? 6 : firstDayOfActualMonth;
116
116
  var gridMax = 35;
117
- // eslint-disable-next-line no-plusplus
118
117
  for (var _i = 1 - dayBeforeDiff; _i <= gridMax; _i++) {
119
118
  datesArray.push(new Date(activeYear, activeMonth, _i));
120
119
  }
@@ -175,79 +174,91 @@ function CalendarList(_ref) {
175
174
  }
176
175
  return acc;
177
176
  }, false);
178
- return /*#__PURE__*/React.createElement("div", {
179
- className: classNames([styles.container, _defineProperty({}, className, className !== null)])
180
- }, /*#__PURE__*/React.createElement("div", {
181
- className: styles.inner
182
- }, /*#__PURE__*/React.createElement("div", {
183
- className: styles.calendarHeader
184
- }, /*#__PURE__*/React.createElement(Button, {
185
- className: styles.arrow,
186
- onClick: function onClick(e) {
187
- return onClickPeriodChange(e, true);
188
- }
189
- }, /*#__PURE__*/React.createElement(Icon, {
190
- name: "arrow-left"
191
- })), mode === 'weekly' ? /*#__PURE__*/React.createElement("div", {
192
- className: styles.activePeriod
193
- }, weekHasDates ? /*#__PURE__*/React.createElement("span", {
194
- className: styles.activePeriodWithDates
195
- }, /*#__PURE__*/React.createElement(FormattedDate, {
196
- value: activeDate,
197
- day: "numeric",
198
- month: "long",
199
- year: "numeric"
200
- })) : /*#__PURE__*/React.createElement(FormattedDate, {
201
- value: activeDate,
202
- day: "numeric",
203
- month: "long",
204
- year: "numeric"
205
- })) : /*#__PURE__*/React.createElement("div", {
206
- className: styles.activePeriod
207
- }, monthHasDates ? /*#__PURE__*/React.createElement("span", {
208
- className: styles.activePeriodWithDates
209
- }, /*#__PURE__*/React.createElement(FormattedDate, {
210
- value: activeDate,
211
- month: "long",
212
- year: "numeric"
213
- })) : /*#__PURE__*/React.createElement(FormattedDate, {
214
- value: activeDate,
215
- month: "long",
216
- year: "numeric"
217
- })), /*#__PURE__*/React.createElement(Button, {
218
- className: classNames([styles.arrow, styles.right]),
219
- onClick: onClickPeriodChange
220
- }, /*#__PURE__*/React.createElement(Icon, {
221
- name: "arrow-right"
222
- }))), /*#__PURE__*/React.createElement("div", {
223
- className: styles.calendarGrid
224
- }, days.map(function (d, i) {
225
- return /*#__PURE__*/React.createElement("div", {
226
- key: "day-".concat(i + 1),
227
- className: classNames([styles.calendarBox, styles.headerBox])
228
- }, d);
229
- }), datesArray.map(function (d, i) {
230
- var dTime = format(d, 'yyyy-MM-dd');
231
- var isCurrentYear = d.getUTCFullYear() === currentYear;
232
- var isCurrentMonth = d.getUTCMonth() === currentMonth;
233
- var isToday = isCurrentYear && isCurrentMonth && d.getDate() === currentDayOfTheMonth;
234
- var eventTime = d.getTime();
235
- var todayTime = currentDate.getTime();
236
- var isPast = eventTime < todayTime && !isToday;
237
- var hasItem = dates.includes(dTime);
238
- var inner = hasItem ? /*#__PURE__*/React.createElement(Button, {
239
- onClick: function onClick(e) {
240
- return onSelectDate(e, dTime);
241
- },
242
- className: classNames(styles.day, styles.dayButton, _defineProperty(_defineProperty(_defineProperty({}, styles.isToday, isToday), styles.isPast, isPast), styles.active, dates.includes(dTime)))
243
- }, format(d, 'd')) : /*#__PURE__*/React.createElement("div", {
244
- className: classNames(styles.day, _defineProperty({}, styles.isToday, isToday))
245
- }, format(d, 'd'));
246
- return /*#__PURE__*/React.createElement("div", {
247
- key: "date-".concat(d.getTime, "-").concat(i + 1),
248
- className: styles.calendarBox
249
- }, d.getUTCMonth() !== activeMonth && mode === 'monthly' ? '' : inner);
250
- }))));
177
+ return /*#__PURE__*/jsx("div", {
178
+ className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
179
+ children: /*#__PURE__*/jsxs("div", {
180
+ className: styles.inner,
181
+ children: [/*#__PURE__*/jsxs("div", {
182
+ className: styles.calendarHeader,
183
+ children: [/*#__PURE__*/jsx(Button, {
184
+ className: styles.arrow,
185
+ onClick: function onClick(e) {
186
+ return onClickPeriodChange(e, true);
187
+ },
188
+ children: /*#__PURE__*/jsx(Icon, {
189
+ name: "arrow-left"
190
+ })
191
+ }), mode === 'weekly' ? /*#__PURE__*/jsx("div", {
192
+ className: styles.activePeriod,
193
+ children: weekHasDates ? /*#__PURE__*/jsx("span", {
194
+ className: styles.activePeriodWithDates,
195
+ children: /*#__PURE__*/jsx(FormattedDate, {
196
+ value: activeDate,
197
+ day: "numeric",
198
+ month: "long",
199
+ year: "numeric"
200
+ })
201
+ }) : /*#__PURE__*/jsx(FormattedDate, {
202
+ value: activeDate,
203
+ day: "numeric",
204
+ month: "long",
205
+ year: "numeric"
206
+ })
207
+ }) : /*#__PURE__*/jsx("div", {
208
+ className: styles.activePeriod,
209
+ children: monthHasDates ? /*#__PURE__*/jsx("span", {
210
+ className: styles.activePeriodWithDates,
211
+ children: /*#__PURE__*/jsx(FormattedDate, {
212
+ value: activeDate,
213
+ month: "long",
214
+ year: "numeric"
215
+ })
216
+ }) : /*#__PURE__*/jsx(FormattedDate, {
217
+ value: activeDate,
218
+ month: "long",
219
+ year: "numeric"
220
+ })
221
+ }), /*#__PURE__*/jsx(Button, {
222
+ className: classNames([styles.arrow, styles.right]),
223
+ onClick: onClickPeriodChange,
224
+ children: /*#__PURE__*/jsx(Icon, {
225
+ name: "arrow-right"
226
+ })
227
+ })]
228
+ }), /*#__PURE__*/jsxs("div", {
229
+ className: styles.calendarGrid,
230
+ children: [days.map(function (d, i) {
231
+ return /*#__PURE__*/jsx("div", {
232
+ className: classNames([styles.calendarBox, styles.headerBox]),
233
+ children: d
234
+ }, "day-".concat(i + 1));
235
+ }), datesArray.map(function (d, i) {
236
+ var dTime = format(d, 'yyyy-MM-dd');
237
+ var isCurrentYear = d.getUTCFullYear() === currentYear;
238
+ var isCurrentMonth = d.getUTCMonth() === currentMonth;
239
+ var isToday = isCurrentYear && isCurrentMonth && d.getDate() === currentDayOfTheMonth;
240
+ var eventTime = d.getTime();
241
+ var todayTime = currentDate.getTime();
242
+ var isPast = eventTime < todayTime && !isToday;
243
+ var hasItem = dates.includes(dTime);
244
+ var inner = hasItem ? /*#__PURE__*/jsx(Button, {
245
+ onClick: function onClick(e) {
246
+ return onSelectDate(e, dTime);
247
+ },
248
+ className: classNames(styles.day, styles.dayButton, _defineProperty(_defineProperty(_defineProperty({}, styles.isToday, isToday), styles.isPast, isPast), styles.active, dates.includes(dTime))),
249
+ children: format(d, 'd')
250
+ }) : /*#__PURE__*/jsx("div", {
251
+ className: classNames(styles.day, _defineProperty({}, styles.isToday, isToday)),
252
+ children: format(d, 'd')
253
+ });
254
+ return /*#__PURE__*/jsx("div", {
255
+ className: styles.calendarBox,
256
+ children: d.getUTCMonth() !== activeMonth && mode === 'monthly' ? '' : inner
257
+ }, "date-".concat(d.getTime, "-").concat(i + 1));
258
+ })]
259
+ })]
260
+ })
261
+ });
251
262
  }
252
263
 
253
264
  export { CalendarList as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/list-calendar",
3
- "version": "4.0.1",
3
+ "version": "4.0.4",
4
4
  "description": "Calendar list",
5
5
  "keywords": [
6
6
  "javascript"
@@ -51,12 +51,12 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@babel/runtime": "^7.12.5",
54
- "@panneau/core": "^4.0.1",
55
- "@panneau/element-button": "^4.0.1",
56
- "@panneau/element-card": "^4.0.1",
57
- "@panneau/element-icon": "^4.0.1",
58
- "@panneau/element-loading": "^4.0.1",
59
- "@panneau/themes": "^4.0.1",
54
+ "@panneau/core": "^4.0.4",
55
+ "@panneau/element-button": "^4.0.4",
56
+ "@panneau/element-card": "^4.0.4",
57
+ "@panneau/element-icon": "^4.0.4",
58
+ "@panneau/element-loading": "^4.0.4",
59
+ "@panneau/themes": "^4.0.4",
60
60
  "classnames": "^2.5.1",
61
61
  "date-fns": "^3.3.1",
62
62
  "lodash-es": "^4.17.21",
@@ -67,5 +67,5 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },
70
- "gitHead": "dbdf65640625c027ecd56cf2b816b80a5c38cb8d"
70
+ "gitHead": "e854451a718c6bc7dcde2b804c9913d8ac0297ff"
71
71
  }