@jetbrains/ring-ui 6.0.6-beta.0 → 6.0.6
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 +1 -1
- package/components/alert/alert.css +146 -0
- package/components/alert/alert.d.ts +113 -0
- package/components/alert/alert.js +186 -0
- package/components/alert/container.css +26 -0
- package/components/alert/container.d.ts +15 -0
- package/components/alert/container.js +30 -0
- package/components/alert-service/alert-service.d.ts +36 -0
- package/components/alert-service/alert-service.js +108 -0
- package/components/alert-service/alert-service.stories.css +17 -0
- package/components/analytics/analytics.d.ts +18 -0
- package/components/analytics/analytics.js +18 -0
- package/components/analytics/analytics__custom-plugin.d.ts +28 -0
- package/components/analytics/analytics__custom-plugin.js +58 -0
- package/components/auth/auth.d.ts +3 -0
- package/components/auth/auth.js +42 -0
- package/components/auth/auth__core.d.ts +236 -0
- package/components/auth/auth__core.js +834 -0
- package/components/auth/background-flow.d.ts +31 -0
- package/components/auth/background-flow.js +97 -0
- package/components/auth/down-notification.css +15 -0
- package/components/auth/down-notification.d.ts +15 -0
- package/components/auth/down-notification.js +52 -0
- package/components/auth/iframe-flow.d.ts +20 -0
- package/components/auth/iframe-flow.js +81 -0
- package/components/auth/request-builder.d.ts +48 -0
- package/components/auth/request-builder.js +64 -0
- package/components/auth/response-parser.d.ts +70 -0
- package/components/auth/response-parser.js +99 -0
- package/components/auth/storage.d.ts +112 -0
- package/components/auth/storage.js +224 -0
- package/components/auth/token-validator.d.ts +93 -0
- package/components/auth/token-validator.js +169 -0
- package/components/auth/window-flow.d.ts +26 -0
- package/components/auth/window-flow.js +102 -0
- package/components/auth-dialog/auth-dialog.css +54 -0
- package/components/auth-dialog/auth-dialog.d.ts +60 -0
- package/components/auth-dialog/auth-dialog.js +93 -0
- package/components/auth-dialog-service/auth-dialog-service.d.ts +6 -0
- package/components/auth-dialog-service/auth-dialog-service.js +26 -0
- package/components/avatar/avatar-example-datauri.d.ts +1 -0
- package/components/avatar/avatar-example-datauri.js +24 -0
- package/components/avatar/avatar.css +27 -0
- package/components/avatar/avatar.d.ts +52 -0
- package/components/avatar/avatar.js +98 -0
- package/components/avatar/fallback-avatar.d.ts +17 -0
- package/components/avatar/fallback-avatar.js +113 -0
- package/components/badge/badge.css +42 -0
- package/components/badge/badge.d.ts +24 -0
- package/components/badge/badge.js +35 -0
- package/components/button/button.css +397 -0
- package/components/button/button.d.ts +67 -0
- package/components/button/button.js +70 -0
- package/components/button/button__classes.d.ts +2 -0
- package/components/button/button__classes.js +18 -0
- package/components/button-group/button-group.css +236 -0
- package/components/button-group/button-group.d.ts +18 -0
- package/components/button-group/button-group.js +21 -0
- package/components/button-group/caption.d.ts +8 -0
- package/components/button-group/caption.js +14 -0
- package/components/button-set/button-set.css +21 -0
- package/components/button-set/button-set.d.ts +16 -0
- package/components/button-set/button-set.js +22 -0
- package/components/button-toolbar/button-toolbar.css +25 -0
- package/components/button-toolbar/button-toolbar.d.ts +16 -0
- package/components/button-toolbar/button-toolbar.js +20 -0
- package/components/caret/caret.d.ts +66 -0
- package/components/caret/caret.js +216 -0
- package/components/checkbox/checkbox.css +146 -0
- package/components/checkbox/checkbox.d.ts +45 -0
- package/components/checkbox/checkbox.js +72 -0
- package/components/clipboard/clipboard-fallback.d.ts +2 -0
- package/components/clipboard/clipboard-fallback.js +44 -0
- package/components/clipboard/clipboard.d.ts +5 -0
- package/components/clipboard/clipboard.js +41 -0
- package/components/code/code.css +29 -0
- package/components/code/code.d.ts +44 -0
- package/components/code/code.js +94 -0
- package/components/code/highlight.css +112 -0
- package/components/collapse/collapse-content.d.ts +11 -0
- package/components/collapse/collapse-content.js +72 -0
- package/components/collapse/collapse-context.d.ts +10 -0
- package/components/collapse/collapse-context.js +10 -0
- package/components/collapse/collapse-control.d.ts +11 -0
- package/components/collapse/collapse-control.js +22 -0
- package/components/collapse/collapse.css +40 -0
- package/components/collapse/collapse.d.ts +12 -0
- package/components/collapse/collapse.js +26 -0
- package/components/collapse/collapse.stories.css +25 -0
- package/components/collapse/consts.d.ts +4 -0
- package/components/collapse/consts.js +4 -0
- package/components/collapse/utils.d.ts +1 -0
- package/components/collapse/utils.js +1 -0
- package/components/confirm/confirm.css +7 -0
- package/components/confirm/confirm.d.ts +48 -0
- package/components/confirm/confirm.js +59 -0
- package/components/confirm-service/confirm-service.d.ts +21 -0
- package/components/confirm-service/confirm-service.js +52 -0
- package/components/content-layout/content-layout.css +108 -0
- package/components/content-layout/content-layout.d.ts +26 -0
- package/components/content-layout/content-layout.js +45 -0
- package/components/content-layout/sidebar.d.ts +31 -0
- package/components/content-layout/sidebar.js +76 -0
- package/components/contenteditable/contenteditable.d.ts +47 -0
- package/components/contenteditable/contenteditable.js +47 -0
- package/components/control-label/control-label.css +23 -0
- package/components/control-label/control-label.d.ts +11 -0
- package/components/control-label/control-label.js +22 -0
- package/components/data-list/data-list.css +97 -0
- package/components/data-list/data-list.d.ts +85 -0
- package/components/data-list/data-list.js +119 -0
- package/components/data-list/data-list.mock.d.ts +16 -0
- package/components/data-list/data-list.mock.js +207 -0
- package/components/data-list/item.d.ts +50 -0
- package/components/data-list/item.js +114 -0
- package/components/data-list/selection.d.ts +16 -0
- package/components/data-list/selection.js +81 -0
- package/components/data-list/title.d.ts +26 -0
- package/components/data-list/title.js +65 -0
- package/components/date-picker/consts.d.ts +98 -0
- package/components/date-picker/consts.js +44 -0
- package/components/date-picker/date-input.d.ts +47 -0
- package/components/date-picker/date-input.js +91 -0
- package/components/date-picker/date-picker.css +602 -0
- package/components/date-picker/date-picker.d.ts +77 -0
- package/components/date-picker/date-picker.js +218 -0
- package/components/date-picker/date-popup.d.ts +55 -0
- package/components/date-picker/date-popup.js +347 -0
- package/components/date-picker/day.d.ts +30 -0
- package/components/date-picker/day.js +88 -0
- package/components/date-picker/formats.d.ts +2 -0
- package/components/date-picker/formats.js +1 -0
- package/components/date-picker/month-names.d.ts +13 -0
- package/components/date-picker/month-names.js +62 -0
- package/components/date-picker/month-slider.d.ts +29 -0
- package/components/date-picker/month-slider.js +56 -0
- package/components/date-picker/month.d.ts +14 -0
- package/components/date-picker/month.js +33 -0
- package/components/date-picker/months.d.ts +11 -0
- package/components/date-picker/months.js +101 -0
- package/components/date-picker/weekdays.d.ts +13 -0
- package/components/date-picker/weekdays.js +24 -0
- package/components/date-picker/years.d.ts +25 -0
- package/components/date-picker/years.js +87 -0
- package/components/dialog/dialog.css +137 -0
- package/components/dialog/dialog.d.ts +64 -0
- package/components/dialog/dialog.js +128 -0
- package/components/dialog/dialog__body-scroll-preventer.d.ts +9 -0
- package/components/dialog/dialog__body-scroll-preventer.js +43 -0
- package/components/dropdown/anchor.d.ts +11 -0
- package/components/dropdown/anchor.js +16 -0
- package/components/dropdown/dropdown.css +18 -0
- package/components/dropdown/dropdown.d.ts +87 -0
- package/components/dropdown/dropdown.js +159 -0
- package/components/dropdown-menu/dropdown-menu.d.ts +36 -0
- package/components/dropdown-menu/dropdown-menu.js +56 -0
- package/components/editable-heading/editable-heading.css +198 -0
- package/components/editable-heading/editable-heading.d.ts +32 -0
- package/components/editable-heading/editable-heading.js +141 -0
- package/components/error-bubble/error-bubble-legacy.css +77 -0
- package/components/error-bubble/error-bubble.css +54 -0
- package/components/error-bubble/error-bubble.d.ts +18 -0
- package/components/error-bubble/error-bubble.js +28 -0
- package/components/error-message/error-message.css +37 -0
- package/components/error-message/error-message.d.ts +27 -0
- package/components/error-message/error-message.js +37 -0
- package/components/error-page/error-page.css +24 -0
- package/components/error-page/error-page.gif +0 -0
- package/components/footer/footer.css +83 -0
- package/components/footer/footer.d.ts +28 -0
- package/components/footer/footer.js +97 -0
- package/components/form/form.css +266 -0
- package/components/form/form.stories.js +138 -0
- package/components/global/compose.d.ts +7 -0
- package/components/global/compose.js +4 -0
- package/components/global/composeRefs.d.ts +3 -0
- package/components/global/composeRefs.js +8 -0
- package/components/global/controls-height.d.ts +9 -0
- package/components/global/controls-height.js +16 -0
- package/components/global/create-stateful-context.d.ts +27 -0
- package/components/global/create-stateful-context.js +38 -0
- package/components/global/data-tests.d.ts +3 -0
- package/components/global/data-tests.js +17 -0
- package/components/global/dom.d.ts +37 -0
- package/components/global/dom.js +83 -0
- package/components/global/focus-sensor-hoc.d.ts +19 -0
- package/components/global/focus-sensor-hoc.js +102 -0
- package/components/global/fuzzy-highlight.d.ts +11 -0
- package/components/global/fuzzy-highlight.js +58 -0
- package/components/global/get-event-key.d.ts +2 -0
- package/components/global/get-event-key.js +100 -0
- package/components/global/get-uid.d.ts +1 -0
- package/components/global/get-uid.js +16 -0
- package/components/global/global.css +101 -0
- package/components/global/inject-styles.d.ts +3 -0
- package/components/global/inject-styles.js +12 -0
- package/components/global/linear-function.d.ts +6 -0
- package/components/global/linear-function.js +13 -0
- package/components/global/listeners.d.ts +8 -0
- package/components/global/listeners.js +27 -0
- package/components/global/memoize.d.ts +1 -0
- package/components/global/memoize.js +15 -0
- package/components/global/normalize-indent.d.ts +1 -0
- package/components/global/normalize-indent.js +30 -0
- package/components/global/promise-with-timeout.d.ts +5 -0
- package/components/global/promise-with-timeout.js +11 -0
- package/components/global/prop-types.d.ts +4 -0
- package/components/global/prop-types.js +4 -0
- package/components/global/react-dom-renderer.d.ts +16 -0
- package/components/global/react-dom-renderer.js +25 -0
- package/components/global/react-render-adapter.d.ts +1 -0
- package/components/global/react-render-adapter.js +3 -0
- package/components/global/rerender-hoc.d.ts +10 -0
- package/components/global/rerender-hoc.js +14 -0
- package/components/global/schedule-raf.d.ts +1 -0
- package/components/global/schedule-raf.js +27 -0
- package/components/global/sniffer.d.ts +3 -0
- package/components/global/sniffer.js +4 -0
- package/components/global/theme.d.ts +21 -0
- package/components/global/theme.js +70 -0
- package/components/global/trivial-template-tag.d.ts +1 -0
- package/components/global/trivial-template-tag.js +9 -0
- package/components/global/typescript-utils.d.ts +2 -0
- package/components/global/typescript-utils.js +2 -0
- package/components/global/url.d.ts +57 -0
- package/components/global/url.js +136 -0
- package/components/global/use-event-callback.d.ts +1 -0
- package/components/global/use-event-callback.js +14 -0
- package/components/global/variables.css +179 -0
- package/components/global/variables.d.ts +89 -0
- package/components/global/variables.js +1 -0
- package/components/global/variables_dark.css +132 -0
- package/components/grid/col.d.ts +31 -0
- package/components/grid/col.js +49 -0
- package/components/grid/grid.css +915 -0
- package/components/grid/grid.d.ts +14 -0
- package/components/grid/grid.js +22 -0
- package/components/grid/row.d.ts +40 -0
- package/components/grid/row.js +51 -0
- package/components/group/group.css +7 -0
- package/components/group/group.d.ts +12 -0
- package/components/group/group.js +20 -0
- package/components/header/header.css +169 -0
- package/components/header/header.d.ts +34 -0
- package/components/header/header.js +46 -0
- package/components/header/logo.d.ts +14 -0
- package/components/header/logo.js +22 -0
- package/components/header/profile.d.ts +75 -0
- package/components/header/profile.js +119 -0
- package/components/header/services-link.d.ts +25 -0
- package/components/header/services-link.js +26 -0
- package/components/header/services.css +97 -0
- package/components/header/services.d.ts +33 -0
- package/components/header/services.js +62 -0
- package/components/header/smart-profile.d.ts +36 -0
- package/components/header/smart-profile.js +86 -0
- package/components/header/smart-services.d.ts +26 -0
- package/components/header/smart-services.js +49 -0
- package/components/header/tray-icon.d.ts +32 -0
- package/components/header/tray-icon.js +20 -0
- package/components/header/tray.d.ts +9 -0
- package/components/header/tray.js +18 -0
- package/components/heading/heading.css +68 -0
- package/components/heading/heading.d.ts +25 -0
- package/components/heading/heading.js +52 -0
- package/components/http/http.d.ts +61 -0
- package/components/http/http.js +192 -0
- package/components/http/http.mock.d.ts +20 -0
- package/components/http/http.mock.js +52 -0
- package/components/hub-source/hub-source.d.ts +44 -0
- package/components/hub-source/hub-source.js +107 -0
- package/components/hub-source/hub-source__user.d.ts +4 -0
- package/components/hub-source/hub-source__user.js +20 -0
- package/components/hub-source/hub-source__users-groups.d.ts +24 -0
- package/components/hub-source/hub-source__users-groups.js +53 -0
- package/components/i18n/README.md +46 -0
- package/components/i18n/i18n-context.d.ts +13 -0
- package/components/i18n/i18n-context.js +14 -0
- package/components/i18n/i18n.d.ts +59 -0
- package/components/i18n/i18n.js +26 -0
- package/components/i18n/messages.json +53 -0
- package/components/icon/icon.css +100 -0
- package/components/icon/icon.d.ts +43 -0
- package/components/icon/icon.js +69 -0
- package/components/icon/icon__constants.d.ts +30 -0
- package/components/icon/icon__constants.js +32 -0
- package/components/icon/icon__svg.d.ts +15 -0
- package/components/icon/icon__svg.js +58 -0
- package/components/icon/index.d.ts +2 -0
- package/components/icon/index.js +2 -0
- package/components/input/input-legacy.css +123 -0
- package/components/input/input.css +194 -0
- package/components/input/input.d.ts +77 -0
- package/components/input/input.js +165 -0
- package/components/input-size/input-size.css +82 -0
- package/components/input-size/input-size.stories.js +73 -0
- package/components/island/adaptive-island-hoc.d.ts +61 -0
- package/components/island/adaptive-island-hoc.js +28 -0
- package/components/island/content.d.ts +43 -0
- package/components/island/content.js +100 -0
- package/components/island/header.d.ts +8 -0
- package/components/island/header.js +78 -0
- package/components/island/island.css +131 -0
- package/components/island/island.d.ts +78 -0
- package/components/island/island.js +31 -0
- package/components/island-legacy/content-legacy.d.ts +10 -0
- package/components/island-legacy/content-legacy.js +17 -0
- package/components/island-legacy/header-legacy.d.ts +10 -0
- package/components/island-legacy/header-legacy.js +19 -0
- package/components/island-legacy/island-legacy.css +98 -0
- package/components/island-legacy/island-legacy.d.ts +12 -0
- package/components/island-legacy/island-legacy.js +19 -0
- package/components/line/line.css +14 -0
- package/components/link/clickableLink.d.ts +20 -0
- package/components/link/clickableLink.js +33 -0
- package/components/link/link.css +64 -0
- package/components/link/link.d.ts +138 -0
- package/components/link/link.js +44 -0
- package/components/list/consts.d.ts +77 -0
- package/components/list/consts.js +25 -0
- package/components/list/list.css +298 -0
- package/components/list/list.d.ts +205 -0
- package/components/list/list.js +590 -0
- package/components/list/list.stories.css +3 -0
- package/components/list/list__custom.d.ts +6 -0
- package/components/list/list__custom.js +52 -0
- package/components/list/list__hint.d.ts +15 -0
- package/components/list/list__hint.js +16 -0
- package/components/list/list__item.d.ts +8 -0
- package/components/list/list__item.js +130 -0
- package/components/list/list__link.d.ts +9 -0
- package/components/list/list__link.js +43 -0
- package/components/list/list__separator.d.ts +5 -0
- package/components/list/list__separator.js +21 -0
- package/components/list/list__title.d.ts +5 -0
- package/components/list/list__title.js +28 -0
- package/components/list/list__users-groups-source.d.ts +27 -0
- package/components/list/list__users-groups-source.js +74 -0
- package/components/loader/loader.css +27 -0
- package/components/loader/loader.d.ts +28 -0
- package/components/loader/loader.js +44 -0
- package/components/loader/loader__core.d.ts +75 -0
- package/components/loader/loader__core.js +219 -0
- package/components/loader-inline/loader-inline.css +73 -0
- package/components/loader-inline/loader-inline.d.ts +18 -0
- package/components/loader-inline/loader-inline.js +27 -0
- package/components/loader-screen/loader-screen.css +29 -0
- package/components/loader-screen/loader-screen.d.ts +17 -0
- package/components/loader-screen/loader-screen.js +25 -0
- package/components/login-dialog/login-dialog.css +23 -0
- package/components/login-dialog/login-dialog.d.ts +47 -0
- package/components/login-dialog/login-dialog.js +84 -0
- package/components/login-dialog/service.d.ts +2 -0
- package/components/login-dialog/service.js +24 -0
- package/components/markdown/markdown.css +126 -0
- package/components/markdown/markdown.d.ts +12 -0
- package/components/markdown/markdown.js +25 -0
- package/components/message/message.css +61 -0
- package/components/message/message.d.ts +55 -0
- package/components/message/message.js +129 -0
- package/components/old-browsers-message/old-browsers-message.css +26 -0
- package/components/old-browsers-message/old-browsers-message.d.ts +2 -0
- package/components/old-browsers-message/old-browsers-message.js +83 -0
- package/components/old-browsers-message/old-browsers-message__stop.d.ts +1 -0
- package/components/old-browsers-message/old-browsers-message__stop.js +2 -0
- package/components/old-browsers-message/white-list.d.ts +2 -0
- package/components/old-browsers-message/white-list.js +25 -0
- package/components/pager/pager.css +19 -0
- package/components/pager/pager.d.ts +78 -0
- package/components/pager/pager.js +223 -0
- package/components/palette/palette.css +216 -0
- package/components/panel/panel.css +20 -0
- package/components/panel/panel.d.ts +12 -0
- package/components/panel/panel.js +20 -0
- package/components/permissions/permissions.d.ts +111 -0
- package/components/permissions/permissions.js +177 -0
- package/components/permissions/permissions__cache.d.ts +93 -0
- package/components/permissions/permissions__cache.js +228 -0
- package/components/popup/popup.consts.d.ts +37 -0
- package/components/popup/popup.consts.js +45 -0
- package/components/popup/popup.css +34 -0
- package/components/popup/popup.d.ts +147 -0
- package/components/popup/popup.js +312 -0
- package/components/popup/popup.target.d.ts +7 -0
- package/components/popup/popup.target.js +15 -0
- package/components/popup/position.d.ts +30 -0
- package/components/popup/position.js +202 -0
- package/components/popup-menu/popup-menu.d.ts +80 -0
- package/components/popup-menu/popup-menu.js +41 -0
- package/components/progress-bar/progress-bar.css +82 -0
- package/components/progress-bar/progress-bar.d.ts +64 -0
- package/components/progress-bar/progress-bar.js +76 -0
- package/components/query-assist/query-assist.css +275 -0
- package/components/query-assist/query-assist.d.ts +306 -0
- package/components/query-assist/query-assist.js +847 -0
- package/components/query-assist/query-assist__suggestions.d.ts +29 -0
- package/components/query-assist/query-assist__suggestions.js +60 -0
- package/components/radio/radio.css +122 -0
- package/components/radio/radio.d.ts +18 -0
- package/components/radio/radio.js +27 -0
- package/components/radio/radio__item.d.ts +28 -0
- package/components/radio/radio__item.js +41 -0
- package/components/select/select-popup.css +103 -0
- package/components/select/select.css +235 -0
- package/components/select/select.d.ts +276 -0
- package/components/select/select.js +957 -0
- package/components/select/select__filter.d.ts +19 -0
- package/components/select/select__filter.js +49 -0
- package/components/select/select__popup.d.ts +166 -0
- package/components/select/select__popup.js +408 -0
- package/components/shortcuts/core.d.ts +74 -0
- package/components/shortcuts/core.js +191 -0
- package/components/shortcuts/shortcut-title.d.ts +1 -0
- package/components/shortcuts/shortcut-title.js +50 -0
- package/components/shortcuts/shortcuts-hoc.d.ts +65 -0
- package/components/shortcuts/shortcuts-hoc.js +19 -0
- package/components/shortcuts/shortcuts.d.ts +28 -0
- package/components/shortcuts/shortcuts.js +50 -0
- package/components/sidebar/sidebar.css +157 -0
- package/components/storage/storage.d.ts +18 -0
- package/components/storage/storage.js +22 -0
- package/components/storage/storage__fallback.d.ts +79 -0
- package/components/storage/storage__fallback.js +181 -0
- package/components/storage/storage__local.d.ts +38 -0
- package/components/storage/storage__local.js +119 -0
- package/components/tab-trap/tab-trap.css +6 -0
- package/components/tab-trap/tab-trap.d.ts +43 -0
- package/components/tab-trap/tab-trap.js +125 -0
- package/components/table/cell.d.ts +13 -0
- package/components/table/cell.js +16 -0
- package/components/table/disable-hover-hoc.d.ts +64 -0
- package/components/table/disable-hover-hoc.js +32 -0
- package/components/table/header-cell.d.ts +43 -0
- package/components/table/header-cell.js +56 -0
- package/components/table/header.d.ts +56 -0
- package/components/table/header.js +67 -0
- package/components/table/multitable.d.ts +25 -0
- package/components/table/multitable.js +81 -0
- package/components/table/row-with-focus-sensor.d.ts +18 -0
- package/components/table/row-with-focus-sensor.js +25 -0
- package/components/table/row.d.ts +59 -0
- package/components/table/row.js +154 -0
- package/components/table/selection-adapter.d.ts +5 -0
- package/components/table/selection-adapter.js +10 -0
- package/components/table/selection-shortcuts-hoc.d.ts +17 -0
- package/components/table/selection-shortcuts-hoc.js +146 -0
- package/components/table/selection.d.ts +47 -0
- package/components/table/selection.js +150 -0
- package/components/table/smart-table.d.ts +64 -0
- package/components/table/smart-table.js +40 -0
- package/components/table/table.css +259 -0
- package/components/table/table.d.ts +159 -0
- package/components/table/table.examples2.json +19 -0
- package/components/table/table.js +231 -0
- package/components/table/table.stories.json +45 -0
- package/components/table-legacy/table-legacy.css +346 -0
- package/components/table-legacy/table-legacy__toolbar.css +25 -0
- package/components/tabs/collapsible-more.d.ts +29 -0
- package/components/tabs/collapsible-more.js +97 -0
- package/components/tabs/collapsible-tab.d.ts +16 -0
- package/components/tabs/collapsible-tab.js +34 -0
- package/components/tabs/collapsible-tabs.d.ts +43 -0
- package/components/tabs/collapsible-tabs.js +196 -0
- package/components/tabs/custom-item.d.ts +9 -0
- package/components/tabs/custom-item.js +5 -0
- package/components/tabs/dumb-tabs.d.ts +35 -0
- package/components/tabs/dumb-tabs.js +56 -0
- package/components/tabs/smart-tabs.d.ts +20 -0
- package/components/tabs/smart-tabs.js +25 -0
- package/components/tabs/tab-link.d.ts +18 -0
- package/components/tabs/tab-link.js +24 -0
- package/components/tabs/tab.d.ts +27 -0
- package/components/tabs/tab.js +19 -0
- package/components/tabs/tabs.css +223 -0
- package/components/tabs/tabs.d.ts +7 -0
- package/components/tabs/tabs.js +7 -0
- package/components/tag/tag.css +184 -0
- package/components/tag/tag.d.ts +64 -0
- package/components/tag/tag.js +130 -0
- package/components/tags-input/tags-input.css +100 -0
- package/components/tags-input/tags-input.d.ts +138 -0
- package/components/tags-input/tags-input.js +275 -0
- package/components/tags-list/tags-list.d.ts +46 -0
- package/components/tags-list/tags-list.js +45 -0
- package/components/text/text.css +21 -0
- package/components/text/text.d.ts +23 -0
- package/components/text/text.js +31 -0
- package/components/toggle/toggle.css +198 -0
- package/components/toggle/toggle.d.ts +39 -0
- package/components/toggle/toggle.js +46 -0
- package/components/tooltip/tooltip.css +17 -0
- package/components/tooltip/tooltip.d.ts +65 -0
- package/components/tooltip/tooltip.js +126 -0
- package/components/user-agreement/service.d.ts +69 -0
- package/components/user-agreement/service.js +242 -0
- package/components/user-agreement/toolbox.eula.d.ts +2 -0
- package/components/user-agreement/toolbox.eula.js +160 -0
- package/components/user-agreement/user-agreement.css +29 -0
- package/components/user-agreement/user-agreement.d.ts +60 -0
- package/components/user-agreement/user-agreement.js +80 -0
- package/components/user-card/card.d.ts +70 -0
- package/components/user-card/card.js +89 -0
- package/components/user-card/smart-user-card-tooltip.d.ts +20 -0
- package/components/user-card/smart-user-card-tooltip.js +47 -0
- package/components/user-card/tooltip.d.ts +36 -0
- package/components/user-card/tooltip.js +43 -0
- package/components/user-card/user-card.css +123 -0
- package/components/user-card/user-card.d.ts +11 -0
- package/components/user-card/user-card.js +11 -0
- package/package.json +61 -61
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { addDays } from 'date-fns/addDays';
|
|
5
|
+
import { format } from 'date-fns/format';
|
|
6
|
+
import { getDay } from 'date-fns/getDay';
|
|
7
|
+
import { getDate } from 'date-fns/getDate';
|
|
8
|
+
import { isAfter } from 'date-fns/isAfter';
|
|
9
|
+
import { isBefore } from 'date-fns/isBefore';
|
|
10
|
+
import { isSameDay } from 'date-fns/isSameDay';
|
|
11
|
+
import { isToday } from 'date-fns/isToday';
|
|
12
|
+
import { startOfDay } from 'date-fns/startOfDay';
|
|
13
|
+
import { dateType, weekdays } from './consts';
|
|
14
|
+
import styles from './date-picker.css';
|
|
15
|
+
let hoverTO;
|
|
16
|
+
export default class Day extends Component {
|
|
17
|
+
static propTypes = {
|
|
18
|
+
day: dateType,
|
|
19
|
+
from: dateType,
|
|
20
|
+
currentRange: PropTypes.arrayOf(dateType),
|
|
21
|
+
activeRange: PropTypes.arrayOf(dateType),
|
|
22
|
+
empty: PropTypes.bool,
|
|
23
|
+
onSelect: PropTypes.func,
|
|
24
|
+
parseDateInput: PropTypes.func,
|
|
25
|
+
onHover: PropTypes.func,
|
|
26
|
+
minDate: dateType,
|
|
27
|
+
maxDate: dateType
|
|
28
|
+
};
|
|
29
|
+
handleClick = () => this.props.onSelect(this.props.day);
|
|
30
|
+
handleMouseOver = () => {
|
|
31
|
+
if (hoverTO) {
|
|
32
|
+
window.clearTimeout(hoverTO);
|
|
33
|
+
hoverTO = null;
|
|
34
|
+
}
|
|
35
|
+
this.props.onHover(this.props.day);
|
|
36
|
+
};
|
|
37
|
+
handleMouseOut = () => {
|
|
38
|
+
hoverTO = window.setTimeout(this.props.onHover, 0);
|
|
39
|
+
};
|
|
40
|
+
isDay = (date) => isSameDay(this.props.day, date);
|
|
41
|
+
is = (name) => {
|
|
42
|
+
const value = this.props[name];
|
|
43
|
+
return value != null && this.isDay(value);
|
|
44
|
+
};
|
|
45
|
+
inRange = (range) => range &&
|
|
46
|
+
isAfter(startOfDay(this.props.day), startOfDay(range[0])) &&
|
|
47
|
+
isBefore(startOfDay(this.props.day), startOfDay(range[1]));
|
|
48
|
+
isDisabled = (date) => {
|
|
49
|
+
const min = this.parse(this.props.minDate);
|
|
50
|
+
const max = this.parse(this.props.maxDate);
|
|
51
|
+
return (min != null && isBefore(startOfDay(date), startOfDay(min))) ||
|
|
52
|
+
(max != null && isAfter(startOfDay(date), startOfDay(max)));
|
|
53
|
+
};
|
|
54
|
+
parse(text) {
|
|
55
|
+
return this.props.parseDateInput(text);
|
|
56
|
+
}
|
|
57
|
+
render() {
|
|
58
|
+
const { day, from, currentRange, activeRange, empty } = this.props;
|
|
59
|
+
const reverse = activeRange && activeRange[1] === from;
|
|
60
|
+
function makeSpreadRange(range) {
|
|
61
|
+
return range && [range[0], addDays(range[1], 1)];
|
|
62
|
+
}
|
|
63
|
+
const spreadRange = makeSpreadRange(currentRange);
|
|
64
|
+
const disabled = this.isDisabled(day);
|
|
65
|
+
const activeSpreadRange = makeSpreadRange(activeRange);
|
|
66
|
+
return (
|
|
67
|
+
// TODO make keyboard navigation actually work
|
|
68
|
+
<button type="button" className={classNames(styles.day, styles[format(day, 'EEEE')], {
|
|
69
|
+
[styles.current]: ['date', 'from', 'to'].some(this.is),
|
|
70
|
+
[styles.active]: !disabled && this.is('activeDate'),
|
|
71
|
+
[styles.weekend]: [weekdays.SA, weekdays.SU].includes(getDay(day)),
|
|
72
|
+
[styles.empty]: empty,
|
|
73
|
+
[styles.from]: (currentRange && this.isDay(currentRange[0]) && !reverse ||
|
|
74
|
+
activeRange && this.isDay(activeRange[0])),
|
|
75
|
+
[styles.to]: (currentRange && this.isDay(currentRange[1])) ||
|
|
76
|
+
activeRange && this.isDay(activeRange[1]),
|
|
77
|
+
[styles.between]: this.inRange(currentRange),
|
|
78
|
+
[styles.activeBetween]: !disabled && this.inRange(activeRange),
|
|
79
|
+
[styles.first]: getDate(day) === 1,
|
|
80
|
+
[styles.spread]: this.inRange(spreadRange),
|
|
81
|
+
[styles.activeSpread]: !disabled && this.inRange(activeSpreadRange),
|
|
82
|
+
[styles.disabled]: disabled
|
|
83
|
+
})} onClick={this.handleClick} onMouseOver={this.handleMouseOver} onFocus={this.handleMouseOver} onMouseOut={this.handleMouseOut} onBlur={this.handleMouseOut} disabled={disabled}>
|
|
84
|
+
{empty || (<span className={classNames({ [styles.today]: isToday(day) })}>
|
|
85
|
+
{format(day, 'd')}</span>)}
|
|
86
|
+
</button>);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default ['d M', 'dd M', 'dd MM', 'd-M', 'dd-M', 'dd-MM', 'd.M', 'dd.M', 'dd.MM', 'd\\M', 'dd\\M', 'dd\\MM', 'd/M', 'dd/M', 'dd/MM', 'd M yy', 'dd M yy', 'dd MM yy', 'd M yyyy', 'dd M yyyy', 'dd MM yyyy', 'd-M-yy', 'dd-M-yy', 'dd-MM-yy', 'd-M-yyyy', 'dd-M-yyyy', 'dd-MM-yyyy', 'd.M.yy', 'dd.M.yy', 'dd.MM.yy', 'd.M.yyyy', 'dd.M.yyyy', 'dd.MM.yyyy', 'd\\M\\yy', 'dd\\M\\yy', 'dd\\MM\\yy', 'd\\M\\yyyy', 'dd\\M\\yyyy', 'dd\\MM\\yyyy', 'd/M/yy', 'dd/M/yy', 'dd/MM/yy', 'd/M/yyyy', 'dd/M/yyyy', 'dd/MM/yyyy', 'd M yy', 'dd M yy', 'dd MM yy', 'd M yyyy', 'dd M yyyy', 'dd MM yyyy', 'd-M-yy', 'dd-M-yy', 'dd-MM-yy', 'd-M-yyyy', 'dd-M-yyyy', 'dd-MM-yyyy', 'd.M.yy', 'dd.M.yy', 'dd.MM.yy', 'd.M.yyyy', 'dd.M.yyyy', 'dd.MM.yyyy', 'd\\M\\yy', 'dd\\M\\yy', 'dd\\MM\\yy', 'd\\M\\yyyy', 'dd\\M\\yyyy', 'dd\\MM\\yyyy', 'd/M/yy', 'dd/M/yy', 'dd/MM/yy', 'd/M/yyyy', 'dd/M/yyyy', 'dd/MM/yyyy', 'yy M d', 'yy M dd', 'yy MM dd', 'yyyy M d', 'yyyy M dd', 'yyyy MM dd', 'yy-M-d', 'yy-M-dd', 'yy-MM-dd', 'yyyy-M-d', 'yyyy-M-dd', 'yyyy-MM-dd', 'yy.M.d', 'yy.M.dd', 'yy.MM.dd', 'yyyy.M.d', 'yyyy.M.dd', 'yyyy.MM.dd', 'yy\\M\\d', 'yy\\M\\dd', 'yy\\MM\\dd', 'yyyy\\M\\d', 'yyyy\\M\\dd', 'yyyy\\MM\\dd', 'yy/M/d', 'yy/M/dd', 'yy/MM/dd', 'yyyy/M/d', 'yyyy/M/dd', 'yyyy/MM/dd', 'yy d M', 'yy dd M', 'yy dd MM', 'yyyy d M', 'yyyy dd MM', 'yyyy dd MM', 'yy-d-M', 'yy-dd-M', 'yy-dd-MM', 'yyyy-d-M', 'yyyy-dd-MM', 'yyyy-dd-MM', 'yy.d.M', 'yy.dd.M', 'yy.dd.MM', 'yyyy.d.M', 'yyyy.dd.MM', 'yyyy.dd.MM', 'yy\\d\\M', 'yy\\dd\\M', 'yy\\dd\\MM', 'yyyy\\d\\M', 'yyyy\\dd\\MM', 'yyyy\\dd\\MM', 'yy/d/M', 'yy/dd/M', 'yy/dd/MM', 'yyyy/d/M', 'yyyy/dd/MM', 'yyyy/dd/MM', 'd MMM', 'd MMMM', 'dd MMM', 'dd MMMM', 'd M HH:mm', 'd M, HH:mm', 'dd M HH:mm', 'dd M, HH:mm', 'dd MM HH:mm', 'dd MM, HH:mm', 'd-M HH:mm', 'd-M, HH:mm', 'dd-M HH:mm', 'dd-M, HH:mm', 'dd-MM HH:mm', 'dd-MM, HH:mm', 'd.M HH:mm', 'd.M, HH:mm', 'dd.M HH:mm', 'dd.M, HH:mm', 'dd.MM HH:mm', 'dd.MM, HH:mm', 'd\\M HH:mm', 'd\\M, HH:mm', 'dd\\M HH:mm', 'dd\\M, HH:mm', 'dd\\MM HH:mm', 'dd\\MM, HH:mm', 'd/M HH:mm', 'd/M, HH:mm', 'dd/M HH:mm', 'dd/M, HH:mm', 'dd/MM HH:mm', 'dd/MM, HH:mm', 'd M yy HH:mm', 'd M yy, HH:mm', 'dd M yy HH:mm', 'dd M yy, HH:mm', 'dd MM yy HH:mm', 'dd MM yy, HH:mm', 'd M yyyy HH:mm', 'd M yyyy, HH:mm', 'dd M yyyy HH:mm', 'dd M yyyy, HH:mm', 'dd MM yyyy HH:mm', 'dd MM yyyy, HH:mm', 'd-M-yy HH:mm', 'd-M-yy, HH:mm', 'dd-M-yy HH:mm', 'dd-M-yy, HH:mm', 'dd-MM-yy HH:mm', 'dd-MM-yy, HH:mm', 'd-M-yyyy HH:mm', 'd-M-yyyy, HH:mm', 'dd-M-yyyy HH:mm', 'dd-M-yyyy, HH:mm', 'dd-MM-yyyy HH:mm', 'dd-MM-yyyy, HH:mm', 'd.M.yy HH:mm', 'd.M.yy, HH:mm', 'dd.M.yy HH:mm', 'dd.M.yy, HH:mm', 'dd.MM.yy HH:mm', 'dd.MM.yy, HH:mm', 'd.M.yyyy HH:mm', 'd.M.yyyy, HH:mm', 'dd.M.yyyy HH:mm', 'dd.M.yyyy, HH:mm', 'dd.MM.yyyy HH:mm', 'dd.MM.yyyy, HH:mm', 'd\\M\\yy HH:mm', 'd\\M\\yy, HH:mm', 'dd\\M\\yy HH:mm', 'dd\\M\\yy, HH:mm', 'dd\\MM\\yy HH:mm', 'dd\\MM\\yy, HH:mm', 'd\\M\\yyyy HH:mm', 'd\\M\\yyyy, HH:mm', 'dd\\M\\yyyy HH:mm', 'dd\\M\\yyyy, HH:mm', 'dd\\MM\\yyyy HH:mm', 'dd\\MM\\yyyy, HH:mm', 'd/M/yy HH:mm', 'd/M/yy, HH:mm', 'dd/M/yy HH:mm', 'dd/M/yy, HH:mm', 'dd/MM/yy HH:mm', 'dd/MM/yy, HH:mm', 'd/M/yyyy HH:mm', 'd/M/yyyy, HH:mm', 'dd/M/yyyy HH:mm', 'dd/M/yyyy, HH:mm', 'dd/MM/yyyy HH:mm', 'dd/MM/yyyy, HH:mm', 'd M yy HH:mm', 'd M yy, HH:mm', 'dd M yy HH:mm', 'dd M yy, HH:mm', 'dd MM yy HH:mm', 'dd MM yy, HH:mm', 'd M yyyy HH:mm', 'd M yyyy, HH:mm', 'dd M yyyy HH:mm', 'dd M yyyy, HH:mm', 'dd MM yyyy HH:mm', 'dd MM yyyy, HH:mm', 'd-M-yy HH:mm', 'd-M-yy, HH:mm', 'dd-M-yy HH:mm', 'dd-M-yy, HH:mm', 'dd-MM-yy HH:mm', 'dd-MM-yy, HH:mm', 'd-M-yyyy HH:mm', 'd-M-yyyy, HH:mm', 'dd-M-yyyy HH:mm', 'dd-M-yyyy, HH:mm', 'dd-MM-yyyy HH:mm', 'dd-MM-yyyy, HH:mm', 'd.M.yy HH:mm', 'd.M.yy, HH:mm', 'dd.M.yy HH:mm', 'dd.M.yy, HH:mm', 'dd.MM.yy HH:mm', 'dd.MM.yy, HH:mm', 'd.M.yyyy HH:mm', 'd.M.yyyy, HH:mm', 'dd.M.yyyy HH:mm', 'dd.M.yyyy, HH:mm', 'dd.MM.yyyy HH:mm', 'dd.MM.yyyy, HH:mm', 'd\\M\\yy HH:mm', 'd\\M\\yy, HH:mm', 'dd\\M\\yy HH:mm', 'dd\\M\\yy, HH:mm', 'dd\\MM\\yy HH:mm', 'dd\\MM\\yy, HH:mm', 'd\\M\\yyyy HH:mm', 'd\\M\\yyyy, HH:mm', 'dd\\M\\yyyy HH:mm', 'dd\\M\\yyyy, HH:mm', 'dd\\MM\\yyyy HH:mm', 'dd\\MM\\yyyy, HH:mm', 'd/M/yy HH:mm', 'd/M/yy, HH:mm', 'dd/M/yy HH:mm', 'dd/M/yy, HH:mm', 'dd/MM/yy HH:mm', 'dd/MM/yy, HH:mm', 'd/M/yyyy HH:mm', 'd/M/yyyy, HH:mm', 'dd/M/yyyy HH:mm', 'dd/M/yyyy, HH:mm', 'dd/MM/yyyy HH:mm', 'dd/MM/yyyy, HH:mm', 'yy M d HH:mm', 'yy M d, HH:mm', 'yy M dd HH:mm', 'yy M dd, HH:mm', 'yy MM dd HH:mm', 'yy MM dd, HH:mm', 'yyyy M d HH:mm', 'yyyy M d, HH:mm', 'yyyy M dd HH:mm', 'yyyy M dd, HH:mm', 'yyyy MM dd HH:mm', 'yyyy MM dd, HH:mm', 'yy-M-d HH:mm', 'yy-M-d, HH:mm', 'yy-M-dd HH:mm', 'yy-M-dd, HH:mm', 'yy-MM-dd HH:mm', 'yy-MM-dd, HH:mm', 'yyyy-M-d HH:mm', 'yyyy-M-d, HH:mm', 'yyyy-M-dd HH:mm', 'yyyy-M-dd, HH:mm', 'yyyy-MM-dd HH:mm', 'yyyy-MM-dd, HH:mm', 'yy.M.d HH:mm', 'yy.M.d, HH:mm', 'yy.M.dd HH:mm', 'yy.M.dd, HH:mm', 'yy.MM.dd HH:mm', 'yy.MM.dd, HH:mm', 'yyyy.M.d HH:mm', 'yyyy.M.d, HH:mm', 'yyyy.M.dd HH:mm', 'yyyy.M.dd, HH:mm', 'yyyy.MM.dd HH:mm', 'yyyy.MM.dd, HH:mm', 'yy\\M\\d HH:mm', 'yy\\M\\d, HH:mm', 'yy\\M\\dd HH:mm', 'yy\\M\\dd, HH:mm', 'yy\\MM\\dd HH:mm', 'yy\\MM\\dd, HH:mm', 'yyyy\\M\\d HH:mm', 'yyyy\\M\\d, HH:mm', 'yyyy\\M\\dd HH:mm', 'yyyy\\M\\dd, HH:mm', 'yyyy\\MM\\dd HH:mm', 'yyyy\\MM\\dd, HH:mm', 'yy/M/d HH:mm', 'yy/M/d, HH:mm', 'yy/M/dd HH:mm', 'yy/M/dd, HH:mm', 'yy/MM/dd HH:mm', 'yy/MM/dd, HH:mm', 'yyyy/M/d HH:mm', 'yyyy/M/d, HH:mm', 'yyyy/M/dd HH:mm', 'yyyy/M/dd, HH:mm', 'yyyy/MM/dd HH:mm', 'yyyy/MM/dd, HH:mm', 'yy d M HH:mm', 'yy d M, HH:mm', 'yy dd M HH:mm', 'yy dd M, HH:mm', 'yy dd MM HH:mm', 'yy dd MM, HH:mm', 'yyyy d M HH:mm', 'yyyy d M, HH:mm', 'yyyy dd MM HH:mm', 'yyyy dd MM, HH:mm', 'yyyy dd MM HH:mm', 'yyyy dd MM, HH:mm', 'yy-d-M HH:mm', 'yy-d-M, HH:mm', 'yy-dd-M HH:mm', 'yy-dd-M, HH:mm', 'yy-dd-MM HH:mm', 'yy-dd-MM, HH:mm', 'yyyy-d-M HH:mm', 'yyyy-d-M, HH:mm', 'yyyy-dd-MM HH:mm', 'yyyy-dd-MM, HH:mm', 'yyyy-dd-MM HH:mm', 'yyyy-dd-MM, HH:mm', 'yy.d.M HH:mm', 'yy.d.M, HH:mm', 'yy.dd.M HH:mm', 'yy.dd.M, HH:mm', 'yy.dd.MM HH:mm', 'yy.dd.MM, HH:mm', 'yyyy.d.M HH:mm', 'yyyy.d.M, HH:mm', 'yyyy.dd.MM HH:mm', 'yyyy.dd.MM, HH:mm', 'yyyy.dd.MM HH:mm', 'yyyy.dd.MM, HH:mm', 'yy\\d\\M HH:mm', 'yy\\d\\M, HH:mm', 'yy\\dd\\M HH:mm', 'yy\\dd\\M, HH:mm', 'yy\\dd\\MM HH:mm', 'yy\\dd\\MM, HH:mm', 'yyyy\\d\\M HH:mm', 'yyyy\\d\\M, HH:mm', 'yyyy\\dd\\MM HH:mm', 'yyyy\\dd\\MM, HH:mm', 'yyyy\\dd\\MM HH:mm', 'yyyy\\dd\\MM, HH:mm', 'yy/d/M HH:mm', 'yy/d/M, HH:mm', 'yy/dd/M HH:mm', 'yy/dd/M, HH:mm', 'yy/dd/MM HH:mm', 'yy/dd/MM, HH:mm', 'yyyy/d/M HH:mm', 'yyyy/d/M, HH:mm', 'yyyy/dd/MM HH:mm', 'yyyy/dd/MM, HH:mm', 'yyyy/dd/MM HH:mm', 'yyyy/dd/MM, HH:mm', 'd MMM HH:mm', 'd MMM, HH:mm', 'd MMMM HH:mm', 'd MMMM, HH:mm', 'dd MMM HH:mm', 'dd MMM, HH:mm', 'dd MMMM HH:mm', 'dd MMMM, HH:mm', 'yyyy MMM d', 'yyyy MMMM d', 'yyyy MMM dd', 'yyyy MMMM dd', 'yyyy d MMM', 'yyyy d MMMM', 'yyyy dd MMM', 'yyyy dd MMMM', 'd MMM yy', 'd MMMM yy', 'dd MMM yy', 'dd MMMM yy', 'd MMM yyyy', 'd MMMM yyyy', 'dd MMM yyyy', 'dd MMMM yyyy', 'd MMM yy', 'd MMMM yy', 'dd MMM yy', 'dd MMMM yy', 'd MMM yyyy', 'd MMMM yyyy', 'dd MMM yyyy', 'dd MMMM yyyy', 'MMM d yyyy', 'MMMM d yyyy', 'MMM dd yyyy', 'MMMM dd yyyy', 'yy MMM d', 'yy MMMM d', 'yy MMM dd', 'yy MMMM dd', 'yy d MMM', 'yy d MMMM', 'yy dd MMM', 'yy dd MMMM', 'd MMM', 'd MMMM', 'dd MMM', 'dd MMMM', 'yyyy MMM d HH:mm', 'yyyy MMM d, HH:mm', 'yyyy MMMM d HH:mm', 'yyyy MMMM d, HH:mm', 'yyyy MMM dd HH:mm', 'yyyy MMM dd, HH:mm', 'yyyy MMMM dd HH:mm', 'yyyy MMMM dd, HH:mm', 'yyyy d MMM HH:mm', 'yyyy d MMM, HH:mm', 'yyyy d MMMM HH:mm', 'yyyy d MMMM, HH:mm', 'yyyy dd MMM HH:mm', 'yyyy dd MMM, HH:mm', 'yyyy dd MMMM HH:mm', 'yyyy dd MMMM, HH:mm', 'd MMM yy HH:mm', 'd MMM yy, HH:mm', 'd MMMM yy HH:mm', 'd MMMM yy, HH:mm', 'dd MMM yy HH:mm', 'dd MMM yy, HH:mm', 'dd MMMM yy HH:mm', 'dd MMMM yy, HH:mm', 'd MMM yyyy HH:mm', 'd MMM yyyy, HH:mm', 'd MMMM yyyy HH:mm', 'd MMMM yyyy, HH:mm', 'dd MMM yyyy HH:mm', 'dd MMM yyyy, HH:mm', 'dd MMMM yyyy HH:mm', 'dd MMMM yyyy, HH:mm', 'd MMM yy HH:mm', 'd MMM yy, HH:mm', 'd MMMM yy HH:mm', 'd MMMM yy, HH:mm', 'dd MMM yy HH:mm', 'dd MMM yy, HH:mm', 'dd MMMM yy HH:mm', 'dd MMMM yy, HH:mm', 'd MMM yyyy HH:mm', 'd MMM yyyy, HH:mm', 'd MMMM yyyy HH:mm', 'd MMMM yyyy, HH:mm', 'dd MMM yyyy HH:mm', 'dd MMM yyyy, HH:mm', 'dd MMMM yyyy HH:mm', 'dd MMMM yyyy, HH:mm', 'MMM d yyyy HH:mm', 'MMM d yyyy, HH:mm', 'MMMM d yyyy HH:mm', 'MMMM d yyyy, HH:mm', 'MMM dd yyyy HH:mm', 'MMM dd yyyy, HH:mm', 'MMMM dd yyyy HH:mm', 'MMMM dd yyyy, HH:mm', 'yy MMM d HH:mm', 'yy MMM d, HH:mm', 'yy MMMM d HH:mm', 'yy MMMM d, HH:mm', 'yy MMM dd HH:mm', 'yy MMM dd, HH:mm', 'yy MMMM dd HH:mm', 'yy MMMM dd, HH:mm', 'yy d MMM HH:mm', 'yy d MMM, HH:mm', 'yy d MMMM HH:mm', 'yy d MMMM, HH:mm', 'yy dd MMM HH:mm', 'yy dd MMM, HH:mm', 'yy dd MMMM HH:mm', 'yy dd MMMM, HH:mm', 'd MMM HH:mm', 'd MMM, HH:mm', 'd MMMM HH:mm', 'd MMMM, HH:mm', 'dd MMM HH:mm', 'dd MMM, HH:mm', 'dd MMMM HH:mm', 'dd MMMM, HH:mm', 'yyyy MMM d', 'yyyy MMMM d', 'yyyy MMM dd', 'yyyy MMMM dd', 'yyyy d MMM', 'yyyy d MMMM', 'yyyy dd MMM', 'yyyy dd MMMM', 'd MMM yy', 'd MMMM yy', 'dd MMM yy', 'dd MMMM yy', 'd MMM yyyy', 'd MMMM yyyy', 'dd MMM yyyy', 'dd MMMM yyyy', 'd MMM yy', 'd MMMM yy', 'dd MMM yy', 'dd MMMM yy', 'd MMM yyyy', 'd MMMM yyyy', 'dd MMM yyyy', 'dd MMMM yyyy', 'MMM d yyyy', 'MMMM d yyyy', 'MMM dd yyyy', 'MMMM dd yyyy', 'yy MMM d', 'yy MMMM d', 'yy MMM dd', 'yy MMMM dd', 'yy d MMM', 'yy d MMMM', 'yy dd MMM', 'yy dd MMMM', 'yyyy MMM d HH:mm', 'yyyy MMM d, HH:mm', 'yyyy MMMM d HH:mm', 'yyyy MMMM d, HH:mm', 'yyyy MMM dd HH:mm', 'yyyy MMM dd, HH:mm', 'yyyy MMMM dd HH:mm', 'yyyy MMMM dd, HH:mm', 'yyyy d MMM HH:mm', 'yyyy d MMM, HH:mm', 'yyyy d MMMM HH:mm', 'yyyy d MMMM, HH:mm', 'yyyy dd MMM HH:mm', 'yyyy dd MMM, HH:mm', 'yyyy dd MMMM HH:mm', 'yyyy dd MMMM, HH:mm', 'd MMM yy HH:mm', 'd MMM yy, HH:mm', 'd MMMM yy HH:mm', 'd MMMM yy, HH:mm', 'dd MMM yy HH:mm', 'dd MMM yy, HH:mm', 'dd MMMM yy HH:mm', 'dd MMMM yy, HH:mm', 'd MMM yyyy HH:mm', 'd MMM yyyy, HH:mm', 'd MMMM yyyy HH:mm', 'd MMMM yyyy, HH:mm', 'dd MMM yyyy HH:mm', 'dd MMM yyyy, HH:mm', 'dd MMMM yyyy HH:mm', 'dd MMMM yyyy, HH:mm', 'd MMM yy HH:mm', 'd MMM yy, HH:mm', 'd MMMM yy HH:mm', 'd MMMM yy, HH:mm', 'dd MMM yy HH:mm', 'dd MMM yy, HH:mm', 'dd MMMM yy HH:mm', 'dd MMMM yy, HH:mm', 'd MMM yyyy HH:mm', 'd MMM yyyy, HH:mm', 'd MMMM yyyy HH:mm', 'd MMMM yyyy, HH:mm', 'dd MMM yyyy HH:mm', 'dd MMM yyyy, HH:mm', 'dd MMMM yyyy HH:mm', 'dd MMMM yyyy, HH:mm', 'MMM d yyyy HH:mm', 'MMM d yyyy, HH:mm', 'MMMM d yyyy HH:mm', 'MMMM d yyyy, HH:mm', 'MMM dd yyyy HH:mm', 'MMM dd yyyy, HH:mm', 'MMMM dd yyyy HH:mm', 'MMMM dd yyyy, HH:mm', 'yy MMM d HH:mm', 'yy MMM d, HH:mm', 'yy MMMM d HH:mm', 'yy MMMM d, HH:mm', 'yy MMM dd HH:mm', 'yy MMM dd, HH:mm', 'yy MMMM dd HH:mm', 'yy MMMM dd, HH:mm', 'yy d MMM HH:mm', 'yy d MMM, HH:mm', 'yy d MMMM HH:mm', 'yy d MMMM, HH:mm', 'yy dd MMM HH:mm', 'yy dd MMM, HH:mm', 'yy dd MMMM HH:mm', 'yy dd MMMM, HH:mm'];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { MonthsProps } from './consts';
|
|
4
|
+
declare function MonthNames(props: MonthsProps): React.JSX.Element;
|
|
5
|
+
declare namespace MonthNames {
|
|
6
|
+
var propTypes: {
|
|
7
|
+
scrollDate: PropTypes.Requireable<NonNullable<string | number | Date | null | undefined>>;
|
|
8
|
+
onScrollChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
9
|
+
currentRange: PropTypes.Requireable<(NonNullable<string | number | Date | null | undefined> | null | undefined)[]>;
|
|
10
|
+
locale: PropTypes.Requireable<string>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export default MonthNames;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { endOfMonth } from 'date-fns/endOfMonth';
|
|
5
|
+
import { format } from 'date-fns/format';
|
|
6
|
+
import { isThisMonth } from 'date-fns/isThisMonth';
|
|
7
|
+
import { set } from 'date-fns/set';
|
|
8
|
+
import { startOfDay } from 'date-fns/startOfDay';
|
|
9
|
+
import { startOfYear } from 'date-fns/startOfYear';
|
|
10
|
+
import linearFunction from '../global/linear-function';
|
|
11
|
+
import MonthSlider from './month-slider';
|
|
12
|
+
import { YEAR, MIDDLE_DAY, yearScrollSpeed, dateType } from './consts';
|
|
13
|
+
import styles from './date-picker.css';
|
|
14
|
+
class MonthName extends PureComponent {
|
|
15
|
+
static propTypes = {
|
|
16
|
+
month: dateType,
|
|
17
|
+
onScrollChange: PropTypes.func,
|
|
18
|
+
locale: PropTypes.string
|
|
19
|
+
};
|
|
20
|
+
handleClick = () => {
|
|
21
|
+
const end = endOfMonth(this.props.month);
|
|
22
|
+
this.props.onScrollChange(end.getTime());
|
|
23
|
+
};
|
|
24
|
+
render() {
|
|
25
|
+
const { month, locale } = this.props;
|
|
26
|
+
return (<button type="button" className={classNames(styles.monthName, {
|
|
27
|
+
[styles.today]: isThisMonth(month)
|
|
28
|
+
})} onClick={this.handleClick}>
|
|
29
|
+
{format(month, 'LLL', { locale })}
|
|
30
|
+
</button>);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export default function MonthNames(props) {
|
|
34
|
+
const { scrollDate, locale } = props;
|
|
35
|
+
const months = [];
|
|
36
|
+
for (let i = 0; i < YEAR; i++) {
|
|
37
|
+
const middleDay = set(scrollDate, { month: i, date: MIDDLE_DAY });
|
|
38
|
+
months.push(startOfDay(middleDay));
|
|
39
|
+
}
|
|
40
|
+
const pxToDate = linearFunction(0, Number(startOfYear(scrollDate)), yearScrollSpeed);
|
|
41
|
+
let top = 0;
|
|
42
|
+
let bottom = 0;
|
|
43
|
+
if (props.currentRange) {
|
|
44
|
+
[top, bottom] = props.currentRange.
|
|
45
|
+
map(date => Math.floor(pxToDate.x(Number(date))));
|
|
46
|
+
}
|
|
47
|
+
return (<div className={styles.monthNames}>
|
|
48
|
+
{months.map(month => (<MonthName key={+month} month={month} onScrollChange={props.onScrollChange} locale={locale}/>))}
|
|
49
|
+
{props.currentRange &&
|
|
50
|
+
(<div className={styles.range} style={{
|
|
51
|
+
top: top - 1,
|
|
52
|
+
height: (bottom + 1) - (top - 1)
|
|
53
|
+
}}/>)}
|
|
54
|
+
<MonthSlider {...props} pxToDate={pxToDate}/>
|
|
55
|
+
</div>);
|
|
56
|
+
}
|
|
57
|
+
MonthNames.propTypes = {
|
|
58
|
+
scrollDate: dateType,
|
|
59
|
+
onScrollChange: PropTypes.func,
|
|
60
|
+
currentRange: PropTypes.arrayOf(dateType),
|
|
61
|
+
locale: PropTypes.string
|
|
62
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { LinearFunction } from '../global/linear-function';
|
|
4
|
+
import { MonthsProps } from './consts';
|
|
5
|
+
export interface MonthSliderProps extends MonthsProps {
|
|
6
|
+
pxToDate: LinearFunction;
|
|
7
|
+
}
|
|
8
|
+
interface MonthSliderState {
|
|
9
|
+
dragging: boolean;
|
|
10
|
+
}
|
|
11
|
+
export default class MonthSlider extends PureComponent<MonthSliderProps> {
|
|
12
|
+
static propTypes: {
|
|
13
|
+
scrollDate: PropTypes.Requireable<NonNullable<string | number | Date | null | undefined>>;
|
|
14
|
+
onScroll: PropTypes.Requireable<(...args: any[]) => any>;
|
|
15
|
+
pxToDate: PropTypes.Requireable<PropTypes.InferProps<{
|
|
16
|
+
x: PropTypes.Requireable<(...args: any[]) => any>;
|
|
17
|
+
y: PropTypes.Requireable<(...args: any[]) => any>;
|
|
18
|
+
}>>;
|
|
19
|
+
};
|
|
20
|
+
state: {
|
|
21
|
+
dragging: boolean;
|
|
22
|
+
};
|
|
23
|
+
componentDidUpdate(prevProps: MonthSliderProps, prevState: MonthSliderState): void;
|
|
24
|
+
onMouseDown: () => void;
|
|
25
|
+
onMouseUp: () => void;
|
|
26
|
+
onMouseMove: (e: MouseEvent) => void;
|
|
27
|
+
render(): React.JSX.Element;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { addYears } from 'date-fns/addYears';
|
|
5
|
+
import { startOfDay } from 'date-fns/startOfDay';
|
|
6
|
+
import { subYears } from 'date-fns/subYears';
|
|
7
|
+
import linearFunction from '../global/linear-function';
|
|
8
|
+
import units, { dateType, yearScrollSpeed } from './consts';
|
|
9
|
+
import styles from './date-picker.css';
|
|
10
|
+
const COVERYEARS = 3;
|
|
11
|
+
export default class MonthSlider extends PureComponent {
|
|
12
|
+
static propTypes = {
|
|
13
|
+
scrollDate: dateType,
|
|
14
|
+
onScroll: PropTypes.func,
|
|
15
|
+
pxToDate: PropTypes.shape({
|
|
16
|
+
x: PropTypes.func,
|
|
17
|
+
y: PropTypes.func
|
|
18
|
+
})
|
|
19
|
+
};
|
|
20
|
+
state = {
|
|
21
|
+
dragging: false
|
|
22
|
+
};
|
|
23
|
+
componentDidUpdate(prevProps, prevState) {
|
|
24
|
+
if (this.state.dragging && !prevState.dragging) {
|
|
25
|
+
window.addEventListener('mousemove', this.onMouseMove);
|
|
26
|
+
window.addEventListener('mouseup', this.onMouseUp);
|
|
27
|
+
}
|
|
28
|
+
else if (!this.state.dragging && prevState.dragging) {
|
|
29
|
+
window.removeEventListener('mousemove', this.onMouseMove);
|
|
30
|
+
window.removeEventListener('mouseup', this.onMouseUp);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
onMouseDown = () => {
|
|
34
|
+
this.setState({ dragging: true });
|
|
35
|
+
};
|
|
36
|
+
onMouseUp = () => {
|
|
37
|
+
this.setState({ dragging: false });
|
|
38
|
+
};
|
|
39
|
+
onMouseMove = (e) => {
|
|
40
|
+
this.props.onScroll(linearFunction(0, Number(this.props.scrollDate), yearScrollSpeed).y(e.movementY));
|
|
41
|
+
};
|
|
42
|
+
render() {
|
|
43
|
+
let year = subYears(startOfDay(this.props.scrollDate), 1);
|
|
44
|
+
const years = [year];
|
|
45
|
+
for (let i = 0; i <= COVERYEARS; i++) {
|
|
46
|
+
year = addYears(year, 1);
|
|
47
|
+
years.push(year);
|
|
48
|
+
}
|
|
49
|
+
const classes = classNames(styles.monthSlider, { [styles.dragging]: this.state.dragging });
|
|
50
|
+
return (<div>
|
|
51
|
+
{years.map(date => (<button type="button" key={+date} className={classes} style={{
|
|
52
|
+
top: Math.floor(this.props.pxToDate.x(Number(date)) - units.cellSize)
|
|
53
|
+
}} onMouseDown={this.onMouseDown}/>))}
|
|
54
|
+
</div>);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { MonthsProps } from './consts';
|
|
4
|
+
export interface MonthProps extends MonthsProps {
|
|
5
|
+
month: Date;
|
|
6
|
+
}
|
|
7
|
+
declare function Month(props: MonthProps): React.JSX.Element;
|
|
8
|
+
declare namespace Month {
|
|
9
|
+
var propTypes: {
|
|
10
|
+
month: PropTypes.Requireable<NonNullable<string | number | Date | null | undefined>>;
|
|
11
|
+
locale: PropTypes.Requireable<string>;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export default Month;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { addDays } from 'date-fns/addDays';
|
|
3
|
+
import { endOfMonth } from 'date-fns/endOfMonth';
|
|
4
|
+
import { format } from 'date-fns/format';
|
|
5
|
+
import { getDay } from 'date-fns/getDay';
|
|
6
|
+
import { setDay } from 'date-fns/setDay';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import Day from './day';
|
|
9
|
+
import { dateType, WEEK, weekdays } from './consts';
|
|
10
|
+
import styles from './date-picker.css';
|
|
11
|
+
export default function Month(props) {
|
|
12
|
+
const start = props.month;
|
|
13
|
+
const end = endOfMonth(start);
|
|
14
|
+
const { locale } = props;
|
|
15
|
+
// pad with empty cells starting from last friday
|
|
16
|
+
const weekday = getDay(start);
|
|
17
|
+
let day = setDay(start, weekday >= weekdays.FR ? weekdays.FR : weekdays.FR - WEEK);
|
|
18
|
+
const days = [];
|
|
19
|
+
while (day < end) {
|
|
20
|
+
days.push(day);
|
|
21
|
+
day = addDays(day, 1);
|
|
22
|
+
}
|
|
23
|
+
return (<div className={styles.month}>
|
|
24
|
+
<span className={styles.monthTitle}>
|
|
25
|
+
{format(props.month, 'LLLL', { locale })}
|
|
26
|
+
</span>
|
|
27
|
+
{days.map(date => (<Day {...props} day={date} empty={date < start} key={+date}/>))}
|
|
28
|
+
</div>);
|
|
29
|
+
}
|
|
30
|
+
Month.propTypes = {
|
|
31
|
+
month: dateType,
|
|
32
|
+
locale: PropTypes.string
|
|
33
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { MonthsProps } from './consts';
|
|
4
|
+
declare function Months(props: MonthsProps): React.JSX.Element;
|
|
5
|
+
declare namespace Months {
|
|
6
|
+
var propTypes: {
|
|
7
|
+
onScroll: PropTypes.Requireable<(...args: any[]) => any>;
|
|
8
|
+
scrollDate: PropTypes.Requireable<NonNullable<string | number | Date | null | undefined>>;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export default Months;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { addMonths } from 'date-fns/addMonths';
|
|
4
|
+
import { getDay } from 'date-fns/getDay';
|
|
5
|
+
import { getDaysInMonth } from 'date-fns/getDaysInMonth';
|
|
6
|
+
import { startOfMonth } from 'date-fns/startOfMonth';
|
|
7
|
+
import { subMonths } from 'date-fns/subMonths';
|
|
8
|
+
import { endOfMonth } from 'date-fns/endOfMonth';
|
|
9
|
+
import scheduleRAF from '../global/schedule-raf';
|
|
10
|
+
import linearFunction from '../global/linear-function';
|
|
11
|
+
import useEventCallback from '../global/use-event-callback';
|
|
12
|
+
import Month from './month';
|
|
13
|
+
import MonthNames from './month-names';
|
|
14
|
+
import styles from './date-picker.css';
|
|
15
|
+
import units, { dateType, DOUBLE, HALF, WEEK, weekdays } from './consts';
|
|
16
|
+
const { unit, cellSize, calHeight } = units;
|
|
17
|
+
const FridayToSunday = WEEK + weekdays.SU - weekdays.FR;
|
|
18
|
+
const FIVELINES = 31;
|
|
19
|
+
const TALLMONTH = 6;
|
|
20
|
+
const SHORTMONTH = 5;
|
|
21
|
+
const PADDING = 2;
|
|
22
|
+
const MONTHSBACK = 2;
|
|
23
|
+
function monthHeight(date) {
|
|
24
|
+
const monthStart = startOfMonth(date);
|
|
25
|
+
const daysSinceLastFriday = (getDay(monthStart) + FridayToSunday) % WEEK;
|
|
26
|
+
const monthLines = daysSinceLastFriday + getDaysInMonth(monthStart) > FIVELINES ? TALLMONTH : SHORTMONTH;
|
|
27
|
+
return monthLines * cellSize + unit * PADDING;
|
|
28
|
+
}
|
|
29
|
+
// in milliseconds per pixel
|
|
30
|
+
function scrollSpeed(date) {
|
|
31
|
+
const monthStart = startOfMonth(date);
|
|
32
|
+
const monthEnd = endOfMonth(date);
|
|
33
|
+
return (Number(monthEnd) - Number(monthStart)) / monthHeight(monthStart);
|
|
34
|
+
}
|
|
35
|
+
const scrollSchedule = scheduleRAF();
|
|
36
|
+
let dy = 0;
|
|
37
|
+
export default function Months(props) {
|
|
38
|
+
const { scrollDate } = props;
|
|
39
|
+
const monthDate = scrollDate instanceof Date ? scrollDate : new Date(scrollDate);
|
|
40
|
+
const monthStart = startOfMonth(monthDate);
|
|
41
|
+
const months = useMemo(() => {
|
|
42
|
+
let month = subMonths(monthStart, MONTHSBACK);
|
|
43
|
+
const result = [month];
|
|
44
|
+
for (let i = 0; i < MONTHSBACK * DOUBLE; i++) {
|
|
45
|
+
month = addMonths(month, 1);
|
|
46
|
+
result.push(month);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}, [monthStart]);
|
|
50
|
+
const currentSpeed = scrollSpeed(scrollDate);
|
|
51
|
+
const pxToDate = linearFunction(0, Number(scrollDate), currentSpeed);
|
|
52
|
+
const offset = pxToDate.x(Number(monthStart)); // is a negative number
|
|
53
|
+
const bottomOffset = monthHeight(scrollDate) + offset;
|
|
54
|
+
const componentRef = useRef(null);
|
|
55
|
+
const handleWheel = useEventCallback((e) => {
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
dy += e.deltaY;
|
|
58
|
+
scrollSchedule(() => {
|
|
59
|
+
let date;
|
|
60
|
+
// adjust scroll speed to prevent glitches
|
|
61
|
+
if (dy < offset) {
|
|
62
|
+
date = pxToDate.y(offset) + (dy - offset) * scrollSpeed(months[1]);
|
|
63
|
+
}
|
|
64
|
+
else if (dy > bottomOffset) {
|
|
65
|
+
date =
|
|
66
|
+
pxToDate.y(bottomOffset) +
|
|
67
|
+
(dy - bottomOffset) *
|
|
68
|
+
scrollSpeed(months[MONTHSBACK + 1]);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
date = pxToDate.y(dy);
|
|
72
|
+
}
|
|
73
|
+
props.onScroll(date);
|
|
74
|
+
dy = 0;
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
const current = componentRef.current;
|
|
79
|
+
if (current !== null) {
|
|
80
|
+
current.addEventListener('wheel', handleWheel, { passive: false });
|
|
81
|
+
}
|
|
82
|
+
return () => {
|
|
83
|
+
if (current !== null) {
|
|
84
|
+
current.removeEventListener('wheel', handleWheel);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}, [handleWheel]);
|
|
88
|
+
return (<div className={styles.months} ref={componentRef}>
|
|
89
|
+
<div style={{
|
|
90
|
+
top: Math.
|
|
91
|
+
floor(calHeight * HALF - monthHeight(months[0]) - monthHeight(months[1]) + offset)
|
|
92
|
+
}} className={styles.days}>
|
|
93
|
+
{months.map(date => (<Month {...props} month={date} key={+date}/>))}
|
|
94
|
+
</div>
|
|
95
|
+
<MonthNames {...props}/>
|
|
96
|
+
</div>);
|
|
97
|
+
}
|
|
98
|
+
Months.propTypes = {
|
|
99
|
+
onScroll: PropTypes.func,
|
|
100
|
+
scrollDate: dateType
|
|
101
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Locale } from 'date-fns';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
interface WeekdaysProps {
|
|
5
|
+
locale: Locale | undefined;
|
|
6
|
+
}
|
|
7
|
+
declare function Weekdays(props: WeekdaysProps): React.JSX.Element;
|
|
8
|
+
declare namespace Weekdays {
|
|
9
|
+
var propTypes: {
|
|
10
|
+
locale: PropTypes.Requireable<string>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export default Weekdays;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { getDay } from 'date-fns/getDay';
|
|
4
|
+
import { format } from 'date-fns/format';
|
|
5
|
+
import { setDay } from 'date-fns/setDay';
|
|
6
|
+
import { startOfDay } from 'date-fns/startOfDay';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { weekdays } from './consts';
|
|
9
|
+
import styles from './date-picker.css';
|
|
10
|
+
export default function Weekdays(props) {
|
|
11
|
+
const days = Object.values(weekdays).
|
|
12
|
+
map(value => startOfDay(setDay(new Date(), value)));
|
|
13
|
+
const { locale } = props;
|
|
14
|
+
return (<div className={styles.weekdays}>
|
|
15
|
+
{days.map(day => (<span className={classNames(styles.weekday, {
|
|
16
|
+
[styles.weekend]: [weekdays.SA, weekdays.SU].includes(getDay(day))
|
|
17
|
+
})} key={+day}>
|
|
18
|
+
{format(day, 'EEEEEE', { locale })}
|
|
19
|
+
</span>))}
|
|
20
|
+
</div>);
|
|
21
|
+
}
|
|
22
|
+
Weekdays.propTypes = {
|
|
23
|
+
locale: PropTypes.string
|
|
24
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { CalendarProps } from './consts';
|
|
4
|
+
interface YearsState {
|
|
5
|
+
scrollDate: Date | null;
|
|
6
|
+
}
|
|
7
|
+
export default class Years extends PureComponent<CalendarProps> {
|
|
8
|
+
static propTypes: {
|
|
9
|
+
scrollDate: PropTypes.Requireable<NonNullable<string | number | Date | null | undefined>>;
|
|
10
|
+
onScroll: PropTypes.Requireable<(...args: any[]) => any>;
|
|
11
|
+
onScrollChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
12
|
+
};
|
|
13
|
+
state: {
|
|
14
|
+
scrollDate: null;
|
|
15
|
+
};
|
|
16
|
+
componentDidMount(): void;
|
|
17
|
+
componentDidUpdate(prevProps: CalendarProps, prevState: YearsState): void;
|
|
18
|
+
componentWillUnmount(): void;
|
|
19
|
+
stoppedScrolling?: boolean;
|
|
20
|
+
setYear(date: number): void;
|
|
21
|
+
componentRef: React.RefObject<HTMLDivElement>;
|
|
22
|
+
handleWheel: (e: WheelEvent) => void;
|
|
23
|
+
render(): React.JSX.Element;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React, { createRef, PureComponent } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { addYears } from 'date-fns/addYears';
|
|
5
|
+
import { getYear } from 'date-fns/getYear';
|
|
6
|
+
import { format } from 'date-fns/format';
|
|
7
|
+
import { isSameYear } from 'date-fns/isSameYear';
|
|
8
|
+
import { isThisYear } from 'date-fns/isThisYear';
|
|
9
|
+
import { setYear } from 'date-fns/setYear';
|
|
10
|
+
import { startOfYear } from 'date-fns/startOfYear';
|
|
11
|
+
import { subYears } from 'date-fns/subYears';
|
|
12
|
+
import linearFunction from '../global/linear-function';
|
|
13
|
+
import styles from './date-picker.css';
|
|
14
|
+
import units, { dateType, DOUBLE, HALF, yearDuration } from './consts';
|
|
15
|
+
const { yearHeight, calHeight } = units;
|
|
16
|
+
let scrollTO;
|
|
17
|
+
const YEARSBACK = 5;
|
|
18
|
+
const scrollDelay = 100;
|
|
19
|
+
export default class Years extends PureComponent {
|
|
20
|
+
static propTypes = {
|
|
21
|
+
scrollDate: dateType,
|
|
22
|
+
onScroll: PropTypes.func,
|
|
23
|
+
onScrollChange: PropTypes.func
|
|
24
|
+
};
|
|
25
|
+
state = { scrollDate: null };
|
|
26
|
+
componentDidMount() {
|
|
27
|
+
if (this.componentRef.current) {
|
|
28
|
+
this.componentRef.current.addEventListener('wheel', this.handleWheel);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
componentDidUpdate(prevProps, prevState) {
|
|
32
|
+
this.stoppedScrolling = prevState.scrollDate != null && !this.state.scrollDate;
|
|
33
|
+
}
|
|
34
|
+
componentWillUnmount() {
|
|
35
|
+
if (this.componentRef.current) {
|
|
36
|
+
this.componentRef.current.removeEventListener('wheel', this.handleWheel);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
stoppedScrolling;
|
|
40
|
+
setYear(date) {
|
|
41
|
+
if (scrollTO) {
|
|
42
|
+
window.clearTimeout(scrollTO);
|
|
43
|
+
scrollTO = null;
|
|
44
|
+
}
|
|
45
|
+
this.setState({ scrollDate: null });
|
|
46
|
+
this.props.onScroll(Number(setYear(this.props.scrollDate, getYear(date))));
|
|
47
|
+
}
|
|
48
|
+
componentRef = createRef();
|
|
49
|
+
handleWheel = (e) => {
|
|
50
|
+
const { scrollDate } = this.props;
|
|
51
|
+
const date = this.state.scrollDate || scrollDate;
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
const newScrollDate = linearFunction(0, Number(date), yearDuration / yearHeight).y(e.deltaY);
|
|
54
|
+
this.setState({
|
|
55
|
+
scrollDate: newScrollDate
|
|
56
|
+
});
|
|
57
|
+
if (scrollTO) {
|
|
58
|
+
window.clearTimeout(scrollTO);
|
|
59
|
+
}
|
|
60
|
+
scrollTO = window.setTimeout(() => this.setYear(newScrollDate), scrollDelay);
|
|
61
|
+
};
|
|
62
|
+
render() {
|
|
63
|
+
const { onScrollChange, scrollDate } = this.props;
|
|
64
|
+
const date = this.state.scrollDate || scrollDate;
|
|
65
|
+
const yearStart = startOfYear(date);
|
|
66
|
+
let year = subYears(yearStart, YEARSBACK);
|
|
67
|
+
const years = [year];
|
|
68
|
+
for (let i = 0; i < YEARSBACK * DOUBLE; i++) {
|
|
69
|
+
year = addYears(year, 1);
|
|
70
|
+
years.push(year);
|
|
71
|
+
}
|
|
72
|
+
const pxToDate = linearFunction(0, Number(years[0]), yearDuration / yearHeight);
|
|
73
|
+
return (<div className={styles.years} ref={this.componentRef} style={{
|
|
74
|
+
transition: this.stoppedScrolling ? 'top .2s ease-out 0s' : 'none',
|
|
75
|
+
top: Math.floor(calHeight * HALF - pxToDate.x(Number(date)))
|
|
76
|
+
}}>
|
|
77
|
+
{years.map(item => (<button type="button" key={+item} className={classNames(styles.year, {
|
|
78
|
+
[styles.currentYear]: isSameYear(item, date),
|
|
79
|
+
[styles.today]: isThisYear(item)
|
|
80
|
+
})} onClick={function handleClick() {
|
|
81
|
+
onScrollChange(Number(setYear(scrollDate, getYear(item))));
|
|
82
|
+
}}>
|
|
83
|
+
{format(item, 'yyyy')}
|
|
84
|
+
</button>))}
|
|
85
|
+
</div>);
|
|
86
|
+
}
|
|
87
|
+
}
|