bulma-extensions
Advanced tools
Comparing version 6.2.2 to 6.2.3
@@ -78,4 +78,12 @@ import * as utils from '../utils'; | ||
set start(date) { | ||
this._date.start = date ? (this._isValidDate(date, this.min, this.max) ? dateFns.startOfDay(date) : this._date.start) : undefined; | ||
set start(date = undefined) { | ||
if (date) { | ||
if (type.isDate(date)) { | ||
this._date.start = this._isValidDate(date, this.min, this.max) ? dateFns.startOfDay(date) : this._date.start; | ||
} | ||
if (type.isString(date)) { | ||
this._date.start = this._isValidDate(dateFns.parse(date), this.min, this.max) ? dateFns.startOfDay(dateFns.parse(date)) : this._date.start; | ||
} | ||
} | ||
return this; | ||
@@ -87,4 +95,12 @@ } | ||
set end(date) { | ||
this._date.end = date ? (this._isValidDate(date, this.min, this.max) ? dateFns.startOfDay(date) : this._date.end) : undefined; | ||
set end(date = undefined) { | ||
if (date) { | ||
if (type.isDate(date)) { | ||
this._date.end = this._isValidDate(date, this.min, this.max) ? dateFns.startOfDay(date) : this._date.end; | ||
} | ||
if (type.isString(date)) { | ||
this._date.end = this._isValidDate(dateFns.parse(date), this.min, this.max) ? dateFns.startOfDay(dateFns.parse(date)) : this._date.end; | ||
} | ||
} | ||
return this; | ||
@@ -98,3 +114,11 @@ } | ||
set min(date = undefined) { | ||
this._min = date ? (this._isValidDate(date) ? dateFns.startOfDay(date) : this._min) : undefined; | ||
if (date) { | ||
if (type.isDate(date)) { | ||
this._min = this._isValidDate(date) ? dateFns.startOfDay(date) : this._min; | ||
} | ||
if (type.isString(date)) { | ||
this._min = this._isValidDate(dateFns.parse(date)) ? dateFns.startOfDay(date) : this._min; | ||
} | ||
} | ||
return this; | ||
@@ -109,3 +133,11 @@ } | ||
set max(date = null) { | ||
this._max = date ? (this._isValidDate(date) ? dateFns.startOfDay(date) : this._max) : undefined; | ||
if (date) { | ||
if (type.isDate(date)) { | ||
this._max = this._isValidDate(date) ? dateFns.startOfDay(date) : this._max; | ||
} | ||
if (type.isString(date)) { | ||
this._max = this._isValidDate(dateFns.parse(date)) ? dateFns.startOfDay(date) : this._max; | ||
} | ||
} | ||
return this; | ||
@@ -463,4 +495,4 @@ } | ||
this.disabledWeekDays = type.isString(this.options.disabledWeekDays) ? this.options.disabledWeekDays.split(',') : (Array.isArray(this.options.disabledWeekDays) ? this.options.disabledWeekDays : []); | ||
this.min = this.options.min; | ||
this.max = this.options.max; | ||
this.min = this.options.minDate; | ||
this.max = this.options.maxDate; | ||
this._date = { | ||
@@ -721,2 +753,2 @@ start: this.options.startDate, | ||
} | ||
} | ||
} |
import * as utils from './utils/index'; | ||
import * as types from './utils/type'; | ||
import * as dateFns from 'date-fns'; | ||
import dateUtils from 'date-and-time'; | ||
import EventEmitter from './utils/events'; | ||
@@ -35,2 +36,3 @@ | ||
}, {}) : {}; | ||
// Set default options - dataset attributes are master | ||
@@ -149,3 +151,3 @@ this.options = { | ||
set startDate(date = undefined) { | ||
this.datePicker.start = date; | ||
this.datePicker.start = dateUtils.parse(date, this.dateFormat); | ||
return this; | ||
@@ -158,3 +160,3 @@ } | ||
set endDate(date = undefined) { | ||
this.datePicker.end = date; | ||
this.datePicker.end = dateUtils.parse(date, this.dateFormat); | ||
return this; | ||
@@ -170,3 +172,3 @@ } | ||
set minDate(date = undefined) { | ||
this.datePicker.minDate = date; | ||
this.datePicker.minDate = dateUtils.parse(date, this.dateFormat); | ||
return this; | ||
@@ -181,3 +183,3 @@ } | ||
set maxDate(date = undefined) { | ||
this.datePicker.maxDate = date; | ||
this.datePicker.maxDate = dateUtils.parse(date, this.dateFormat); | ||
return this; | ||
@@ -275,7 +277,2 @@ } | ||
onDocumentClickDateTimePicker(e) { | ||
if (!this._supportsPassive) { | ||
e.preventDefault(); | ||
} | ||
e.stopPropagation(); | ||
// Check is e.target not within datepicker element | ||
@@ -666,12 +663,12 @@ const target = e.target || e.srcElement; | ||
if (!this.options.showHeader) { | ||
if (!types.BooleanParse(this.options.showHeader)) { | ||
this._ui.header.container.classList.add('is-hidden'); | ||
} | ||
if (!this.options.showFooter) { | ||
if (!types.BooleanParse(this.options.showFooter)) { | ||
this._ui.footer.container.classList.add('is-hidden'); | ||
} | ||
if (!this.options.showTodayButton) { | ||
if (!types.BooleanParse(this.options.showTodayButton)) { | ||
this._ui.footer.today.classList.add('is-hidden'); | ||
} | ||
if (!this.options.showClearButton) { | ||
if (!types.BooleanParse(this.options.showClearButton)) { | ||
this._ui.footer.clear.classList.add('is-hidden'); | ||
@@ -678,0 +675,0 @@ } |
export const isFunction = unknown => typeof unknown === 'function'; | ||
export const isString = unknown => (typeof unknown === 'string' || ((!!unknown && typeof unknown === 'object') && Object.prototype.toString.call(unknown) === '[object String]')); | ||
export const isDate = unknown => (Object.prototype.toString.call(unknown) === '[object Date]' || unknown instanceof Date) && !isNaN(unknown.valueOf()); | ||
export const isObject = unknown => ((typeof unknown === 'function' || (typeof unknown === 'object' && !!unknown)) && !Array.isArray(unknown)); | ||
export const isObject = unknown => ((typeof unknown === 'function' || (typeof unknown === 'object' && !!unknown)) && !Array.isArray(unknown)); | ||
const falsy = /^(?:f(?:alse)?|no?|0+)$/i; | ||
export const BooleanParse = function (val) { | ||
return !falsy.test(val) && !!val; | ||
}; |
@@ -6,3 +6,3 @@ { | ||
"style": "./dist/css/bulma-extensions.min.css", | ||
"version": "6.2.2", | ||
"version": "6.2.3", | ||
"scripts": { | ||
@@ -9,0 +9,0 @@ "build": "gulp", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5441023
78518
292