@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,102 @@
|
|
|
1
|
+
import AuthResponseParser from './response-parser';
|
|
2
|
+
const NAVBAR_HEIGHT = 50;
|
|
3
|
+
const CLOSED_CHECK_INTERVAL = 200;
|
|
4
|
+
export default class WindowFlow {
|
|
5
|
+
_timeoutId = undefined;
|
|
6
|
+
_requestBuilder;
|
|
7
|
+
_storage;
|
|
8
|
+
reject;
|
|
9
|
+
_loginWindow;
|
|
10
|
+
_promise;
|
|
11
|
+
constructor(requestBuilder, storage) {
|
|
12
|
+
this._requestBuilder = requestBuilder;
|
|
13
|
+
this._storage = storage;
|
|
14
|
+
this._reset();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Opens window with the given URL
|
|
18
|
+
* @param {string} url
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
_openWindow(url) {
|
|
22
|
+
const height = 700;
|
|
23
|
+
const width = 750;
|
|
24
|
+
const screenHalves = 2;
|
|
25
|
+
const top = (window.screen.height - height - NAVBAR_HEIGHT) / screenHalves;
|
|
26
|
+
const left = (window.screen.width - width) / screenHalves;
|
|
27
|
+
return window.open(url, 'HubLoginWindow', `height=${height}, width=${width}, left=${left}, top=${top}`);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Initiates authorization in window
|
|
31
|
+
*/
|
|
32
|
+
async _load() {
|
|
33
|
+
const authRequest = await this._requestBuilder.prepareAuthRequest(
|
|
34
|
+
// eslint-disable-next-line camelcase
|
|
35
|
+
{ request_credentials: 'required', auth_mode: 'bypass_to_login' }, { nonRedirect: true });
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
this.reject = reject;
|
|
38
|
+
let cleanRun;
|
|
39
|
+
const cleanUp = () => {
|
|
40
|
+
if (cleanRun) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
cleanRun = true;
|
|
44
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
45
|
+
removeStateListener();
|
|
46
|
+
removeTokenListener();
|
|
47
|
+
/* eslint-enable @typescript-eslint/no-use-before-define */
|
|
48
|
+
this._loginWindow?.close();
|
|
49
|
+
clearTimeout(this._timeoutId);
|
|
50
|
+
};
|
|
51
|
+
const removeTokenListener = this._storage.onTokenChange(token => {
|
|
52
|
+
if (token) {
|
|
53
|
+
cleanUp();
|
|
54
|
+
resolve(token.accessToken);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const removeStateListener = this._storage.onStateChange(authRequest.stateId, state => {
|
|
58
|
+
if (state && state.error) {
|
|
59
|
+
cleanUp();
|
|
60
|
+
reject(new AuthResponseParser.AuthError(state));
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
if (this._loginWindow == null || this._loginWindow.closed) {
|
|
64
|
+
this._loginWindow = this._openWindow(authRequest.url);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this._loginWindow.location.href = authRequest.url;
|
|
68
|
+
}
|
|
69
|
+
this.checkIsClosed();
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
checkIsClosed = () => {
|
|
73
|
+
if (this._loginWindow?.closed) {
|
|
74
|
+
this.stop();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this._timeoutId = window.setTimeout(this.checkIsClosed, CLOSED_CHECK_INTERVAL);
|
|
78
|
+
};
|
|
79
|
+
_reset = () => {
|
|
80
|
+
this._promise = null;
|
|
81
|
+
this._loginWindow = null;
|
|
82
|
+
clearTimeout(this._timeoutId);
|
|
83
|
+
};
|
|
84
|
+
stop() {
|
|
85
|
+
if (this._loginWindow != null) {
|
|
86
|
+
this._loginWindow.close();
|
|
87
|
+
}
|
|
88
|
+
if (this.reject) {
|
|
89
|
+
this.reject('Authorization window closed');
|
|
90
|
+
}
|
|
91
|
+
this._reset();
|
|
92
|
+
}
|
|
93
|
+
authorize() {
|
|
94
|
+
if (this._promise != null && this._loginWindow != null && !this._loginWindow.closed) {
|
|
95
|
+
this._loginWindow.focus();
|
|
96
|
+
return this._promise;
|
|
97
|
+
}
|
|
98
|
+
this._promise = this._load();
|
|
99
|
+
this._promise.then(this._reset, this._reset);
|
|
100
|
+
return this._promise;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
@import "../global/variables.css";
|
|
2
|
+
|
|
3
|
+
.dialog.dialog {
|
|
4
|
+
width: auto;
|
|
5
|
+
max-width: 400px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.content {
|
|
9
|
+
composes: font from "../global/global.css";
|
|
10
|
+
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
|
|
15
|
+
margin: calc(var(--ring-unit) * 2) 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.button {
|
|
19
|
+
width: calc(var(--ring-unit) * 25);
|
|
20
|
+
margin-top: var(--ring-unit);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.firstButton {
|
|
24
|
+
composes: button;
|
|
25
|
+
|
|
26
|
+
margin-top: calc(var(--ring-unit) * 4);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.title.title {
|
|
30
|
+
margin-top: 0;
|
|
31
|
+
margin-bottom: var(--ring-unit);
|
|
32
|
+
|
|
33
|
+
text-align: center;
|
|
34
|
+
|
|
35
|
+
font-weight: 100;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.logo {
|
|
39
|
+
width: calc(var(--ring-unit) * 12);
|
|
40
|
+
height: calc(var(--ring-unit) * 12);
|
|
41
|
+
margin-bottom: 12px;
|
|
42
|
+
object-fit: contain;
|
|
43
|
+
|
|
44
|
+
@media (height <= 400px) {
|
|
45
|
+
width: calc(var(--ring-unit) * 4);
|
|
46
|
+
height: calc(var(--ring-unit) * 4);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.error {
|
|
51
|
+
text-align: center;
|
|
52
|
+
|
|
53
|
+
color: var(--ring-error-color);
|
|
54
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
/**
|
|
4
|
+
* @name Auth Dialog
|
|
5
|
+
*/
|
|
6
|
+
export interface AuthDialogProps {
|
|
7
|
+
className?: string | undefined;
|
|
8
|
+
title?: string | null | undefined;
|
|
9
|
+
errorMessage?: string | null | undefined;
|
|
10
|
+
serviceImage?: string | null | undefined;
|
|
11
|
+
serviceName?: string | null | undefined;
|
|
12
|
+
loginCaption: string;
|
|
13
|
+
loginToCaption: string;
|
|
14
|
+
show: boolean;
|
|
15
|
+
cancelOnEsc: boolean;
|
|
16
|
+
confirmLabel: string;
|
|
17
|
+
cancelLabel: string;
|
|
18
|
+
tryAgainLabel: string;
|
|
19
|
+
onConfirm: () => void;
|
|
20
|
+
onCancel: () => void;
|
|
21
|
+
onTryAgain?: () => void;
|
|
22
|
+
}
|
|
23
|
+
export default class AuthDialog extends Component<AuthDialogProps> {
|
|
24
|
+
static propTypes: {
|
|
25
|
+
className: PropTypes.Requireable<string>;
|
|
26
|
+
title: PropTypes.Requireable<string>;
|
|
27
|
+
errorMessage: PropTypes.Requireable<string>;
|
|
28
|
+
serviceImage: PropTypes.Requireable<string>;
|
|
29
|
+
serviceName: PropTypes.Requireable<string>;
|
|
30
|
+
loginCaption: PropTypes.Requireable<string>;
|
|
31
|
+
loginToCaption: PropTypes.Requireable<string>;
|
|
32
|
+
show: PropTypes.Requireable<boolean>;
|
|
33
|
+
cancelOnEsc: PropTypes.Requireable<boolean>;
|
|
34
|
+
confirmLabel: PropTypes.Requireable<string>;
|
|
35
|
+
cancelLabel: PropTypes.Requireable<string>;
|
|
36
|
+
tryAgainLabel: PropTypes.Requireable<string>;
|
|
37
|
+
onConfirm: PropTypes.Requireable<(...args: any[]) => any>;
|
|
38
|
+
onCancel: PropTypes.Requireable<(...args: any[]) => any>;
|
|
39
|
+
onTryAgain: PropTypes.Requireable<(...args: any[]) => any>;
|
|
40
|
+
};
|
|
41
|
+
static defaultProps: {
|
|
42
|
+
loginCaption: string;
|
|
43
|
+
loginToCaption: string;
|
|
44
|
+
tryAgainLabel: string;
|
|
45
|
+
show: boolean;
|
|
46
|
+
cancelOnEsc: boolean;
|
|
47
|
+
confirmLabel: string;
|
|
48
|
+
cancelLabel: string;
|
|
49
|
+
onConfirm: () => void;
|
|
50
|
+
onCancel: () => void;
|
|
51
|
+
};
|
|
52
|
+
state: {
|
|
53
|
+
retrying: boolean;
|
|
54
|
+
};
|
|
55
|
+
componentDidMount(): void;
|
|
56
|
+
componentWillUnmount(): void;
|
|
57
|
+
onEscPress: () => void;
|
|
58
|
+
onRetryPress: () => Promise<void>;
|
|
59
|
+
render(): React.JSX.Element;
|
|
60
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { Content } from '../island/island';
|
|
5
|
+
import Dialog from '../dialog/dialog';
|
|
6
|
+
import Button from '../button/button';
|
|
7
|
+
import { H2 } from '../heading/heading';
|
|
8
|
+
import styles from './auth-dialog.css';
|
|
9
|
+
export default class AuthDialog extends Component {
|
|
10
|
+
static propTypes = {
|
|
11
|
+
className: PropTypes.string,
|
|
12
|
+
title: PropTypes.string,
|
|
13
|
+
errorMessage: PropTypes.string,
|
|
14
|
+
serviceImage: PropTypes.string,
|
|
15
|
+
serviceName: PropTypes.string,
|
|
16
|
+
loginCaption: PropTypes.string,
|
|
17
|
+
loginToCaption: PropTypes.string,
|
|
18
|
+
show: PropTypes.bool,
|
|
19
|
+
cancelOnEsc: PropTypes.bool,
|
|
20
|
+
confirmLabel: PropTypes.string,
|
|
21
|
+
cancelLabel: PropTypes.string,
|
|
22
|
+
tryAgainLabel: PropTypes.string,
|
|
23
|
+
onConfirm: PropTypes.func,
|
|
24
|
+
onCancel: PropTypes.func,
|
|
25
|
+
onTryAgain: PropTypes.func
|
|
26
|
+
};
|
|
27
|
+
static defaultProps = {
|
|
28
|
+
loginCaption: 'Log in',
|
|
29
|
+
loginToCaption: 'Log in to %serviceName%',
|
|
30
|
+
tryAgainLabel: 'Try again',
|
|
31
|
+
show: false,
|
|
32
|
+
cancelOnEsc: true,
|
|
33
|
+
confirmLabel: 'Log in',
|
|
34
|
+
cancelLabel: 'Remain a guest',
|
|
35
|
+
onConfirm: () => { },
|
|
36
|
+
onCancel: () => { }
|
|
37
|
+
};
|
|
38
|
+
state = {
|
|
39
|
+
retrying: false
|
|
40
|
+
};
|
|
41
|
+
componentDidMount() {
|
|
42
|
+
window.addEventListener('online', this.onRetryPress);
|
|
43
|
+
}
|
|
44
|
+
componentWillUnmount() {
|
|
45
|
+
window.removeEventListener('online', this.onRetryPress);
|
|
46
|
+
}
|
|
47
|
+
onEscPress = () => {
|
|
48
|
+
if (this.props.cancelOnEsc) {
|
|
49
|
+
this.props.onCancel();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
onRetryPress = async () => {
|
|
53
|
+
if (!this.props.onTryAgain || this.state.retrying) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this.setState({ retrying: true });
|
|
57
|
+
try {
|
|
58
|
+
await this.props.onTryAgain();
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
// do nothing, error is handled in onTryAgain
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
this.setState({ retrying: false });
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
render() {
|
|
68
|
+
const { show, className, errorMessage, serviceImage, serviceName, loginCaption, loginToCaption, confirmLabel, cancelLabel, tryAgainLabel, onConfirm, onCancel, onTryAgain } = this.props;
|
|
69
|
+
const { retrying } = this.state;
|
|
70
|
+
const defaultTitle = serviceName ? loginToCaption : loginCaption;
|
|
71
|
+
const title = (this.props.title || defaultTitle).
|
|
72
|
+
replace('%serviceName%', serviceName ?? '').
|
|
73
|
+
replace('{{serviceName}}', serviceName ?? '');
|
|
74
|
+
return (<Dialog label={title} data-test="ring-auth-dialog" className={className} contentClassName={classNames(className, styles.dialog)} onEscPress={this.onEscPress} show={show} trapFocus>
|
|
75
|
+
<Content>
|
|
76
|
+
<div className={styles.content}>
|
|
77
|
+
{serviceImage && (<img alt={`${serviceName} logo`} className={styles.logo} src={serviceImage}/>)}
|
|
78
|
+
<H2 className={styles.title}>{title}</H2>
|
|
79
|
+
{errorMessage && (<div className={styles.error}>{errorMessage}</div>)}
|
|
80
|
+
<Button primary className={styles.firstButton} data-test="auth-dialog-confirm-button" onClick={onConfirm}>
|
|
81
|
+
{confirmLabel}
|
|
82
|
+
</Button>
|
|
83
|
+
{onTryAgain && (<Button className={styles.button} data-test="auth-dialog-retry-button" onClick={() => this.onRetryPress()} loader={retrying} disabled={retrying}>
|
|
84
|
+
{tryAgainLabel}
|
|
85
|
+
</Button>)}
|
|
86
|
+
<Button className={styles.button} data-test="auth-dialog-cancel-button" onClick={onCancel}>
|
|
87
|
+
{cancelLabel}
|
|
88
|
+
</Button>
|
|
89
|
+
</div>
|
|
90
|
+
</Content>
|
|
91
|
+
</Dialog>);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import AuthDialog, { AuthDialogProps } from '../auth-dialog/auth-dialog';
|
|
3
|
+
export declare const reactRoot: import("react-dom/client").Root;
|
|
4
|
+
type AuthDialogAttributes = JSX.LibraryManagedAttributes<typeof AuthDialog, AuthDialogProps>;
|
|
5
|
+
export default function showAuthDialog(props?: AuthDialogAttributes): () => void;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
|
+
import { ControlsHeightContext, getGlobalControlsHeight } from '../global/controls-height';
|
|
4
|
+
import AuthDialog from '../auth-dialog/auth-dialog';
|
|
5
|
+
/**
|
|
6
|
+
* @name Auth Dialog Service
|
|
7
|
+
*/
|
|
8
|
+
const containerElement = document.createElement('div');
|
|
9
|
+
export const reactRoot = createRoot(containerElement);
|
|
10
|
+
/**
|
|
11
|
+
* Renders AuthDialog into virtual node to skip maintaining container
|
|
12
|
+
*/
|
|
13
|
+
function renderAuthDialog(props) {
|
|
14
|
+
reactRoot.render((<ControlsHeightContext.Provider value={getGlobalControlsHeight()}>
|
|
15
|
+
<AuthDialog {...props}/>
|
|
16
|
+
</ControlsHeightContext.Provider>));
|
|
17
|
+
}
|
|
18
|
+
export default function showAuthDialog(props = {}) {
|
|
19
|
+
renderAuthDialog({
|
|
20
|
+
...props,
|
|
21
|
+
show: true
|
|
22
|
+
});
|
|
23
|
+
return () => {
|
|
24
|
+
renderAuthDialog({ show: false });
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const avatarDataUri: string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Taken from https://hub.jetbrains.com/api/rest/avatar/default?username=Jet%20Brains&dpr=2&size=56
|
|
2
|
+
export const avatarDataUri = `data:image/svg+xml,${encodeURIComponent(`
|
|
3
|
+
<svg viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg">
|
|
4
|
+
<defs>
|
|
5
|
+
<linearGradient id="gradient" x1="0" y1="0" x2="0" y2="1">
|
|
6
|
+
<stop stop-color="#D50F6B" offset="0"/>
|
|
7
|
+
<stop stop-color="#E73AE8" offset="1"/>
|
|
8
|
+
</linearGradient>
|
|
9
|
+
</defs>
|
|
10
|
+
<g>
|
|
11
|
+
<rect fill="url(#gradient)"
|
|
12
|
+
x="0" y="0" width="40" height="40"
|
|
13
|
+
rx="3" ry="3"/>
|
|
14
|
+
<text x="5" y="19"
|
|
15
|
+
font-family="Arial, Helvetica, sans-serif"
|
|
16
|
+
font-size="15px"
|
|
17
|
+
letter-spacing="1"
|
|
18
|
+
fill="#FFFFFF">
|
|
19
|
+
<tspan>JB</tspan>
|
|
20
|
+
<tspan x="6" y="28">_</tspan>
|
|
21
|
+
</text>
|
|
22
|
+
</g>
|
|
23
|
+
</svg>
|
|
24
|
+
`)}`;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@import "../global/variables.css";
|
|
2
|
+
|
|
3
|
+
.avatar {
|
|
4
|
+
display: inline-block;
|
|
5
|
+
object-fit: cover;
|
|
6
|
+
object-position: center;
|
|
7
|
+
|
|
8
|
+
/* This is a "graceful degradation" fallback, while the real value is controlled by JS */
|
|
9
|
+
|
|
10
|
+
border-radius: var(--ring-border-radius);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.subavatar {
|
|
14
|
+
position: absolute;
|
|
15
|
+
top: 15px;
|
|
16
|
+
left: 27px;
|
|
17
|
+
|
|
18
|
+
border: 1px var(--ring-content-background-color) solid;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.empty {
|
|
22
|
+
display: inline-block;
|
|
23
|
+
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
|
|
26
|
+
border: 1px solid var(--ring-borders-color);
|
|
27
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React, { PureComponent, ImgHTMLAttributes } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
/**
|
|
4
|
+
* @name Avatar
|
|
5
|
+
*/
|
|
6
|
+
export declare enum Size {
|
|
7
|
+
Size18 = 18,
|
|
8
|
+
Size20 = 20,
|
|
9
|
+
Size24 = 24,
|
|
10
|
+
Size28 = 28,
|
|
11
|
+
Size32 = 32,
|
|
12
|
+
Size40 = 40,
|
|
13
|
+
Size48 = 48,
|
|
14
|
+
Size56 = 56
|
|
15
|
+
}
|
|
16
|
+
export interface AvatarProps extends ImgHTMLAttributes<HTMLImageElement> {
|
|
17
|
+
dpr: number;
|
|
18
|
+
size: Size | number;
|
|
19
|
+
subavatarSize: number;
|
|
20
|
+
url?: string | null | undefined;
|
|
21
|
+
round?: boolean | null | undefined;
|
|
22
|
+
subavatar?: string | null | undefined;
|
|
23
|
+
username?: string | null | undefined;
|
|
24
|
+
skipParams?: boolean | null | undefined;
|
|
25
|
+
}
|
|
26
|
+
export default class Avatar extends PureComponent<AvatarProps> {
|
|
27
|
+
static propTypes: {
|
|
28
|
+
dpr: PropTypes.Requireable<number>;
|
|
29
|
+
className: PropTypes.Requireable<string>;
|
|
30
|
+
size: PropTypes.Requireable<number>;
|
|
31
|
+
style: PropTypes.Requireable<object>;
|
|
32
|
+
url: PropTypes.Requireable<string>;
|
|
33
|
+
round: PropTypes.Requireable<boolean>;
|
|
34
|
+
subavatar: PropTypes.Requireable<string>;
|
|
35
|
+
subavatarSize: PropTypes.Requireable<number>;
|
|
36
|
+
username: PropTypes.Requireable<string>;
|
|
37
|
+
skipParams: PropTypes.Requireable<boolean>;
|
|
38
|
+
};
|
|
39
|
+
static defaultProps: {
|
|
40
|
+
dpr: number;
|
|
41
|
+
size: Size;
|
|
42
|
+
subavatarSize: number;
|
|
43
|
+
style: {};
|
|
44
|
+
};
|
|
45
|
+
state: {
|
|
46
|
+
errorUrl: string;
|
|
47
|
+
};
|
|
48
|
+
handleError: () => void;
|
|
49
|
+
handleSuccess: () => void;
|
|
50
|
+
render(): React.JSX.Element;
|
|
51
|
+
}
|
|
52
|
+
export type AvatarAttrs = JSX.LibraryManagedAttributes<typeof Avatar, AvatarProps>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { encodeURL, isDataURI, parseQueryString } from '../global/url';
|
|
5
|
+
import { getPixelRatio } from '../global/dom';
|
|
6
|
+
import styles from './avatar.css';
|
|
7
|
+
import FallbackAvatar from './fallback-avatar';
|
|
8
|
+
/**
|
|
9
|
+
* @name Avatar
|
|
10
|
+
*/
|
|
11
|
+
export var Size;
|
|
12
|
+
(function (Size) {
|
|
13
|
+
Size[Size["Size18"] = 18] = "Size18";
|
|
14
|
+
Size[Size["Size20"] = 20] = "Size20";
|
|
15
|
+
Size[Size["Size24"] = 24] = "Size24";
|
|
16
|
+
Size[Size["Size28"] = 28] = "Size28";
|
|
17
|
+
Size[Size["Size32"] = 32] = "Size32";
|
|
18
|
+
Size[Size["Size40"] = 40] = "Size40";
|
|
19
|
+
Size[Size["Size48"] = 48] = "Size48";
|
|
20
|
+
Size[Size["Size56"] = 56] = "Size56";
|
|
21
|
+
})(Size || (Size = {}));
|
|
22
|
+
export default class Avatar extends PureComponent {
|
|
23
|
+
static propTypes = {
|
|
24
|
+
dpr: PropTypes.number,
|
|
25
|
+
className: PropTypes.string,
|
|
26
|
+
size: PropTypes.number,
|
|
27
|
+
style: PropTypes.object,
|
|
28
|
+
url: PropTypes.string,
|
|
29
|
+
round: PropTypes.bool,
|
|
30
|
+
subavatar: PropTypes.string,
|
|
31
|
+
subavatarSize: PropTypes.number,
|
|
32
|
+
username: PropTypes.string,
|
|
33
|
+
skipParams: PropTypes.bool
|
|
34
|
+
};
|
|
35
|
+
static defaultProps = {
|
|
36
|
+
dpr: getPixelRatio(),
|
|
37
|
+
size: Size.Size20,
|
|
38
|
+
subavatarSize: Size.Size20 / 2,
|
|
39
|
+
style: {}
|
|
40
|
+
};
|
|
41
|
+
state = {
|
|
42
|
+
errorUrl: ''
|
|
43
|
+
};
|
|
44
|
+
handleError = () => {
|
|
45
|
+
this.setState({ errorUrl: this.props.url });
|
|
46
|
+
};
|
|
47
|
+
handleSuccess = () => {
|
|
48
|
+
this.setState({ errorUrl: '' });
|
|
49
|
+
};
|
|
50
|
+
render() {
|
|
51
|
+
const { size, url, dpr, style, round, subavatar, subavatarSize, username, skipParams, ...restProps } = this.props;
|
|
52
|
+
const sizeString = `${size}px`;
|
|
53
|
+
const subavatarSizeString = `${subavatarSize}px`;
|
|
54
|
+
const borderRadius = size <= Size.Size18 ? 'var(--ring-border-radius-small)' : 'var(--ring-border-radius)';
|
|
55
|
+
const styleObj = {
|
|
56
|
+
borderRadius: round ? '50%' : borderRadius,
|
|
57
|
+
height: sizeString,
|
|
58
|
+
width: sizeString,
|
|
59
|
+
...style
|
|
60
|
+
};
|
|
61
|
+
const styleObjGroup = {
|
|
62
|
+
borderRadius: '2px',
|
|
63
|
+
height: subavatarSizeString,
|
|
64
|
+
width: subavatarSizeString,
|
|
65
|
+
...style
|
|
66
|
+
};
|
|
67
|
+
if (!url || this.state.errorUrl === url) {
|
|
68
|
+
return (<span {...restProps} data-test="avatar" className={classNames(styles.avatar, this.props.className, { [styles.empty]: username == null })} style={styleObj}>{username != null && (<FallbackAvatar size={size} round={round} username={username}/>)}</span>);
|
|
69
|
+
}
|
|
70
|
+
let src = url;
|
|
71
|
+
if (!skipParams && !isDataURI(url)) {
|
|
72
|
+
const [urlStart, query] = url.split('?');
|
|
73
|
+
const queryParams = {
|
|
74
|
+
...parseQueryString(query),
|
|
75
|
+
dpr,
|
|
76
|
+
size
|
|
77
|
+
};
|
|
78
|
+
src = encodeURL(urlStart, queryParams);
|
|
79
|
+
}
|
|
80
|
+
let subavatarSrc = null;
|
|
81
|
+
if (subavatar && !isDataURI(subavatar)) {
|
|
82
|
+
const [urlStart, query] = subavatar.split('?');
|
|
83
|
+
const queryParams = {
|
|
84
|
+
...parseQueryString(query),
|
|
85
|
+
dpr,
|
|
86
|
+
subavatarSizeString
|
|
87
|
+
};
|
|
88
|
+
subavatarSrc = skipParams ? subavatar : encodeURL(urlStart, queryParams);
|
|
89
|
+
return (<div>
|
|
90
|
+
<img {...restProps} onError={this.handleError} onLoad={this.handleSuccess} className={classNames(styles.avatar, this.props.className)} style={styleObj} src={src} alt="User avatar"/>
|
|
91
|
+
<img {...restProps} data-test="avatar" onError={this.handleError} onLoad={this.handleSuccess} className={classNames(styles.subavatar)} style={styleObjGroup} src={subavatarSrc} alt="Subavatar"/>
|
|
92
|
+
</div>);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
return (<img {...restProps} data-test="avatar" onError={this.handleError} onLoad={this.handleSuccess} className={classNames(styles.avatar, this.props.className)} style={styleObj} src={src} alt="User avatar"/>);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Size } from './avatar';
|
|
4
|
+
export interface FallbackAvatarProps {
|
|
5
|
+
username: string;
|
|
6
|
+
size: Size;
|
|
7
|
+
round: boolean | null | undefined;
|
|
8
|
+
}
|
|
9
|
+
declare function FallbackAvatar({ username, size, round }: FallbackAvatarProps): React.JSX.Element;
|
|
10
|
+
declare namespace FallbackAvatar {
|
|
11
|
+
var propTypes: {
|
|
12
|
+
username: PropTypes.Validator<string>;
|
|
13
|
+
size: PropTypes.Validator<number>;
|
|
14
|
+
round: PropTypes.Requireable<boolean>;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export default FallbackAvatar;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import getUID from '../global/get-uid';
|
|
4
|
+
const colorPairs = [
|
|
5
|
+
['#60A800', '#D5CA00'],
|
|
6
|
+
['#21D370', '#03E9E1'],
|
|
7
|
+
['#3BA1FF', '#36E97D'],
|
|
8
|
+
['#00C243', '#00FFFF'],
|
|
9
|
+
['#4BE098', '#627FFF'],
|
|
10
|
+
['#168BFA', '#26F7C7'],
|
|
11
|
+
['#9D4CFF', '#39D3C3'],
|
|
12
|
+
['#0A81F6', '#0ACFF6'],
|
|
13
|
+
['#765AF8', '#5A91F8'],
|
|
14
|
+
['#9E54FF', '#0ACFF6'],
|
|
15
|
+
['#B345F1', '#669DFF'],
|
|
16
|
+
['#765AF8', '#C059EE'],
|
|
17
|
+
['#9039D0', '#C239D0'],
|
|
18
|
+
['#9F2AFF', '#FD56FD'],
|
|
19
|
+
['#AB3AF2', '#E40568'],
|
|
20
|
+
['#9F2AFF', '#E9A80B'],
|
|
21
|
+
['#D50F6B', '#E73AE8'],
|
|
22
|
+
['#ED5502', '#E73AE8'],
|
|
23
|
+
['#ED358C', '#DBED18'],
|
|
24
|
+
['#ED358C', '#F9902E'],
|
|
25
|
+
['#FF7500', '#FFCA00']
|
|
26
|
+
];
|
|
27
|
+
const Sizes = {
|
|
28
|
+
18: {
|
|
29
|
+
radius: 2,
|
|
30
|
+
text: { x: 9, y: 13 },
|
|
31
|
+
fontSize: '11px',
|
|
32
|
+
textAnchor: 'middle'
|
|
33
|
+
},
|
|
34
|
+
24: {
|
|
35
|
+
radius: 3,
|
|
36
|
+
text: { x: 2, y: 13 },
|
|
37
|
+
fontSize: '11px',
|
|
38
|
+
underscore: { x: 3, y: 17 }
|
|
39
|
+
},
|
|
40
|
+
32: {
|
|
41
|
+
radius: 3,
|
|
42
|
+
text: { x: 3, y: 17 },
|
|
43
|
+
fontSize: '13px',
|
|
44
|
+
letterSpacing: 1,
|
|
45
|
+
underscore: { x: 4, y: 22 }
|
|
46
|
+
},
|
|
47
|
+
40: {
|
|
48
|
+
radius: 3,
|
|
49
|
+
text: { x: 5, y: 19 },
|
|
50
|
+
fontSize: '15px',
|
|
51
|
+
letterSpacing: 1,
|
|
52
|
+
underscore: { x: 6, y: 28 }
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const sizeKeys = Object.keys(Sizes).map(Number);
|
|
56
|
+
function extractLetters(name) {
|
|
57
|
+
const names = name.split(/[\s._]+/).filter(Boolean).map(word => Array.from(word));
|
|
58
|
+
if (names.length >= 2) {
|
|
59
|
+
return names[0][0].toUpperCase() + names[1][0].toUpperCase();
|
|
60
|
+
}
|
|
61
|
+
else if (names.length === 1) {
|
|
62
|
+
if (names[0].length >= 2) {
|
|
63
|
+
return names[0].slice(0, 2).join('').toUpperCase();
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return `${names[0][0].toUpperCase()}X`;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return 'XX';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// https://gist.github.com/hyamamoto/fd435505d29ebfa3d9716fd2be8d42f0#gistcomment-2775538
|
|
74
|
+
const BASE = 32;
|
|
75
|
+
function hashCode(s) {
|
|
76
|
+
let h = 0;
|
|
77
|
+
for (let i = 0; i < s.length; i++) {
|
|
78
|
+
h = Math.imul(BASE - 1, h) + s.charCodeAt(i) | 0;
|
|
79
|
+
}
|
|
80
|
+
return h;
|
|
81
|
+
}
|
|
82
|
+
export default function FallbackAvatar({ username, size, round }) {
|
|
83
|
+
const hash = Math.abs(hashCode(username.toLowerCase()));
|
|
84
|
+
const [fromColor, toColor] = colorPairs[hash % colorPairs.length];
|
|
85
|
+
const possibleSizeKeys = sizeKeys.filter(key => key >= size);
|
|
86
|
+
const sizeKey = possibleSizeKeys.length > 0
|
|
87
|
+
? Math.min(...possibleSizeKeys)
|
|
88
|
+
: Math.max(...sizeKeys);
|
|
89
|
+
const sizes = Sizes[sizeKey];
|
|
90
|
+
const radius = round ? '50%' : sizes.radius;
|
|
91
|
+
const gradientId = useMemo(() => getUID('gradient-'), []);
|
|
92
|
+
return (<svg viewBox={`0 0 ${sizeKey} ${sizeKey}`} xmlns="http://www.w3.org/2000/svg">
|
|
93
|
+
<defs>
|
|
94
|
+
<linearGradient id={gradientId} x1="0" y1="0" x2="0" y2="1">
|
|
95
|
+
<stop stopColor={fromColor} offset="0"/>
|
|
96
|
+
<stop stopColor={toColor} offset="1"/>
|
|
97
|
+
</linearGradient>
|
|
98
|
+
</defs>
|
|
99
|
+
<g>
|
|
100
|
+
<rect fill={`url(#${gradientId})`} x="0" y="0" width={sizeKey} height={sizeKey} rx={radius} ry={radius}/>
|
|
101
|
+
<text x={sizes.text.x} y={sizes.text.y} fontFamily="Arial, Helvetica, sans-serif" fontSize={sizes.fontSize} letterSpacing={sizes.letterSpacing} fill="#FFFFFF" textAnchor={sizes.textAnchor} cursor="default">
|
|
102
|
+
<tspan>{extractLetters(username)}</tspan>
|
|
103
|
+
{sizes.underscore && <tspan x={sizes.underscore.x} y={sizes.underscore.y}>{'_'}</tspan>}
|
|
104
|
+
</text>
|
|
105
|
+
<title>{username}</title>
|
|
106
|
+
</g>
|
|
107
|
+
</svg>);
|
|
108
|
+
}
|
|
109
|
+
FallbackAvatar.propTypes = {
|
|
110
|
+
username: PropTypes.string.isRequired,
|
|
111
|
+
size: PropTypes.number.isRequired,
|
|
112
|
+
round: PropTypes.bool
|
|
113
|
+
};
|