diff --git a/db-viewer-ui/package.json b/db-viewer-ui/package.json index 13d3ef1..328cd71 100644 --- a/db-viewer-ui/package.json +++ b/db-viewer-ui/package.json @@ -47,7 +47,7 @@ "react-router-dom": ">=6 <7" }, "dependencies": { - "@skbkontur/edi-ui": "^0.2.2", + "@skbkontur/edi-ui": "^0.2.3", "@skbkontur/react-stack-layout": "^1.0.3", "@skbkontur/react-ui-validations": "^1.8.3", "date-fns": "^2.29.1", diff --git a/db-viewer-ui/src/Components/DateTimeRangePicker/DatePicker.tsx b/db-viewer-ui/src/Components/DateTimeRangePicker/DatePicker.tsx index e579ece..ae84f02 100644 --- a/db-viewer-ui/src/Components/DateTimeRangePicker/DatePicker.tsx +++ b/db-viewer-ui/src/Components/DateTimeRangePicker/DatePicker.tsx @@ -1,4 +1,4 @@ -import { RussianDateFormat, parseDate, Time, TimeZone, TimeUtils, StringUtils, formatDate } from "@skbkontur/edi-ui"; +import { RussianDateFormat, Time, TimeZone, TimeUtils, StringUtils, DateUtils } from "@skbkontur/edi-ui"; import { DatePicker as DefaultDatePicker } from "@skbkontur/react-ui"; import React from "react"; @@ -83,8 +83,8 @@ export class DatePicker extends React.Component { const { timeZone } = this.props; - const date = parseDate(newStringifiedDate); - const ISODate = formatDate(date, "yyyy-MM-dd"); + const date = DateUtils.parseDate(newStringifiedDate); + const ISODate = DateUtils.formatDate(date, "yyyy-MM-dd"); const time = this.props.defaultTime || defaultTime; const timeZoneOffset = TimeUtils.getTimeZoneOffsetOrDefault(timeZone); return new Date(`${ISODate}T${time}${TimeUtils.timeZoneOffsetToString(timeZoneOffset)}`); @@ -92,6 +92,6 @@ export class DatePicker extends React.Component, timeZone?: number) => { const timeZoneOffset = TimeUtils.getTimeZoneOffsetOrDefault(timeZone); - return date ? formatDate(date, "dd.MM.yyyy", timeZoneOffset) : ""; + return date ? DateUtils.formatDate(date, "dd.MM.yyyy", timeZoneOffset) : ""; }; } diff --git a/db-viewer-ui/src/Components/DateTimeRangePicker/DateTimePicker.tsx b/db-viewer-ui/src/Components/DateTimeRangePicker/DateTimePicker.tsx index 9a6d484..c67128e 100644 --- a/db-viewer-ui/src/Components/DateTimeRangePicker/DateTimePicker.tsx +++ b/db-viewer-ui/src/Components/DateTimeRangePicker/DateTimePicker.tsx @@ -1,4 +1,4 @@ -import { Time, TimeZone, TimeUtils, formatDate } from "@skbkontur/edi-ui"; +import { Time, TimeZone, TimeUtils, DateUtils } from "@skbkontur/edi-ui"; import React from "react"; import { DatePicker } from "./DatePicker"; @@ -31,7 +31,7 @@ export function DateTimePicker({ } const timeZoneOffset = TimeUtils.getTimeZoneOffsetOrDefault(timeZone); - const date = formatDate(value, "yyyy-MM-dd", timeZoneOffset); + const date = DateUtils.formatDate(value, "yyyy-MM-dd", timeZoneOffset); const newDateTime = new Date(`${date}T${newTime}${TimeUtils.timeZoneOffsetToString(timeZoneOffset)}`); onChange(newDateTime); }; @@ -42,7 +42,7 @@ export function DateTimePicker({ } const timeZoneOffset = TimeUtils.getTimeZoneOffsetOrDefault(timeZone); - const time = formatDate(date, "HH:mm", timeZoneOffset); + const time = DateUtils.formatDate(date, "HH:mm", timeZoneOffset); setTime(time); }; diff --git a/db-viewer-ui/src/Components/DateTimeRangePicker/DateTimePickerWithTimeZone.tsx b/db-viewer-ui/src/Components/DateTimeRangePicker/DateTimePickerWithTimeZone.tsx index 670fdc8..92c53ef 100644 --- a/db-viewer-ui/src/Components/DateTimeRangePicker/DateTimePickerWithTimeZone.tsx +++ b/db-viewer-ui/src/Components/DateTimeRangePicker/DateTimePickerWithTimeZone.tsx @@ -1,4 +1,4 @@ -import { formatDate, fromLocalToUtc, Time } from "@skbkontur/edi-ui"; +import { DateUtils, Time } from "@skbkontur/edi-ui"; import { Select } from "@skbkontur/react-ui"; import React, { useState, useEffect } from "react"; @@ -38,7 +38,7 @@ export const DateTimePickerWithTimeZone = ({ onChange(null); return; } - const date = formatDate(newDate, "yyyy-MM-dd", 0); + const date = DateUtils.formatDate(newDate, "yyyy-MM-dd", 0); const newDateTime = `${date}T${newTime ?? defaultTime}${newOffset ?? ""}`; onChange(newDateTime); }; @@ -50,8 +50,8 @@ export const DateTimePickerWithTimeZone = ({ const timeOffset = getTimeZoneString(dateStr); setOffset(timeOffset); const dateTimeWithoutTimezone = timeOffset ? dateStr.slice(0, -timeOffset.length) : dateStr; - setDate(fromLocalToUtc(new Date(dateTimeWithoutTimezone))); - setTime(formatDate(dateTimeWithoutTimezone, "HH:mm:ss.SSS")); + setDate(DateUtils.fromLocalToUtc(new Date(dateTimeWithoutTimezone))); + setTime(DateUtils.formatDate(dateTimeWithoutTimezone, "HH:mm:ss.SSS")); }; const getTimeZoneString = (date: string): Nullable => { diff --git a/db-viewer-ui/src/Components/DateTimeRangePicker/TimePicker.tsx b/db-viewer-ui/src/Components/DateTimeRangePicker/TimePicker.tsx index 9787501..f49b1b9 100644 --- a/db-viewer-ui/src/Components/DateTimeRangePicker/TimePicker.tsx +++ b/db-viewer-ui/src/Components/DateTimeRangePicker/TimePicker.tsx @@ -1,4 +1,4 @@ -import { Time } from "@skbkontur/edi-ui"; +import { Time, TimeUtils } from "@skbkontur/edi-ui"; import { Input } from "@skbkontur/react-ui"; import React, { useEffect, useState } from "react"; @@ -39,10 +39,9 @@ export const TimePicker = ({ setValue(value); }; - const isCorrectTime = (time: string) => Boolean(time.match(/^([01]?[0-9]|2[0-3]):[0-5][0-9]/)); const handleBlur = () => { const trimmed = value.endsWith(".") || value.endsWith(":") ? value.slice(0, -1) : value; - if (isCorrectTime(trimmed)) { + if (TimeUtils.isCorrectTime(trimmed)) { onChange(trimmed); if (defaultTime === trimmed) { setValue(emptyValue); @@ -54,7 +53,7 @@ export const TimePicker = ({ }; const handleFocus = () => { - if (!isCorrectTime(value)) { + if (!TimeUtils.isCorrectTime(value)) { setValue(defaultTime); } }; diff --git a/db-viewer-ui/yarn.lock b/db-viewer-ui/yarn.lock index 4f2b81d..e362e28 100644 --- a/db-viewer-ui/yarn.lock +++ b/db-viewer-ui/yarn.lock @@ -2299,7 +2299,7 @@ __metadata: version: 0.0.0-use.local resolution: "@skbkontur/db-viewer-ui@workspace:." dependencies: - "@skbkontur/edi-ui": "npm:^0.2.2" + "@skbkontur/edi-ui": "npm:^0.2.3" "@skbkontur/icons": "npm:^1.7.3" "@skbkontur/react-selenium-testing": "npm:^0.2.1" "@skbkontur/react-stack-layout": "npm:^1.0.3" @@ -2346,9 +2346,9 @@ __metadata: languageName: unknown linkType: soft -"@skbkontur/edi-ui@npm:^0.2.2": - version: 0.2.2 - resolution: "@skbkontur/edi-ui@npm:0.2.2" +"@skbkontur/edi-ui@npm:^0.2.3": + version: 0.2.3 + resolution: "@skbkontur/edi-ui@npm:0.2.3" dependencies: "@skbkontur/colors": "npm:0.4.4" "@skbkontur/icons": "npm:1.10.0" @@ -2362,7 +2362,7 @@ __metadata: "@skbkontur/react-ui": ">=4" react: ">=16 <=18" react-dom: ">=16 <=18" - checksum: fdeb778443a969cf8f66ea600d46d664bc2d2543dd9763361579067087ff3d41ff15e15cd2d0da24cf063313ca84fe9d058bbb523601bcb92cde81a1d99a155a + checksum: 98b20235ecd51367140c419929aafffaaac526f1d4dcc47890a0849243d1398dc00215331eca8d84d7d1f86117f7580d964650c6624c1731f6424ed7669ab780 languageName: node linkType: hard