@weni/unnnic-system 3.31.1-alpha.2 → 3.32.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/dist/style.css +1 -1
- package/dist/unnnic.mjs +1 -1
- package/dist/unnnic.umd.js +1 -1
- package/package.json +8 -9
- package/public/doris.png +0 -0
- package/public/favicon.ico +0 -0
- package/src/App.vue +0 -0
- package/src/assets/emoji/u1F600.png +0 -0
- package/src/assets/emoji/u1F601.png +0 -0
- package/src/assets/emoji/u1F602.png +0 -0
- package/src/assets/emoji/u1F603.png +0 -0
- package/src/assets/emoji/u1F604.png +0 -0
- package/src/assets/emoji/u1F605.png +0 -0
- package/src/assets/emoji/u1F606.png +0 -0
- package/src/assets/emoji/u1F607.png +0 -0
- package/src/assets/emoji/u1F608.png +0 -0
- package/src/assets/emoji/u1F609.png +0 -0
- package/src/assets/emoji/u1F610.png +0 -0
- package/src/assets/emoji/u1F611.png +0 -0
- package/src/assets/emoji/u1F612.png +0 -0
- package/src/assets/emoji/u1F613.png +0 -0
- package/src/assets/emoji/u1F614.png +0 -0
- package/src/assets/emoji/u1F615.png +0 -0
- package/src/assets/emoji/u1F616.png +0 -0
- package/src/assets/emoji/u1F617.png +0 -0
- package/src/assets/emoji/u1F618.png +0 -0
- package/src/assets/emoji/u1F619.png +0 -0
- package/src/assets/emoji/u1F620.png +0 -0
- package/src/assets/emoji/u1F621.png +0 -0
- package/src/assets/emoji/u1F622.png +0 -0
- package/src/assets/emoji/u1F623.png +0 -0
- package/src/assets/emoji/u1F624.png +0 -0
- package/src/assets/emoji/u1F625.png +0 -0
- package/src/assets/emoji/u1F626.png +0 -0
- package/src/assets/emoji/u1F627.png +0 -0
- package/src/assets/emoji/u1F628.png +0 -0
- package/src/assets/emoji/u1F629.png +0 -0
- package/src/assets/emoji/u1F630.png +0 -0
- package/src/assets/emoji/u1F631.png +0 -0
- package/src/assets/emoji/u1F632.png +0 -0
- package/src/assets/emoji/u1F633.png +0 -0
- package/src/assets/emoji/u1F634.png +0 -0
- package/src/assets/emoji/u1F635.png +0 -0
- package/src/assets/emoji/u1F636.png +0 -0
- package/src/assets/emoji/u1F637.png +0 -0
- package/src/assets/emoji/u1F638.png +0 -0
- package/src/assets/emoji/u1F639.png +0 -0
- package/src/assets/emoji/u1F640.png +0 -0
- package/src/assets/emoji/u1F641.png +0 -0
- package/src/assets/emoji/u1F642.png +0 -0
- package/src/assets/emoji/u1F643.png +0 -0
- package/src/assets/emoji/u1F644.png +0 -0
- package/src/assets/emoji/u1F645.png +0 -0
- package/src/assets/fonts/material-symbols-rounded.woff2 +0 -0
- package/src/assets/icons/Brazil.vue +74 -0
- package/src/assets/icons/CheckboxDefault.vue +19 -0
- package/src/assets/icons/CheckboxDisable.vue +19 -0
- package/src/assets/icons/CheckboxLess.vue +23 -0
- package/src/assets/icons/CheckboxSelect.vue +25 -0
- package/src/assets/icons/FitnessBiceps1.vue +15 -0
- package/src/assets/icons/Indicator.vue +18 -0
- package/src/assets/icons/Messages.vue +18 -0
- package/src/assets/icons/NavigationMenuVertical1.vue +25 -0
- package/src/assets/icons/Pin.vue +33 -0
- package/src/assets/icons/RadioDefault.vue +17 -0
- package/src/assets/icons/RadioDisable.vue +17 -0
- package/src/assets/icons/RadioSelected.vue +23 -0
- package/src/assets/icons/SingleNeutral2.vue +20 -0
- package/src/assets/icons/SingleNeutralActions1.vue +20 -0
- package/src/assets/icons/SocialInstagram1.vue +15 -0
- package/src/assets/icons/SocialMediaFacebook1.vue +15 -0
- package/src/assets/icons/SortAsc.vue +19 -0
- package/src/assets/icons/SortDefault.vue +20 -0
- package/src/assets/icons/SortDesc.vue +19 -0
- package/src/assets/icons/Spain.vue +1846 -0
- package/src/assets/icons/SwitchDefault.vue +31 -0
- package/src/assets/icons/SwitchDefaultDisabled.vue +25 -0
- package/src/assets/icons/SwitchSelected.vue +31 -0
- package/src/assets/icons/SwitchSelectedDisabled.vue +23 -0
- package/src/assets/icons/TransferMessage.vue +24 -0
- package/src/assets/icons/USA.vue +192 -0
- package/src/assets/icons/Unpin.vue +33 -0
- package/src/assets/icons/checkbox-checked-disabled.svg +3 -0
- package/src/assets/icons/checkbox-checked.svg +3 -0
- package/src/assets/icons/checkbox-less-disabled.svg +3 -0
- package/src/assets/icons/checkbox-less.svg +3 -0
- package/src/assets/icons/radio-checked.svg +3 -0
- package/src/assets/icons/switch-checked-disabled.svg +3 -0
- package/src/assets/icons/switch-checked.svg +3 -0
- package/src/assets/icons/weni-loading.svg +2 -0
- package/src/assets/img/flag/en.svg +28 -0
- package/src/assets/img/flag/pt-br.svg +21 -0
- package/src/assets/img/previews/doc-preview.png +0 -0
- package/src/assets/img/previews/image-preview.png +0 -0
- package/src/assets/img/previews/video-preview.png +0 -0
- package/src/assets/tokens/colors-primitives.json +155 -0
- package/src/assets/tokens/colors-semantic-dark.json +55 -0
- package/src/assets/tokens/colors-semantic.json +55 -0
- package/src/assets/tokens/fonts.json +70 -0
- package/src/assets/tokens/icon-sizes.json +22 -0
- package/src/assets/tokens/radii.json +28 -0
- package/src/assets/tokens/shadows.json +10 -0
- package/src/assets/tokens/spaces.json +46 -0
- package/src/components/Accordion/Accordion.vue +149 -0
- package/src/components/Alert/Alert.vue +62 -0
- package/src/components/Alert/Version1dot1.vue +231 -0
- package/src/components/Alert/__tests__/Alert.spec.js +41 -0
- package/src/components/Alert/__tests__/Version1dot1.spec.js +101 -0
- package/src/components/Alert/__tests__/__snapshots__/Alert.spec.js.snap +15 -0
- package/src/components/Alert/__tests__/__snapshots__/AlertBanner.spec.js.snap +10 -0
- package/src/components/Alert/__tests__/__snapshots__/AlertCaller.spec.js.snap +3 -0
- package/src/components/Alert/__tests__/__snapshots__/Version1dot1.spec.js.snap +13 -0
- package/src/components/AudioRecorder/AudioHandler.vue +121 -0
- package/src/components/AudioRecorder/AudioPlayer.vue +403 -0
- package/src/components/AudioRecorder/AudioRecorder.vue +475 -0
- package/src/components/AudioRecorder/AudioTranscriptionButton.vue +73 -0
- package/src/components/AvatarIcon/AvatarIcon.vue +107 -0
- package/src/components/AvatarIcon/__tests__/AvatarIcon.spec.js +84 -0
- package/src/components/AvatarIcon/__tests__/__snapshots__/AvatarIcon.spec.js.snap +7 -0
- package/src/components/Banner/Banner.vue +79 -0
- package/src/components/Banner/InfoBanner.vue +158 -0
- package/src/components/Breadcrumb/Breadcrumb.vue +82 -0
- package/src/components/Breadcrumb/__tests__/Breadcrumb.spec.js +68 -0
- package/src/components/Button/Button.vue +371 -0
- package/src/components/Button/__tests__/Button.spec.js +188 -0
- package/src/components/Button/types.ts +22 -0
- package/src/components/Card/AccountCard.vue +94 -0
- package/src/components/Card/BlankCard.vue +85 -0
- package/src/components/Card/Card.vue +218 -0
- package/src/components/Card/CardCompany.vue +189 -0
- package/src/components/Card/CardData.vue +123 -0
- package/src/components/Card/CardStatusesContainer.vue +255 -0
- package/src/components/Card/ContentCard.vue +145 -0
- package/src/components/Card/DashCard.vue +144 -0
- package/src/components/Card/DefaultCard.vue +87 -0
- package/src/components/Card/MarketplaceCard.vue +187 -0
- package/src/components/Card/SimpleCard.vue +166 -0
- package/src/components/Card/StatusCard.vue +113 -0
- package/src/components/Card/TitleCard.vue +100 -0
- package/src/components/CardImage/CardImage.vue +172 -0
- package/src/components/CardInformation/CardInformation.vue +65 -0
- package/src/components/CardNumber/CardNumber.vue +61 -0
- package/src/components/CardProject/CardProject.vue +320 -0
- package/src/components/CardProject/__tests__/CardProject.spec.js +161 -0
- package/src/components/ChartBar/ChartBar.vue +428 -0
- package/src/components/ChartFunnel/ChartFunnel.vue +70 -0
- package/src/components/ChartFunnel/DefaultFunnel/ChartDefaultFunnelBase.vue +200 -0
- package/src/components/ChartFunnel/DefaultFunnel/__tests__/ChartDefaultFunnelBase.unit.spec.js +123 -0
- package/src/components/ChartFunnel/DefaultFunnel/__tests__/__snapshots__/ChartDefaultFunnelBase.unit.spec.js.snap +66 -0
- package/src/components/ChartFunnel/SvgFunnel/ChartFunnelBaseRow.vue +79 -0
- package/src/components/ChartFunnel/SvgFunnel/ChartFunnelFiveRows.vue +101 -0
- package/src/components/ChartFunnel/SvgFunnel/ChartFunnelFourRows.vue +89 -0
- package/src/components/ChartFunnel/SvgFunnel/ChartFunnelThreeRows.vue +77 -0
- package/src/components/ChartFunnel/SvgFunnel/ChartFunnelTwoRows.vue +64 -0
- package/src/components/ChartFunnel/SvgFunnel/__tests__/ChartFunnelBaseRow.unit.spec.js +192 -0
- package/src/components/ChartFunnel/SvgFunnel/__tests__/ChartFunnelFiveRows.unit.spec.js +126 -0
- package/src/components/ChartFunnel/SvgFunnel/__tests__/ChartFunnelFourRows.unit.spec.js +122 -0
- package/src/components/ChartFunnel/SvgFunnel/__tests__/ChartFunnelThreeRow.unit.spec.js +120 -0
- package/src/components/ChartFunnel/SvgFunnel/__tests__/__snapshots__/ChartFunnelBaseRow.unit.spec.js.snap +15 -0
- package/src/components/ChartFunnel/SvgFunnel/__tests__/__snapshots__/ChartFunnelFiveRows.unit.spec.js.snap +3 -0
- package/src/components/ChartFunnel/SvgFunnel/__tests__/__snapshots__/ChartFunnelFourRows.unit.spec.js.snap +3 -0
- package/src/components/ChartFunnel/SvgFunnel/__tests__/__snapshots__/ChartFunnelThreeRow.unit.spec.js.snap +3 -0
- package/src/components/ChartFunnel/__tests__/ChartFunnel.unit.spec.js +161 -0
- package/src/components/ChartFunnel/__tests__/__snapshots__/ChartFunnel.unit.spec.js.snap +3 -0
- package/src/components/ChartLine/ChartLine.vue +322 -0
- package/src/components/ChartLine/__tests__/ChartLine.spec.js +170 -0
- package/src/components/ChartMultiLine/ChartMultiLine.vue +326 -0
- package/src/components/ChartMultiLine/Line/Line.vue +170 -0
- package/src/components/ChartRainbow/ChartRainbow.vue +201 -0
- package/src/components/ChatsUserAvatar/ChatsUserAvatar.vue +158 -0
- package/src/components/Checkbox/Checkbox.vue +192 -0
- package/src/components/Checkbox/__tests__/Checkbox.spec.js +65 -0
- package/src/components/CheckboxGroup/CheckboxGroup.vue +88 -0
- package/src/components/CheckboxGroup/__tests__/CheckboxGroup.spec.js +62 -0
- package/src/components/Chip/Chip.vue +125 -0
- package/src/components/Chip/__tests__/Chip.spec.js +164 -0
- package/src/components/Chip/types.ts +8 -0
- package/src/components/Collapse/Collapse.vue +142 -0
- package/src/components/Collapse/__tests__/Collapse.spec.js +117 -0
- package/src/components/Collapse/__tests__/__snapshots__/Collapse.spec.js.snap +8 -0
- package/src/components/Comment/Comment.vue +99 -0
- package/src/components/DataArea/DataArea.vue +99 -0
- package/src/components/DataTable/index.vue +555 -0
- package/src/components/DateFilter/DateFilter.vue +82 -0
- package/src/components/DatePicker/DatePicker.vue +1148 -0
- package/src/components/DatePicker/__tests__/DatePicker.spec.js +591 -0
- package/src/components/DatePicker/translations.js +148 -0
- package/src/components/Disclaimer/Disclaimer.vue +179 -0
- package/src/components/Disclaimer/__tests__/Disclaimer.spec.js +165 -0
- package/src/components/Disclaimer/types.ts +16 -0
- package/src/components/Drawer/Drawer.vue +248 -0
- package/src/components/Drawer/__tests__/Drawer.spec.js +280 -0
- package/src/components/Drawer/__tests__/__snapshots__/Drawer.spec.js.snap +22 -0
- package/src/components/DropArea/DropArea.vue +373 -0
- package/src/components/DropArea/__tests__/DropArea.spec.js +333 -0
- package/src/components/Dropdown/Dropdown.vue +142 -0
- package/src/components/Dropdown/DropdownItem.vue +32 -0
- package/src/components/Dropdown/DropdownSkeleton.vue +180 -0
- package/src/components/Dropdown/LanguageSelect.vue +296 -0
- package/src/components/Dropdown/__tests__/Dropdown.spec.js +155 -0
- package/src/components/Dropdown/__tests__/DropdownItem.spec.js +25 -0
- package/src/components/Dropdown/__tests__/DropdownSkeleton.spec.js +147 -0
- package/src/components/EmojiPicker/EmojiPicker.vue +244 -0
- package/src/components/EmojiPicker/__tests__/EmojiPicker.spec.js +236 -0
- package/src/components/Flag.vue +40 -0
- package/src/components/FormElement/FormElement.vue +139 -0
- package/src/components/Icon/OldIconsMap.json +111 -0
- package/src/components/Icon/types.ts +26 -0
- package/src/components/Icon.vue +198 -0
- package/src/components/IconLoading/IconLoading.vue +107 -0
- package/src/components/ImportCard/ImportCard.vue +245 -0
- package/src/components/Input/BaseInput.vue +156 -0
- package/src/components/Input/Input.scss +43 -0
- package/src/components/Input/Input.vue +191 -0
- package/src/components/Input/TextInput.vue +233 -0
- package/src/components/Input/__test__/BaseInput.spec.js +107 -0
- package/src/components/Input/__test__/Input.spec.js +103 -0
- package/src/components/Input/__test__/TextInput.spec.js +209 -0
- package/src/components/Input/__test__/__snapshots__/BaseInput.spec.js.snap +3 -0
- package/src/components/Input/__test__/__snapshots__/Input.spec.js.snap +22 -0
- package/src/components/Input/__test__/__snapshots__/TextInput.spec.js.snap +9 -0
- package/src/components/InputDatePicker/InputDatePicker.vue +253 -0
- package/src/components/InputDatePicker/__test__/InputDatePicker.spec.js +208 -0
- package/src/components/Label/Label.vue +62 -0
- package/src/components/Label/__tests__/Label.spec.js +30 -0
- package/src/components/Label/__tests__/__snapshots__/Label.spec.js.snap +3 -0
- package/src/components/Modal/CallModal.vue +23 -0
- package/src/components/Modal/Modal.vue +377 -0
- package/src/components/ModalDialog/ModalDialog.vue +245 -0
- package/src/components/ModalDialog/__tests__/ModalDialog.spec.js +159 -0
- package/src/components/ModalDialog/__tests__/__snapshots__/ModalDialog.spec.js.snap +3 -0
- package/src/components/ModalNext/ModalNext.vue +437 -0
- package/src/components/MultiSelect/MultiSelectOption.vue +49 -0
- package/src/components/MultiSelect/__tests__/MultiSelect.spec.js +655 -0
- package/src/components/MultiSelect/__tests__/MultiSelectOption.spec.js +229 -0
- package/src/components/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +91 -0
- package/src/components/MultiSelect/__tests__/__snapshots__/MultiSelectOption.spec.js.snap +51 -0
- package/src/components/MultiSelect/index.vue +240 -0
- package/src/components/Navigator/__tests__/Navigator.spec.js +55 -0
- package/src/components/Navigator/index.vue +100 -0
- package/src/components/PageHeader/PageHeader.vue +151 -0
- package/src/components/PageHeader/__tests__/PageHeader.spec.js +97 -0
- package/src/components/PageHeader/index.ts +2 -0
- package/src/components/PageHeader/types.ts +11 -0
- package/src/components/Pagination/Pagination.vue +190 -0
- package/src/components/Pagination/__tests__/Pagination.spec.js +307 -0
- package/src/components/ProgressBar/ProgressBar.vue +245 -0
- package/src/components/Radio/Radio.vue +168 -0
- package/src/components/Radio/__test__/Radio.spec.js +145 -0
- package/src/components/Radio/__test__/__snapshots__/Radio.spec.js.snap +8 -0
- package/src/components/RadioGroup/RadioGroup.vue +128 -0
- package/src/components/RadioGroup/__tests__/RadioGroup.spec.js +100 -0
- package/src/components/Select/SelectItem.vue +85 -0
- package/src/components/Select/__tests__/Select.spec.js +626 -0
- package/src/components/Select/__tests__/SelectItem.spec.js +330 -0
- package/src/components/Select/__tests__/__snapshots__/Popover.spec.js.snap +8 -0
- package/src/components/Select/__tests__/__snapshots__/Select.spec.js.snap +91 -0
- package/src/components/Select/__tests__/__snapshots__/SelectItem.spec.js.snap +15 -0
- package/src/components/Select/__tests__/__snapshots__/SelectOption.spec.js.snap +25 -0
- package/src/components/Select/__tests__/__snapshots__/SelectPopover.spec.js.snap +8 -0
- package/src/components/Select/_select-shared.scss +25 -0
- package/src/components/Select/index.vue +459 -0
- package/src/components/Select/types.ts +37 -0
- package/src/components/SelectSmart/SelectSmart.vue +873 -0
- package/src/components/SelectSmart/SelectSmartMultipleHeader.vue +144 -0
- package/src/components/SelectSmart/SelectSmartOption.vue +178 -0
- package/src/components/SelectSmart/__tests__/SelectSmart.spec.js +527 -0
- package/src/components/SelectSmart/__tests__/SelectSmartMultipleHeader.spec.js +86 -0
- package/src/components/SelectSmart/__tests__/SelectSmartOption.spec.js +139 -0
- package/src/components/SelectSmart/__tests__/__snapshots__/SelectSmartMultipleHeader.spec.js.snap +8 -0
- package/src/components/SelectSmart/__tests__/__snapshots__/SelectSmartOption.spec.js.snap +10 -0
- package/src/components/SelectTime/index.vue +220 -0
- package/src/components/Sidebar/SidebarItem.vue +224 -0
- package/src/components/Sidebar/__tests__/SidebarItem.spec.js +105 -0
- package/src/components/Sidebar/__tests__/Siderbar.spec.js +92 -0
- package/src/components/Sidebar/index.vue +126 -0
- package/src/components/Sidebar/propsValidator.js +24 -0
- package/src/components/SkeletonLoading/SkeletonLoading.vue +156 -0
- package/src/components/SkeletonLoading/__tests__/SkeletonLoading.spec.js +128 -0
- package/src/components/SkeletonLoading/skeletonTheme.vue +66 -0
- package/src/components/Switch/Switch.vue +185 -0
- package/src/components/Switch/__tests__/Switch.spec.js +55 -0
- package/src/components/Switch/__tests__/__snapshots__/Switch.spec.js.snap +10 -0
- package/src/components/Tab/Tab.vue +203 -0
- package/src/components/Tab/__test__/Tab.spec.js +152 -0
- package/src/components/Tab/__test__/__snapshots__/Tab.spec.js.snap +23 -0
- package/src/components/Table/Table.vue +143 -0
- package/src/components/Table/TableRow.vue +101 -0
- package/src/components/TableNext/TableBodyCell.vue +47 -0
- package/src/components/TableNext/TableNext.vue +428 -0
- package/src/components/TableNext/TablePagination.vue +98 -0
- package/src/components/TableNext/__test__/TableBodyCell.spec.js +65 -0
- package/src/components/TableNext/__test__/TableNext.spec.js +197 -0
- package/src/components/TableNext/__test__/TablePagination.spec.js +65 -0
- package/src/components/TableNext/__test__/__snapshots__/TableNext.spec.js.snap +59 -0
- package/src/components/TableNext/__test__/__snapshots__/TablePagination.spec.js.snap +41 -0
- package/src/components/TableNext/__test__/validation.unit.test.js +90 -0
- package/src/components/TableNext/validation.js +66 -0
- package/src/components/TabsExpanded/TabsExpanded.vue +156 -0
- package/src/components/TabsExpanded/__tests__/TabsExpanded.spec.js +78 -0
- package/src/components/Tag/DefaultTag.vue +87 -0
- package/src/components/Tag/Tag.vue +43 -0
- package/src/components/Tag/__tests__/DefaultTag.spec.js +51 -0
- package/src/components/Tag/__tests__/Tag.spec.js +82 -0
- package/src/components/Tag/types.ts +19 -0
- package/src/components/TemplatePreview/TemplatePreview.vue +252 -0
- package/src/components/TemplatePreview/TemplatePreviewModal.vue +51 -0
- package/src/components/TemplatePreview/types.d.ts +16 -0
- package/src/components/TextArea/TextArea.vue +138 -0
- package/src/components/TextArea/__test__/TextArea.spec.js +218 -0
- package/src/components/TextArea/__test__/__snapshots__/TextArea.spec.js.snap +17 -0
- package/src/components/Toast/Toast.vue +252 -0
- package/src/components/Toast/ToastManager.ts +113 -0
- package/src/components/Toast/__tests__/Toast.spec.js +291 -0
- package/src/components/Toast/__tests__/ToastManager.spec.js +298 -0
- package/src/components/Toast/types.ts +57 -0
- package/src/components/ToolTip/ToolTip.vue +99 -0
- package/src/components/ToolTip/__tests__/ToolTip.spec.js +451 -0
- package/src/components/Tour/Tour.vue +138 -0
- package/src/components/Tour/TourMask.vue +135 -0
- package/src/components/Tour/TourPopover.vue +236 -0
- package/src/components/Tour/propsValidation.js +82 -0
- package/src/components/UploadArea/UploadArea.vue +141 -0
- package/src/components/__tests__/Icon.spec.js +94 -0
- package/src/components/config.js +1 -0
- package/src/components/grid/Grid.vue +50 -0
- package/src/components/icons/IconCommunity.vue +12 -0
- package/src/components/icons/IconDocumentation.vue +12 -0
- package/src/components/icons/IconEcosystem.vue +12 -0
- package/src/components/icons/IconSupport.vue +12 -0
- package/src/components/icons/IconTooling.vue +19 -0
- package/src/components/icons/iconArrowsDefault.vue +16 -0
- package/src/components/index.ts +468 -0
- package/src/components/ui/dialog/Dialog.vue +51 -0
- package/src/components/ui/dialog/DialogClose.vue +29 -0
- package/src/components/ui/dialog/DialogContent.vue +141 -0
- package/src/components/ui/dialog/DialogFooter.vue +46 -0
- package/src/components/ui/dialog/DialogHeader.vue +83 -0
- package/src/components/ui/dialog/DialogTitle.vue +38 -0
- package/src/components/ui/dialog/DialogTrigger.vue +16 -0
- package/src/components/ui/dialog/index.ts +7 -0
- package/src/components/ui/drawer/Drawer.vue +80 -0
- package/src/components/ui/drawer/DrawerClose.vue +31 -0
- package/src/components/ui/drawer/DrawerContent.vue +114 -0
- package/src/components/ui/drawer/DrawerDescription.vue +40 -0
- package/src/components/ui/drawer/DrawerFooter.vue +34 -0
- package/src/components/ui/drawer/DrawerHeader.vue +57 -0
- package/src/components/ui/drawer/DrawerOverlay.vue +33 -0
- package/src/components/ui/drawer/DrawerTitle.vue +37 -0
- package/src/components/ui/drawer/DrawerTrigger.vue +31 -0
- package/src/components/ui/drawer/index.ts +10 -0
- package/src/components/ui/popover/Popover.vue +19 -0
- package/src/components/ui/popover/PopoverContent.vue +113 -0
- package/src/components/ui/popover/PopoverFooter.vue +47 -0
- package/src/components/ui/popover/PopoverOption.vue +130 -0
- package/src/components/ui/popover/PopoverTrigger.vue +27 -0
- package/src/components/ui/popover/__tests__/PopoverFooter.spec.js +116 -0
- package/src/components/ui/popover/context.ts +4 -0
- package/src/components/ui/popover/index.ts +6 -0
- package/src/components/ui/segmented-control/SegmentedControlList.vue +51 -0
- package/src/components/ui/segmented-control/SegmentedControlTrigger.vue +81 -0
- package/src/components/ui/segmented-control/index.ts +4 -0
- package/src/components/ui/table/Table.vue +29 -0
- package/src/components/ui/table/TableBody.vue +14 -0
- package/src/components/ui/table/TableCell.vue +28 -0
- package/src/components/ui/table/TableHead.vue +27 -0
- package/src/components/ui/table/TableHeader.vue +24 -0
- package/src/components/ui/table/TableRow.vue +51 -0
- package/src/components/ui/table/index.ts +6 -0
- package/src/components/ui/tabs/Tabs.vue +19 -0
- package/src/components/ui/tabs/TabsContent.vue +22 -0
- package/src/components/ui/tabs/TabsList.vue +40 -0
- package/src/components/ui/tabs/TabsTrigger.vue +63 -0
- package/src/components/ui/tabs/index.ts +4 -0
- package/src/components/ui/tooltip/Tooltip.vue +21 -0
- package/src/components/ui/tooltip/TooltipContent.vue +84 -0
- package/src/components/ui/tooltip/TooltipTrigger.vue +24 -0
- package/src/components/ui/tooltip/index.ts +3 -0
- package/src/composables/useDelayedUnmount.ts +48 -0
- package/src/composables/useSelectBase.ts +119 -0
- package/src/composables/useSelectKeyboard.ts +91 -0
- package/src/composables/useTheme.ts +67 -0
- package/src/index.ts +29 -0
- package/src/lib/__tests__/teleport-target.spec.ts +73 -0
- package/src/lib/layer-manager.ts +64 -0
- package/src/lib/teleport-target.ts +46 -0
- package/src/lib/utils.ts +7 -0
- package/src/locales/en.json +50 -0
- package/src/locales/es.json +50 -0
- package/src/locales/pt_br.json +50 -0
- package/src/main.ts +9 -0
- package/src/mixins/i18n.js +74 -0
- package/src/stories/Accordion.stories.js +54 -0
- package/src/stories/Alert.stories.js +157 -0
- package/src/stories/AudioRecorder.stories.js +52 -0
- package/src/stories/AvatarIcon.stories.js +57 -0
- package/src/stories/Banner.stories.js +54 -0
- package/src/stories/Breadcrumb.stories.js +30 -0
- package/src/stories/Button.stories.js +183 -0
- package/src/stories/Card.stories.js +154 -0
- package/src/stories/CardCompany.stories.js +64 -0
- package/src/stories/CardData.stories.js +25 -0
- package/src/stories/CardImage.stories.js +58 -0
- package/src/stories/CardInformation.stories.js +44 -0
- package/src/stories/CardNumber.stories.js +15 -0
- package/src/stories/CardProject.stories.js +70 -0
- package/src/stories/CardSimple.stories.js +73 -0
- package/src/stories/ChartBar.stories.js +123 -0
- package/src/stories/ChartFunnel.stories.js +127 -0
- package/src/stories/ChartLine.stories.js +55 -0
- package/src/stories/ChartMultiLine.stories.js +50 -0
- package/src/stories/ChartRainbow.stories.js +18 -0
- package/src/stories/ChatsUserAvatar.stories.js +36 -0
- package/src/stories/Checkbox.stories.js +79 -0
- package/src/stories/CheckboxGroup.stories.js +105 -0
- package/src/stories/Chip.stories.js +194 -0
- package/src/stories/Collapse.stories.js +81 -0
- package/src/stories/Colors.mdx +13 -0
- package/src/stories/Colors.stories.js +132 -0
- package/src/stories/Comment.stories.js +66 -0
- package/src/stories/DataArea.stories.js +78 -0
- package/src/stories/DataTable.stories.js +588 -0
- package/src/stories/DateFilter.stories.js +18 -0
- package/src/stories/DatePicker.stories.js +114 -0
- package/src/stories/Dialog.stories.js +851 -0
- package/src/stories/Disclaimer.stories.js +93 -0
- package/src/stories/Drawer.stories.js +242 -0
- package/src/stories/DrawerNext.stories.js +631 -0
- package/src/stories/DropArea.mdx +66 -0
- package/src/stories/DropArea.stories.js +74 -0
- package/src/stories/Dropdown.stories.js +35 -0
- package/src/stories/EmojiPicker.stories.js +93 -0
- package/src/stories/FormElement.stories.js +35 -0
- package/src/stories/Grid.stories.js +19 -0
- package/src/stories/Icon.stories.js +144 -0
- package/src/stories/IconLoading.stories.js +63 -0
- package/src/stories/Iconography.mdx +7 -0
- package/src/stories/ImportCard.stories.js +33 -0
- package/src/stories/Input.mdx +79 -0
- package/src/stories/Input.stories.js +157 -0
- package/src/stories/InputDatePicker.stories.js +155 -0
- package/src/stories/Label.stories.js +30 -0
- package/src/stories/LanguageSelect.stories.js +26 -0
- package/src/stories/LayerManager.docs.mdx +40 -0
- package/src/stories/LayerManager.stories.js +407 -0
- package/src/stories/Modal.stories.js +101 -0
- package/src/stories/ModalDialog.mdx +89 -0
- package/src/stories/ModalDialog.stories.js +448 -0
- package/src/stories/ModalNext.stories.js +191 -0
- package/src/stories/MultiSelect.stories.js +169 -0
- package/src/stories/Navigator.stories.js +26 -0
- package/src/stories/PageHeader.stories.js +364 -0
- package/src/stories/Pagination.stories.js +37 -0
- package/src/stories/Popover.stories.js +457 -0
- package/src/stories/PopoverOption.stories.js +128 -0
- package/src/stories/ProgressBar.stories.js +38 -0
- package/src/stories/Radio.stories.js +104 -0
- package/src/stories/RadioGroup.stories.js +145 -0
- package/src/stories/SegmentedControl.stories.js +253 -0
- package/src/stories/Select.stories.js +375 -0
- package/src/stories/SelectSmart.mdx +152 -0
- package/src/stories/SelectSmart.stories.js +594 -0
- package/src/stories/SelectTime.stories.js +25 -0
- package/src/stories/Sidebar.stories.js +157 -0
- package/src/stories/SkeletonLoading.stories.js +28 -0
- package/src/stories/Switch.stories.js +46 -0
- package/src/stories/Tab.stories.js +56 -0
- package/src/stories/Table.stories.js +218 -0
- package/src/stories/TableNext.stories.js +176 -0
- package/src/stories/Tabs.stories.js +169 -0
- package/src/stories/TabsExpanded.stories.js +69 -0
- package/src/stories/Tag.stories.js +59 -0
- package/src/stories/TemplatePreview.stories.js +94 -0
- package/src/stories/TemplatePreviewModal.stories.js +110 -0
- package/src/stories/TextArea.mdx +68 -0
- package/src/stories/TextArea.stories.js +117 -0
- package/src/stories/Toast.mdx +123 -0
- package/src/stories/Toast.stories.js +126 -0
- package/src/stories/ToolTip.stories.js +71 -0
- package/src/stories/Tour.stories.js +216 -0
- package/src/stories/Typography.mdx +83 -0
- package/src/stories/Typography.stories.js +66 -0
- package/src/stories/UploadArea.stories.js +42 -0
- package/src/stories/assets/audios/audio-recorder-sample.mp3 +0 -0
- package/src/stories/assets/code-brackets.svg +1 -0
- package/src/stories/assets/colors.svg +1 -0
- package/src/stories/assets/comments.svg +1 -0
- package/src/stories/assets/direction.svg +1 -0
- package/src/stories/assets/flow.svg +1 -0
- package/src/stories/assets/images/un.png +0 -0
- package/src/stories/assets/images/unnnic.png +0 -0
- package/src/stories/assets/images/unnnicPortrait.png +0 -0
- package/src/stories/assets/plugin.svg +1 -0
- package/src/stories/assets/repo.svg +1 -0
- package/src/stories/assets/stackalt.svg +1 -0
- package/src/stories/assets/videos/weni.mp4 +0 -0
- package/src/types/index.d.ts +53 -0
- package/src/types/scheme-colors.d.ts +209 -0
- package/src/types/unnnic-utils.d.ts +88 -0
- package/src/types/vue-shims.d.ts +5 -0
- package/src/types/vueuse-overrides.d.ts +7 -0
- package/src/utils/call.js +81 -0
- package/src/utils/colorTokens.js +2 -0
- package/src/utils/colorsList.js +89 -0
- package/src/utils/emojiList.js +47 -0
- package/src/utils/hours.js +100 -0
- package/src/utils/iconList.js +108 -0
- package/src/utils/icons.js +59 -0
- package/src/utils/plugins/i18n.js +20 -0
- package/src/utils/sanitize.js +75 -0
- /package/{dist → src/assets}/scss/colors-hsl.scss +0 -0
- /package/{dist → src/assets}/scss/colors.scss +0 -0
- /package/{dist → src/assets}/scss/deprecated/colors.scss +0 -0
- /package/{dist → src/assets}/scss/deprecated/fonts.scss +0 -0
- /package/{dist → src/assets}/scss/deprecated/grid.scss +0 -0
- /package/{dist → src/assets}/scss/deprecated/spacing.scss +0 -0
- /package/{dist → src/assets}/scss/fonts.scss +0 -0
- /package/{dist → src/assets}/scss/icon-sizes.scss +0 -0
- /package/{dist → src/assets}/scss/radii.scss +0 -0
- /package/{dist → src/assets}/scss/scheme-colors.scss +0 -0
- /package/{dist → src/assets}/scss/semantic-colors.scss +0 -0
- /package/{dist → src/assets}/scss/semantic-text-utilities.scss +0 -0
- /package/{dist → src/assets}/scss/shadows.scss +0 -0
- /package/{dist → src/assets}/scss/spaces.scss +0 -0
- /package/{dist → src/assets}/scss/tailwind.scss +0 -0
- /package/{dist → src/assets}/scss/theme.scss +0 -0
- /package/{dist → src/assets}/scss/unnnic.scss +0 -0
|
@@ -0,0 +1,1148 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="['unnnic-date-picker', `unnnic-date-picker--${props.variant}`]"
|
|
4
|
+
data-testid="date-picker-root"
|
|
5
|
+
>
|
|
6
|
+
<template v-if="type === 'day'">
|
|
7
|
+
<template
|
|
8
|
+
v-for="(openMonth, index) in openMonths"
|
|
9
|
+
:key="openMonth"
|
|
10
|
+
>
|
|
11
|
+
<div
|
|
12
|
+
class="month-container"
|
|
13
|
+
data-testid="date-picker-month-container"
|
|
14
|
+
>
|
|
15
|
+
<div :class="['header', `header--${size}`]">
|
|
16
|
+
<UnnnicButton
|
|
17
|
+
size="small"
|
|
18
|
+
:iconCenter="`keyboard_arrow_${index === 0 ? 'left' : 'right'}`"
|
|
19
|
+
:type="size === 'large' ? 'secondary' : 'tertiary'"
|
|
20
|
+
class="button-space"
|
|
21
|
+
:style="{ gridArea: `${index === 0 ? 'left' : 'right'}-button` }"
|
|
22
|
+
:data-testid="`date-picker-nav-${index === 0 ? 'left' : 'right'}`"
|
|
23
|
+
@click.stop="
|
|
24
|
+
referenceDate = addMonth(referenceDate, index === 0 ? -1 : 1)
|
|
25
|
+
"
|
|
26
|
+
/>
|
|
27
|
+
|
|
28
|
+
<div :class="['label', `label--${size}`]">
|
|
29
|
+
{{ monthsLocale[Number(getMonth(openMonth)) - 1] }}
|
|
30
|
+
{{ getFullYear(openMonth) }}
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<div :class="['days', `days--${size}`]">
|
|
35
|
+
<div
|
|
36
|
+
v-for="(day, dayIndex) in daysLocale"
|
|
37
|
+
:key="dayIndex"
|
|
38
|
+
class="name"
|
|
39
|
+
>
|
|
40
|
+
{{ day }}
|
|
41
|
+
</div>
|
|
42
|
+
<div
|
|
43
|
+
v-for="(date, dateIndex) in getDatesOfTheMonth(openMonth)"
|
|
44
|
+
:key="`${openMonth}-${dateIndex}`"
|
|
45
|
+
:class="{
|
|
46
|
+
disabled:
|
|
47
|
+
!date.properties.includes('inside month') ||
|
|
48
|
+
date.properties.includes('out of range'),
|
|
49
|
+
selectable:
|
|
50
|
+
date.properties.includes('inside month') &&
|
|
51
|
+
!date.properties.includes('out of range'),
|
|
52
|
+
today: date.properties.includes('today'),
|
|
53
|
+
selected: date.properties.includes('selected'),
|
|
54
|
+
highlighted: date.properties.includes('highlighted'),
|
|
55
|
+
left: date.properties.includes('left-highlighted'),
|
|
56
|
+
right: date.properties.includes('right-highlighted'),
|
|
57
|
+
}"
|
|
58
|
+
data-testid="date-picker-day"
|
|
59
|
+
@click="
|
|
60
|
+
date.properties.includes('inside month') &&
|
|
61
|
+
!date.properties.includes('out of range') &&
|
|
62
|
+
selectDate(date)
|
|
63
|
+
"
|
|
64
|
+
>
|
|
65
|
+
{{ getDate(date) }}
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<div class="divider"></div>
|
|
71
|
+
</template>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<template v-else-if="type === 'month'">
|
|
75
|
+
<template
|
|
76
|
+
v-for="openMonth in [referenceDate]"
|
|
77
|
+
:key="openMonth"
|
|
78
|
+
>
|
|
79
|
+
<div
|
|
80
|
+
class="month-container"
|
|
81
|
+
data-testid="date-picker-month-container"
|
|
82
|
+
>
|
|
83
|
+
<div :class="['header', `header--${size}`]">
|
|
84
|
+
<UnnnicButton
|
|
85
|
+
size="small"
|
|
86
|
+
iconCenter="keyboard_arrow_left"
|
|
87
|
+
:type="size === 'large' ? 'secondary' : 'tertiary'"
|
|
88
|
+
class="button-space"
|
|
89
|
+
:style="{ gridArea: 'left-button' }"
|
|
90
|
+
data-testid="date-picker-month-nav-left"
|
|
91
|
+
@click="referenceDate = addMonth(referenceDate, -12)"
|
|
92
|
+
/>
|
|
93
|
+
|
|
94
|
+
<div :class="['label', `label--${size}`]">
|
|
95
|
+
{{ getFullYear(openMonth) }}
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<UnnnicButton
|
|
99
|
+
size="small"
|
|
100
|
+
iconCenter="keyboard_arrow_right"
|
|
101
|
+
:type="size === 'large' ? 'secondary' : 'tertiary'"
|
|
102
|
+
class="button-space"
|
|
103
|
+
:style="{ gridArea: 'right-button' }"
|
|
104
|
+
data-testid="date-picker-month-nav-right"
|
|
105
|
+
@click="referenceDate = addMonth(referenceDate, 12)"
|
|
106
|
+
/>
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
<div :class="['days', `months--${size}`]">
|
|
110
|
+
<div
|
|
111
|
+
v-for="(date, index) in getMonthsOfTheYear(openMonth)"
|
|
112
|
+
:key="`${openMonth}-${index}`"
|
|
113
|
+
:class="{
|
|
114
|
+
disabled: !date.properties.includes('inside month'),
|
|
115
|
+
selectable: date.properties.includes('inside month'),
|
|
116
|
+
today: date.properties.includes('today'),
|
|
117
|
+
selected: date.properties.includes('selected'),
|
|
118
|
+
highlighted: date.properties.includes('highlighted'),
|
|
119
|
+
left: date.properties.includes('left-highlighted'),
|
|
120
|
+
right: date.properties.includes('right-highlighted'),
|
|
121
|
+
}"
|
|
122
|
+
data-testid="date-picker-month-cell"
|
|
123
|
+
@click="
|
|
124
|
+
date.properties.includes('inside month') && selectDate(date)
|
|
125
|
+
"
|
|
126
|
+
>
|
|
127
|
+
{{ monthsLocale[getMonth(date) - 1].substr(0, 3) }}
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
<div class="divider"></div>
|
|
133
|
+
</template>
|
|
134
|
+
</template>
|
|
135
|
+
|
|
136
|
+
<template v-else-if="type === 'year'">
|
|
137
|
+
<template
|
|
138
|
+
v-for="openMonth in [referenceDate]"
|
|
139
|
+
:key="openMonth"
|
|
140
|
+
>
|
|
141
|
+
<div
|
|
142
|
+
class="month-container"
|
|
143
|
+
data-testid="date-picker-month-container"
|
|
144
|
+
>
|
|
145
|
+
<div :class="['header', `header--${size}`]">
|
|
146
|
+
<UnnnicButton
|
|
147
|
+
size="small"
|
|
148
|
+
iconCenter="arrow-left-1-1"
|
|
149
|
+
:type="size === 'large' ? 'secondary' : 'tertiary'"
|
|
150
|
+
class="button-space"
|
|
151
|
+
:style="{ gridArea: 'left-button' }"
|
|
152
|
+
data-testid="date-picker-year-nav-left"
|
|
153
|
+
@click="referenceDate = addMonth(referenceDate, -12 * 12)"
|
|
154
|
+
/>
|
|
155
|
+
|
|
156
|
+
<div :class="['label', `label--${size}`]">
|
|
157
|
+
{{ getFullYear(openMonth) }}
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
<UnnnicButton
|
|
161
|
+
size="small"
|
|
162
|
+
iconCenter="arrow-right-1-1"
|
|
163
|
+
:type="size === 'large' ? 'secondary' : 'tertiary'"
|
|
164
|
+
class="button-space"
|
|
165
|
+
:style="{ gridArea: 'right-button' }"
|
|
166
|
+
data-testid="date-picker-year-nav-right"
|
|
167
|
+
@click="referenceDate = addMonth(referenceDate, 12 * 12)"
|
|
168
|
+
/>
|
|
169
|
+
</div>
|
|
170
|
+
|
|
171
|
+
<div :class="['days', `months--${size}`]">
|
|
172
|
+
<div
|
|
173
|
+
v-for="(date, index) in getYears(openMonth)"
|
|
174
|
+
:key="`${openMonth}-${index}`"
|
|
175
|
+
:class="{
|
|
176
|
+
disabled: !date.properties.includes('inside month'),
|
|
177
|
+
selectable: date.properties.includes('inside month'),
|
|
178
|
+
today: date.properties.includes('today'),
|
|
179
|
+
selected: date.properties.includes('selected'),
|
|
180
|
+
highlighted: date.properties.includes('highlighted'),
|
|
181
|
+
left: date.properties.includes('left-highlighted'),
|
|
182
|
+
right: date.properties.includes('right-highlighted'),
|
|
183
|
+
}"
|
|
184
|
+
data-testid="date-picker-year-cell"
|
|
185
|
+
@click="
|
|
186
|
+
date.properties.includes('inside month') && selectDate(date)
|
|
187
|
+
"
|
|
188
|
+
>
|
|
189
|
+
{{ date.date }}
|
|
190
|
+
</div>
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
|
|
194
|
+
<div class="divider"></div>
|
|
195
|
+
</template>
|
|
196
|
+
</template>
|
|
197
|
+
|
|
198
|
+
<div
|
|
199
|
+
v-if="size !== 'small'"
|
|
200
|
+
class="options-container"
|
|
201
|
+
:style="{ flexDirection: containerOptionsFlexDirection }"
|
|
202
|
+
data-testid="date-picker-options"
|
|
203
|
+
>
|
|
204
|
+
<div
|
|
205
|
+
v-if="!hideOptions"
|
|
206
|
+
class="options"
|
|
207
|
+
>
|
|
208
|
+
<div
|
|
209
|
+
v-for="(option, index) in periodsLocale"
|
|
210
|
+
:key="index"
|
|
211
|
+
:class="[
|
|
212
|
+
'option',
|
|
213
|
+
{
|
|
214
|
+
selectable: option.id !== 'custom',
|
|
215
|
+
selected: optionSelected === option.id,
|
|
216
|
+
},
|
|
217
|
+
]"
|
|
218
|
+
data-testid="date-picker-option"
|
|
219
|
+
@click="option.id === 'custom' ? null : autoSelect(option.id)"
|
|
220
|
+
>
|
|
221
|
+
{{ option.name }}
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
|
|
225
|
+
<div class="actions">
|
|
226
|
+
<UnnnicButton
|
|
227
|
+
v-if="!disableClear"
|
|
228
|
+
size="small"
|
|
229
|
+
:text="clearText"
|
|
230
|
+
type="tertiary"
|
|
231
|
+
data-testid="date-picker-clear"
|
|
232
|
+
@click="clear"
|
|
233
|
+
/>
|
|
234
|
+
|
|
235
|
+
<UnnnicButton
|
|
236
|
+
size="small"
|
|
237
|
+
:text="filterText"
|
|
238
|
+
type="secondary"
|
|
239
|
+
data-testid="date-picker-submit"
|
|
240
|
+
@click="submit"
|
|
241
|
+
/>
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
</div>
|
|
245
|
+
</template>
|
|
246
|
+
|
|
247
|
+
<script setup lang="ts">
|
|
248
|
+
import {
|
|
249
|
+
computed,
|
|
250
|
+
getCurrentInstance,
|
|
251
|
+
nextTick,
|
|
252
|
+
onMounted,
|
|
253
|
+
ref,
|
|
254
|
+
watch,
|
|
255
|
+
} from 'vue';
|
|
256
|
+
import { get } from 'lodash';
|
|
257
|
+
|
|
258
|
+
import {
|
|
259
|
+
months as translationMonths,
|
|
260
|
+
days as translationDays,
|
|
261
|
+
periods as translationPeriods,
|
|
262
|
+
buttons as translationButtons,
|
|
263
|
+
} from './translations.js';
|
|
264
|
+
|
|
265
|
+
import i18n from '@/utils/plugins/i18n';
|
|
266
|
+
|
|
267
|
+
import UnnnicButton from '../Button/Button.vue';
|
|
268
|
+
|
|
269
|
+
defineOptions({
|
|
270
|
+
name: 'UnnnicDatePicker',
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
type PeriodOption = {
|
|
274
|
+
id: string;
|
|
275
|
+
name: string;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
export interface DatePickerProps {
|
|
279
|
+
initialStartDate?: string;
|
|
280
|
+
initialEndDate?: string;
|
|
281
|
+
|
|
282
|
+
minDate?: string;
|
|
283
|
+
maxDate?: string;
|
|
284
|
+
|
|
285
|
+
periodBaseDate?: string;
|
|
286
|
+
|
|
287
|
+
equivalentOption?: string;
|
|
288
|
+
|
|
289
|
+
type?: 'day' | 'month' | 'year';
|
|
290
|
+
size?: 'small' | 'large';
|
|
291
|
+
|
|
292
|
+
clearLabel?: string;
|
|
293
|
+
actionLabel?: string;
|
|
294
|
+
|
|
295
|
+
months?: string[];
|
|
296
|
+
days?: string[];
|
|
297
|
+
options?: PeriodOption[];
|
|
298
|
+
|
|
299
|
+
disableClear?: boolean;
|
|
300
|
+
hideOptions?: boolean;
|
|
301
|
+
|
|
302
|
+
locale?: string;
|
|
303
|
+
translations?: Record<string, unknown>;
|
|
304
|
+
|
|
305
|
+
variant?: 'card' | 'popover';
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const props = withDefaults(defineProps<DatePickerProps>(), {
|
|
309
|
+
initialStartDate: '',
|
|
310
|
+
initialEndDate: '',
|
|
311
|
+
minDate: '',
|
|
312
|
+
maxDate: '',
|
|
313
|
+
periodBaseDate: '',
|
|
314
|
+
equivalentOption: '',
|
|
315
|
+
type: 'day',
|
|
316
|
+
size: 'large',
|
|
317
|
+
clearLabel: '',
|
|
318
|
+
actionLabel: '',
|
|
319
|
+
months: () => [],
|
|
320
|
+
days: () => [],
|
|
321
|
+
options: () => [],
|
|
322
|
+
disableClear: false,
|
|
323
|
+
hideOptions: false,
|
|
324
|
+
locale: undefined,
|
|
325
|
+
translations: undefined,
|
|
326
|
+
variant: 'card',
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
const emit = defineEmits<{
|
|
330
|
+
(e: 'change', value: { startDate: string; endDate: string }): void;
|
|
331
|
+
(e: 'submit', value: { startDate: string; endDate: string }): void;
|
|
332
|
+
(e: 'update:equivalentOption', equivalentOption: string): void;
|
|
333
|
+
}>();
|
|
334
|
+
|
|
335
|
+
const today = new Date();
|
|
336
|
+
const referenceDate = ref<string>(
|
|
337
|
+
`${today.getMonth() + 1} 1 ${today.getFullYear()}`,
|
|
338
|
+
);
|
|
339
|
+
const startDate = ref<string>(
|
|
340
|
+
(props.initialStartDate || '').replace(/-/g, ' '),
|
|
341
|
+
);
|
|
342
|
+
const endDate = ref<string>((props.initialEndDate || '').replace(/-/g, ' '));
|
|
343
|
+
const optionSelected = ref<string>('');
|
|
344
|
+
|
|
345
|
+
const defaultTranslations = {
|
|
346
|
+
clean: {
|
|
347
|
+
'pt-br': 'Limpar',
|
|
348
|
+
en: 'Clean',
|
|
349
|
+
es: 'Limpiar',
|
|
350
|
+
},
|
|
351
|
+
filter: {
|
|
352
|
+
'pt-br': 'Filtrar',
|
|
353
|
+
en: 'Filter',
|
|
354
|
+
es: 'Filtrar',
|
|
355
|
+
},
|
|
356
|
+
} as const;
|
|
357
|
+
|
|
358
|
+
const instance = getCurrentInstance();
|
|
359
|
+
|
|
360
|
+
type I18nProxy = {
|
|
361
|
+
$i18n?: {
|
|
362
|
+
locale?: string;
|
|
363
|
+
};
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
const i18nLocale = computed(() => {
|
|
367
|
+
const localeFromInstance = (instance?.proxy as I18nProxy | null)?.$i18n
|
|
368
|
+
?.locale;
|
|
369
|
+
const finalLocale = localeFromInstance || 'en-us';
|
|
370
|
+
|
|
371
|
+
return String(finalLocale).toLowerCase();
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
const monthsLocale = computed(() => {
|
|
375
|
+
const months = props.months || [];
|
|
376
|
+
return months.length ? months : translationMonths[i18nLocale.value];
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
const daysLocale = computed(() => {
|
|
380
|
+
const days = props.days || [];
|
|
381
|
+
return days.length ? days : translationDays[i18nLocale.value];
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
const periodsLocale = computed<PeriodOption[]>(() => {
|
|
385
|
+
const options = props.options || [];
|
|
386
|
+
return options.length ? options : translationPeriods[i18nLocale.value];
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
const clearText = computed(() => {
|
|
390
|
+
return props.clearLabel || translationButtons[i18nLocale.value].clear;
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
const filterText = computed(() => {
|
|
394
|
+
return props.actionLabel || translationButtons[i18nLocale.value].filter;
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
const value = computed(() => ({
|
|
398
|
+
startDate: startDate.value.replaceAll(' ', '-'),
|
|
399
|
+
endDate: endDate.value.replaceAll(' ', '-'),
|
|
400
|
+
}));
|
|
401
|
+
|
|
402
|
+
const containerOptionsFlexDirection = computed(() => {
|
|
403
|
+
return props.hideOptions ? 'column-reverse' : 'column';
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
const i18nFn = (...args: any[]): string | undefined => {
|
|
407
|
+
const [key, defaults] = args;
|
|
408
|
+
|
|
409
|
+
const validLocaleValues = Object.keys(
|
|
410
|
+
((i18n as any).global.messages as Record<string, unknown>) || {},
|
|
411
|
+
);
|
|
412
|
+
|
|
413
|
+
let locale = props.locale as string | undefined;
|
|
414
|
+
|
|
415
|
+
const treatedSelectedLocale =
|
|
416
|
+
get(i18n, 'global.locale') === 'en-us'
|
|
417
|
+
? 'en'
|
|
418
|
+
: (get(i18n, 'global.locale') as string | undefined);
|
|
419
|
+
|
|
420
|
+
locale =
|
|
421
|
+
locale && validLocaleValues.includes(locale)
|
|
422
|
+
? locale
|
|
423
|
+
: treatedSelectedLocale;
|
|
424
|
+
|
|
425
|
+
locale = locale?.toLowerCase();
|
|
426
|
+
|
|
427
|
+
let text = get(
|
|
428
|
+
props.translations,
|
|
429
|
+
`${key}.${locale}`,
|
|
430
|
+
get(props.translations, key),
|
|
431
|
+
) as string | undefined;
|
|
432
|
+
|
|
433
|
+
if (!text) {
|
|
434
|
+
text = get(
|
|
435
|
+
defaultTranslations as Record<string, unknown>,
|
|
436
|
+
`${key}.${locale}`,
|
|
437
|
+
get(defaultTranslations as Record<string, unknown>, key, defaults),
|
|
438
|
+
) as string | undefined;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
if (text?.includes('|') && typeof args[1] === 'number') {
|
|
442
|
+
const count: number = args[1];
|
|
443
|
+
const pluralization = text.split('|');
|
|
444
|
+
|
|
445
|
+
if (pluralization.length === 3) {
|
|
446
|
+
text = pluralization[count] || pluralization[2];
|
|
447
|
+
} else if (pluralization.length === 2) {
|
|
448
|
+
text = count === 1 ? pluralization[0] : pluralization[1];
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
let vars: Record<string, string> = {};
|
|
453
|
+
|
|
454
|
+
Object.values(args)
|
|
455
|
+
.slice(1)
|
|
456
|
+
.forEach((argument) => {
|
|
457
|
+
if (!(argument instanceof Array) && argument instanceof Object) {
|
|
458
|
+
vars = argument as Record<string, string>;
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
Object.keys(vars).forEach((varName) => {
|
|
463
|
+
text = text?.replaceAll(new RegExp(`{ *${varName} *}`, 'g'), vars[varName]);
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
return text;
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
defineExpose({
|
|
470
|
+
i18n: i18nFn,
|
|
471
|
+
|
|
472
|
+
startDate,
|
|
473
|
+
endDate,
|
|
474
|
+
optionSelected,
|
|
475
|
+
referenceDate,
|
|
476
|
+
|
|
477
|
+
autoSelect,
|
|
478
|
+
dateToString,
|
|
479
|
+
getStartAndEndDateByPeriod,
|
|
480
|
+
getDatesOfTheMonth,
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
function dateToString(date: Date): string {
|
|
484
|
+
return `${date.getMonth() + 1} ${date.getDate()} ${date.getFullYear()}`;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
function dateToStringMonth(date: Date): string {
|
|
488
|
+
return `${date.getMonth() + 1} ${date.getFullYear()}`;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
function dateToStringYear(date: Date): number {
|
|
492
|
+
return date.getFullYear();
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
function stringToTime(date: string): number {
|
|
496
|
+
const [month, day, year] = date.split(' ');
|
|
497
|
+
return new Date(Number(year), Number(month) - 1, Number(day)).getTime();
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
function getDate(date: { toString: () => string }): string {
|
|
501
|
+
return date.toString().split(' ')[1];
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
function getMonth(date: { toString: () => string }): number {
|
|
505
|
+
return Number(date.toString().split(' ')[0]);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
function getFullYear(date: string): number {
|
|
509
|
+
const [month, day, year] = date.split(' ');
|
|
510
|
+
return new Date(Number(year), Number(month) - 1, Number(day)).getFullYear();
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
function addMonth(reference: string, quantity: number): string {
|
|
514
|
+
const [month, day, year] = reference.split(' ');
|
|
515
|
+
|
|
516
|
+
const date = new Date(Number(year), Number(month) - 1, Number(day));
|
|
517
|
+
|
|
518
|
+
date.setMonth(date.getMonth() + quantity);
|
|
519
|
+
|
|
520
|
+
return dateToString(date);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function isDateBetween(internalDate: number): boolean {
|
|
524
|
+
if (startDate.value && endDate.value) {
|
|
525
|
+
if (
|
|
526
|
+
internalDate >= stringToTime(startDate.value) &&
|
|
527
|
+
internalDate <= stringToTime(endDate.value)
|
|
528
|
+
) {
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
} else if (startDate.value && internalDate >= stringToTime(startDate.value)) {
|
|
532
|
+
return true;
|
|
533
|
+
} else if (endDate.value && internalDate <= stringToTime(endDate.value)) {
|
|
534
|
+
return true;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
function isDateBetweenMonth(internalDate: number): boolean {
|
|
541
|
+
if (startDate.value && endDate.value) {
|
|
542
|
+
const startTime = stringToTime(startDate.value);
|
|
543
|
+
const endTime = stringToTime(endDate.value);
|
|
544
|
+
|
|
545
|
+
return internalDate >= startTime && internalDate <= endTime;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
if (startDate.value) {
|
|
549
|
+
const startTime = stringToTime(startDate.value);
|
|
550
|
+
return internalDate >= startTime;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
if (endDate.value) {
|
|
554
|
+
const endTime = stringToTime(endDate.value);
|
|
555
|
+
return internalDate <= endTime;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
return false;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
function isDateBetweenYear(internalDate: number): boolean {
|
|
562
|
+
if (startDate.value && endDate.value) {
|
|
563
|
+
const startTime = stringToTime(startDate.value);
|
|
564
|
+
const endTime = stringToTime(endDate.value);
|
|
565
|
+
|
|
566
|
+
return internalDate >= startTime && internalDate <= endTime;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
if (startDate.value) {
|
|
570
|
+
const startTime = stringToTime(startDate.value);
|
|
571
|
+
return internalDate >= startTime;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
if (endDate.value) {
|
|
575
|
+
const endTime = stringToTime(endDate.value);
|
|
576
|
+
return internalDate <= endTime;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
return false;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
function getDatesOfTheMonth(reference: string) {
|
|
583
|
+
const [month, day, year] = reference.split(' ');
|
|
584
|
+
|
|
585
|
+
const date = new Date(Number(year), Number(month) - 1, Number(day));
|
|
586
|
+
|
|
587
|
+
const currentMonth = date.getMonth();
|
|
588
|
+
const oneDayInSeconds = 86400;
|
|
589
|
+
|
|
590
|
+
date.setDate(1 - date.getDay());
|
|
591
|
+
|
|
592
|
+
const dates: { properties: string[]; toString: () => string }[] = [];
|
|
593
|
+
|
|
594
|
+
for (let i = 0; i < 6 * 7; i += 1) {
|
|
595
|
+
const dateString = dateToString(date);
|
|
596
|
+
const properties: string[] = [];
|
|
597
|
+
|
|
598
|
+
if (props.minDate) {
|
|
599
|
+
const [minDateYear, minDateMonth, minDateDay] = props.minDate.split('-');
|
|
600
|
+
|
|
601
|
+
const formatedMinDate = new Date(
|
|
602
|
+
Number(minDateYear),
|
|
603
|
+
Number(minDateMonth) - 1,
|
|
604
|
+
Number(minDateDay),
|
|
605
|
+
);
|
|
606
|
+
|
|
607
|
+
if (date < formatedMinDate) properties.push('out of range');
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
if (props.maxDate) {
|
|
611
|
+
const [maxDateYear, maxDateMonth, maxDateDay] = props.maxDate.split('-');
|
|
612
|
+
|
|
613
|
+
const formatedMaxDate = new Date(
|
|
614
|
+
Number(maxDateYear),
|
|
615
|
+
Number(maxDateMonth) - 1,
|
|
616
|
+
Number(maxDateDay),
|
|
617
|
+
);
|
|
618
|
+
|
|
619
|
+
if (date > formatedMaxDate) properties.push('out of range');
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
if (currentMonth === date.getMonth()) {
|
|
623
|
+
properties.push('inside month');
|
|
624
|
+
|
|
625
|
+
const dateInTime = stringToTime(dateToString(date));
|
|
626
|
+
const dayBefore = dateInTime - oneDayInSeconds;
|
|
627
|
+
const dayAfter = dateInTime + oneDayInSeconds;
|
|
628
|
+
|
|
629
|
+
if (isDateBetween(dateInTime)) {
|
|
630
|
+
properties.push('selected');
|
|
631
|
+
|
|
632
|
+
if (!isDateBetween(dayBefore)) {
|
|
633
|
+
properties.push('left-highlighted');
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
if (!isDateBetween(dayAfter)) {
|
|
637
|
+
properties.push('right-highlighted');
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
if (
|
|
641
|
+
properties.includes('left-highlighted') ||
|
|
642
|
+
properties.includes('right-highlighted')
|
|
643
|
+
) {
|
|
644
|
+
properties.push('highlighted');
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
if (dateToString(date) === dateToString(new Date())) {
|
|
650
|
+
properties.push('today');
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
dates.push({
|
|
654
|
+
properties,
|
|
655
|
+
toString: () => dateString,
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
date.setDate(date.getDate() + 1);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
return dates;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
function getMonthsOfTheYear(reference: string) {
|
|
665
|
+
const [month, day, year] = reference.split(' ');
|
|
666
|
+
|
|
667
|
+
const date = new Date(Number(year), Number(month) - 1, Number(day));
|
|
668
|
+
|
|
669
|
+
date.setMonth(0);
|
|
670
|
+
|
|
671
|
+
const dates: {
|
|
672
|
+
properties: string[];
|
|
673
|
+
date: string;
|
|
674
|
+
toString: () => string;
|
|
675
|
+
}[] = [];
|
|
676
|
+
|
|
677
|
+
for (let i = 0; i < 3 * 4; i += 1) {
|
|
678
|
+
const dateString = dateToString(date);
|
|
679
|
+
const properties: string[] = [];
|
|
680
|
+
|
|
681
|
+
properties.push('inside month');
|
|
682
|
+
|
|
683
|
+
const dateInTime = stringToTime(dateToString(date));
|
|
684
|
+
const monthBefore = new Date(dateInTime);
|
|
685
|
+
const monthAfter = new Date(dateInTime);
|
|
686
|
+
|
|
687
|
+
monthBefore.setMonth(monthBefore.getMonth() - 1);
|
|
688
|
+
monthAfter.setMonth(monthAfter.getMonth() + 1);
|
|
689
|
+
|
|
690
|
+
const monthBeforeTime = monthBefore.getTime();
|
|
691
|
+
const monthAfterTime = monthAfter.getTime();
|
|
692
|
+
|
|
693
|
+
if (isDateBetweenMonth(dateInTime)) {
|
|
694
|
+
properties.push('selected');
|
|
695
|
+
|
|
696
|
+
if (!isDateBetweenMonth(monthBeforeTime)) {
|
|
697
|
+
properties.push('left-highlighted');
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
if (!isDateBetweenMonth(monthAfterTime)) {
|
|
701
|
+
properties.push('right-highlighted');
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
if (
|
|
705
|
+
properties.includes('left-highlighted') ||
|
|
706
|
+
properties.includes('right-highlighted')
|
|
707
|
+
) {
|
|
708
|
+
properties.push('highlighted');
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
if (dateToStringMonth(date) === dateToStringMonth(new Date())) {
|
|
713
|
+
properties.push('today');
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
dates.push({
|
|
717
|
+
properties,
|
|
718
|
+
date: dateString,
|
|
719
|
+
toString: () => dateString,
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
date.setMonth(date.getMonth() + 1);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
return dates;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
function getYears(reference: string) {
|
|
729
|
+
const [month, day, year] = reference.split(' ');
|
|
730
|
+
|
|
731
|
+
const date = new Date(Number(year), Number(month) - 1, Number(day));
|
|
732
|
+
|
|
733
|
+
date.setMonth(0);
|
|
734
|
+
|
|
735
|
+
const dates: {
|
|
736
|
+
properties: string[];
|
|
737
|
+
date: number;
|
|
738
|
+
toString: () => string;
|
|
739
|
+
}[] = [];
|
|
740
|
+
|
|
741
|
+
for (let i = 0; i < 3 * 4; i += 1) {
|
|
742
|
+
const dateString = dateToString(date);
|
|
743
|
+
const properties: string[] = [];
|
|
744
|
+
|
|
745
|
+
properties.push('inside month');
|
|
746
|
+
|
|
747
|
+
const dateInTime = stringToTime(dateToString(date));
|
|
748
|
+
|
|
749
|
+
const [dateInTimeMonth, dateInTimeDay, dateInTimeYear] =
|
|
750
|
+
reference.split(' ');
|
|
751
|
+
|
|
752
|
+
const yearBefore = new Date(
|
|
753
|
+
Number(dateInTimeYear),
|
|
754
|
+
Number(dateInTimeMonth) - 1,
|
|
755
|
+
Number(dateInTimeDay),
|
|
756
|
+
);
|
|
757
|
+
const yearAfter = new Date(
|
|
758
|
+
Number(dateInTimeYear),
|
|
759
|
+
Number(dateInTimeMonth) - 1,
|
|
760
|
+
Number(dateInTimeDay),
|
|
761
|
+
);
|
|
762
|
+
|
|
763
|
+
yearBefore.setMonth(yearBefore.getMonth() - 12);
|
|
764
|
+
yearAfter.setMonth(yearAfter.getMonth() + 12);
|
|
765
|
+
|
|
766
|
+
const yearBeforeTime = yearBefore.getTime();
|
|
767
|
+
const yearAfterTime = yearAfter.getTime();
|
|
768
|
+
|
|
769
|
+
if (isDateBetweenYear(dateInTime)) {
|
|
770
|
+
properties.push('selected');
|
|
771
|
+
|
|
772
|
+
if (!isDateBetweenYear(yearBeforeTime)) {
|
|
773
|
+
properties.push('left-highlighted');
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
if (!isDateBetweenYear(yearAfterTime)) {
|
|
777
|
+
properties.push('right-highlighted');
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
if (
|
|
781
|
+
properties.includes('left-highlighted') ||
|
|
782
|
+
properties.includes('right-highlighted')
|
|
783
|
+
) {
|
|
784
|
+
properties.push('highlighted');
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
if (dateToStringYear(date) === dateToStringYear(new Date())) {
|
|
789
|
+
properties.push('today');
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
dates.push({
|
|
793
|
+
properties,
|
|
794
|
+
date: date.getFullYear(),
|
|
795
|
+
toString: () => dateString,
|
|
796
|
+
});
|
|
797
|
+
|
|
798
|
+
date.setFullYear(date.getFullYear() + 1);
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
return dates;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
function selectDate(date: { toString: () => string }) {
|
|
805
|
+
if (!startDate.value || !endDate.value) {
|
|
806
|
+
startDate.value = date.toString();
|
|
807
|
+
endDate.value = startDate.value;
|
|
808
|
+
} else {
|
|
809
|
+
const self = stringToTime(date.toString());
|
|
810
|
+
|
|
811
|
+
const startTime = stringToTime(startDate.value);
|
|
812
|
+
const endTime = stringToTime(endDate.value);
|
|
813
|
+
|
|
814
|
+
if (startTime !== endTime) {
|
|
815
|
+
startDate.value = date.toString();
|
|
816
|
+
endDate.value = startDate.value;
|
|
817
|
+
} else if (self > endTime) {
|
|
818
|
+
endDate.value = date.toString();
|
|
819
|
+
} else if (self < startTime) {
|
|
820
|
+
startDate.value = date.toString();
|
|
821
|
+
} else if (self === startTime || self === endTime) {
|
|
822
|
+
startDate.value = date.toString();
|
|
823
|
+
endDate.value = startDate.value;
|
|
824
|
+
} else if (self - startTime < endTime - self) {
|
|
825
|
+
startDate.value = date.toString();
|
|
826
|
+
} else {
|
|
827
|
+
endDate.value = date.toString();
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
function clear() {
|
|
833
|
+
startDate.value = '';
|
|
834
|
+
endDate.value = '';
|
|
835
|
+
optionSelected.value = '';
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
function getStartAndEndDateByPeriod(period: string) {
|
|
839
|
+
let periodStartDate: string | undefined;
|
|
840
|
+
let periodEndDate: string | undefined;
|
|
841
|
+
|
|
842
|
+
let baseDate: Date;
|
|
843
|
+
|
|
844
|
+
if (props.periodBaseDate) {
|
|
845
|
+
const parts = props.periodBaseDate.split('-');
|
|
846
|
+
|
|
847
|
+
if (parts.length === 3) {
|
|
848
|
+
const [year, month, day] = parts;
|
|
849
|
+
|
|
850
|
+
baseDate = new Date(Number(year), Number(month) - 1, Number(day));
|
|
851
|
+
} else {
|
|
852
|
+
const parsed = new Date(props.periodBaseDate);
|
|
853
|
+
baseDate = Number.isNaN(parsed.getTime()) ? new Date() : parsed;
|
|
854
|
+
}
|
|
855
|
+
} else {
|
|
856
|
+
baseDate = new Date();
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
const todayClone = new Date(baseDate.getTime());
|
|
860
|
+
|
|
861
|
+
const daysMatch = period.match(/^last-(\d+)-days$/);
|
|
862
|
+
const monthsMatch = period.match(/^last-(\d+)-months$/);
|
|
863
|
+
|
|
864
|
+
if (daysMatch) {
|
|
865
|
+
const howMuch = Number(daysMatch[1]);
|
|
866
|
+
|
|
867
|
+
periodEndDate = dateToString(todayClone);
|
|
868
|
+
todayClone.setDate(todayClone.getDate() - howMuch + 1);
|
|
869
|
+
periodStartDate = dateToString(todayClone);
|
|
870
|
+
} else if (monthsMatch) {
|
|
871
|
+
const howMuch = Number(monthsMatch[1]);
|
|
872
|
+
|
|
873
|
+
periodEndDate = dateToString(todayClone);
|
|
874
|
+
todayClone.setDate(todayClone.getDate() + 1);
|
|
875
|
+
todayClone.setMonth(todayClone.getMonth() - howMuch);
|
|
876
|
+
periodStartDate = dateToString(todayClone);
|
|
877
|
+
} else if (period === 'current-month') {
|
|
878
|
+
const referenceDay = baseDate.getDate();
|
|
879
|
+
|
|
880
|
+
todayClone.setDate(1);
|
|
881
|
+
periodStartDate = dateToString(todayClone);
|
|
882
|
+
todayClone.setDate(referenceDay);
|
|
883
|
+
periodEndDate = dateToString(todayClone);
|
|
884
|
+
} else if (period === 'previous-month') {
|
|
885
|
+
todayClone.setDate(1);
|
|
886
|
+
todayClone.setMonth(todayClone.getMonth() - 1);
|
|
887
|
+
periodStartDate = dateToString(todayClone);
|
|
888
|
+
todayClone.setMonth(todayClone.getMonth() + 1);
|
|
889
|
+
todayClone.setDate(0);
|
|
890
|
+
periodEndDate = dateToString(todayClone);
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
return { startDate: periodStartDate, endDate: periodEndDate };
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
function autoSelect(method: string) {
|
|
897
|
+
const { startDate: periodStartDate, endDate: periodEndDate } =
|
|
898
|
+
getStartAndEndDateByPeriod(method);
|
|
899
|
+
|
|
900
|
+
startDate.value = periodStartDate || '';
|
|
901
|
+
endDate.value = periodEndDate || '';
|
|
902
|
+
|
|
903
|
+
if (endDate.value) {
|
|
904
|
+
const secondMonth = addMonth(referenceDate.value, 1);
|
|
905
|
+
|
|
906
|
+
const firstDateOfEndDate = `${Number(
|
|
907
|
+
getMonth({
|
|
908
|
+
toString: () => endDate.value,
|
|
909
|
+
}),
|
|
910
|
+
)} 1 ${getFullYear(endDate.value)}`;
|
|
911
|
+
|
|
912
|
+
if (![referenceDate.value, secondMonth].includes(firstDateOfEndDate)) {
|
|
913
|
+
referenceDate.value = firstDateOfEndDate;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
nextTick(() => {
|
|
918
|
+
optionSelected.value = method;
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
function submit() {
|
|
923
|
+
emit('submit', value.value);
|
|
924
|
+
|
|
925
|
+
if (optionSelected.value === 'custom') {
|
|
926
|
+
emit('update:equivalentOption', '');
|
|
927
|
+
} else {
|
|
928
|
+
const period = periodsLocale.value.find(
|
|
929
|
+
({ id }) => id === optionSelected.value,
|
|
930
|
+
);
|
|
931
|
+
|
|
932
|
+
emit('update:equivalentOption', period?.name || '');
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
function updateOptionSelected() {
|
|
937
|
+
const { startDate: start, endDate: end } = value.value;
|
|
938
|
+
|
|
939
|
+
const isSameTime = (date1?: string, date2?: string) => {
|
|
940
|
+
if (!date1 || !date2) return false;
|
|
941
|
+
return new Date(date1).getTime() === new Date(date2).getTime();
|
|
942
|
+
};
|
|
943
|
+
|
|
944
|
+
const period = periodsLocale.value.find(({ id }) => {
|
|
945
|
+
const { startDate: periodStartDate, endDate: periodEndDate } =
|
|
946
|
+
getStartAndEndDateByPeriod(id);
|
|
947
|
+
|
|
948
|
+
return isSameTime(start, periodStartDate) && isSameTime(end, periodEndDate);
|
|
949
|
+
});
|
|
950
|
+
|
|
951
|
+
optionSelected.value = start || end ? (period ? period.id : 'custom') : '';
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
const openMonths = computed(() => [
|
|
955
|
+
addMonth(referenceDate.value, -1),
|
|
956
|
+
referenceDate.value,
|
|
957
|
+
]);
|
|
958
|
+
|
|
959
|
+
watch(value, (newValue) => {
|
|
960
|
+
updateOptionSelected();
|
|
961
|
+
emit('change', newValue);
|
|
962
|
+
});
|
|
963
|
+
|
|
964
|
+
onMounted(() => {
|
|
965
|
+
updateOptionSelected();
|
|
966
|
+
});
|
|
967
|
+
</script>
|
|
968
|
+
|
|
969
|
+
<style lang="scss" scoped>
|
|
970
|
+
@use '@/assets/scss/unnnic' as *;
|
|
971
|
+
|
|
972
|
+
.unnnic-date-picker {
|
|
973
|
+
display: inline-flex;
|
|
974
|
+
background-color: $unnnic-color-bg-base;
|
|
975
|
+
border-radius: $unnnic-border-radius-sm;
|
|
976
|
+
box-shadow: $unnnic-shadow-1;
|
|
977
|
+
overflow: hidden;
|
|
978
|
+
|
|
979
|
+
&--popover {
|
|
980
|
+
border-radius: 0;
|
|
981
|
+
box-shadow: none;
|
|
982
|
+
overflow: visible;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
.month-container {
|
|
986
|
+
display: flex;
|
|
987
|
+
flex-direction: column;
|
|
988
|
+
justify-content: center;
|
|
989
|
+
|
|
990
|
+
padding: $unnnic-spacing-inset-sm;
|
|
991
|
+
|
|
992
|
+
.header {
|
|
993
|
+
display: grid;
|
|
994
|
+
align-items: center;
|
|
995
|
+
grid-template-areas: 'left-button label right-button';
|
|
996
|
+
|
|
997
|
+
&--small {
|
|
998
|
+
grid-template-columns: 32px auto 32px;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
&--large {
|
|
1002
|
+
grid-template-columns: 36px auto 36px;
|
|
1003
|
+
margin-bottom: $unnnic-spacing-stack-xs;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
.label {
|
|
1007
|
+
font-family: $unnnic-font-family-secondary;
|
|
1008
|
+
font-weight: $unnnic-font-weight-black;
|
|
1009
|
+
color: $unnnic-color-fg-emphasized;
|
|
1010
|
+
text-align: center;
|
|
1011
|
+
grid-area: label;
|
|
1012
|
+
|
|
1013
|
+
&--small {
|
|
1014
|
+
font-size: $unnnic-font-size-body-gt;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
&--large {
|
|
1018
|
+
font-size: $unnnic-font-size-body-gt;
|
|
1019
|
+
line-height: $unnnic-font-size-body-gt + $unnnic-line-height-md;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
.days {
|
|
1025
|
+
display: grid;
|
|
1026
|
+
font-family: $unnnic-font-family-secondary;
|
|
1027
|
+
font-weight: $unnnic-font-weight-regular;
|
|
1028
|
+
color: $unnnic-color-fg-emphasized;
|
|
1029
|
+
text-align: center;
|
|
1030
|
+
|
|
1031
|
+
user-select: none;
|
|
1032
|
+
|
|
1033
|
+
&--small {
|
|
1034
|
+
grid-template-columns: repeat(7, 28px);
|
|
1035
|
+
grid-template-rows: repeat(7, 28px);
|
|
1036
|
+
font-size: $unnnic-font-size-body-md;
|
|
1037
|
+
line-height: 28px;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
&--large {
|
|
1041
|
+
grid-template-columns: repeat(7, 32px);
|
|
1042
|
+
grid-template-rows: repeat(7, 32px);
|
|
1043
|
+
font-size: $unnnic-font-size-body-gt;
|
|
1044
|
+
line-height: 32px;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
&.months--small,
|
|
1048
|
+
&.months--large {
|
|
1049
|
+
grid-template-columns: repeat(3, 4.75 * $unnnic-font-size);
|
|
1050
|
+
grid-template-rows: repeat(4, 3.3125 * $unnnic-font-size);
|
|
1051
|
+
font-size: $unnnic-font-size-body-md;
|
|
1052
|
+
line-height: 3.3125 * $unnnic-font-size;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
.selectable {
|
|
1056
|
+
cursor: pointer;
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
.name {
|
|
1060
|
+
font-weight: $unnnic-font-weight-black;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
.today {
|
|
1064
|
+
font-weight: $unnnic-font-weight-black;
|
|
1065
|
+
background-color: $unnnic-color-bg-base-soft;
|
|
1066
|
+
border-radius: $unnnic-border-radius-sm;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
.selected {
|
|
1070
|
+
font-weight: $unnnic-font-weight-black;
|
|
1071
|
+
background-color: $unnnic-color-bg-base-soft;
|
|
1072
|
+
color: $unnnic-color-fg-accent;
|
|
1073
|
+
border-radius: 0;
|
|
1074
|
+
|
|
1075
|
+
&.highlighted {
|
|
1076
|
+
background-color: $unnnic-color-bg-accent-strong;
|
|
1077
|
+
color: $unnnic-color-fg-on-primary;
|
|
1078
|
+
|
|
1079
|
+
&.left {
|
|
1080
|
+
border-top-left-radius: $unnnic-border-radius-sm;
|
|
1081
|
+
border-bottom-left-radius: $unnnic-border-radius-sm;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
&.right {
|
|
1085
|
+
border-top-right-radius: $unnnic-border-radius-sm;
|
|
1086
|
+
border-bottom-right-radius: $unnnic-border-radius-sm;
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
.disabled {
|
|
1092
|
+
opacity: $unnnic-opacity-level-overlay;
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
.divider {
|
|
1098
|
+
width: 1px;
|
|
1099
|
+
background-color: $unnnic-color-bg-muted;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
.options-container {
|
|
1103
|
+
display: flex;
|
|
1104
|
+
flex-direction: v-bind(containerOptionsFlexDirection);
|
|
1105
|
+
justify-content: space-between;
|
|
1106
|
+
|
|
1107
|
+
.options {
|
|
1108
|
+
.option {
|
|
1109
|
+
font-family: $unnnic-font-family-secondary;
|
|
1110
|
+
font-weight: $unnnic-font-weight-regular;
|
|
1111
|
+
font-size: $unnnic-font-size-body-gt;
|
|
1112
|
+
line-height: $unnnic-font-size-body-gt + $unnnic-line-height-md;
|
|
1113
|
+
color: $unnnic-color-fg-emphasized;
|
|
1114
|
+
|
|
1115
|
+
padding: $unnnic-spacing-stack-xs $unnnic-spacing-inline-sm;
|
|
1116
|
+
user-select: none;
|
|
1117
|
+
|
|
1118
|
+
&.selectable {
|
|
1119
|
+
cursor: pointer;
|
|
1120
|
+
|
|
1121
|
+
&:hover {
|
|
1122
|
+
background-color: $unnnic-color-bg-base-soft;
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
&.selected {
|
|
1127
|
+
background-color: $unnnic-color-bg-base-soft;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
&.selected {
|
|
1131
|
+
font-weight: $unnnic-font-weight-bold;
|
|
1132
|
+
color: $unnnic-color-fg-accent;
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
.actions {
|
|
1138
|
+
display: grid;
|
|
1139
|
+
grid-template-columns: 1fr;
|
|
1140
|
+
&:has(:nth-child(2)) {
|
|
1141
|
+
grid-template-columns: 1fr 1fr;
|
|
1142
|
+
}
|
|
1143
|
+
gap: $unnnic-spacing-inline-xs;
|
|
1144
|
+
padding: $unnnic-spacing-stack-xs $unnnic-spacing-inline-sm;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
</style>
|