Socket
Socket
Sign inDemoInstall

@vaadin/date-picker

Package Overview
Dependencies
21
Maintainers
12
Versions
331
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 24.4.0-dev.223e39f050 to 24.4.0-dev.4b20a0c55

22

package.json
{
"name": "@vaadin/date-picker",
"version": "24.4.0-dev.223e39f050",
"version": "24.4.0-dev.4b20a0c55",
"publishConfig": {

@@ -39,11 +39,11 @@ "access": "public"

"@polymer/polymer": "^3.2.0",
"@vaadin/a11y-base": "24.4.0-dev.223e39f050",
"@vaadin/button": "24.4.0-dev.223e39f050",
"@vaadin/component-base": "24.4.0-dev.223e39f050",
"@vaadin/field-base": "24.4.0-dev.223e39f050",
"@vaadin/input-container": "24.4.0-dev.223e39f050",
"@vaadin/overlay": "24.4.0-dev.223e39f050",
"@vaadin/vaadin-lumo-styles": "24.4.0-dev.223e39f050",
"@vaadin/vaadin-material-styles": "24.4.0-dev.223e39f050",
"@vaadin/vaadin-themable-mixin": "24.4.0-dev.223e39f050",
"@vaadin/a11y-base": "24.4.0-dev.4b20a0c55",
"@vaadin/button": "24.4.0-dev.4b20a0c55",
"@vaadin/component-base": "24.4.0-dev.4b20a0c55",
"@vaadin/field-base": "24.4.0-dev.4b20a0c55",
"@vaadin/input-container": "24.4.0-dev.4b20a0c55",
"@vaadin/overlay": "24.4.0-dev.4b20a0c55",
"@vaadin/vaadin-lumo-styles": "24.4.0-dev.4b20a0c55",
"@vaadin/vaadin-material-styles": "24.4.0-dev.4b20a0c55",
"@vaadin/vaadin-themable-mixin": "24.4.0-dev.4b20a0c55",
"lit": "^3.0.0"

@@ -60,3 +60,3 @@ },

],
"gitHead": "5e2e3bfc811c95aed9354235fab93fdbf43eb354"
"gitHead": "b79c81e5f6fd24684b34ee0dc434e94d943ea13e"
}

@@ -8,3 +8,2 @@ # @vaadin/date-picker

[![npm version](https://badgen.net/npm/v/@vaadin/date-picker)](https://www.npmjs.com/package/@vaadin/date-picker)
[![Discord](https://img.shields.io/discord/732335336448852018?label=discord)](https://discord.gg/PHmkCKC)

@@ -11,0 +10,0 @@ ```html

@@ -20,3 +20,8 @@ /**

*/
declare function dateAllowed(date: Date, min: Date | null, max: Date | null): boolean;
declare function dateAllowed(
date: Date,
min: Date | null,
max: Date | null,
isDateDisabled: (DatePickerDate) => boolean | null,
): boolean;

@@ -23,0 +28,0 @@ /**

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -57,2 +57,16 @@ */

/**
* Extracts the basic component parts of a date (day, month and year)
* to the expected format.
* @param {!Date} date
* @return {{day: number, month: number, year: number}}
*/
export function extractDateParts(date) {
return {
day: date.getDate(),
month: date.getMonth(),
year: date.getFullYear(),
};
}
/**
* Check if the given date is in the range of allowed dates.

@@ -63,6 +77,13 @@ *

* @param {Date} max Range end
* @param {function(!DatePickerDate): boolean} isDateDisabled Callback to check if the date is disabled
* @return {boolean} True if the date is in the range
*/
export function dateAllowed(date, min, max) {
return (!min || date >= min) && (!max || date <= max);
export function dateAllowed(date, min, max, isDateDisabled) {
let dateIsDisabled = false;
if (typeof isDateDisabled === 'function' && !!date) {
const dateToCheck = extractDateParts(date);
dateIsDisabled = isDateDisabled(dateToCheck);
}
return (!min || date >= min) && (!max || date <= max) && !dateIsDisabled;
}

@@ -96,16 +117,2 @@

/**
* Extracts the basic component parts of a date (day, month and year)
* to the expected format.
* @param {!Date} date
* @return {{day: number, month: number, year: number}}
*/
export function extractDateParts(date) {
return {
day: date.getDate(),
month: date.getMonth(),
year: date.getFullYear(),
};
}
/**
* Get difference in months between today and given months value.

@@ -112,0 +119,0 @@ *

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -5,0 +5,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -5,0 +5,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -241,2 +241,9 @@ */

/**
* A function to be used to determine whether the user can select a given date.
* Receives a `DatePickerDate` object of the date to be selected and should return a
* boolean.
*/
isDateDisabled: (date: DatePickerDate) => boolean;
/**
* Opens the dropdown.

@@ -243,0 +250,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -306,2 +306,13 @@ */

/**
* A function to be used to determine whether the user can select a given date.
* Receives a `DatePickerDate` object of the date to be selected and should return a
* boolean.
*
* @type {function(DatePickerDate): boolean | undefined}
*/
isDateDisabled: {
type: Function,
},
/**
* The earliest date that can be selected. All earlier dates will be disabled.

@@ -369,3 +380,3 @@ * @type {Date | undefined}

'_focusedDateChanged(_focusedDate, i18n)',
'__updateOverlayContent(_overlayContent, i18n, label, _minDate, _maxDate, _focusedDate, _selectedDate, showWeekNumbers)',
'__updateOverlayContent(_overlayContent, i18n, label, _minDate, _maxDate, _focusedDate, _selectedDate, showWeekNumbers, isDateDisabled)',
'__updateOverlayContentTheme(_overlayContent, _theme)',

@@ -606,3 +617,4 @@ '__updateOverlayContentFullScreen(_overlayContent, _fullscreen)',

const inputValid = !inputValue || (!!this._selectedDate && inputValue === this.__formatDate(this._selectedDate));
const minMaxValid = !this._selectedDate || dateAllowed(this._selectedDate, this._minDate, this._maxDate);
const isDateValid =
!this._selectedDate || dateAllowed(this._selectedDate, this._minDate, this._maxDate, this.isDateDisabled);

@@ -619,3 +631,3 @@ let inputValidity = true;

return inputValid && minMaxValid && inputValidity;
return inputValid && isDateValid && inputValidity;
}

@@ -859,3 +871,13 @@

// eslint-disable-next-line max-params
__updateOverlayContent(overlayContent, i18n, label, minDate, maxDate, focusedDate, selectedDate, showWeekNumbers) {
__updateOverlayContent(
overlayContent,
i18n,
label,
minDate,
maxDate,
focusedDate,
selectedDate,
showWeekNumbers,
isDateDisabled,
) {
if (overlayContent) {

@@ -869,2 +891,3 @@ overlayContent.i18n = i18n;

overlayContent.showWeekNumbers = showWeekNumbers;
overlayContent.isDateDisabled = isDateDisabled;
}

@@ -941,5 +964,7 @@ }

return parsedInitialPosition || dateAllowed(initialPosition, this._minDate, this._maxDate)
return parsedInitialPosition || dateAllowed(initialPosition, this._minDate, this._maxDate, this.isDateDisabled)
? initialPosition
: getClosestDate(initialPosition, [this._minDate, this._maxDate]);
: this._minDate || this._maxDate
? getClosestDate(initialPosition, [this._minDate, this._maxDate])
: new Date();
}

@@ -946,0 +971,0 @@

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -5,0 +5,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -13,3 +13,9 @@ */

import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
import { dateAfterXMonths, dateEquals, extractDateParts, getClosestDate } from './vaadin-date-picker-helper.js';
import {
dateAfterXMonths,
dateAllowed,
dateEquals,
extractDateParts,
getClosestDate,
} from './vaadin-date-picker-helper.js';

@@ -112,2 +118,13 @@ /**

/**
* A function to be used to determine whether the user can select a given date.
* Receives a `DatePickerDate` object of the date to be selected and should return a
* boolean.
*
* @type {function(DatePickerDate): boolean | undefined}
*/
isDateDisabled: {
type: Function,
},
/**
* Input label

@@ -139,5 +156,5 @@ */

return [
'__updateCalendars(calendars, i18n, minDate, maxDate, selectedDate, focusedDate, showWeekNumbers, _ignoreTaps, _theme)',
'__updateCalendars(calendars, i18n, minDate, maxDate, selectedDate, focusedDate, showWeekNumbers, _ignoreTaps, _theme, isDateDisabled)',
'__updateCancelButton(_cancelButton, i18n)',
'__updateTodayButton(_todayButton, i18n, minDate, maxDate)',
'__updateTodayButton(_todayButton, i18n, minDate, maxDate, isDateDisabled)',
'__updateYears(years, selectedDate, _theme)',

@@ -309,6 +326,6 @@ ];

/** @private */
__updateTodayButton(todayButton, i18n, minDate, maxDate) {
__updateTodayButton(todayButton, i18n, minDate, maxDate, isDateDisabled) {
if (todayButton) {
todayButton.textContent = i18n && i18n.today;
todayButton.disabled = !this._isTodayAllowed(minDate, maxDate);
todayButton.disabled = !this._isTodayAllowed(minDate, maxDate, isDateDisabled);
}

@@ -328,2 +345,3 @@ }

theme,
isDateDisabled,
) {

@@ -335,2 +353,3 @@ if (calendars && calendars.length) {

calendar.maxDate = maxDate;
calendar.isDateDisabled = isDateDisabled;
calendar.focusedDate = focusedDate;

@@ -370,2 +389,5 @@ calendar.selectedDate = selectedDate;

_selectDate(dateToSelect) {
if (!this._dateAllowed(dateToSelect)) {
return false;
}
this.selectedDate = dateToSelect;

@@ -375,2 +397,3 @@ this.dispatchEvent(

);
return true;
}

@@ -786,5 +809,6 @@

case 'Enter':
this._selectDate(this.focusedDate);
this._close();
handled = true;
if (this._selectDate(this.focusedDate)) {
this._close();
handled = true;
}
break;

@@ -943,3 +967,4 @@ case ' ':

_focusAllowedDate(dateToFocus, diff, keepMonth) {
if (this._dateAllowed(dateToFocus)) {
// For this check we do consider the isDateDisabled function because disabled dates are allowed to be focused, just not outside min/max
if (this._dateAllowed(dateToFocus, undefined, undefined, () => false)) {
this.focusDate(dateToFocus, keepMonth);

@@ -1022,8 +1047,8 @@ } else if (this._dateAllowed(this.focusedDate)) {

/** @private */
_dateAllowed(date, min = this.minDate, max = this.maxDate) {
return (!min || date >= min) && (!max || date <= max);
_dateAllowed(date, min = this.minDate, max = this.maxDate, isDateDisabled = this.isDateDisabled) {
return dateAllowed(date, min, max, isDateDisabled);
}
/** @private */
_isTodayAllowed(min, max) {
_isTodayAllowed(min, max, isDateDisabled) {
const today = new Date();

@@ -1034,3 +1059,3 @@ const todayMidnight = new Date(0, 0);

todayMidnight.setDate(today.getDate());
return this._dateAllowed(todayMidnight, min, max);
return this._dateAllowed(todayMidnight, min, max, isDateDisabled);
}

@@ -1037,0 +1062,0 @@

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -5,0 +5,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -5,0 +5,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -5,0 +5,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -5,0 +5,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -5,0 +5,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -5,0 +5,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -5,0 +5,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -5,0 +5,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -5,0 +5,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -5,0 +5,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -5,0 +5,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -5,0 +5,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -5,0 +5,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -5,0 +5,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -28,3 +28,3 @@ */

*
* This component is an experiment not intended for publishing to npm.
* This component is an experiment and not yet a part of Vaadin platform.
* There is no ETA regarding specific Vaadin version where it'll land.

@@ -31,0 +31,0 @@ * Feel free to try this code in your apps as per Apache 2.0 license.

@@ -64,3 +64,3 @@ /**

const isSelected = dateEquals(date, this.selectedDate);
const isDisabled = !dateAllowed(date, this.minDate, this.maxDate);
const isDisabled = !dateAllowed(date, this.minDate, this.maxDate, this.isDateDisabled);

@@ -67,0 +67,0 @@ const parts = [

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -83,2 +83,13 @@ */

/**
* A function to be used to determine whether the user can select a given date.
* Receives a `DatePickerDate` object of the date to be selected and should return a
* boolean.
* @type {Function | undefined}
*/
isDateDisabled: {
type: Function,
value: () => false,
},
disabled: {

@@ -85,0 +96,0 @@ type: Boolean,

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -5,0 +5,0 @@ */

/**
* @license
* Copyright (c) 2016 - 2023 Vaadin Ltd.
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/

@@ -53,8 +53,8 @@ */

role="gridcell"
part$="[[__getDatePart(item, focusedDate, selectedDate, minDate, maxDate)]]"
part$="[[__getDatePart(item, focusedDate, selectedDate, minDate, maxDate, isDateDisabled)]]"
date="[[item]]"
tabindex$="[[__getDayTabindex(item, focusedDate)]]"
disabled$="[[__isDayDisabled(item, minDate, maxDate)]]"
disabled$="[[__isDayDisabled(item, minDate, maxDate, isDateDisabled)]]"
aria-selected$="[[__getDayAriaSelected(item, selectedDate)]]"
aria-disabled$="[[__getDayAriaDisabled(item, minDate, maxDate)]]"
aria-disabled$="[[__getDayAriaDisabled(item, minDate, maxDate, isDateDisabled)]]"
aria-label$="[[__getDayAriaLabel(item)]]"

@@ -80,3 +80,3 @@ >[[_getDate(item)]]</td

type: Array,
computed: '_getDays(month, i18n, minDate, maxDate)',
computed: '_getDays(month, i18n, minDate, maxDate, isDateDisabled)',
},

@@ -112,6 +112,6 @@

/** @private */
__getDatePart(date, focusedDate, selectedDate, minDate, maxDate) {
__getDatePart(date, focusedDate, selectedDate, minDate, maxDate, isDateDisabled) {
const result = ['date'];
if (this.__isDayDisabled(date, minDate, maxDate)) {
if (this.__isDayDisabled(date, minDate, maxDate, isDateDisabled)) {
result.push('disabled');

@@ -153,13 +153,13 @@ }

/** @private */
__isDayDisabled(date, minDate, maxDate) {
return !dateAllowed(date, minDate, maxDate);
__isDayDisabled(date, minDate, maxDate, isDateDisabled) {
return !dateAllowed(date, minDate, maxDate, isDateDisabled);
}
/** @private */
__getDayAriaDisabled(date, min, max) {
if (date === undefined || min === undefined || max === undefined) {
__getDayAriaDisabled(date, min, max, isDateDisabled) {
if (date === undefined || (min === undefined && max === undefined && isDateDisabled === undefined)) {
return;
}
if (this.__isDayDisabled(date, min, max)) {
if (this.__isDayDisabled(date, min, max, isDateDisabled)) {
return 'true';

@@ -166,0 +166,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc