@panneau/list-calendar 3.0.307 → 4.0.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.
Files changed (2) hide show
  1. package/es/index.js +27 -55
  2. package/package.json +9 -9
package/es/index.js CHANGED
@@ -3,61 +3,35 @@ 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 PropTypes from 'prop-types';
7
6
  import React, { useState, useMemo, useCallback, useEffect } from 'react';
8
7
  import { useIntl, FormattedDate } from 'react-intl';
9
- import { PropTypes as PropTypes$1 } from '@panneau/core';
10
8
  import Button from '@panneau/element-button';
11
9
  import Icon from '@panneau/element-icon';
12
10
 
13
11
  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"};
14
12
 
15
- var propTypes = {
16
- mode: PropTypes.string,
17
- resource: PropTypes$1.resource.isRequired,
18
- component: PropTypes.func,
19
- items: PropTypes$1.items,
20
- itemDateField: PropTypes.string,
21
- loading: PropTypes.bool,
22
- // onQueryChange: PropTypes.func,
23
- filter: PropTypes.shape({
24
- dates: PropTypes.arrayOf(PropTypes.string)
25
- }),
26
- // eslint-disable-next-line react/forbid-prop-types
27
- value: PropTypes.any,
28
- multiple: PropTypes.bool,
29
- onDateChange: PropTypes.func,
30
- onPeriodChange: PropTypes.func,
31
- initialDate: PropTypes.string,
32
- className: PropTypes.string
33
- };
34
- var defaultProps = {
35
- mode: 'monthly',
36
- component: null,
37
- items: [],
38
- itemDateField: 'date',
39
- filter: null,
40
- value: null,
41
- multiple: false,
42
- onDateChange: null,
43
- onPeriodChange: null,
44
- initialDate: null,
45
- loading: false,
46
- className: null
47
- };
48
- var CalendarList = function CalendarList(_ref) {
49
- var mode = _ref.mode;
13
+ var DEFAULT_ITEMS = [];
14
+ function CalendarList(_ref) {
15
+ var _ref$mode = _ref.mode,
16
+ mode = _ref$mode === void 0 ? 'monthly' : _ref$mode;
50
17
  _ref.resource;
51
18
  _ref.component;
52
- var items = _ref.items,
53
- itemDateField = _ref.itemDateField;
19
+ var _ref$items = _ref.items,
20
+ items = _ref$items === void 0 ? DEFAULT_ITEMS : _ref$items,
21
+ _ref$itemDateField = _ref.itemDateField,
22
+ itemDateField = _ref$itemDateField === void 0 ? 'date' : _ref$itemDateField;
54
23
  _ref.loading;
55
- var value = _ref.value,
56
- multiple = _ref.multiple,
57
- onDateChange = _ref.onDateChange,
58
- onPeriodChange = _ref.onPeriodChange,
59
- initialDate = _ref.initialDate,
60
- className = _ref.className;
24
+ _ref.value;
25
+ var _ref$multiple = _ref.multiple,
26
+ multiple = _ref$multiple === void 0 ? false : _ref$multiple,
27
+ _ref$onDateChange = _ref.onDateChange,
28
+ onDateChange = _ref$onDateChange === void 0 ? null : _ref$onDateChange,
29
+ _ref$onPeriodChange = _ref.onPeriodChange,
30
+ onPeriodChange = _ref$onPeriodChange === void 0 ? null : _ref$onPeriodChange,
31
+ _ref$initialDate = _ref.initialDate,
32
+ initialDate = _ref$initialDate === void 0 ? null : _ref$initialDate,
33
+ _ref$className = _ref.className,
34
+ className = _ref$className === void 0 ? null : _ref$className;
61
35
  var intl = useIntl();
62
36
  var _useState = useState(0),
63
37
  _useState2 = _slicedToArray(_useState, 2),
@@ -128,7 +102,7 @@ var CalendarList = function CalendarList(_ref) {
128
102
  "value": "S"
129
103
  }]
130
104
  })];
131
- }, []);
105
+ }, [intl]);
132
106
  var datesArray = [];
