@moysklad/uikit 30.4.0 → 31.20.0
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.
- package/README.md +9 -4
- package/dist/colorVariables.css +23 -1
- package/dist/components/AutoComplete/AutoComplete.js +2 -2
- package/dist/components/BentoBlock/BentoBlock.d.ts +15 -0
- package/dist/components/BentoBlock/BentoBlock.js +20 -0
- package/dist/components/BentoBlock/BentoBlock.module.js +9 -0
- package/dist/components/BentoBlock/BentoBlock_module.css +50 -0
- package/dist/components/BentoBlock/consts.d.ts +14 -0
- package/dist/components/BentoBlock/consts.js +15 -0
- package/dist/components/Button/Button.d.ts +5 -2
- package/dist/components/Button/Button.js +28 -19
- package/dist/components/Button/Button_module.css +16 -14
- package/dist/components/Checkbox/Checkbox.js +1 -1
- package/dist/components/DateRange/ArrowButton/ArrowButton.module.js +6 -0
- package/dist/components/DateRange/ArrowButton/ArrowButton_module.css +26 -0
- package/dist/components/DateRange/ArrowButton/index.d.ts +8 -0
- package/dist/components/DateRange/ArrowButton/index.js +23 -0
- package/dist/components/DateRange/Calendar/index.d.ts +12 -0
- package/dist/components/DateRange/Calendar/index.js +22 -0
- package/dist/components/DateRange/DateRange.d.ts +6 -0
- package/dist/components/DateRange/DateRange.js +51 -0
- package/dist/components/DateRange/DateRangeDefaultTrigger/DateRangeDefaultTrigger.d.ts +44 -0
- package/dist/components/DateRange/DateRangeDefaultTrigger/DateRangeDefaultTrigger.js +128 -0
- package/dist/components/DateRange/DateRangeDefaultTrigger/DateRangeDefaultTrigger.module.js +19 -0
- package/dist/components/DateRange/DateRangeDefaultTrigger/DateRangeDefaultTrigger_module.css +170 -0
- package/dist/components/DateRange/DateRangeDefaultTrigger.module.js +12 -0
- package/dist/components/DateRange/DateRangeDefaultTrigger_module.css +43 -0
- package/dist/components/DateRange/DateRangeInput/DateRangeInput.d.ts +4 -0
- package/dist/components/DateRange/DateRangeInput/DateRangeInput.js +69 -0
- package/dist/components/DateRange/Day/Day.module.js +16 -0
- package/dist/components/DateRange/Day/Day_module.css +80 -0
- package/dist/components/DateRange/Day/index.d.ts +12 -0
- package/dist/components/DateRange/Day/index.js +39 -0
- package/dist/components/DateRange/DropdownContent/DropdownContent.module.js +10 -0
- package/dist/components/DateRange/DropdownContent/DropdownContent_module.css +34 -0
- package/dist/components/DateRange/DropdownContent/index.d.ts +24 -0
- package/dist/components/DateRange/DropdownContent/index.js +132 -0
- package/dist/components/DateRange/InputContent/InputContent.module.js +9 -0
- package/dist/components/DateRange/InputContent/InputContent_module.css +31 -0
- package/dist/components/DateRange/InputContent/index.d.ts +12 -0
- package/dist/components/DateRange/InputContent/index.js +59 -0
- package/dist/components/DateRange/Month/Month.module.js +7 -0
- package/dist/components/DateRange/Month/Month_module.css +17 -0
- package/dist/components/DateRange/Month/index.d.ts +15 -0
- package/dist/components/DateRange/Month/index.js +158 -0
- package/dist/components/DateRange/Month/utils.d.ts +2 -0
- package/dist/components/DateRange/Month/utils.js +8 -0
- package/dist/components/DateRange/MonthHeader/MonthHeader.module.js +5 -0
- package/dist/components/DateRange/MonthHeader/MonthHeader_module.css +10 -0
- package/dist/components/DateRange/MonthHeader/index.d.ts +5 -0
- package/dist/components/DateRange/MonthHeader/index.js +26 -0
- package/dist/components/DateRange/MonthList/MonthList.module.js +7 -0
- package/dist/components/DateRange/MonthList/MonthList_module.css +25 -0
- package/dist/components/DateRange/MonthList/index.d.ts +11 -0
- package/dist/components/DateRange/MonthList/index.js +91 -0
- package/dist/components/DateRange/PeriodVariantList/PeriodVariantList.module.js +9 -0
- package/dist/components/DateRange/PeriodVariantList/PeriodVariantList_module.css +18 -0
- package/dist/components/DateRange/PeriodVariantList/index.d.ts +18 -0
- package/dist/components/DateRange/PeriodVariantList/index.js +83 -0
- package/dist/components/DateRange/SideMenu/SideMenu.module.js +6 -0
- package/dist/components/DateRange/SideMenu/SideMenu_module.css +18 -0
- package/dist/components/DateRange/SideMenu/index.d.ts +13 -0
- package/dist/components/DateRange/SideMenu/index.js +73 -0
- package/dist/components/DateRange/TooltipedText/index.d.ts +8 -0
- package/dist/components/DateRange/TooltipedText/index.js +30 -0
- package/dist/components/DateRange/Year/Year.module.js +11 -0
- package/dist/components/DateRange/Year/Year_module.css +60 -0
- package/dist/components/DateRange/Year/index.d.ts +8 -0
- package/dist/components/DateRange/Year/index.js +47 -0
- package/dist/components/DateRange/YearsList/YearsList.module.js +5 -0
- package/dist/components/DateRange/YearsList/YearsList_module.css +15 -0
- package/dist/components/DateRange/YearsList/index.d.ts +12 -0
- package/dist/components/DateRange/YearsList/index.js +47 -0
- package/dist/components/DateRange/consts.d.ts +20 -0
- package/dist/components/DateRange/consts.js +81 -0
- package/dist/components/DateRange/formatDateRangeValue.d.ts +24 -0
- package/dist/components/DateRange/formatDateRangeValue.js +116 -0
- package/dist/components/DateRange/hooks/useCalendar.d.ts +13 -0
- package/dist/components/DateRange/hooks/useCalendar.js +88 -0
- package/dist/components/DateRange/hooks/useDateRange.d.ts +392 -0
- package/dist/components/DateRange/hooks/useDateRange.js +36 -0
- package/dist/components/DateRange/hooks/useDateRangeDropdown.d.ts +47 -0
- package/dist/components/DateRange/hooks/useDateRangeDropdown.js +117 -0
- package/dist/components/DateRange/hooks/useDateRangeValue.d.ts +56 -0
- package/dist/components/DateRange/hooks/useDateRangeValue.js +173 -0
- package/dist/components/DateRange/hooks/useMaskInput.d.ts +18 -0
- package/dist/components/DateRange/hooks/useMaskInput.js +169 -0
- package/dist/components/DateRange/hooks/useMonthList.d.ts +12 -0
- package/dist/components/DateRange/hooks/useMonthList.js +80 -0
- package/dist/components/DateRange/hooks/useSideMenu.d.ts +14 -0
- package/dist/components/DateRange/hooks/useSideMenu.js +113 -0
- package/dist/components/DateRange/index.d.ts +1 -0
- package/dist/components/DateRange/index.js +1 -0
- package/dist/components/DateRange/locale/en-US.d.ts +2 -0
- package/dist/components/DateRange/locale/en-US.js +82 -0
- package/dist/components/DateRange/locale/index.d.ts +4 -0
- package/dist/components/DateRange/locale/index.js +3 -0
- package/dist/components/DateRange/locale/ru-RU.d.ts +2 -0
- package/dist/components/DateRange/locale/ru-RU.js +82 -0
- package/dist/components/DateRange/locale/types.d.ts +9 -0
- package/dist/components/DateRange/locale/types.js +7 -0
- package/dist/components/DateRange/locale/useLocale.d.ts +8 -0
- package/dist/components/DateRange/locale/useLocale.js +31 -0
- package/dist/components/DateRange/props.d.ts +39 -0
- package/dist/components/DateRange/props.js +0 -0
- package/dist/components/DateRange/types.d.ts +126 -0
- package/dist/components/DateRange/types.js +13 -0
- package/dist/components/DateRange/utils.d.ts +33 -0
- package/dist/components/DateRange/utils.js +105 -0
- package/dist/components/Datepicker/Datepicker.d.ts +3 -1
- package/dist/components/Datepicker/Datepicker.js +4 -2
- package/dist/components/EditableDate/DropdownContent/DropdownContent.d.ts +9 -0
- package/dist/components/EditableDate/DropdownContent/DropdownContent.js +36 -0
- package/dist/components/EditableDate/EditableDate.d.ts +9 -0
- package/dist/components/EditableDate/EditableDate.js +142 -0
- package/dist/components/EditableDate/EditableDate.module.js +7 -0
- package/dist/components/EditableDate/EditableDate_module.css +32 -0
- package/dist/components/EditableTitle/EditableTitle.d.ts +7 -2
- package/dist/components/EditableTitle/EditableTitle.js +63 -31
- package/dist/components/EditableTitle/EditableTitle.module.js +1 -0
- package/dist/components/EditableTitle/EditableTitle_module.css +6 -0
- package/dist/components/EmptyState/EmptyState.d.ts +1 -1
- package/dist/components/EmptyStateLarge/EmptyStateLarge_module.css +2 -2
- package/dist/components/Help/Help_module.css +1 -1
- package/dist/components/Informer/Informer.d.ts +37 -0
- package/dist/components/Informer/Informer.js +36 -0
- package/dist/components/Informer/Informer.module.js +7 -0
- package/dist/components/Informer/Informer_module.css +24 -0
- package/dist/components/Input/Input.js +10 -5
- package/dist/components/Input/components/InfoBlock.d.ts +3 -1
- package/dist/components/Input/components/InfoBlock.js +7 -4
- package/dist/components/InputUnit/InputUnit.js +4 -4
- package/dist/components/LabelValue/LabelValue.d.ts +14 -10
- package/dist/components/LabelValue/LabelValue.js +46 -25
- package/dist/components/LabelValue/LabelValue.module.js +10 -4
- package/dist/components/LabelValue/LabelValue_module.css +53 -19
- package/dist/components/LabelValue/ValueBlock/ValueBlock.d.ts +2 -0
- package/dist/components/LabelValue/ValueBlock/ValueBlock.js +82 -0
- package/dist/components/LabelValue/ValueBlockWrapper.d.ts +5 -0
- package/dist/components/LabelValue/ValueBlockWrapper.js +13 -0
- package/dist/components/LabelValue/ValueIcon.d.ts +4 -0
- package/dist/components/LabelValue/ValueIcon.js +9 -0
- package/dist/components/LabelValue/ValueText.d.ts +10 -0
- package/dist/components/LabelValue/ValueText.js +24 -0
- package/dist/components/LabelValue/ValueTextWithHint.d.ts +12 -0
- package/dist/components/LabelValue/ValueTextWithHint.js +29 -0
- package/dist/components/LabelValue/hooks/useValueBlock.d.ts +29 -0
- package/dist/components/LabelValue/hooks/useValueBlock.js +72 -0
- package/dist/components/LabelValue/{ValueBlock/index.d.ts → types.d.ts} +8 -4
- package/dist/components/LabelValue/types.js +0 -0
- package/dist/components/LabelValueDate/LabelValueDate.js +2 -2
- package/dist/components/LabelValueFile/DeleteButton/DeleteButton.d.ts +9 -0
- package/dist/components/LabelValueFile/DeleteButton/DeleteButton.js +17 -0
- package/dist/components/LabelValueFile/FilePreviewIcon/FilePreviewIcon.d.ts +7 -0
- package/dist/components/LabelValueFile/FilePreviewIcon/FilePreviewIcon.js +15 -0
- package/dist/components/LabelValueFile/FilePreviewIcon/FilePreviewIcon.module.js +6 -0
- package/dist/components/LabelValueFile/FilePreviewIcon/FilePreviewIcon_module.css +10 -0
- package/dist/components/LabelValueFile/ImagePreview/ImagePreview.d.ts +8 -0
- package/dist/components/LabelValueFile/ImagePreview/ImagePreview.js +53 -0
- package/dist/components/LabelValueFile/ImagePreview/ImagePreview.module.js +6 -0
- package/dist/components/LabelValueFile/ImagePreview/ImagePreview_module.css +13 -0
- package/dist/components/LabelValueFile/LabelValueFile.d.ts +7 -0
- package/dist/components/LabelValueFile/LabelValueFile.js +42 -0
- package/dist/components/LabelValueFile/LabelValueFile.module.js +12 -0
- package/dist/components/LabelValueFile/LabelValueFile_module.css +57 -0
- package/dist/components/LabelValueFile/ValueBlock/ValueBlock.d.ts +15 -0
- package/dist/components/LabelValueFile/ValueBlock/ValueBlock.js +130 -0
- package/dist/components/LabelValueFile/ValueBlock/ValueBlock.module.js +7 -0
- package/dist/components/LabelValueFile/ValueBlock/ValueBlock_module.css +17 -0
- package/dist/components/LabelValueInput/DropdownConnent/DropdownContent.d.ts +2 -0
- package/dist/components/LabelValueInput/DropdownConnent/DropdownContent.js +2 -0
- package/dist/components/LabelValueLink/LabelValueLink.d.ts +2 -0
- package/dist/components/LabelValueLink/LabelValueLink.js +76 -0
- package/dist/components/LabelValueLink/LabelValueLink.module.js +6 -0
- package/dist/components/LabelValueLink/LabelValueLink_module.css +11 -0
- package/dist/components/LabelValueLink/ValueBlock/LabelValueLinkValueBlock.d.ts +2 -0
- package/dist/components/LabelValueLink/ValueBlock/LabelValueLinkValueBlock.js +117 -0
- package/dist/components/LabelValueLink/ValueBlock/LabelValueLinkValueBlock.module.js +6 -0
- package/dist/components/LabelValueLink/ValueBlock/LabelValueLinkValueBlock_module.css +8 -0
- package/dist/components/LabelValueLink/normalizeLinkValue.d.ts +1 -0
- package/dist/components/LabelValueLink/normalizeLinkValue.js +10 -0
- package/dist/components/LabelValueLink/useLinkDropdownValue.d.ts +15 -0
- package/dist/components/LabelValueLink/useLinkDropdownValue.js +26 -0
- package/dist/components/LabelValueSelect/Input/index.js +1 -1
- package/dist/components/LabelValueSelect/LabelValueSelect.d.ts +4 -2
- package/dist/components/Layout/Layout.d.ts +13 -0
- package/dist/components/Layout/Layout.js +41 -0
- package/dist/components/Layout/Layout.module.js +15 -0
- package/dist/components/Layout/Layout_module.css +77 -0
- package/dist/components/Link/Link.d.ts +5 -6
- package/dist/components/Link/Link.js +35 -9
- package/dist/components/Link/Link.module.js +1 -0
- package/dist/components/Link/Link_module.css +9 -0
- package/dist/components/MentionsTextfield/Mentions/style.css +2 -6
- package/dist/components/MentionsTextfield/MentionsTextfield.js +2 -1
- package/dist/components/Multiselect/AllSelectedChip/AllSelectedChip.d.ts +8 -0
- package/dist/components/Multiselect/AllSelectedChip/AllSelectedChip.js +13 -0
- package/dist/components/Multiselect/AllSelectedChip/AllSelectedChip.module.js +5 -0
- package/dist/components/Multiselect/AllSelectedChip/AllSelectedChip_module.css +9 -0
- package/dist/components/Multiselect/DropdownContent/MultiselectDropdownContent.d.ts +12 -1
- package/dist/components/Multiselect/DropdownContent/MultiselectDropdownContent.js +20 -15
- package/dist/components/Multiselect/Input/Input.d.ts +6 -2
- package/dist/components/Multiselect/Input/Input.js +18 -4
- package/dist/components/Multiselect/Multiselect.d.ts +4 -2
- package/dist/components/Multiselect/Multiselect.js +14 -2
- package/dist/components/Multiselect/ShortDropdownContent/ShortDropdownContent.js +2 -1
- package/dist/components/Multiselect/TextField/MultiselectTextField.d.ts +5 -1
- package/dist/components/Multiselect/TextField/MultiselectTextField.js +15 -2
- package/dist/components/Multiselect/lib/consts.d.ts +1 -1
- package/dist/components/Multiselect/lib/consts.js +1 -1
- package/dist/components/Multiselect/lib/helpers.d.ts +24 -0
- package/dist/components/Multiselect/lib/helpers.js +15 -0
- package/dist/components/Multiselect/types.d.ts +2 -0
- package/dist/components/Panel/Panel.d.ts +34 -0
- package/dist/components/Panel/Panel.js +39 -0
- package/dist/components/Panel/Panel.module.js +6 -0
- package/dist/components/Panel/Panel_module.css +17 -0
- package/dist/components/Radiobutton/Radiobutton.js +1 -1
- package/dist/components/Radiobutton/Radiobutton_module.css +5 -0
- package/dist/components/SearchInput/SearchInput_module.css +1 -1
- package/dist/components/Select/ArchivedInputValue/ArchivedInputValue.d.ts +3 -4
- package/dist/components/Select/ArchivedInputValue/ArchivedInputValue.js +19 -24
- package/dist/components/Select/ArchivedInputValue/ArchivedInputValue.module.js +1 -2
- package/dist/components/Select/ArchivedInputValue/ArchivedInputValue_module.css +5 -12
- package/dist/components/Select/Combobox/Combobox.d.ts +3 -1
- package/dist/components/Select/Combobox/Combobox.js +19 -8
- package/dist/components/Select/Combobox/Combobox.module.js +4 -3
- package/dist/components/Select/Combobox/Combobox_module.css +15 -9
- package/dist/components/Select/OptionsList/OptionsList.d.ts +3 -1
- package/dist/components/Select/OptionsList/OptionsList.js +37 -21
- package/dist/components/Select/OptionsList/OptionsList.module.js +2 -0
- package/dist/components/Select/OptionsList/OptionsList_module.css +15 -0
- package/dist/components/Select/Select.d.ts +2 -3
- package/dist/components/Select/Select.js +17 -7
- package/dist/components/Select/Select_module.css +5 -0
- package/dist/components/Select/ShortVariant/ShortVariant.js +1 -1
- package/dist/components/StatusBadge/StatusBadge.d.ts +28 -0
- package/dist/components/StatusBadge/StatusBadge.js +167 -0
- package/dist/components/StatusBadge/StatusBadge.module.js +37 -0
- package/dist/components/StatusBadge/StatusBadge_module.css +149 -0
- package/dist/components/StatusBadge/utils/StatusBadgeColor.d.ts +21 -0
- package/dist/components/StatusBadge/utils/StatusBadgeColor.js +20 -0
- package/dist/components/StatusBadge/utils/getStatusBadgeColor.d.ts +2 -0
- package/dist/components/StatusBadge/utils/getStatusBadgeColor.js +8 -0
- package/dist/components/Textfield/Textfield.d.ts +7 -2
- package/dist/components/Textfield/Textfield.js +2 -1
- package/dist/components/Textfield/components/Container/Container.d.ts +2 -0
- package/dist/components/Textfield/components/Container/Container.js +17 -6
- package/dist/components/Textfield/components/Container/Container.module.js +2 -1
- package/dist/components/Textfield/components/Container/Container_module.css +4 -0
- package/dist/components/Toggle/Toggle.js +1 -1
- package/dist/components/ViewersStack/ViewersStack.js +5 -3
- package/dist/components/_shared/CustomDatepickerDropdownContent/CustomDatepickerDropdownContent.d.ts +12 -0
- package/dist/components/{LabelValueDate/DropdownContent/index.js → _shared/CustomDatepickerDropdownContent/CustomDatepickerDropdownContent.js} +10 -10
- package/dist/components/_shared/CustomDatepickerDropdownContent/CustomDatepickerDropdownContent.module.js +9 -0
- package/dist/components/{LabelValueDate/DropdownContent/DropdownContent_module.css → _shared/CustomDatepickerDropdownContent/CustomDatepickerDropdownContent_module.css} +6 -6
- package/dist/components/_shared/FieldLabel/FieldLabel.d.ts +18 -0
- package/dist/components/{FieldLabel → _shared/FieldLabel}/FieldLabel.js +19 -12
- package/dist/components/_shared/FieldLabel/FieldLabel.module.js +11 -0
- package/dist/components/{FieldLabel → _shared/FieldLabel}/FieldLabel_module.css +8 -8
- package/dist/components/{FieldLabel → _shared/FieldLabel}/components/HelpButton.d.ts +1 -1
- package/dist/components/{FieldLabel → _shared/FieldLabel}/components/HelpButton.js +2 -2
- package/dist/components/{FieldLabel → _shared/FieldLabel}/components/HelpButton.module.js +1 -1
- package/dist/components/{FieldLabel → _shared/FieldLabel}/components/HelpButton_module.css +1 -1
- package/dist/components/{FieldRow → _shared/FieldRow}/FieldRow.d.ts +1 -1
- package/dist/components/{FieldRow → _shared/FieldRow}/FieldRow.js +1 -1
- package/dist/components/{FieldRow → _shared/FieldRow}/FieldRow.module.js +3 -3
- package/dist/components/{FieldRow → _shared/FieldRow}/FieldRow_module.css +3 -3
- package/dist/components/{Info → _shared/Info}/Info.d.ts +3 -1
- package/dist/components/{Info → _shared/Info}/Info.js +9 -6
- package/dist/components/_shared/Info/Info.module.js +9 -0
- package/dist/components/{Info → _shared/Info}/Info_module.css +6 -6
- package/dist/components/_shared/Info/types/index.d.ts +6 -0
- package/dist/components/_shared/Info/types/index.js +5 -0
- package/dist/components/{InputClear → _shared/InputClear}/InputClear.d.ts +1 -1
- package/dist/components/{InputClear → _shared/InputClear}/InputClear.js +2 -2
- package/dist/components/{InputClear → _shared/InputClear}/InputClear.module.js +3 -3
- package/dist/components/{InputClear → _shared/InputClear}/InputClear_module.css +5 -5
- package/dist/components/_shared/utils/polymorphicClickableTypes.d.ts +17 -0
- package/dist/components/_shared/utils/polymorphicClickableTypes.js +7 -0
- package/dist/data-grid/Filters/DateRangeFilter/DropdownContent/index.js +3 -3
- package/dist/data-grid/Filters/DateRangeFilter/InputContent/index.js +29 -26
- package/dist/data-grid/Filters/DateRangeFilter/PeriodVariantList/index.js +5 -3
- package/dist/data-grid/Filters/DateRangeFilter/Year/index.js +3 -3
- package/dist/data-grid/Filters/DateRangeFilter/consts.js +6 -6
- package/dist/data-grid/Filters/DateRangeFilter/hooks/useMaskInput.js +6 -6
- package/dist/data-grid/Filters/DateRangeFilter/hooks/useSideMenu.js +1 -4
- package/dist/data-grid/Filters/DateRangeFilter/types.d.ts +68 -56
- package/dist/data-grid/Filters/FiltersContainer/FiltersContainer.js +2 -1
- package/dist/data-grid/Filters/FiltersContainer/utils/useRenderParams.d.ts +1 -0
- package/dist/data-grid/Filters/FiltersContainer/utils/useRenderParams.js +14 -6
- package/dist/data-grid/Filters/MultiselectFilter/MultiselectFilter.js +2 -2
- package/dist/data-grid/Filters/OutlineInput/OutlineInput.js +2 -2
- package/dist/data-grid/Filters/OutlineInput/OutlineInput_module.css +1 -1
- package/dist/data-grid/Table/Table_module.css +0 -1
- package/dist/data-grid/cells/ImageCell/ImageMiniature/ImageMiniature_module.css +1 -1
- package/dist/data-grid/cells/components/TableNumberInput/TableNumberInput.d.ts +1 -0
- package/dist/data-grid/cells/components/TableNumberInput/TableNumberInput.js +17 -5
- package/dist/data-grid/cells/components/TableSelect/TableSelect.js +3 -2
- package/dist/data-grid/headers/components/Dropdown/Dropdown.d.ts +3 -0
- package/dist/data-grid/headers/components/HeaderBuilder/HeaderBuilder.js +1 -0
- package/dist/data-grid/index.d.ts +0 -4
- package/dist/data-grid/locale/en-US.js +68 -56
- package/dist/data-grid/locale/ru-RU.js +68 -56
- package/dist/data-grid/locale/useLocale.d.ts +6 -1
- package/dist/data-grid/locale/useLocale.js +14 -5
- package/dist/hooks/useIsElementOverflowing/index.d.ts +1 -0
- package/dist/hooks/useIsElementOverflowing/index.js +8 -2
- package/dist/hooks/useOverflowHint/index.d.ts +7 -0
- package/dist/hooks/useOverflowHint/index.js +16 -0
- package/dist/hooks/useTextField/useTextField.d.ts +1 -1
- package/dist/icon/components/MsLogo12Icon.d.ts +8 -0
- package/dist/icon/components/MsLogo12Icon.js +28 -0
- package/dist/icon/components/MsLogo16Icon.d.ts +8 -0
- package/dist/icon/components/MsLogo16Icon.js +26 -0
- package/dist/icon/components/MsLogo20Icon.d.ts +8 -0
- package/dist/icon/components/MsLogo20Icon.js +28 -0
- package/dist/icon/components/Phone12Icon.d.ts +8 -0
- package/dist/icon/components/Phone12Icon.js +18 -0
- package/dist/icon/components/Phone16Icon.d.ts +8 -0
- package/dist/icon/components/Phone16Icon.js +17 -0
- package/dist/icon/components/Phone20Icon.d.ts +8 -0
- package/dist/icon/components/Phone20Icon.js +18 -0
- package/dist/icon/index.d.ts +6 -0
- package/dist/icon/index.js +6 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.js +8 -0
- package/dist/utils/checkIsArchivedValue.d.ts +2 -0
- package/dist/utils/checkIsArchivedValue.js +5 -0
- package/dist/utils/utils.d.ts +1 -0
- package/dist/utils/utils.js +1 -0
- package/package.json +70 -13
- package/dist/components/FieldLabel/FieldLabel.d.ts +0 -17
- package/dist/components/FieldLabel/FieldLabel.module.js +0 -11
- package/dist/components/Info/Info.module.js +0 -9
- package/dist/components/LabelValue/ValueBlock/index.js +0 -138
- package/dist/components/LabelValue/hooks/useTooltip.d.ts +0 -8
- package/dist/components/LabelValue/hooks/useTooltip.js +0 -16
- package/dist/components/LabelValueDate/DropdownContent/DropdownContent.module.js +0 -9
- package/dist/components/LabelValueDate/DropdownContent/index.d.ts +0 -12
- package/dist/components/MentionsTextfield/OptionForStory/OptionForStory.d.ts +0 -7
- package/dist/components/MentionsTextfield/OptionForStory/OptionForStory.js +0 -27
- package/dist/components/MentionsTextfield/OptionForStory/OptionForStory.module.js +0 -8
- package/dist/components/MentionsTextfield/OptionForStory/OptionForStory_module.css +0 -25
- package/dist/components/MentionsTextfield/OptionForStory/index.d.ts +0 -1
- package/dist/components/MentionsTextfield/OptionForStory/index.js +0 -1
- package/dist/components/Textfield/components/Label/Label.d.ts +0 -11
- package/dist/components/Textfield/components/Label/Label.js +0 -38
- package/dist/components/Textfield/components/Label/Label.module.js +0 -7
- package/dist/components/Textfield/components/Label/Label_module.css +0 -17
- package/dist/components/Textfield/components/Label/index.d.ts +0 -1
- package/dist/components/Textfield/components/Label/index.js +0 -1
- /package/dist/components/{FieldLabel → _shared/FieldLabel}/FieldLabel.constants.d.ts +0 -0
- /package/dist/components/{FieldLabel → _shared/FieldLabel}/FieldLabel.constants.js +0 -0
- /package/dist/components/{FieldLabel → _shared/FieldLabel}/components/index.d.ts +0 -0
- /package/dist/components/{FieldLabel → _shared/FieldLabel}/components/index.js +0 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { ELanguages } from "../../../context/index.js";
|
|
3
|
+
import { useLocaleContext } from "../../../context/contexts/LocaleContext.js";
|
|
4
|
+
import { CalendarVariant, FOCUSED_WIDTH_WITHOUT_TIME, FOCUSED_WIDTH_WITH_TIME, FOCUSED_WIDTH_WITH_TIME_EN, INPUT_CONTENT_VARIANTS, NAVIGATION_VARIANTS, getDefaultVariant } from "../consts.js";
|
|
5
|
+
import { formatDateRangeValue, getDateRangePeriodName, getDateRangeSliderText } from "../formatDateRangeValue.js";
|
|
6
|
+
import { LocaleKey, useLocale } from "../locale/index.js";
|
|
7
|
+
import { getPeriodValue, isAnyDateValue, isDayValue, isMonthValue, isNoDateValue, isRangeValue, isTimeDefault, isValueNullable, isValuePeriod, isWeekValue, normalizeValue } from "../utils.js";
|
|
8
|
+
import { useCalendar } from "./useCalendar.js";
|
|
9
|
+
import { useMaskInput } from "./useMaskInput.js";
|
|
10
|
+
import { useMonthList } from "./useMonthList.js";
|
|
11
|
+
const useDateRangeValue = ({ value: valueProp, onChange, minDate, maxDate, withPeriod, withAnyDate, withNoDate, withTimeSelection, withClearButton, disabled, quickFilter })=>{
|
|
12
|
+
const { lang } = useLocaleContext();
|
|
13
|
+
const dateRangeLocale = useLocale('DateRange');
|
|
14
|
+
const dateRangeFormatLocale = useLocale('DateRange', LocaleKey.Locale);
|
|
15
|
+
const features = useMemo(()=>({
|
|
16
|
+
withPeriod,
|
|
17
|
+
withAnyDate,
|
|
18
|
+
withNoDate,
|
|
19
|
+
withTimeSelection,
|
|
20
|
+
withClearButton,
|
|
21
|
+
quickFilter
|
|
22
|
+
}), [
|
|
23
|
+
withAnyDate,
|
|
24
|
+
withClearButton,
|
|
25
|
+
withNoDate,
|
|
26
|
+
withPeriod,
|
|
27
|
+
withTimeSelection,
|
|
28
|
+
quickFilter
|
|
29
|
+
]);
|
|
30
|
+
const defaultType = getDefaultVariant(features);
|
|
31
|
+
const rawValue = valueProp ?? {
|
|
32
|
+
type: defaultType,
|
|
33
|
+
value: defaultType === CalendarVariant.period ? [
|
|
34
|
+
void 0,
|
|
35
|
+
void 0
|
|
36
|
+
] : null
|
|
37
|
+
};
|
|
38
|
+
const value = normalizeValue(rawValue, features);
|
|
39
|
+
const [withTime, setWithTime] = useState(false);
|
|
40
|
+
const handlePickDates = (nextValue)=>{
|
|
41
|
+
if (!isRangeValue(nextValue) && !isDayValue(nextValue) && !isWeekValue(nextValue) && !isMonthValue(nextValue)) return;
|
|
42
|
+
onChange?.(nextValue);
|
|
43
|
+
};
|
|
44
|
+
const calendar = useCalendar({
|
|
45
|
+
value,
|
|
46
|
+
minDate,
|
|
47
|
+
maxDate,
|
|
48
|
+
onChangeValue: handlePickDates
|
|
49
|
+
});
|
|
50
|
+
const monthList = useMonthList({
|
|
51
|
+
minDate: calendar.minDate
|
|
52
|
+
});
|
|
53
|
+
const inputMaskValue = useMaskInput({
|
|
54
|
+
withTime,
|
|
55
|
+
value,
|
|
56
|
+
onChangeValue: onChange,
|
|
57
|
+
scrollToMonthHandler: monthList.scrollToMonth
|
|
58
|
+
});
|
|
59
|
+
useEffect(()=>{
|
|
60
|
+
if (!valueProp) return void inputMaskValue.changeValue('');
|
|
61
|
+
if (valueProp && isRangeValue(valueProp)) {
|
|
62
|
+
const timeDefault = isTimeDefault(valueProp.value);
|
|
63
|
+
const showTime = !timeDefault || void 0;
|
|
64
|
+
inputMaskValue.changeInterval(valueProp, showTime);
|
|
65
|
+
}
|
|
66
|
+
}, [
|
|
67
|
+
valueProp
|
|
68
|
+
]);
|
|
69
|
+
const needMaskInput = false !== features.withPeriod && value.type === CalendarVariant.period;
|
|
70
|
+
const needInputContent = INPUT_CONTENT_VARIANTS.includes(value.type);
|
|
71
|
+
const getClearValue = ()=>{
|
|
72
|
+
if (false !== features.withPeriod) return {
|
|
73
|
+
type: CalendarVariant.period,
|
|
74
|
+
value: [
|
|
75
|
+
null,
|
|
76
|
+
null
|
|
77
|
+
]
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
type: CalendarVariant.day,
|
|
81
|
+
value: null
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
const handleClickOnClearButton = ()=>{
|
|
85
|
+
onChange?.(getClearValue());
|
|
86
|
+
inputMaskValue.clear();
|
|
87
|
+
};
|
|
88
|
+
const handleClickPrevButton = ()=>{
|
|
89
|
+
const newValue = monthList.getActionHandler('prev')(value);
|
|
90
|
+
onChange?.(newValue);
|
|
91
|
+
};
|
|
92
|
+
const handleClickNextButton = ()=>{
|
|
93
|
+
const newValue = monthList.getActionHandler('next')(value);
|
|
94
|
+
onChange?.(newValue);
|
|
95
|
+
};
|
|
96
|
+
const isFilled = ()=>{
|
|
97
|
+
if (!valueProp) return false;
|
|
98
|
+
if (isValuePeriod(valueProp.value)) {
|
|
99
|
+
const { startDate, endDate } = getPeriodValue(valueProp.value);
|
|
100
|
+
return !(null === startDate && null === endDate);
|
|
101
|
+
}
|
|
102
|
+
if (isAnyDateValue(valueProp) || isNoDateValue(valueProp)) return true;
|
|
103
|
+
return null !== valueProp.value;
|
|
104
|
+
};
|
|
105
|
+
const getFocusedWidth = ()=>{
|
|
106
|
+
if (!withTime) return FOCUSED_WIDTH_WITHOUT_TIME;
|
|
107
|
+
if (lang === ELanguages.EN) return FOCUSED_WIDTH_WITH_TIME_EN;
|
|
108
|
+
return FOCUSED_WIDTH_WITH_TIME;
|
|
109
|
+
};
|
|
110
|
+
const isInputContentButtonsDisabled = ()=>{
|
|
111
|
+
if (disabled) return true;
|
|
112
|
+
return isValueNullable(value);
|
|
113
|
+
};
|
|
114
|
+
const handleChangeWithTime = (withTimeArg, options)=>{
|
|
115
|
+
setWithTime(withTimeArg);
|
|
116
|
+
if (withTimeArg && !options?.notChangeInputMask) return void inputMaskValue.showTime();
|
|
117
|
+
if (!options?.notChangeInputMask) inputMaskValue.hideTime();
|
|
118
|
+
};
|
|
119
|
+
useEffect(()=>{
|
|
120
|
+
if (!withTime && valueProp && isValuePeriod(valueProp.value)) {
|
|
121
|
+
const timeDefault = isTimeDefault(valueProp.value);
|
|
122
|
+
if (!timeDefault) handleChangeWithTime(true, {
|
|
123
|
+
notChangeInputMask: true
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}, [
|
|
127
|
+
valueProp
|
|
128
|
+
]);
|
|
129
|
+
const localeOptions = {
|
|
130
|
+
translates: dateRangeLocale,
|
|
131
|
+
lang,
|
|
132
|
+
formatTranslates: dateRangeFormatLocale
|
|
133
|
+
};
|
|
134
|
+
const formattedValue = formatDateRangeValue(value, {
|
|
135
|
+
...localeOptions,
|
|
136
|
+
withTime,
|
|
137
|
+
periodFormattedValue: needMaskInput ? inputMaskValue.value : void 0,
|
|
138
|
+
emptyPeriodMaskValue: inputMaskValue.emptyRangeMaskInputValue
|
|
139
|
+
});
|
|
140
|
+
const sliderText = getDateRangeSliderText(value, localeOptions);
|
|
141
|
+
const showNavigationArrows = NAVIGATION_VARIANTS.includes(value.type);
|
|
142
|
+
return {
|
|
143
|
+
valueProp,
|
|
144
|
+
value,
|
|
145
|
+
withTime,
|
|
146
|
+
features,
|
|
147
|
+
needMaskInput,
|
|
148
|
+
needInputContent,
|
|
149
|
+
calendar,
|
|
150
|
+
monthList,
|
|
151
|
+
inputMaskValue,
|
|
152
|
+
getClearValue,
|
|
153
|
+
handleClickOnClearButton,
|
|
154
|
+
handleClickPrevButton,
|
|
155
|
+
handleClickNextButton,
|
|
156
|
+
handleChangeWithTime,
|
|
157
|
+
isFilled,
|
|
158
|
+
getFocusedWidth,
|
|
159
|
+
isInputContentButtonsDisabled,
|
|
160
|
+
formattedValue,
|
|
161
|
+
sliderText,
|
|
162
|
+
periodName: getDateRangePeriodName(value, dateRangeLocale),
|
|
163
|
+
showNavigationArrows,
|
|
164
|
+
withPeriod,
|
|
165
|
+
withAnyDate,
|
|
166
|
+
withNoDate,
|
|
167
|
+
withTimeSelection,
|
|
168
|
+
withClearButton,
|
|
169
|
+
quickFilter,
|
|
170
|
+
onChange
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
export { useDateRangeValue };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DateRangeRangeValue, DateRangeValue } from '../types';
|
|
2
|
+
interface UseMaskInputArgs {
|
|
3
|
+
value: DateRangeValue;
|
|
4
|
+
withTime: boolean;
|
|
5
|
+
onChangeValue?: (value: DateRangeRangeValue) => void;
|
|
6
|
+
scrollToMonthHandler?: (date: Date) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const useMaskInput: (args: UseMaskInputArgs) => {
|
|
9
|
+
value: string;
|
|
10
|
+
inputMask: string;
|
|
11
|
+
emptyRangeMaskInputValue: string;
|
|
12
|
+
changeValue: (value: string) => void;
|
|
13
|
+
showTime: () => void;
|
|
14
|
+
hideTime: () => void;
|
|
15
|
+
clear: () => void;
|
|
16
|
+
changeInterval: (options: DateRangeRangeValue, withTime?: boolean) => void;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { format, isBefore, isEqual, isValid, parse } from "date-fns";
|
|
3
|
+
import { joinFormattedDateRange, splitFormattedDateRange } from "../formatDateRangeValue.js";
|
|
4
|
+
import { LocaleKey, useLocale } from "../locale/index.js";
|
|
5
|
+
import { getEndOfDay, getPeriodValue, getRangeDates as external_utils_js_getRangeDates, getStartOfDay, isRangeValue } from "../utils.js";
|
|
6
|
+
const getEmptyMask = (withTime, translates)=>withTime ? translates.format.emptyDate.withTime : translates.format.emptyDate.withoutTime;
|
|
7
|
+
const isDateValuesEqual = (value1, value2)=>{
|
|
8
|
+
if (value1 && value2) return isEqual(value1, value2);
|
|
9
|
+
return value1 === value2;
|
|
10
|
+
};
|
|
11
|
+
const useMaskInput = (args)=>{
|
|
12
|
+
const translates = useLocale('DateRange', LocaleKey.Locale);
|
|
13
|
+
const getDateFormat = (withTime)=>withTime ? translates.format.dateWithTimeFormat : translates.format.dateFormat;
|
|
14
|
+
const inputMask = args.withTime ? joinFormattedDateRange(translates.format.inputMask.withTime, translates.format.inputMask.withTime) : joinFormattedDateRange(translates.format.inputMask.withoutTime, translates.format.inputMask.withoutTime);
|
|
15
|
+
const formatDate = (date, withTime)=>{
|
|
16
|
+
const timeString = format(date, 'HH:mm');
|
|
17
|
+
return `${format(date, translates.format.dateFormat)}${withTime ? ` ${timeString}` : ''}`;
|
|
18
|
+
};
|
|
19
|
+
const getFormatedDate = (date, withTime = false)=>date ? formatDate(date, withTime) : getEmptyMask(withTime, translates);
|
|
20
|
+
const getRangeDates = (options, withTime)=>{
|
|
21
|
+
const { startDate, endDate } = getPeriodValue(options.value);
|
|
22
|
+
const formatedStartDate = getFormatedDate(startDate, withTime);
|
|
23
|
+
const formatedEndDate = getFormatedDate(endDate, withTime);
|
|
24
|
+
return {
|
|
25
|
+
startDate: formatedStartDate,
|
|
26
|
+
endDate: formatedEndDate
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const [inputMaskValue, setInputMaskValue] = useState(()=>{
|
|
30
|
+
if (!isRangeValue(args.value)) return '';
|
|
31
|
+
const { startDate, endDate } = getPeriodValue(args.value.value);
|
|
32
|
+
if (!startDate && !endDate) return '';
|
|
33
|
+
const range = getRangeDates(args.value, args.withTime);
|
|
34
|
+
return joinFormattedDateRange(range.startDate, range.endDate);
|
|
35
|
+
});
|
|
36
|
+
const emptyMask = getEmptyMask(args.withTime, translates);
|
|
37
|
+
const emptyRangeMask = joinFormattedDateRange(emptyMask, emptyMask);
|
|
38
|
+
const parseDate = (dateString, withTime = args.withTime)=>{
|
|
39
|
+
if (!dateString) return null;
|
|
40
|
+
if (dateString.includes('_')) return null;
|
|
41
|
+
return parse(dateString, getDateFormat(withTime), new Date());
|
|
42
|
+
};
|
|
43
|
+
const isInvalidInterval = (startDate, endDate)=>isBefore(endDate, startDate);
|
|
44
|
+
const getParsedDate = (dateString)=>{
|
|
45
|
+
const isDateStringDirty = dateString !== emptyMask && dateString.includes('_');
|
|
46
|
+
const date = isDateStringDirty ? void 0 : parseDate(dateString);
|
|
47
|
+
const isInvalidDate = !!date && !isValid(date);
|
|
48
|
+
return {
|
|
49
|
+
date: isInvalidDate ? null : date,
|
|
50
|
+
isInvalidDate
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const getStartOfDayIfWithoutTime = (date)=>{
|
|
54
|
+
if (args.withTime) return date;
|
|
55
|
+
return getStartOfDay(date);
|
|
56
|
+
};
|
|
57
|
+
const getEndOfDayIfWithoutTime = (date)=>{
|
|
58
|
+
if (args.withTime) return date;
|
|
59
|
+
return getEndOfDay(date);
|
|
60
|
+
};
|
|
61
|
+
const changeDatesHandler = (handlerArgs)=>{
|
|
62
|
+
if (args.value && isRangeValue(args.value)) {
|
|
63
|
+
const { startDate, endDate } = external_utils_js_getRangeDates(args.value);
|
|
64
|
+
if (isDateValuesEqual(startDate, handlerArgs.startDate) && isDateValuesEqual(endDate, handlerArgs.endDate)) return;
|
|
65
|
+
}
|
|
66
|
+
args.onChangeValue?.({
|
|
67
|
+
type: 'period',
|
|
68
|
+
value: [
|
|
69
|
+
getStartOfDayIfWithoutTime(handlerArgs.startDate),
|
|
70
|
+
getEndOfDayIfWithoutTime(handlerArgs.endDate)
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
const scrollToOnceDate = (period)=>{
|
|
75
|
+
const dateToScroll = period.endDate ?? period.startDate;
|
|
76
|
+
if (dateToScroll) args.scrollToMonthHandler?.(dateToScroll);
|
|
77
|
+
};
|
|
78
|
+
const changeValueArg = (value)=>{
|
|
79
|
+
const { startDate: startDateString, endDate: endDateString } = splitFormattedDateRange(value);
|
|
80
|
+
if (!startDateString || !endDateString) return;
|
|
81
|
+
const { date: startDate, isInvalidDate: isInvalidStartDate } = getParsedDate(startDateString);
|
|
82
|
+
const { date: endDate, isInvalidDate: isInvalidEndDate } = getParsedDate(endDateString);
|
|
83
|
+
if (isInvalidStartDate || isInvalidEndDate) return void args.onChangeValue?.({
|
|
84
|
+
type: 'period',
|
|
85
|
+
value: [
|
|
86
|
+
getStartOfDayIfWithoutTime(startDate),
|
|
87
|
+
getEndOfDayIfWithoutTime(endDate)
|
|
88
|
+
]
|
|
89
|
+
});
|
|
90
|
+
if (startDate && endDate && isInvalidInterval(startDate, endDate)) {
|
|
91
|
+
changeDatesHandler?.({
|
|
92
|
+
startDate: endDate,
|
|
93
|
+
endDate: startDate
|
|
94
|
+
});
|
|
95
|
+
args.scrollToMonthHandler?.(startDate);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const period = {
|
|
99
|
+
startDate,
|
|
100
|
+
endDate
|
|
101
|
+
};
|
|
102
|
+
if (startDate && endDate) args.scrollToMonthHandler?.(endDate);
|
|
103
|
+
else scrollToOnceDate(period);
|
|
104
|
+
changeDatesHandler?.(period);
|
|
105
|
+
};
|
|
106
|
+
const changeValue = (value)=>{
|
|
107
|
+
setInputMaskValue(value);
|
|
108
|
+
changeValueArg(value);
|
|
109
|
+
};
|
|
110
|
+
const showTime = ()=>{
|
|
111
|
+
if (!isRangeValue(args.value)) return;
|
|
112
|
+
const { startDate, endDate } = external_utils_js_getRangeDates(args.value);
|
|
113
|
+
const { startDate: startDateWithoutTimeString, endDate: endDateWithoutTimeString } = splitFormattedDateRange(inputMaskValue || emptyRangeMask);
|
|
114
|
+
const startTime = startDate && isValid(startDate) ? '00:00' : '__:__';
|
|
115
|
+
const endTime = endDate && isValid(endDate) ? '23:59' : '__:__';
|
|
116
|
+
const startDateString = `${startDateWithoutTimeString} ${startTime}`;
|
|
117
|
+
const endDateString = `${endDateWithoutTimeString} ${endTime}`;
|
|
118
|
+
setInputMaskValue(joinFormattedDateRange(startDateString, endDateString));
|
|
119
|
+
};
|
|
120
|
+
const hideTime = ()=>{
|
|
121
|
+
if (!isRangeValue(args.value)) return;
|
|
122
|
+
const { startDate: startDateWithTimeString, endDate: endDateWithTimeString } = splitFormattedDateRange(inputMaskValue);
|
|
123
|
+
const [startDateString] = startDateWithTimeString.split(' ');
|
|
124
|
+
const [endDateString] = endDateWithTimeString.split(' ');
|
|
125
|
+
const parsedStartDate = getStartOfDay(parseDate(startDateString, false));
|
|
126
|
+
const parsedEndDate = getEndOfDay(parseDate(endDateString, false));
|
|
127
|
+
const startDateValue = parsedStartDate && isValid(parsedStartDate) ? parsedStartDate : args.value.value[0];
|
|
128
|
+
const endDateValue = parsedEndDate && isValid(parsedEndDate) ? parsedEndDate : args.value.value[1];
|
|
129
|
+
args.onChangeValue?.({
|
|
130
|
+
type: 'period',
|
|
131
|
+
value: [
|
|
132
|
+
startDateValue,
|
|
133
|
+
endDateValue
|
|
134
|
+
]
|
|
135
|
+
});
|
|
136
|
+
setInputMaskValue(joinFormattedDateRange(startDateString, endDateString));
|
|
137
|
+
};
|
|
138
|
+
const clear = ()=>{
|
|
139
|
+
setInputMaskValue('');
|
|
140
|
+
};
|
|
141
|
+
const changeInterval = (options, withTime)=>{
|
|
142
|
+
const range = getRangeDates(options, withTime ?? args.withTime);
|
|
143
|
+
setInputMaskValue((inputMaskOldValue)=>{
|
|
144
|
+
const { startDate: startDateString, endDate: endDateString } = splitFormattedDateRange(inputMaskOldValue);
|
|
145
|
+
const { startDate, endDate } = getPeriodValue(options.value);
|
|
146
|
+
if (!startDate && !endDate && !endDateString && !startDateString) return '';
|
|
147
|
+
if (void 0 === startDate && !startDateString || void 0 === endDate && !endDateString) return '';
|
|
148
|
+
const formatedStartDate = void 0 === startDate ? startDateString : range.startDate;
|
|
149
|
+
const formatedEndDate = void 0 === endDate ? endDateString : range.endDate;
|
|
150
|
+
return joinFormattedDateRange(formatedStartDate, formatedEndDate);
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
useEffect(()=>{
|
|
154
|
+
if (isRangeValue(args.value)) changeInterval(args.value);
|
|
155
|
+
}, [
|
|
156
|
+
translates
|
|
157
|
+
]);
|
|
158
|
+
return {
|
|
159
|
+
value: inputMaskValue,
|
|
160
|
+
inputMask,
|
|
161
|
+
emptyRangeMaskInputValue: emptyRangeMask,
|
|
162
|
+
changeValue,
|
|
163
|
+
showTime,
|
|
164
|
+
hideTime,
|
|
165
|
+
clear,
|
|
166
|
+
changeInterval
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
export { useMaskInput };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { VirtuosoHandle } from 'react-virtuoso';
|
|
2
|
+
import type { DateRangeValue } from '../types';
|
|
3
|
+
interface UseMonthListArgs {
|
|
4
|
+
minDate: Date;
|
|
5
|
+
}
|
|
6
|
+
type Action = 'prev' | 'next';
|
|
7
|
+
export declare const useMonthList: (args: UseMonthListArgs) => {
|
|
8
|
+
virtuosoRef: import("react").RefObject<VirtuosoHandle>;
|
|
9
|
+
getActionHandler: (action: Action) => (value: DateRangeValue) => DateRangeValue;
|
|
10
|
+
scrollToMonth: (date: Date) => void;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { useRef } from "react";
|
|
2
|
+
import { addDays, addMonths, addWeeks, differenceInMonths, differenceInYears, endOfMonth, endOfWeek, startOfMonth, startOfWeek, subDays, subMonths, subWeeks } from "date-fns";
|
|
3
|
+
import { getRangeDates, isDayValue, isMonthValue, isWeekValue } from "../utils.js";
|
|
4
|
+
const getNewDateForDayMode = (action, oldDate)=>'next' === action ? addDays(oldDate, 1) : subDays(oldDate, 1);
|
|
5
|
+
const getNewStartDateForWeekMode = (action, oldDate)=>'next' === action ? startOfWeek(addWeeks(oldDate, 1), {
|
|
6
|
+
weekStartsOn: 1
|
|
7
|
+
}) : startOfWeek(subWeeks(oldDate, 1), {
|
|
8
|
+
weekStartsOn: 1
|
|
9
|
+
});
|
|
10
|
+
const getWeekEndDate = (startDate)=>endOfWeek(startDate, {
|
|
11
|
+
weekStartsOn: 1
|
|
12
|
+
});
|
|
13
|
+
const getNewStartDateForMonthMode = (action, oldDate)=>'next' === action ? startOfMonth(addMonths(oldDate, 1)) : startOfMonth(subMonths(oldDate, 1));
|
|
14
|
+
const getMonthEndDate = (startDate)=>endOfMonth(startDate);
|
|
15
|
+
const useMonthList = (args)=>{
|
|
16
|
+
const virtuosoRef = useRef(null);
|
|
17
|
+
const scrollToMonth = (date)=>{
|
|
18
|
+
const monthIndex = differenceInMonths(date, args.minDate);
|
|
19
|
+
virtuosoRef.current?.scrollToIndex({
|
|
20
|
+
index: monthIndex,
|
|
21
|
+
align: 'center'
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const scrollToYear = (date)=>{
|
|
25
|
+
const yearIndex = differenceInYears(date, args.minDate);
|
|
26
|
+
virtuosoRef.current?.scrollToIndex({
|
|
27
|
+
index: yearIndex,
|
|
28
|
+
align: 'center'
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
const getDayActionHandler = (action, options)=>{
|
|
32
|
+
if (!options.value) return options;
|
|
33
|
+
const newDate = getNewDateForDayMode(action, options.value);
|
|
34
|
+
scrollToMonth(newDate);
|
|
35
|
+
return {
|
|
36
|
+
...options,
|
|
37
|
+
value: newDate
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const getWeekActionHandler = (action, value)=>{
|
|
41
|
+
const { startDate, endDate } = getRangeDates(value);
|
|
42
|
+
if (!startDate || !endDate) return value;
|
|
43
|
+
const newStartDate = getNewStartDateForWeekMode(action, startDate);
|
|
44
|
+
const newEndDate = getWeekEndDate(newStartDate);
|
|
45
|
+
scrollToMonth(newEndDate);
|
|
46
|
+
return {
|
|
47
|
+
...value,
|
|
48
|
+
value: [
|
|
49
|
+
newStartDate,
|
|
50
|
+
newEndDate
|
|
51
|
+
]
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
const getMonthActionHandler = (action, value)=>{
|
|
55
|
+
const { startDate, endDate } = getRangeDates(value);
|
|
56
|
+
if (!startDate || !endDate) return value;
|
|
57
|
+
const newStartDate = getNewStartDateForMonthMode(action, startDate);
|
|
58
|
+
const newEndDate = getMonthEndDate(newStartDate);
|
|
59
|
+
scrollToYear(newEndDate);
|
|
60
|
+
return {
|
|
61
|
+
...value,
|
|
62
|
+
value: [
|
|
63
|
+
newStartDate,
|
|
64
|
+
newEndDate
|
|
65
|
+
]
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
const getActionHandler = (action)=>(value)=>{
|
|
69
|
+
if (isDayValue(value)) return getDayActionHandler(action, value);
|
|
70
|
+
if (isWeekValue(value)) return getWeekActionHandler(action, value);
|
|
71
|
+
if (isMonthValue(value)) return getMonthActionHandler(action, value);
|
|
72
|
+
return value;
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
virtuosoRef,
|
|
76
|
+
getActionHandler,
|
|
77
|
+
scrollToMonth
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
export { useMonthList };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DateRangeValue, DateSelectVariant } from '../types';
|
|
2
|
+
interface UseSideMenuArgs {
|
|
3
|
+
value: DateRangeValue;
|
|
4
|
+
requiredDate?: boolean;
|
|
5
|
+
onChangeValue?: (value: DateRangeValue) => void;
|
|
6
|
+
handleScrollToMoth?: (date: Date) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const useSideMenu: (args: UseSideMenuArgs) => {
|
|
9
|
+
changeVariantHandler: (variant: DateSelectVariant) => void;
|
|
10
|
+
yesterdayButtonClickHandler: () => void;
|
|
11
|
+
todayButtonClickHandler: () => void;
|
|
12
|
+
tomorrowButtonClickHandler: () => void;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { addDays, startOfDay, subDays } from "date-fns";
|
|
2
|
+
import { CalendarVariant } from "../consts.js";
|
|
3
|
+
import { getCorrectInterval, getEndOfDay, getRequiredDateRangeValue, getStartOfDay, isDayValue, isRangeValue, isValuePeriod } from "../utils.js";
|
|
4
|
+
const getCorrentRangeDates = (value)=>{
|
|
5
|
+
const [startDate, endDate] = value;
|
|
6
|
+
return startDate && endDate ? getCorrectInterval(startDate, endDate) : [
|
|
7
|
+
null,
|
|
8
|
+
null
|
|
9
|
+
];
|
|
10
|
+
};
|
|
11
|
+
const useSideMenu = (args)=>{
|
|
12
|
+
const changeModeOnPeriodWhenValueIsRange = (value)=>{
|
|
13
|
+
const interval = getCorrentRangeDates(value);
|
|
14
|
+
args.onChangeValue?.({
|
|
15
|
+
type: CalendarVariant.period,
|
|
16
|
+
value: interval
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
const changeModeOnPeriod = ()=>{
|
|
20
|
+
if (isRangeValue(args.value)) return;
|
|
21
|
+
if (isValuePeriod(args.value.value)) return void changeModeOnPeriodWhenValueIsRange(args.value.value);
|
|
22
|
+
args.onChangeValue?.({
|
|
23
|
+
type: CalendarVariant.period,
|
|
24
|
+
value: [
|
|
25
|
+
getStartOfDay(args.value.value),
|
|
26
|
+
getEndOfDay(args.value.value)
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const applyRequiredVariantValue = (variant)=>{
|
|
31
|
+
const emptyValue = 'day' === variant ? {
|
|
32
|
+
type: variant,
|
|
33
|
+
value: null
|
|
34
|
+
} : {
|
|
35
|
+
type: variant,
|
|
36
|
+
value: [
|
|
37
|
+
null,
|
|
38
|
+
null
|
|
39
|
+
]
|
|
40
|
+
};
|
|
41
|
+
const requiredValue = getRequiredDateRangeValue(emptyValue);
|
|
42
|
+
if (!requiredValue) return false;
|
|
43
|
+
if (isDayValue(requiredValue) && requiredValue.value) args.handleScrollToMoth?.(requiredValue.value);
|
|
44
|
+
else if (isValuePeriod(requiredValue.value) && requiredValue.value[0]) args.handleScrollToMoth?.(requiredValue.value[0]);
|
|
45
|
+
args.onChangeValue?.(requiredValue);
|
|
46
|
+
return true;
|
|
47
|
+
};
|
|
48
|
+
const changeVariantHandler = (variant)=>{
|
|
49
|
+
switch(variant){
|
|
50
|
+
case 'period':
|
|
51
|
+
changeModeOnPeriod();
|
|
52
|
+
break;
|
|
53
|
+
case 'week':
|
|
54
|
+
case 'month':
|
|
55
|
+
if (args.requiredDate && applyRequiredVariantValue(variant)) break;
|
|
56
|
+
args.onChangeValue?.({
|
|
57
|
+
type: variant,
|
|
58
|
+
value: [
|
|
59
|
+
null,
|
|
60
|
+
null
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
break;
|
|
64
|
+
case 'day':
|
|
65
|
+
if (args.requiredDate && applyRequiredVariantValue(variant)) break;
|
|
66
|
+
args.onChangeValue?.({
|
|
67
|
+
type: variant,
|
|
68
|
+
value: null
|
|
69
|
+
});
|
|
70
|
+
break;
|
|
71
|
+
case 'anyDate':
|
|
72
|
+
case 'noDate':
|
|
73
|
+
args.onChangeValue?.({
|
|
74
|
+
type: variant,
|
|
75
|
+
value: null
|
|
76
|
+
});
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
throw new Error(`неизвестный вариант ${variant}`);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const yesterdayButtonClickHandler = ()=>{
|
|
83
|
+
const date = startOfDay(subDays(new Date(), 1));
|
|
84
|
+
args.handleScrollToMoth?.(date);
|
|
85
|
+
args.onChangeValue?.({
|
|
86
|
+
type: CalendarVariant.day,
|
|
87
|
+
value: date
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
const todayButtonClickHandler = ()=>{
|
|
91
|
+
const date = startOfDay(new Date());
|
|
92
|
+
args.handleScrollToMoth?.(date);
|
|
93
|
+
args.onChangeValue?.({
|
|
94
|
+
type: CalendarVariant.day,
|
|
95
|
+
value: date
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
const tomorrowButtonClickHandler = ()=>{
|
|
99
|
+
const date = startOfDay(addDays(new Date(), 1));
|
|
100
|
+
args.handleScrollToMoth?.(date);
|
|
101
|
+
args.onChangeValue?.({
|
|
102
|
+
type: CalendarVariant.day,
|
|
103
|
+
value: date
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
changeVariantHandler,
|
|
108
|
+
yesterdayButtonClickHandler,
|
|
109
|
+
todayButtonClickHandler,
|
|
110
|
+
tomorrowButtonClickHandler
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
export { useSideMenu };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DateRange';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./DateRange.js";
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const enLocaleValues = {
|
|
2
|
+
DateRange: {
|
|
3
|
+
translate: {
|
|
4
|
+
radiobuttons: {
|
|
5
|
+
period: 'Period',
|
|
6
|
+
day: 'Day',
|
|
7
|
+
week: 'Week',
|
|
8
|
+
month: 'Month',
|
|
9
|
+
anyDate: 'Any date specified',
|
|
10
|
+
noDate: 'No date specified'
|
|
11
|
+
},
|
|
12
|
+
dayQuickFilters: {
|
|
13
|
+
yesterday: 'Yesterday',
|
|
14
|
+
today: 'Today',
|
|
15
|
+
tomorrow: 'Tomorrow'
|
|
16
|
+
},
|
|
17
|
+
footer: {
|
|
18
|
+
timeSelectionToggle: 'Set time',
|
|
19
|
+
timeSelectionToggleHint: 'Setting time is available only in period mode',
|
|
20
|
+
clearFilterButton: 'Clear filter'
|
|
21
|
+
},
|
|
22
|
+
slider: {
|
|
23
|
+
day: {
|
|
24
|
+
title: 'Day',
|
|
25
|
+
placeholder: 'Select day'
|
|
26
|
+
},
|
|
27
|
+
week: {
|
|
28
|
+
title: 'Week',
|
|
29
|
+
placeholder: 'Select week'
|
|
30
|
+
},
|
|
31
|
+
month: {
|
|
32
|
+
title: 'Month',
|
|
33
|
+
placeholder: 'Select month'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
format: {
|
|
38
|
+
slider: {
|
|
39
|
+
day: {
|
|
40
|
+
dateFormat: 'MMMM d, yyyy'
|
|
41
|
+
},
|
|
42
|
+
week: {
|
|
43
|
+
dateFormat: {
|
|
44
|
+
sameMonth: {
|
|
45
|
+
firstDate: 'MMMM d',
|
|
46
|
+
endDate: 'd, yyyy'
|
|
47
|
+
},
|
|
48
|
+
differentMonth: {
|
|
49
|
+
firstDate: 'MMM d',
|
|
50
|
+
endDate: 'MMM d, yyyy'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
tooltipDateFormat: {
|
|
54
|
+
sameMonth: {
|
|
55
|
+
firstDate: 'MMMM d',
|
|
56
|
+
endDate: 'd, yyyy'
|
|
57
|
+
},
|
|
58
|
+
differentMonth: {
|
|
59
|
+
firstDate: 'MMM d',
|
|
60
|
+
endDate: 'MMM d, yyyy'
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
month: {
|
|
65
|
+
dateFormat: 'LLLL yyyy'
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
dateFormat: 'MM/dd/yyyy',
|
|
69
|
+
monthCalendarFormat: 'LLL',
|
|
70
|
+
dateWithTimeFormat: 'MM/dd/yyyy HH:mm',
|
|
71
|
+
emptyDate: {
|
|
72
|
+
withTime: '__/__/____ __:__',
|
|
73
|
+
withoutTime: '__/__/____'
|
|
74
|
+
},
|
|
75
|
+
inputMask: {
|
|
76
|
+
withTime: '99/99/9999 99:99',
|
|
77
|
+
withoutTime: '99/99/9999'
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
export { enLocaleValues };
|