@plusscommunities/pluss-core-web 1.6.4-beta.0 → 1.6.5-beta.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/dist/index.cjs.js CHANGED
@@ -3561,7 +3561,7 @@ var pluss_new = {
3561
3561
  var form = {
3562
3562
  viewBox: "0 0 256 256",
3563
3563
  paths: [
3564
- "M164,152a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,152Zm-4-36H96a4,4,0,0,0,0,8h64a4,4,0,0,0,0-8Zm52-68V216a12,12,0,0,1-12,12H56a12,12,0,0,1-12-12V48A12,12,0,0,1,56,36H94.08a44,44,0,0,1,67.84,0H200A12,12,0,0,1,212,48ZM92,64v4h72V64a36,36,0,0,0-72,0ZM204,48a4,4,0,0,0-4-4H167.17A43.71,43.71,0,0,1,172,64v8a4,4,0,0,1-4,4H88a4,4,0,0,1-4-4V64a43.71,43.71,0,0,1,4.83-20H56a4,4,0,0,0-4,4V216a4,4,0,0,0,4,4H200a4,4,0,0,0,4-4Z"
3564
+ "M200,32H163.74a47.92,47.92,0,0,0-71.48,0H56A16,16,0,0,0,40,48V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V48A16,16,0,0,0,200,32Zm-72,0a32,32,0,0,1,32,32H96A32,32,0,0,1,128,32Zm32,128H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Zm0-32H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Z"
3565
3565
  ]
3566
3566
  };
3567
3567
  var icons = {
@@ -4455,7 +4455,13 @@ var DatePicker = /*#__PURE__*/function (_Component) {
4455
4455
  }, {
4456
4456
  key: "onNewProps",
4457
4457
  value: function onNewProps(nextProps, forceUpdate) {
4458
- if (this.props.multiple && nextProps.selectedDates !== this.props.selectedDates) {
4458
+ if (!!nextProps.shownMonth && nextProps.shownMonth !== this.props.shownMonth) {
4459
+ var shownMonth = new Date(nextProps.shownMonth.getFullYear(), nextProps.shownMonth.getMonth() + 1, 0);
4460
+ this.setState({
4461
+ shownMonth: shownMonth
4462
+ });
4463
+ this.generateGrid(shownMonth);
4464
+ } else if (this.props.multiple && nextProps.selectedDates !== this.props.selectedDates) {
4459
4465
  this.generateGrid(this.state.shownMonth, nextProps.selectedDates);
4460
4466
  } else if (forceUpdate || nextProps.selectedDate !== this.props.selectedDate) {
4461
4467
  var dateToUse = nextProps.selectedDate;
@@ -4468,11 +4474,13 @@ var DatePicker = /*#__PURE__*/function (_Component) {
4468
4474
  dateToUse = new Date();
4469
4475
  }
4470
4476
 
4477
+ var _shownMonth = this.props.shownMonth ? this.state.shownMonth : dateToUse;
4478
+
4471
4479
  this.setState({
4472
- shownMonth: dateToUse,
4480
+ shownMonth: _shownMonth,
4473
4481
  selectedDate: dateToUse
4474
4482
  });
4475
- this.generateGrid(dateToUse, dateToUse);
4483
+ this.generateGrid(_shownMonth, dateToUse);
4476
4484
  }
4477
4485
  }
4478
4486
  }, {
@@ -4507,19 +4515,35 @@ var DatePicker = /*#__PURE__*/function (_Component) {
4507
4515
 
4508
4516
  return date.isSame(selectedDate, 'date');
4509
4517
  }
4518
+ }, {
4519
+ key: "isDateEnabled",
4520
+ value: function isDateEnabled(date) {
4521
+ if (this.props.enabledDates) {
4522
+ var found = this.props.enabledDates.find(function (d) {
4523
+ return moment__default['default'](d.day).format('YYYYMMDD') === date.format('YYYYMMDD');
4524
+ });
4525
+ if (found) return found.enabled;
4526
+ }
4527
+
4528
+ return null;
4529
+ }
4510
4530
  }, {
4511
4531
  key: "changeMonth",
4512
4532
  value: function changeMonth(change) {
4533
+ var _this2 = this;
4534
+
4513
4535
  var newShownDate = new Date(this.state.shownMonth.getFullYear(), this.state.shownMonth.getMonth() + 1 + change, 0);
4514
4536
  this.setState({
4515
4537
  shownMonth: newShownDate
4538
+ }, function () {
4539
+ if (_this2.props.changeMonth) _this2.props.changeMonth(_this2.state.shownMonth);
4516
4540
  });
4517
4541
  this.generateGrid(newShownDate);
4518
4542
  }
4519
4543
  }, {
4520
4544
  key: "selectRange",
4521
4545
  value: function selectRange(date) {
4522
- var _this2 = this;
4546
+ var _this3 = this;
4523
4547
 
4524
4548
  var d1 = moment__default['default'](this.state.lastSelected, 'DD-MM-YYYY');
4525
4549
  var d2 = moment__default['default'](date, 'DD-MM-YYYY');
@@ -4543,7 +4567,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
4543
4567
  }
4544
4568
 
4545
4569
  if (___default['default'].includes(this.props.selectedDates, d2.format('DD-MM-YYYY')) && !___default['default'].includes(this.props.selectedDates, d1.format('DD-MM-YYYY')) || !___default['default'].some(dateRange, function (d) {
4546
- return !___default['default'].includes(_this2.props.selectedDates, d);
4570
+ return !___default['default'].includes(_this3.props.selectedDates, d);
4547
4571
  })) {
4548
4572
  // the first clicked date was just de-selected and then clicked on a selected date
4549
4573
  // or every date in the range is already selected, then
@@ -4560,7 +4584,14 @@ var DatePicker = /*#__PURE__*/function (_Component) {
4560
4584
  }, {
4561
4585
  key: "selectDate",
4562
4586
  value: function selectDate(date, e) {
4563
- console.log('selected a date');
4587
+ var enabled = this.isDateEnabled(date);
4588
+ var isBeforeMinDate = this.props.minDate && moment__default['default'](date).isBefore(this.props.minDate);
4589
+ console.log('selected a date', {
4590
+ date: date,
4591
+ enabled: enabled,
4592
+ isBeforeMinDate: isBeforeMinDate
4593
+ });
4594
+ if (enabled === false || isBeforeMinDate) return;
4564
4595
 
4565
4596
  if (this.props.multiple) {
4566
4597
  var dateKey = moment__default['default'](date).format('DD-MM-YYYY');
@@ -4623,10 +4654,12 @@ var DatePicker = /*#__PURE__*/function (_Component) {
4623
4654
  display: thisDate.date(),
4624
4655
  isFaded: !thisDate.isSame(month, 'month'),
4625
4656
  isToday: thisDate.isSame(moment__default['default'](), 'date'),
4626
- isSelected: this.isDateSelected(thisDate, selectedDateToUse)
4657
+ isSelected: this.isDateSelected(thisDate, selectedDateToUse),
4658
+ isEnabled: this.isDateEnabled(thisDate)
4627
4659
  });
4628
4660
  dateToModify = dateToModify.add(1, 'day');
4629
- }
4661
+ } // console.log('generateGrid', JSON.stringify(rows, null, 2));
4662
+
4630
4663
 
4631
4664
  this.setState({
4632
4665
  grid: rows
@@ -4635,7 +4668,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
4635
4668
  }, {
4636
4669
  key: "renderGrid",
4637
4670
  value: function renderGrid() {
4638
- var _this3 = this;
4671
+ var _this4 = this;
4639
4672
 
4640
4673
  return this.state.grid.map(function (row, index) {
4641
4674
  return /*#__PURE__*/React__default['default'].createElement("div", {
@@ -4656,13 +4689,17 @@ var DatePicker = /*#__PURE__*/function (_Component) {
4656
4689
  classes += ' datepicker__date--selected';
4657
4690
  }
4658
4691
 
4692
+ if (typeof date.isEnabled === 'boolean') {
4693
+ classes += date.isEnabled ? ' datepicker__date--enabled' : ' datepicker__date--disabled';
4694
+ }
4695
+
4659
4696
  return /*#__PURE__*/React__default['default'].createElement("div", {
4660
4697
  className: classes,
4661
4698
  key: date.dateKey
4662
4699
  }, /*#__PURE__*/React__default['default'].createElement("div", {
4663
4700
  className: "datepicker__date__inner",
4664
4701
  onClick: function onClick(e) {
4665
- _this3.selectDate(date.date, e);
4702
+ return _this4.selectDate(date.date, e);
4666
4703
  }
4667
4704
  }, date.display));
4668
4705
  }));
package/dist/index.esm.js CHANGED
@@ -3531,7 +3531,7 @@ var pluss_new = {
3531
3531
  var form = {
3532
3532
  viewBox: "0 0 256 256",
3533
3533
  paths: [
3534
- "M164,152a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,152Zm-4-36H96a4,4,0,0,0,0,8h64a4,4,0,0,0,0-8Zm52-68V216a12,12,0,0,1-12,12H56a12,12,0,0,1-12-12V48A12,12,0,0,1,56,36H94.08a44,44,0,0,1,67.84,0H200A12,12,0,0,1,212,48ZM92,64v4h72V64a36,36,0,0,0-72,0ZM204,48a4,4,0,0,0-4-4H167.17A43.71,43.71,0,0,1,172,64v8a4,4,0,0,1-4,4H88a4,4,0,0,1-4-4V64a43.71,43.71,0,0,1,4.83-20H56a4,4,0,0,0-4,4V216a4,4,0,0,0,4,4H200a4,4,0,0,0,4-4Z"
3534
+ "M200,32H163.74a47.92,47.92,0,0,0-71.48,0H56A16,16,0,0,0,40,48V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V48A16,16,0,0,0,200,32Zm-72,0a32,32,0,0,1,32,32H96A32,32,0,0,1,128,32Zm32,128H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Zm0-32H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Z"
3535
3535
  ]
3536
3536
  };
3537
3537
  var icons = {
@@ -4425,7 +4425,13 @@ var DatePicker = /*#__PURE__*/function (_Component) {
4425
4425
  }, {
4426
4426
  key: "onNewProps",
4427
4427
  value: function onNewProps(nextProps, forceUpdate) {
4428
- if (this.props.multiple && nextProps.selectedDates !== this.props.selectedDates) {
4428
+ if (!!nextProps.shownMonth && nextProps.shownMonth !== this.props.shownMonth) {
4429
+ var shownMonth = new Date(nextProps.shownMonth.getFullYear(), nextProps.shownMonth.getMonth() + 1, 0);
4430
+ this.setState({
4431
+ shownMonth: shownMonth
4432
+ });
4433
+ this.generateGrid(shownMonth);
4434
+ } else if (this.props.multiple && nextProps.selectedDates !== this.props.selectedDates) {
4429
4435
  this.generateGrid(this.state.shownMonth, nextProps.selectedDates);
4430
4436
  } else if (forceUpdate || nextProps.selectedDate !== this.props.selectedDate) {
4431
4437
  var dateToUse = nextProps.selectedDate;
@@ -4438,11 +4444,13 @@ var DatePicker = /*#__PURE__*/function (_Component) {
4438
4444
  dateToUse = new Date();
4439
4445
  }
4440
4446
 
4447
+ var _shownMonth = this.props.shownMonth ? this.state.shownMonth : dateToUse;
4448
+
4441
4449
  this.setState({
4442
- shownMonth: dateToUse,
4450
+ shownMonth: _shownMonth,
4443
4451
  selectedDate: dateToUse
4444
4452
  });
4445
- this.generateGrid(dateToUse, dateToUse);
4453
+ this.generateGrid(_shownMonth, dateToUse);
4446
4454
  }
4447
4455
  }
4448
4456
  }, {
@@ -4477,19 +4485,35 @@ var DatePicker = /*#__PURE__*/function (_Component) {
4477
4485
 
4478
4486
  return date.isSame(selectedDate, 'date');
4479
4487
  }
4488
+ }, {
4489
+ key: "isDateEnabled",
4490
+ value: function isDateEnabled(date) {
4491
+ if (this.props.enabledDates) {
4492
+ var found = this.props.enabledDates.find(function (d) {
4493
+ return moment(d.day).format('YYYYMMDD') === date.format('YYYYMMDD');
4494
+ });
4495
+ if (found) return found.enabled;
4496
+ }
4497
+
4498
+ return null;
4499
+ }
4480
4500
  }, {
4481
4501
  key: "changeMonth",
4482
4502
  value: function changeMonth(change) {
4503
+ var _this2 = this;
4504
+
4483
4505
  var newShownDate = new Date(this.state.shownMonth.getFullYear(), this.state.shownMonth.getMonth() + 1 + change, 0);
4484
4506
  this.setState({
4485
4507
  shownMonth: newShownDate
4508
+ }, function () {
4509
+ if (_this2.props.changeMonth) _this2.props.changeMonth(_this2.state.shownMonth);
4486
4510
  });
4487
4511
  this.generateGrid(newShownDate);
4488
4512
  }
4489
4513
  }, {
4490
4514
  key: "selectRange",
4491
4515
  value: function selectRange(date) {
4492
- var _this2 = this;
4516
+ var _this3 = this;
4493
4517
 
4494
4518
  var d1 = moment(this.state.lastSelected, 'DD-MM-YYYY');
4495
4519
  var d2 = moment(date, 'DD-MM-YYYY');
@@ -4513,7 +4537,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
4513
4537
  }
4514
4538
 
4515
4539
  if (_.includes(this.props.selectedDates, d2.format('DD-MM-YYYY')) && !_.includes(this.props.selectedDates, d1.format('DD-MM-YYYY')) || !_.some(dateRange, function (d) {
4516
- return !_.includes(_this2.props.selectedDates, d);
4540
+ return !_.includes(_this3.props.selectedDates, d);
4517
4541
  })) {
4518
4542
  // the first clicked date was just de-selected and then clicked on a selected date
4519
4543
  // or every date in the range is already selected, then
@@ -4530,7 +4554,14 @@ var DatePicker = /*#__PURE__*/function (_Component) {
4530
4554
  }, {
4531
4555
  key: "selectDate",
4532
4556
  value: function selectDate(date, e) {
4533
- console.log('selected a date');
4557
+ var enabled = this.isDateEnabled(date);
4558
+ var isBeforeMinDate = this.props.minDate && moment(date).isBefore(this.props.minDate);
4559
+ console.log('selected a date', {
4560
+ date: date,
4561
+ enabled: enabled,
4562
+ isBeforeMinDate: isBeforeMinDate
4563
+ });
4564
+ if (enabled === false || isBeforeMinDate) return;
4534
4565
 
4535
4566
  if (this.props.multiple) {
4536
4567
  var dateKey = moment(date).format('DD-MM-YYYY');
@@ -4593,10 +4624,12 @@ var DatePicker = /*#__PURE__*/function (_Component) {
4593
4624
  display: thisDate.date(),
4594
4625
  isFaded: !thisDate.isSame(month, 'month'),
4595
4626
  isToday: thisDate.isSame(moment(), 'date'),
4596
- isSelected: this.isDateSelected(thisDate, selectedDateToUse)
4627
+ isSelected: this.isDateSelected(thisDate, selectedDateToUse),
4628
+ isEnabled: this.isDateEnabled(thisDate)
4597
4629
  });
4598
4630
  dateToModify = dateToModify.add(1, 'day');
4599
- }
4631
+ } // console.log('generateGrid', JSON.stringify(rows, null, 2));
4632
+
4600
4633
 
4601
4634
  this.setState({
4602
4635
  grid: rows
@@ -4605,7 +4638,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
4605
4638
  }, {
4606
4639
  key: "renderGrid",
4607
4640
  value: function renderGrid() {
4608
- var _this3 = this;
4641
+ var _this4 = this;
4609
4642
 
4610
4643
  return this.state.grid.map(function (row, index) {
4611
4644
  return /*#__PURE__*/React.createElement("div", {
@@ -4626,13 +4659,17 @@ var DatePicker = /*#__PURE__*/function (_Component) {
4626
4659
  classes += ' datepicker__date--selected';
4627
4660
  }
4628
4661
 
4662
+ if (typeof date.isEnabled === 'boolean') {
4663
+ classes += date.isEnabled ? ' datepicker__date--enabled' : ' datepicker__date--disabled';
4664
+ }
4665
+
4629
4666
  return /*#__PURE__*/React.createElement("div", {
4630
4667
  className: classes,
4631
4668
  key: date.dateKey
4632
4669
  }, /*#__PURE__*/React.createElement("div", {
4633
4670
  className: "datepicker__date__inner",
4634
4671
  onClick: function onClick(e) {
4635
- _this3.selectDate(date.date, e);
4672
+ return _this4.selectDate(date.date, e);
4636
4673
  }
4637
4674
  }, date.display));
4638
4675
  }));
package/dist/index.umd.js CHANGED
@@ -3529,7 +3529,7 @@
3529
3529
  var form = {
3530
3530
  viewBox: "0 0 256 256",
3531
3531
  paths: [
3532
- "M164,152a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,152Zm-4-36H96a4,4,0,0,0,0,8h64a4,4,0,0,0,0-8Zm52-68V216a12,12,0,0,1-12,12H56a12,12,0,0,1-12-12V48A12,12,0,0,1,56,36H94.08a44,44,0,0,1,67.84,0H200A12,12,0,0,1,212,48ZM92,64v4h72V64a36,36,0,0,0-72,0ZM204,48a4,4,0,0,0-4-4H167.17A43.71,43.71,0,0,1,172,64v8a4,4,0,0,1-4,4H88a4,4,0,0,1-4-4V64a43.71,43.71,0,0,1,4.83-20H56a4,4,0,0,0-4,4V216a4,4,0,0,0,4,4H200a4,4,0,0,0,4-4Z"
3532
+ "M200,32H163.74a47.92,47.92,0,0,0-71.48,0H56A16,16,0,0,0,40,48V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V48A16,16,0,0,0,200,32Zm-72,0a32,32,0,0,1,32,32H96A32,32,0,0,1,128,32Zm32,128H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Zm0-32H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Z"
3533
3533
  ]
3534
3534
  };
3535
3535
  var icons = {
@@ -4423,7 +4423,13 @@
4423
4423
  }, {
4424
4424
  key: "onNewProps",
4425
4425
  value: function onNewProps(nextProps, forceUpdate) {
4426
- if (this.props.multiple && nextProps.selectedDates !== this.props.selectedDates) {
4426
+ if (!!nextProps.shownMonth && nextProps.shownMonth !== this.props.shownMonth) {
4427
+ var shownMonth = new Date(nextProps.shownMonth.getFullYear(), nextProps.shownMonth.getMonth() + 1, 0);
4428
+ this.setState({
4429
+ shownMonth: shownMonth
4430
+ });
4431
+ this.generateGrid(shownMonth);
4432
+ } else if (this.props.multiple && nextProps.selectedDates !== this.props.selectedDates) {
4427
4433
  this.generateGrid(this.state.shownMonth, nextProps.selectedDates);
4428
4434
  } else if (forceUpdate || nextProps.selectedDate !== this.props.selectedDate) {
4429
4435
  var dateToUse = nextProps.selectedDate;
@@ -4436,11 +4442,13 @@
4436
4442
  dateToUse = new Date();
4437
4443
  }
4438
4444
 
4445
+ var _shownMonth = this.props.shownMonth ? this.state.shownMonth : dateToUse;
4446
+
4439
4447
  this.setState({
4440
- shownMonth: dateToUse,
4448
+ shownMonth: _shownMonth,
4441
4449
  selectedDate: dateToUse
4442
4450
  });
4443
- this.generateGrid(dateToUse, dateToUse);
4451
+ this.generateGrid(_shownMonth, dateToUse);
4444
4452
  }
4445
4453
  }
4446
4454
  }, {
@@ -4475,19 +4483,35 @@
4475
4483
 
4476
4484
  return date.isSame(selectedDate, 'date');
4477
4485
  }
4486
+ }, {
4487
+ key: "isDateEnabled",
4488
+ value: function isDateEnabled(date) {
4489
+ if (this.props.enabledDates) {
4490
+ var found = this.props.enabledDates.find(function (d) {
4491
+ return moment__default['default'](d.day).format('YYYYMMDD') === date.format('YYYYMMDD');
4492
+ });
4493
+ if (found) return found.enabled;
4494
+ }
4495
+
4496
+ return null;
4497
+ }
4478
4498
  }, {
4479
4499
  key: "changeMonth",
4480
4500
  value: function changeMonth(change) {
4501
+ var _this2 = this;
4502
+
4481
4503
  var newShownDate = new Date(this.state.shownMonth.getFullYear(), this.state.shownMonth.getMonth() + 1 + change, 0);
4482
4504
  this.setState({
4483
4505
  shownMonth: newShownDate
4506
+ }, function () {
4507
+ if (_this2.props.changeMonth) _this2.props.changeMonth(_this2.state.shownMonth);
4484
4508
  });
4485
4509
  this.generateGrid(newShownDate);
4486
4510
  }
4487
4511
  }, {
4488
4512
  key: "selectRange",
4489
4513
  value: function selectRange(date) {
4490
- var _this2 = this;
4514
+ var _this3 = this;
4491
4515
 
4492
4516
  var d1 = moment__default['default'](this.state.lastSelected, 'DD-MM-YYYY');
4493
4517
  var d2 = moment__default['default'](date, 'DD-MM-YYYY');
@@ -4511,7 +4535,7 @@
4511
4535
  }
4512
4536
 
4513
4537
  if (___default['default'].includes(this.props.selectedDates, d2.format('DD-MM-YYYY')) && !___default['default'].includes(this.props.selectedDates, d1.format('DD-MM-YYYY')) || !___default['default'].some(dateRange, function (d) {
4514
- return !___default['default'].includes(_this2.props.selectedDates, d);
4538
+ return !___default['default'].includes(_this3.props.selectedDates, d);
4515
4539
  })) {
4516
4540
  // the first clicked date was just de-selected and then clicked on a selected date
4517
4541
  // or every date in the range is already selected, then
@@ -4528,7 +4552,14 @@
4528
4552
  }, {
4529
4553
  key: "selectDate",
4530
4554
  value: function selectDate(date, e) {
4531
- console.log('selected a date');
4555
+ var enabled = this.isDateEnabled(date);
4556
+ var isBeforeMinDate = this.props.minDate && moment__default['default'](date).isBefore(this.props.minDate);
4557
+ console.log('selected a date', {
4558
+ date: date,
4559
+ enabled: enabled,
4560
+ isBeforeMinDate: isBeforeMinDate
4561
+ });
4562
+ if (enabled === false || isBeforeMinDate) return;
4532
4563
 
4533
4564
  if (this.props.multiple) {
4534
4565
  var dateKey = moment__default['default'](date).format('DD-MM-YYYY');
@@ -4591,10 +4622,12 @@
4591
4622
  display: thisDate.date(),
4592
4623
  isFaded: !thisDate.isSame(month, 'month'),
4593
4624
  isToday: thisDate.isSame(moment__default['default'](), 'date'),
4594
- isSelected: this.isDateSelected(thisDate, selectedDateToUse)
4625
+ isSelected: this.isDateSelected(thisDate, selectedDateToUse),
4626
+ isEnabled: this.isDateEnabled(thisDate)
4595
4627
  });
4596
4628
  dateToModify = dateToModify.add(1, 'day');
4597
- }
4629
+ } // console.log('generateGrid', JSON.stringify(rows, null, 2));
4630
+
4598
4631
 
4599
4632
  this.setState({
4600
4633
  grid: rows
@@ -4603,7 +4636,7 @@
4603
4636
  }, {
4604
4637
  key: "renderGrid",
4605
4638
  value: function renderGrid() {
4606
- var _this3 = this;
4639
+ var _this4 = this;
4607
4640
 
4608
4641
  return this.state.grid.map(function (row, index) {
4609
4642
  return /*#__PURE__*/React__default['default'].createElement("div", {
@@ -4624,13 +4657,17 @@
4624
4657
  classes += ' datepicker__date--selected';
4625
4658
  }
4626
4659
 
4660
+ if (typeof date.isEnabled === 'boolean') {
4661
+ classes += date.isEnabled ? ' datepicker__date--enabled' : ' datepicker__date--disabled';
4662
+ }
4663
+
4627
4664
  return /*#__PURE__*/React__default['default'].createElement("div", {
4628
4665
  className: classes,
4629
4666
  key: date.dateKey
4630
4667
  }, /*#__PURE__*/React__default['default'].createElement("div", {
4631
4668
  className: "datepicker__date__inner",
4632
4669
  onClick: function onClick(e) {
4633
- _this3.selectDate(date.date, e);
4670
+ return _this4.selectDate(date.date, e);
4634
4671
  }
4635
4672
  }, date.display));
4636
4673
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plusscommunities/pluss-core-web",
3
- "version": "1.6.4-beta.0",
3
+ "version": "1.6.5-beta.0",
4
4
  "description": "Core extension package for Pluss Communities platform",
5
5
  "main": "dist/index.cjs.js",
6
6
  "scripts": {
@@ -18,7 +18,11 @@ class DatePicker extends Component {
18
18
  }
19
19
 
20
20
  onNewProps(nextProps, forceUpdate) {
21
- if (this.props.multiple && nextProps.selectedDates !== this.props.selectedDates) {
21
+ if (!!nextProps.shownMonth && nextProps.shownMonth !== this.props.shownMonth) {
22
+ const shownMonth = new Date(nextProps.shownMonth.getFullYear(), nextProps.shownMonth.getMonth() + 1, 0);
23
+ this.setState({ shownMonth });
24
+ this.generateGrid(shownMonth);
25
+ } else if (this.props.multiple && nextProps.selectedDates !== this.props.selectedDates) {
22
26
  this.generateGrid(this.state.shownMonth, nextProps.selectedDates);
23
27
  } else if (forceUpdate || nextProps.selectedDate !== this.props.selectedDate) {
24
28
  let dateToUse = nextProps.selectedDate;
@@ -28,11 +32,12 @@ class DatePicker extends Component {
28
32
  if (isNaN(dateToUse)) {
29
33
  dateToUse = new Date();
30
34
  }
35
+ const shownMonth = this.props.shownMonth ? this.state.shownMonth : dateToUse;
31
36
  this.setState({
32
- shownMonth: dateToUse,
37
+ shownMonth: shownMonth,
33
38
  selectedDate: dateToUse,
34
39
  });
35
- this.generateGrid(dateToUse, dateToUse);
40
+ this.generateGrid(shownMonth, dateToUse);
36
41
  }
37
42
  }
38
43
 
@@ -61,11 +66,24 @@ class DatePicker extends Component {
61
66
  return date.isSame(selectedDate, 'date');
62
67
  }
63
68
 
69
+ isDateEnabled(date) {
70
+ if (this.props.enabledDates) {
71
+ const found = this.props.enabledDates.find((d) => moment(d.day).format('YYYYMMDD') === date.format('YYYYMMDD'));
72
+ if (found) return found.enabled;
73
+ }
74
+ return null;
75
+ }
76
+
64
77
  changeMonth(change) {
65
78
  const newShownDate = new Date(this.state.shownMonth.getFullYear(), this.state.shownMonth.getMonth() + 1 + change, 0);
66
- this.setState({
67
- shownMonth: newShownDate,
68
- });
79
+ this.setState(
80
+ {
81
+ shownMonth: newShownDate,
82
+ },
83
+ () => {
84
+ if (this.props.changeMonth) this.props.changeMonth(this.state.shownMonth);
85
+ },
86
+ );
69
87
  this.generateGrid(newShownDate);
70
88
  }
71
89
 
@@ -113,7 +131,11 @@ class DatePicker extends Component {
113
131
  }
114
132
 
115
133
  selectDate(date, e) {
116
- console.log('selected a date');
134
+ const enabled = this.isDateEnabled(date);
135
+ const isBeforeMinDate = this.props.minDate && moment(date).isBefore(this.props.minDate);
136
+ console.log('selected a date', { date, enabled, isBeforeMinDate });
137
+ if (enabled === false || isBeforeMinDate) return;
138
+
117
139
  if (this.props.multiple) {
118
140
  const dateKey = moment(date).format('DD-MM-YYYY');
119
141
 
@@ -173,11 +195,13 @@ class DatePicker extends Component {
173
195
  isFaded: !thisDate.isSame(month, 'month'),
174
196
  isToday: thisDate.isSame(moment(), 'date'),
175
197
  isSelected: this.isDateSelected(thisDate, selectedDateToUse),
198
+ isEnabled: this.isDateEnabled(thisDate),
176
199
  });
177
200
 
178
201
  dateToModify = dateToModify.add(1, 'day');
179
202
  }
180
203
 
204
+ // console.log('generateGrid', JSON.stringify(rows, null, 2));
181
205
  this.setState({
182
206
  grid: rows,
183
207
  });
@@ -198,14 +222,12 @@ class DatePicker extends Component {
198
222
  if (date.isSelected) {
199
223
  classes += ' datepicker__date--selected';
200
224
  }
225
+ if (typeof date.isEnabled === 'boolean') {
226
+ classes += date.isEnabled ? ' datepicker__date--enabled' : ' datepicker__date--disabled';
227
+ }
201
228
  return (
202
229
  <div className={classes} key={date.dateKey}>
203
- <div
204
- className="datepicker__date__inner"
205
- onClick={(e) => {
206
- this.selectDate(date.date, e);
207
- }}
208
- >
230
+ <div className="datepicker__date__inner" onClick={(e) => this.selectDate(date.date, e)}>
209
231
  {date.display}
210
232
  </div>
211
233
  </div>
@@ -815,7 +815,7 @@
815
815
  "form": {
816
816
  "viewBox": "0 0 256 256",
817
817
  "paths": [
818
- "M164,152a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,152Zm-4-36H96a4,4,0,0,0,0,8h64a4,4,0,0,0,0-8Zm52-68V216a12,12,0,0,1-12,12H56a12,12,0,0,1-12-12V48A12,12,0,0,1,56,36H94.08a44,44,0,0,1,67.84,0H200A12,12,0,0,1,212,48ZM92,64v4h72V64a36,36,0,0,0-72,0ZM204,48a4,4,0,0,0-4-4H167.17A43.71,43.71,0,0,1,172,64v8a4,4,0,0,1-4,4H88a4,4,0,0,1-4-4V64a43.71,43.71,0,0,1,4.83-20H56a4,4,0,0,0-4,4V216a4,4,0,0,0,4,4H200a4,4,0,0,0,4-4Z"
818
+ "M200,32H163.74a47.92,47.92,0,0,0-71.48,0H56A16,16,0,0,0,40,48V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V48A16,16,0,0,0,200,32Zm-72,0a32,32,0,0,1,32,32H96A32,32,0,0,1,128,32Zm32,128H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Zm0-32H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Z"
819
819
  ]
820
820
  }
821
821
  }