133
107
  if (mode === 'weekly') {
134
108
  // eslint-disable-next-line no-plusplus
@@ -167,19 +141,19 @@ var CalendarList = function CalendarList(_ref) {
167
141
  var onSelectDate = useCallback(function (e, newDate) {
168
142
  e.preventDefault();
169
143
  if (!multiple) {
170
- onDateChange(newDate ? null : newDate);
144
+ onDateChange === null || onDateChange === void 0 || onDateChange(newDate ? null : newDate);
171
145
  return;
172
146
  }
173
147
  var valuesUpdate = _toConsumableArray(dates);
174
148
  if (!valuesUpdate.includes(newDate)) {
175
- onDateChange([newDate]);
149
+ onDateChange === null || onDateChange === void 0 || onDateChange([newDate]);
176
150
  } else {
177
151
  var filteredOptions = valuesUpdate.filter(function (oldDate) {
178
152
  return oldDate !== newDate;
179
153
  });
180
- onDateChange(filteredOptions);
154
+ onDateChange === null || onDateChange === void 0 || onDateChange(filteredOptions);
181
155
  }
182
- }, [dates, onDateChange, multiple, value]);
156
+ }, [dates, onDateChange, multiple]);
183
157
  var weekHasDates = dates.reduce(function (acc, dte) {
184
158
  var parseDte = dte !== null ? parseISO(dte) : null;
185
159
  if (parseDte !== null && compareAsc(parseDte, activeWeekStart) >= 0 && compareDesc(parseDte, activeWeekEnd) >= 0) {
@@ -195,7 +169,7 @@ var CalendarList = function CalendarList(_ref) {
195
169
  year = _ref3$ === void 0 ? null : _ref3$,
196
170
  _ref3$2 = _ref3[1],
197
171
  month = _ref3$2 === void 0 ? null : _ref3$2;
198
- if (parseInt(year, 10) === parseInt(activeYear, 10) && parseInt(month, 10) === parseInt(activeMonth, 10) + 1 // yes this is incredibly stupid
172
+ if (parseInt(year, 10) === parseInt(String(activeYear), 10) && parseInt(month, 10) === parseInt(String(activeMonth), 10) + 1 // yes this is incredibly stupid
199
173
  ) {
200
174
  return true;
201
175
  }
@@ -249,7 +223,7 @@ var CalendarList = function CalendarList(_ref) {
249
223
  className: styles.calendarGrid
250
224
  }, days.map(function (d, i) {
251
225
  return /*#__PURE__*/React.createElement("div", {
252
- key: "day-".concat(d.getTime, "-").concat(i + 1),
226
+ key: "day-".concat(i + 1),
253
227
  className: classNames([styles.calendarBox, styles.headerBox])
254
228
  }, d);
255
229
  }), datesArray.map(function (d, i) {
@@ -274,8 +248,6 @@ var CalendarList = function CalendarList(_ref) {
274
248
  className: styles.calendarBox
275
249
  }, d.getUTCMonth() !== activeMonth && mode === 'monthly' ? '' : inner);
276
250
  }))));
277
- };
278
- CalendarList.propTypes = propTypes;
279
- CalendarList.defaultProps = defaultProps;
251
+ }
280
252
 
281
253
  export { CalendarList as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/list-calendar",
3
- "version": "3.0.307",
3
+ "version": "4.0.0",
4
4
  "description": "Calendar list",
5
5
  "keywords": [
6
6
  "javascript"
@@ -51,21 +51,21 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@babel/runtime": "^7.12.5",
54
- "@panneau/core": "^3.0.307",
55
- "@panneau/element-button": "^3.0.307",
56
- "@panneau/element-card": "^3.0.307",
57
- "@panneau/element-icon": "^3.0.307",
58
- "@panneau/element-loading": "^3.0.307",
59
- "@panneau/themes": "^3.0.307",
54
+ "@panneau/core": "^4.0.0",
55
+ "@panneau/element-button": "^4.0.0",
56
+ "@panneau/element-card": "^4.0.0",
57
+ "@panneau/element-icon": "^4.0.0",
58
+ "@panneau/element-loading": "^4.0.0",
59
+ "@panneau/themes": "^4.0.0",
60
60
  "classnames": "^2.5.1",
61
61
  "date-fns": "^3.3.1",
62
62
  "lodash-es": "^4.17.21",
63
63
  "prop-types": "^15.7.2",
64
64
  "query-string": "^9.0.0",
65
- "react-intl": "^5.15.8||^6.0.0"
65
+ "react-intl": "^5.15.8 || ^6.0.0 || ^7.0.0"
66
66
  },
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },
70
- "gitHead": "cbe5e8b1705d01c5653a4df617a06243344310d3"
70
+ "gitHead": "2cca874e0388b4a20c39aadb205c0e67d5a946fc"
71
71
  }