@homecode/ui 4.22.14 → 4.22.16

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.
@@ -1,7 +1,9 @@
1
1
  function dateToString(date) {
2
- return `${date.year}-${date.month}-${date.day}`;
2
+ const month = String(date.month).padStart(2, '0');
3
+ const day = String(date.day).padStart(2, '0');
4
+ return `${date.year}-${month}-${day}`;
3
5
  }
4
- function strigToDate(dateString) {
6
+ function stringToDate(dateString) {
5
7
  const [year, month, day] = dateString.split('-');
6
8
  return {
7
9
  year: Number(year),
@@ -28,4 +30,4 @@ function isDateBetween(date, startDate, endDate) {
28
30
  return isDateAfter(date, startDate) && isDateBefore(date, endDate);
29
31
  }
30
32
 
31
- export { dateToString, isDateAfter, isDateBefore, isDateBetween, isDateEqual, strigToDate };
33
+ export { dateToString, isDateAfter, isDateBefore, isDateBetween, isDateEqual, stringToDate };
@@ -3,7 +3,7 @@ import { useState, useCallback, createElement } from 'react';
3
3
  import cn from 'classnames';
4
4
  import { Calendar } from '../Calendar/Calendar.js';
5
5
  import { Button } from '../Button/Button.js';
6
- import { dateToString, isDateAfter, strigToDate, isDateBetween, isDateEqual } from './DatePicker.helpers.js';
6
+ import { dateToString, isDateAfter, stringToDate, isDateBetween, isDateEqual } from './DatePicker.helpers.js';
7
7
  import S from './DatePicker.styl.js';
8
8
 
9
9
  function DatePicker(props) {
@@ -21,7 +21,7 @@ function DatePicker(props) {
21
21
  const valStr = dateToString(val);
22
22
  if (isRange && isPicking) {
23
23
  props.onPointerOver = () => {
24
- const newVal = isDateAfter(strigToDate(value[0]), val)
24
+ const newVal = isDateAfter(stringToDate(value[0]), val)
25
25
  ? [valStr, value[0]]
26
26
  : [value[0], valStr];
27
27
  onChange(newVal);
@@ -29,8 +29,8 @@ function DatePicker(props) {
29
29
  }
30
30
  const classes = [className, S.day];
31
31
  if (isRange) {
32
- const from = strigToDate(value[0]);
33
- const to = strigToDate(value[1]);
32
+ const from = stringToDate(value[0]);
33
+ const to = stringToDate(value[1]);
34
34
  if (isDateBetween(val, from, to))
35
35
  classes.push(S.between);
36
36
  if (isDateEqual(val, from))
@@ -41,7 +41,7 @@ function DatePicker(props) {
41
41
  return (createElement(Button, { ...props, variant: "clear", className: cn(classes), size: size, key: `${year}-${month}-${day}` }, day));
42
42
  }, [size, isPicking, isRange, value, onChange]);
43
43
  calendarProps.className = cn(calendarProps.className, S.calendar);
44
- return (jsxs("div", { className: cn(S.root, doubleCalendar && S.doubleCalendar, props.className), onPointerDown: onPointerDown, onPointerUp: onPointerUp, children: [jsx(Calendar, { size: size, hideOtherMonthDays: isRange, ...calendarProps, renderDay: renderDay, value: strigToDate(isRange ? value[0] : value), onDayPointerDown: onFirstDateChange, onDayPointerUp: undefined }), isRange && doubleCalendar && (jsx(Calendar, { size: size, hideOtherMonthDays: isRange, ...calendarProps, renderDay: renderDay, value: strigToDate(value[1]), onDayPointerDown: val => onChange([value[0], dateToString(val)]), onDayPointerUp: val => onChange([value[0], dateToString(val)]) }))] }));
44
+ return (jsxs("div", { className: cn(S.root, doubleCalendar && S.doubleCalendar, props.className), onPointerDown: onPointerDown, onPointerUp: onPointerUp, children: [jsx(Calendar, { size: size, hideOtherMonthDays: isRange, ...calendarProps, renderDay: renderDay, value: stringToDate(isRange ? value[0] : value), onDayPointerDown: onFirstDateChange, onDayPointerUp: undefined }), isRange && doubleCalendar && (jsx(Calendar, { size: size, hideOtherMonthDays: isRange, ...calendarProps, renderDay: renderDay, value: stringToDate(value[1]), onDayPointerDown: val => onChange([value[0], dateToString(val)]), onDayPointerUp: val => onChange([value[0], dateToString(val)]) }))] }));
45
45
  }
46
46
 
47
47
  export { DatePicker };
@@ -12,7 +12,7 @@ function DatePickerInput(props) {
12
12
  const isRange = Array.isArray(value);
13
13
  return (jsx(Popup, { size: size, focusControl: true, direction: "bottom-right", ...popupProps, trigger:
14
14
  // @ts-ignore
15
- jsx(Button, { variant: variant, size: size, children: isRange ? (jsxs(Fragment, { children: [jsx(DateTime, { value: strToDate(value[0]), format: displayFormat }), ' - ', jsx(DateTime, { value: strToDate(value[1]), format: displayFormat })] })) : (jsx(DateTime, { value: strToDate(value), format: displayFormat })) }), contentProps: {
15
+ jsx(Button, { variant: variant, size: size, ...buttonProps, children: isRange ? (jsxs(Fragment, { children: [jsx(DateTime, { value: strToDate(value[0]), format: displayFormat }), ' - ', jsx(DateTime, { value: strToDate(value[1]), format: displayFormat })] })) : (jsx(DateTime, { value: strToDate(value), format: displayFormat })) }), contentProps: {
16
16
  className: cn(S.popupContent, props.doubleCalendar && S.doubleCalendar, S[`size-${size}`], popupProps?.contentProps?.className),
17
17
  }, content: jsx(DatePicker, { ...props, className: S.content, calendarProps: { className: S.calendar } }) }));
18
18
  }
@@ -1,6 +1,6 @@
1
1
  import type { Date } from 'uilib/types';
2
2
  export declare function dateToString(date: Date): string;
3
- export declare function strigToDate(dateString: string): {
3
+ export declare function stringToDate(dateString: string): {
4
4
  year: number;
5
5
  month: number;
6
6
  day: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homecode/ui",
3
- "version": "4.22.14",
3
+ "version": "4.22.16",
4
4
  "description": "React UI components library",
5
5
  "scripts": {
6
6
  "test": "jest",