Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@os-design/date-picker-utils

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@os-design/date-picker-utils - npm Package Compare versions

Comparing version 1.0.12 to 1.0.13

15

dist/cjs/utils/getAccessibilityDateLabel.js

@@ -7,7 +7,12 @@ "use strict";

exports["default"] = void 0;
var getAccessibilityDateLabel = function getAccessibilityDateLabel(date, locale) {
var day = date.getDate();
var month = locale.months[date.getMonth()];
var year = date.getFullYear();
return "".concat(day, " ").concat(month, " ").concat(year);
var getAccessibilityDateLabel = function getAccessibilityDateLabel(value, locale) {
var dateToStr = function dateToStr(date) {
var day = date.getDate();
var month = locale.months[date.getMonth()];
var year = date.getFullYear();
return "".concat(day, " ").concat(month, " ").concat(year);
};
return Array.isArray(value) ? value.map(function (item) {
return dateToStr(item);
}).join(' - ') : dateToStr(value);
};

@@ -14,0 +19,0 @@ var _default = getAccessibilityDateLabel;

@@ -27,3 +27,4 @@ "use strict";

var _useState = (0, _react.useState)(function () {
var date = !value ? new Date() : value;
// eslint-disable-next-line no-nested-ternary
var date = value ? Array.isArray(value) ? value[0] : value : new Date();
return {

@@ -84,7 +85,18 @@ month: date.getMonth(),

})), _toConsumableArray(daysCurMonth.map(function (date) {
if (value && (0, _isSameDay["default"])(date, value)) {
return {
type: 'selectedDay',
date: date
};
if (value) {
var valueArr = Array.isArray(value) ? value : [value];
if (valueArr.some(function (item) {
return (0, _isSameDay["default"])(date, item);
})) {
return {
type: 'selectedDay',
date: date
};
}
if (Array.isArray(value) && date > value[0] && date < value[1]) {
return {
type: 'dayInRange',
date: date
};
}
}

@@ -91,0 +103,0 @@ if ((0, _isSameDay["default"])(date, new Date())) {

@@ -1,8 +0,11 @@

const getAccessibilityDateLabel = (date, locale) => {
const day = date.getDate();
const month = locale.months[date.getMonth()];
const year = date.getFullYear();
return `${day} ${month} ${year}`;
const getAccessibilityDateLabel = (value, locale) => {
const dateToStr = date => {
const day = date.getDate();
const month = locale.months[date.getMonth()];
const year = date.getFullYear();
return `${day} ${month} ${year}`;
};
return Array.isArray(value) ? value.map(item => dateToStr(item)).join(' - ') : dateToStr(value);
};
export default getAccessibilityDateLabel;
//# sourceMappingURL=getAccessibilityDateLabel.js.map

@@ -10,3 +10,4 @@ import { useCallback, useMemo, useState } from 'react';

const [selectedMonth, setSelectedMonth] = useState(() => {
const date = !value ? new Date() : value;
// eslint-disable-next-line no-nested-ternary
const date = value ? Array.isArray(value) ? value[0] : value : new Date();
return {

@@ -67,7 +68,16 @@ month: date.getMonth(),

})), ...daysCurMonth.map(date => {
if (value && isSameDay(date, value)) {
return {
type: 'selectedDay',
date
};
if (value) {
const valueArr = Array.isArray(value) ? value : [value];
if (valueArr.some(item => isSameDay(date, item))) {
return {
type: 'selectedDay',
date
};
}
if (Array.isArray(value) && date > value[0] && date < value[1]) {
return {
type: 'dayInRange',
date
};
}
}

@@ -74,0 +84,0 @@ if (isSameDay(date, new Date())) {

import { DatePickerLocale } from './defaultLocale';
declare const getAccessibilityDateLabel: (date: Date, locale: DatePickerLocale) => string;
declare const getAccessibilityDateLabel: (value: Date | [Date, Date], locale: DatePickerLocale) => string;
export default getAccessibilityDateLabel;
//# sourceMappingURL=getAccessibilityDateLabel.d.ts.map
import { SelectedMonth } from './changeMonth';
export interface UseDatePickerCalendarProps {
value?: Date | null;
value?: Date | [Date, Date] | null;
firstDayOfWeek?: 'sunday' | 'monday';

@@ -5,0 +5,0 @@ }

{
"name": "@os-design/date-picker-utils",
"version": "1.0.12",
"version": "1.0.13",
"license": "UNLICENSED",

@@ -34,3 +34,3 @@ "repository": "git@gitlab.com:os-team/libs/os-design.git",

},
"gitHead": "8cb28f6719d699c014fbce91d832a9ff06abe515"
"gitHead": "47a4e8f4442745e2b279b13b84525270cf4a21b0"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc