From eb0e390708735b3b91e882d1b750a6bdc73bca83 Mon Sep 17 00:00:00 2001 From: Alexey Ivanov Date: Fri, 16 Aug 2024 20:06:58 +0300 Subject: [PATCH] [refactor] Replace moment with dayjs --- .storybook/preview.js | 25 +++++++-- package.json | 2 - src/antd-controls/AntdInputDate.tsx | 17 +++--- src/antd-controls/AntdInputTime.tsx | 4 +- src/controls/AntdDateControl.tsx | 17 +++--- src/controls/AntdDateTimeControl.tsx | 19 ++++--- src/controls/query/Filter.tsx | 14 ++--- .../filtersBody/BodyOfDateTimeFilter.tsx | 53 +++++++++++-------- src/formatters/baseFormatters.tsx | 4 +- stories/CardsGridList.stories.tsx | 6 +-- stories/CardsHorizontalScroller.stories.tsx | 6 +-- stories/Form.stories.tsx | 8 +-- stories/FormColumnsAndTable.stories.tsx | 6 +-- stories/FormOverride.stories.tsx | 6 +-- stories/PanelLayout.stories.tsx | 6 +-- stories/PanelWithFlexLayout.stories.tsx | 6 +-- stories/QueryTableMktp.stories.tsx | 6 +-- stories/QueryTreeTableArtifacts.stories.tsx | 6 +-- ...TableRemoteArtifactsCollection.stories.tsx | 6 +-- .../TableRemoteArtifactsModule.stories.tsx | 6 +-- stories/TableRemoteMktp.stories.tsx | 6 +-- .../TableSurroundedBySplitPane.stories.tsx | 10 ++-- stories/TreeAndFormArtifact.stories.tsx | 6 +-- stories/TreeTableFormMktp.stories.tsx | 6 +-- stories/TwoTables.stories.tsx | 6 +-- stories/TwoTablesBig.stories.tsx | 6 +-- tsconfig.json | 1 + yarn.lock | 5 -- 28 files changed, 147 insertions(+), 122 deletions(-) diff --git a/.storybook/preview.js b/.storybook/preview.js index 68a59b2..03412b3 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -1,9 +1,30 @@ import React from 'react'; -import * as moment from 'moment'; +import * as dayjs from 'dayjs'; +import LocalizedFormat from 'dayjs/plugin/localizedFormat'; +import LocaleData from 'dayjs/plugin/localeData'; +import RelativeTime from 'dayjs/plugin/relativeTime'; +import 'dayjs/locale/ru'; + import { ConfigProvider, theme } from 'antd'; import ruRu from 'antd/es/locale/ru_RU'; +dayjs.extend(LocalizedFormat); // for longDateFormat +dayjs.extend(LocaleData); // for localeData() +dayjs.extend(RelativeTime); // for fromNow() + +dayjs.locale('ru'); + +// for dayjs.defaultFormat +// see https://stackoverflow.com/questions/72681674/how-to-set-the-default-format-in-dayjs +const defaultFormat = 'LLL'; +dayjs.extend((option, dayjsClass, dayjsFactory) => { + const oldFormat = dayjsClass.prototype.format; + + dayjsClass.prototype.format = function (formatString) { + return oldFormat.bind(this)(formatString ?? defaultFormat); + }; +}); // https://storybook.js.org/docs/react/writing-stories/parameters#global-parameters export const parameters = { @@ -34,6 +55,4 @@ export const decorators = [ ), ]; -moment.locale('ru'); -moment.defaultFormat = 'LLL'; export const tags = ['autodocs']; diff --git a/package.json b/package.json index 8d01085..dbdec16 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,6 @@ "mobx": ">=6.13.1", "mobx-react-lite": ">=4.0.7", "mobx-state-tree": ">=6.0.1", - "moment": ">=2.30.1", "rc-util": ">=5.43.0", "react": ">=18.3.1", "react-base-table": ">=1.13.0", @@ -98,7 +97,6 @@ "antd": "^5.20.1", "history": "^5.3.0", "mobx-react-lite": "^4.0.7", - "moment": "^2.30.1", "react": "^18.3.1", "react-base-table": "^1.13.0", "react-dnd": "13.1.1", diff --git a/src/antd-controls/AntdInputDate.tsx b/src/antd-controls/AntdInputDate.tsx index 2351450..4271891 100644 --- a/src/antd-controls/AntdInputDate.tsx +++ b/src/antd-controls/AntdInputDate.tsx @@ -7,20 +7,21 @@ * * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ -import moment, { Moment } from 'moment'; +import dayjs, { Dayjs } from 'dayjs'; import React, { useState, useEffect } from 'react'; import { DatePicker } from 'antd'; -export interface DateControl { - momentLocale?: Moment; -} +/*export interface DateControl { + dateLocale?: Dayjs; +}*/ export const AntdInputDate: React.FC = (props) => { const { data, enabled, handleChange, editing, inputRef } = props; const localeDateTimeFormat = 'L'; const [currentData, setCurrentData] = useState(data); - const onChange = (datetime: any) => { - setCurrentData(datetime ? moment(datetime).format(localeDateTimeFormat) : ''); - handleChange(datetime ? moment(datetime).format(localeDateTimeFormat) : ''); + const onChange = (date: Dayjs) => { + const dateNonNullStr = date ? date.format(localeDateTimeFormat) : ''; + setCurrentData(dateNonNullStr); + handleChange(dateNonNullStr); }; useEffect(() => { if (!editing) { @@ -31,7 +32,7 @@ export const AntdInputDate: React.FC = (props) => { handleChange(path, moment(timeString).format('LTS'))} + onChange={(time: Dayjs) => handleChange(path, time ? time.format('LTS') : '')} className={className} disabled={!enabled} /> diff --git a/src/controls/AntdDateControl.tsx b/src/controls/AntdDateControl.tsx index a14338b..24d6b3c 100644 --- a/src/controls/AntdDateControl.tsx +++ b/src/controls/AntdDateControl.tsx @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ -import moment, { Moment } from 'moment'; +import dayjs, { Dayjs } from 'dayjs'; import React, { useState, useEffect } from 'react'; import { DatePicker, Col, Row } from 'antd'; @@ -17,12 +17,12 @@ import { ControlComponent } from '../Form'; import { withStoreToControlProps } from '../util/ContextToProps'; export interface DateControlProps { - momentLocale?: Moment; + dateLocale?: Dayjs; } export const AntdDateControl: React.FC = (props) => { - const { id, label, editing, enabled, required, handleChange, data, momentLocale, uiOptions = {} } = props; + const { id, label, editing, enabled, required, handleChange, data, dateLocale, uiOptions = {} } = props; const defaultLabel = label as string; - const localeDateTimeFormat = momentLocale ? `${momentLocale.localeData().longDateFormat('L')}` : 'YYYY-MM-DD'; + const localeDateTimeFormat = dateLocale ? `${(dateLocale as any).localeData().longDateFormat('L')}` : 'YYYY-MM-DD'; const [currentData, setCurrentData] = useState(data); let labelText; @@ -32,9 +32,10 @@ export const AntdDateControl: React.FC = (p } else { labelText = defaultLabel; } - const onChange = (datetime: any) => { - setCurrentData(datetime ? moment(datetime).format(localeDateTimeFormat) : 'YYYY-MM-DD'); - handleChange(datetime ? moment(datetime).format(localeDateTimeFormat) : 'YYYY-MM-DD'); + const onChange = (date: Dayjs) => { + const dateNonNullStr = date ? date.format(localeDateTimeFormat) : 'YYYY-MM-DD'; + setCurrentData(dateNonNullStr); + handleChange(dateNonNullStr); }; useEffect(() => { if (!editing) { @@ -51,7 +52,7 @@ export const AntdDateControl: React.FC = (p = (props) => { - const { id, label, editing, enabled, required, handleChange, data, momentLocale, uiOptions = {} } = props; + const { id, label, editing, enabled, required, handleChange, data, dateLocale, uiOptions = {} } = props; const defaultLabel = label as string; - const localeDateTimeFormat = momentLocale ? `${momentLocale.localeData().longDateFormat('L')}` : 'YYYY-MM-DD h:mm a'; + const localeDateTimeFormat = dateLocale + ? `${(dateLocale as any).localeData().longDateFormat('L')}` + : 'YYYY-MM-DD h:mm a'; const [currentData, setCurrentData] = useState(data); let labelText; @@ -33,9 +35,10 @@ export const AntdDateTimeControl: React.FC { - setCurrentData(datetime ? moment(datetime).format(localeDateTimeFormat) : 'YYYY-MM-DD h:mm a'); - handleChange(datetime ? moment(datetime).format(localeDateTimeFormat) : 'YYYY-MM-DD h:mm a'); + const onChange = (datetime: Dayjs) => { + const datetimeNonNullStr = datetime ? datetime.format(localeDateTimeFormat) : 'YYYY-MM-DD h:mm a'; + setCurrentData(datetimeNonNullStr); + handleChange(datetimeNonNullStr); }; useEffect(() => { if (!editing) { @@ -52,7 +55,7 @@ export const AntdDateTimeControl: React.FC = ({ if (typeOfFilter.type === 'date-time') { if (equalTypesOfRelations(typeOfCurrentRelation, 'twoDate')) { defaultValue = { - value: [moment().subtract(1, 'days'), moment()], + value: [dayjs().subtract(1, 'days'), dayjs()], valueName: [localeRus.fromYesterdayToToday], }; } else { defaultValue = { - value: [moment()], + value: [dayjs()], valueName: [localeRus.today], }; } @@ -185,7 +185,7 @@ export const Filter: FunctionComponent = ({ defaultValue.valueName = prevFilter.valueName || []; if (typeOfFilter.type === 'date-time') { - defaultValue.value = prevFilter.value.map((value) => moment(value, 'YYYY-MM-DDThh:mm:ss')); + defaultValue.value = prevFilter.value.map((value) => dayjs(value, 'YYYY-MM-DDThh:mm:ss')); } } } diff --git a/src/controls/query/filtersBody/BodyOfDateTimeFilter.tsx b/src/controls/query/filtersBody/BodyOfDateTimeFilter.tsx index 23e96fe..1017eee 100644 --- a/src/controls/query/filtersBody/BodyOfDateTimeFilter.tsx +++ b/src/controls/query/filtersBody/BodyOfDateTimeFilter.tsx @@ -1,7 +1,8 @@ +import dayjs, { Dayjs } from 'dayjs'; import React, { useEffect, useState } from 'react'; import { DatePicker, Select, Radio, InputNumber } from 'antd'; -import moment, { Moment } from 'moment'; import { RadioChangeEvent } from 'antd/es/radio'; + import { ValueOfFilter } from '../type'; const localeRus = { @@ -29,7 +30,7 @@ export const BodyOfDateTimeFilter: React.FC = ({ hand useEffect(() => { let newValue: any = {}; if (firstValueInThreeVariant && secondValueInThreeVariant) { - let timeOption: moment.unitOfTime.DurationConstructor = 'days'; + let timeOption: dayjs.ManipulateType = 'days'; if (secondValueInThreeVariant.localeCompare(timeValue[0]) === 0) { timeOption = 'days'; } else if (secondValueInThreeVariant.localeCompare(timeValue[1]) === 0) { @@ -37,11 +38,10 @@ export const BodyOfDateTimeFilter: React.FC = ({ hand } else if (secondValueInThreeVariant.localeCompare(timeValue[2]) === 0) { timeOption = 'years'; } - const date = moment().subtract(firstValueInThreeVariant, timeOption); - const foundDate = date.format('YYYY-MM-DD'); + const foundDate = dayjs().subtract(parseInt(firstValueInThreeVariant), timeOption).format('YYYY-MM-DD'); newValue = { value: [`${foundDate}T00:00:00`], - valueName: [moment(foundDate, 'YYYY-MM-DD').fromNow()], + valueName: [(dayjs(foundDate, 'YYYY-MM-DD') as any).fromNow()], }; } else { newValue = { value: [], valueName: [] }; @@ -54,16 +54,14 @@ export const BodyOfDateTimeFilter: React.FC = ({ hand const { value } = e.target; setCheckedOption(value); if (value === 1) { - const date = moment(); - const today = `${date.format('YYYY-MM-DD')}T00:00:00`; + const today = `${dayjs().format('YYYY-MM-DD')}T00:00:00`; handleChange({ value: [today], valueName: [localeRus.today] }); } else if (value === 2) { - const date = moment().subtract(1, 'days'); - const yesterday = `${date.format('YYYY-MM-DD')}T00:00:00`; + const yesterday = `${dayjs().subtract(1, 'days').format('YYYY-MM-DD')}T00:00:00`; handleChange({ value: [yesterday], valueName: [localeRus.yesterday] }); } else if (value === 3) { if (firstValueInThreeVariant && secondValueInThreeVariant) { - let timeOption: moment.unitOfTime.DurationConstructor = 'days'; + let timeOption: dayjs.ManipulateType = 'days'; if (secondValueInThreeVariant.localeCompare(timeValue[0]) === 0) { timeOption = 'days'; } else if (secondValueInThreeVariant.localeCompare(timeValue[1]) === 0) { @@ -71,12 +69,10 @@ export const BodyOfDateTimeFilter: React.FC = ({ hand } else if (secondValueInThreeVariant.localeCompare(timeValue[2]) === 0) { timeOption = 'years'; } - const date = moment().subtract(firstValueInThreeVariant, timeOption); - const foundDate = date.format('YYYY-MM-DD'); - + const foundDate = dayjs().subtract(parseInt(firstValueInThreeVariant), timeOption).format('YYYY-MM-DD'); handleChange({ value: [`${foundDate}T00:00:00`], - valueName: [moment(foundDate, 'YYYY-MM-DD').fromNow()], + valueName: [(dayjs(foundDate, 'YYYY-MM-DD') as any).fromNow()], }); } else { handleChange({ value: [], valueName: [] }); @@ -90,12 +86,17 @@ export const BodyOfDateTimeFilter: React.FC = ({ hand return ( { handleChange({ - value: dateString === '' ? [] : [moment(dateString, moment.defaultFormat).format('YYYY-MM-DDThh:mm:ss')], + value: + dateString === '' + ? [] + : Array.isArray(dateString) + ? [] + : [dayjs(dateString, (dayjs as any).defaultFormat).format('YYYY-MM-DDThh:mm:ss')], valueName: [dateString], }); }} @@ -149,12 +150,16 @@ export const BodyOfDateTimeFilter: React.FC = ({ hand { handleChange({ value: - dateString === '' ? [] : [moment(dateString, moment.defaultFormat).format('YYYY-MM-DDThh:mm:ss')], + dateString === '' + ? [] + : Array.isArray(dateString) + ? [] + : [dayjs(dateString, (dayjs as any).defaultFormat).format('YYYY-MM-DDThh:mm:ss')], valueName: [], }); }} @@ -170,14 +175,16 @@ export const BodyOfDateTimeFilter: React.FC = ({ hand { handleChange({ value: dateString[0] === '' || dateString[1] === '' ? [] - : dateString.map((rangeDate) => moment(rangeDate, moment.defaultFormat).format('YYYY-MM-DDThh:mm:ss')), + : dateString.map((rangeDate) => + dayjs(rangeDate, (dayjs as any).defaultFormat).format('YYYY-MM-DDThh:mm:ss'), + ), valueName: [], }); }} diff --git a/src/formatters/baseFormatters.tsx b/src/formatters/baseFormatters.tsx index 889dcbf..bf3aa1a 100644 --- a/src/formatters/baseFormatters.tsx +++ b/src/formatters/baseFormatters.tsx @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ -import moment from 'moment'; +import dayjs from 'dayjs'; import React from 'react'; import { Link } from 'react-router-dom'; import { Image } from 'antd'; @@ -76,7 +76,7 @@ export const artifactTitle = ({ value, type }: any): JSX.Element => { ); }; -export const dateTime = ({ value }: any): JSX.Element => {moment(value).format('DD.MM.YYYY')}; +export const dateTime = ({ value }: any): JSX.Element => {dayjs(value).format('DD.MM.YYYY')}; export const link = ({ value, link, options }: any): JSX.Element => { const label = options.label || value || link; diff --git a/stories/CardsGridList.stories.tsx b/stories/CardsGridList.stories.tsx index 344ca6e..cfcde80 100644 --- a/stories/CardsGridList.stories.tsx +++ b/stories/CardsGridList.stories.tsx @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ -import moment from 'moment'; +import dayjs from 'dayjs'; import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; @@ -333,7 +333,7 @@ const additionalColls: CollState[] = [ data: viewKinds, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // disable data loading from the server for viewKinds.collConstrs }, }, @@ -343,7 +343,7 @@ const additionalColls: CollState[] = [ data: viewDescrs, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // 'true' here (by default) triggers data loading from the server // for viewDescrs.collConstrs (it loads lazily -- after the first access) }, diff --git a/stories/CardsHorizontalScroller.stories.tsx b/stories/CardsHorizontalScroller.stories.tsx index 4e7ee1f..7728167 100644 --- a/stories/CardsHorizontalScroller.stories.tsx +++ b/stories/CardsHorizontalScroller.stories.tsx @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ -import moment from 'moment'; +import dayjs from 'dayjs'; import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; @@ -330,7 +330,7 @@ const additionalColls: CollState[] = [ data: viewKinds, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // disable data loading from the server for viewKinds.collConstrs }, }, @@ -340,7 +340,7 @@ const additionalColls: CollState[] = [ data: viewDescrs, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // 'true' here (by default) triggers data loading from the server // for viewDescrs.collConstrs (it loads lazily -- after the first access) }, diff --git a/stories/Form.stories.tsx b/stories/Form.stories.tsx index 0255526..363036b 100644 --- a/stories/Form.stories.tsx +++ b/stories/Form.stories.tsx @@ -8,7 +8,7 @@ * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ import { cloneDeep } from 'lodash-es'; -import moment from 'moment'; +import dayjs from 'dayjs'; import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; @@ -141,7 +141,7 @@ const createAdditionalColls = (viewKinds: any, data: JsObject[] | undefined): Co data: viewKinds, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // disable data loading from the server for viewKinds.collConstrs }, }, @@ -151,7 +151,7 @@ const createAdditionalColls = (viewKinds: any, data: JsObject[] | undefined): Co data: viewDescrs, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // 'true' here (by default) triggers data loading from the server // for viewDescrs.collConstrs (it loads lazily -- after the first access) }, @@ -163,7 +163,7 @@ const createAdditionalColls = (viewKinds: any, data: JsObject[] | undefined): Co data, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // 'true' here (by default) triggers data loading from the server // for viewDescrs.collConstrs (it loads lazily -- after the first access) }, diff --git a/stories/FormColumnsAndTable.stories.tsx b/stories/FormColumnsAndTable.stories.tsx index 457374a..12e28ff 100644 --- a/stories/FormColumnsAndTable.stories.tsx +++ b/stories/FormColumnsAndTable.stories.tsx @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ -import moment from 'moment'; +import dayjs from 'dayjs'; import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; @@ -565,7 +565,7 @@ const additionalColls: CollState[] = [ data: viewKinds, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // disable data loading from the server for viewKinds.collConstrs }, }, @@ -575,7 +575,7 @@ const additionalColls: CollState[] = [ data: viewDescrs, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // 'true' here (by default) triggers data loading from the server // for viewDescrs.collConstrs (it loads lazily -- after the first access) }, diff --git a/stories/FormOverride.stories.tsx b/stories/FormOverride.stories.tsx index 2080a13..569ed7d 100644 --- a/stories/FormOverride.stories.tsx +++ b/stories/FormOverride.stories.tsx @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ -import moment from 'moment'; +import dayjs from 'dayjs'; import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; @@ -149,7 +149,7 @@ const additionalColls: CollState[] = [ data: viewKinds, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // disable data loading from the server for viewKinds.collConstrs }, }, @@ -159,7 +159,7 @@ const additionalColls: CollState[] = [ data: viewDescrs, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // 'true' here (by default) triggers data loading from the server // for viewDescrs.collConstrs (it loads lazily -- after the first access) }, diff --git a/stories/PanelLayout.stories.tsx b/stories/PanelLayout.stories.tsx index ca0f6aa..fd71367 100644 --- a/stories/PanelLayout.stories.tsx +++ b/stories/PanelLayout.stories.tsx @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ -import moment from 'moment'; +import dayjs from 'dayjs'; import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; @@ -233,7 +233,7 @@ const additionalColls: CollState[] = [ data: viewKinds, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // disable data loading from the server for viewKinds.collConstrs }, }, @@ -243,7 +243,7 @@ const additionalColls: CollState[] = [ data: viewDescrs, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // 'true' here (by default) triggers data loading from the server // for viewDescrs.collConstrs (it loads lazily -- after the first access) }, diff --git a/stories/PanelWithFlexLayout.stories.tsx b/stories/PanelWithFlexLayout.stories.tsx index 9a264a7..db6c3c2 100644 --- a/stories/PanelWithFlexLayout.stories.tsx +++ b/stories/PanelWithFlexLayout.stories.tsx @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ -import moment from 'moment'; +import dayjs from 'dayjs'; import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; @@ -245,7 +245,7 @@ const additionalColls: CollState[] = [ data: viewKinds, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // disable data loading from the server for viewKinds.collConstrs }, }, @@ -255,7 +255,7 @@ const additionalColls: CollState[] = [ data: viewDescrs, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // 'true' here (by default) triggers data loading from the server // for viewDescrs.collConstrs (it loads lazily -- after the first access) }, diff --git a/stories/QueryTableMktp.stories.tsx b/stories/QueryTableMktp.stories.tsx index 5aea15f..1a9eb5e 100644 --- a/stories/QueryTableMktp.stories.tsx +++ b/stories/QueryTableMktp.stories.tsx @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ -import moment from 'moment'; +import dayjs from 'dayjs'; import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; @@ -213,7 +213,7 @@ const additionalColls: CollState[] = [ data: viewKinds, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // disable data loading from the server for viewKinds.collConstrs }, }, @@ -223,7 +223,7 @@ const additionalColls: CollState[] = [ data: viewDescrs, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // 'true' here (by default) triggers data loading from the server // for viewDescrs.collConstrs (it loads lazily -- after the first access) }, diff --git a/stories/QueryTreeTableArtifacts.stories.tsx b/stories/QueryTreeTableArtifacts.stories.tsx index 7a270b4..a86e709 100644 --- a/stories/QueryTreeTableArtifacts.stories.tsx +++ b/stories/QueryTreeTableArtifacts.stories.tsx @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ -import moment from 'moment'; +import dayjs from 'dayjs'; import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; @@ -371,7 +371,7 @@ const additionalColls: CollState[] = [ data: viewKinds, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // disable data loading from the server for viewKinds.collConstrs }, }, @@ -381,7 +381,7 @@ const additionalColls: CollState[] = [ data: viewDescrs, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // 'true' here (by default) triggers data loading from the server // for viewDescrs.collConstrs (it loads lazily -- after the first access) }, diff --git a/stories/TableRemoteArtifactsCollection.stories.tsx b/stories/TableRemoteArtifactsCollection.stories.tsx index ebf4d33..cb158f9 100644 --- a/stories/TableRemoteArtifactsCollection.stories.tsx +++ b/stories/TableRemoteArtifactsCollection.stories.tsx @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ -import moment from 'moment'; +import dayjs from 'dayjs'; import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; @@ -235,7 +235,7 @@ const additionalColls: CollState[] = [ data: viewKinds, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // disable data loading from the server for viewKinds.collConstrs }, }, @@ -245,7 +245,7 @@ const additionalColls: CollState[] = [ data: viewDescrs, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // 'true' here (by default) triggers data loading from the server // for viewDescrs.collConstrs (it loads lazily -- after the first access) }, diff --git a/stories/TableRemoteArtifactsModule.stories.tsx b/stories/TableRemoteArtifactsModule.stories.tsx index 821ce71..c49d8ec 100644 --- a/stories/TableRemoteArtifactsModule.stories.tsx +++ b/stories/TableRemoteArtifactsModule.stories.tsx @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ -import moment from 'moment'; +import dayjs from 'dayjs'; import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; @@ -327,7 +327,7 @@ const additionalColls: CollState[] = [ data: viewKinds, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // disable data loading from the server for viewKinds.collConstrs }, }, @@ -337,7 +337,7 @@ const additionalColls: CollState[] = [ data: viewDescrs, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // 'true' here (by default) triggers data loading from the server // for viewDescrs.collConstrs (it loads lazily -- after the first access) }, diff --git a/stories/TableRemoteMktp.stories.tsx b/stories/TableRemoteMktp.stories.tsx index b0880f9..bfd4bac 100644 --- a/stories/TableRemoteMktp.stories.tsx +++ b/stories/TableRemoteMktp.stories.tsx @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ -import moment from 'moment'; +import dayjs from 'dayjs'; import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; @@ -194,7 +194,7 @@ const additionalColls: CollState[] = [ data: viewKinds, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // disable data loading from the server for viewKinds.collConstrs }, }, @@ -204,7 +204,7 @@ const additionalColls: CollState[] = [ data: viewDescrs, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // 'true' here (by default) triggers data loading from the server // for viewDescrs.collConstrs (it loads lazily -- after the first access) }, diff --git a/stories/TableSurroundedBySplitPane.stories.tsx b/stories/TableSurroundedBySplitPane.stories.tsx index 4b9be36..f153f06 100644 --- a/stories/TableSurroundedBySplitPane.stories.tsx +++ b/stories/TableSurroundedBySplitPane.stories.tsx @@ -7,9 +7,9 @@ * * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ -import moment from 'moment'; +import dayjs from 'dayjs'; import React from 'react'; -import { Meta, Story } from '@storybook/react'; +import { Meta, StoryObj } from '@storybook/react'; import { Provider } from 'react-redux'; import { asReduxStore, connectReduxDevtools } from 'mst-middlewares'; @@ -51,7 +51,7 @@ const Template: Story = (args: any) => { ); const rootStore = createUiModelFromState('mktp-fed', client, rootModelInitialState, args.additionalColls); const store: any = asReduxStore(rootStore); - // eslint-disable-next-line @typescript-eslint/no-var-requires + connectReduxDevtools(require('remotedev'), rootStore); return (
@@ -430,7 +430,7 @@ const additionalColls: CollState[] = [ data: viewKinds, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // disable data loading from the server for viewKinds.collConstrs }, }, @@ -440,7 +440,7 @@ const additionalColls: CollState[] = [ data: viewDescrs, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // 'true' here (by default) triggers data loading from the server // for viewDescrs.collConstrs (it loads lazily -- after the first access) }, diff --git a/stories/TreeAndFormArtifact.stories.tsx b/stories/TreeAndFormArtifact.stories.tsx index e164715..c67db16 100644 --- a/stories/TreeAndFormArtifact.stories.tsx +++ b/stories/TreeAndFormArtifact.stories.tsx @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ -import moment from 'moment'; +import dayjs from 'dayjs'; import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; @@ -174,7 +174,7 @@ const additionalColls: CollState[] = [ data: viewKinds, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // disable data loading from the server for viewKinds.collConstrs }, }, @@ -184,7 +184,7 @@ const additionalColls: CollState[] = [ data: viewDescrs, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // 'true' here (by default) triggers data loading from the server // for viewDescrs.collConstrs (it loads lazily -- after the first access) }, diff --git a/stories/TreeTableFormMktp.stories.tsx b/stories/TreeTableFormMktp.stories.tsx index f53d677..3c319aa 100644 --- a/stories/TreeTableFormMktp.stories.tsx +++ b/stories/TreeTableFormMktp.stories.tsx @@ -8,7 +8,7 @@ * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ import { cloneDeep } from 'lodash-es'; -import moment from 'moment'; +import dayjs from 'dayjs'; import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; @@ -451,7 +451,7 @@ const additionalColls: CollState[] = [ data: viewKinds, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // disable data loading from the server for viewKinds.collConstrs }, }, @@ -461,7 +461,7 @@ const additionalColls: CollState[] = [ data: viewDescrs, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // 'true' here (by default) triggers data loading from the server // for viewDescrs.collConstrs (it loads lazily -- after the first access) }, diff --git a/stories/TwoTables.stories.tsx b/stories/TwoTables.stories.tsx index decfab2..5b20874 100644 --- a/stories/TwoTables.stories.tsx +++ b/stories/TwoTables.stories.tsx @@ -8,7 +8,7 @@ * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ import { cloneDeep } from 'lodash-es'; -import moment from 'moment'; +import dayjs from 'dayjs'; import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; @@ -723,7 +723,7 @@ const additionalColls: CollState[] = [ data: viewKinds, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // disable data loading from the server for viewKinds.collConstrs }, }, @@ -733,7 +733,7 @@ const additionalColls: CollState[] = [ data: viewDescrs, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // 'true' here (by default) triggers data loading from the server // for viewDescrs.collConstrs (it loads lazily -- after the first access) }, diff --git a/stories/TwoTablesBig.stories.tsx b/stories/TwoTablesBig.stories.tsx index 96e6415..95e1b7c 100644 --- a/stories/TwoTablesBig.stories.tsx +++ b/stories/TwoTablesBig.stories.tsx @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ -import moment from 'moment'; +import dayjs from 'dayjs'; import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; @@ -654,7 +654,7 @@ const additionalColls: CollState[] = [ data: viewKinds, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // disable data loading from the server for viewKinds.collConstrs }, }, @@ -664,7 +664,7 @@ const additionalColls: CollState[] = [ data: viewDescrs, opt: { updPeriod: undefined, - lastSynced: moment.now(), + lastSynced: dayjs().valueOf(), //resolveCollConstrs: false, // 'true' here (by default) triggers data loading from the server // for viewDescrs.collConstrs (it loads lazily -- after the first access) }, diff --git a/tsconfig.json b/tsconfig.json index cd4b8aa..d02d614 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -31,6 +31,7 @@ "jsx": "react", // interop between ESM and CJS modules. Recommended by TS "esModuleInterop": true, + "allowSyntheticDefaultImports": true, "isolatedModules": true, // significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS "skipLibCheck": true, diff --git a/yarn.lock b/yarn.lock index 1b4c7fe..c594b2c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8657,11 +8657,6 @@ mobx@^6.13.1: resolved "https://registry.yarnpkg.com/mobx/-/mobx-6.13.1.tgz#76c41aa675199f75b84a257e4bec8ff839e33259" integrity sha512-ekLRxgjWJr8hVxj9ZKuClPwM/iHckx3euIJ3Np7zLVNtqJvfbbq7l370W/98C8EabdQ1pB5Jd3BbDWxJPNnaOg== -moment@^2.30.1: - version "2.30.1" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae" - integrity sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how== - ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"