@jetbrains/ring-ui 7.0.62 → 7.0.63
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/components/alert/alert.css +1 -1
- package/components/alert/alert.d.ts +1 -1
- package/components/alert/alert.js +3 -3
- package/components/alert/container.css +2 -2
- package/components/alert/container.d.ts +1 -1
- package/components/alert/container.js +1 -1
- package/components/alert-service/alert-service.d.ts +2 -2
- package/components/analytics/{analytics__custom-plugin.d.ts → analytics-custom-plugin.d.ts} +1 -1
- package/components/analytics/{analytics__custom-plugin.js → analytics-custom-plugin.js} +2 -2
- package/components/auth/{auth__core.d.ts → auth-core.d.ts} +9 -8
- package/components/auth/{auth__core.js → auth-core.js} +14 -18
- package/components/auth/auth.d.ts +2 -2
- package/components/auth/auth.js +2 -2
- package/components/auth/background-flow.d.ts +2 -2
- package/components/auth/background-flow.js +0 -1
- package/components/auth/down-notification.css +1 -1
- package/components/auth/down-notification.js +1 -1
- package/components/auth/iframe-flow.d.ts +3 -3
- package/components/auth/iframe-flow.js +3 -5
- package/components/auth/request-builder.d.ts +2 -1
- package/components/auth/request-builder.js +1 -2
- package/components/auth/storage.d.ts +3 -3
- package/components/auth/storage.js +4 -8
- package/components/auth/token-validator.d.ts +2 -1
- package/components/auth/token-validator.js +6 -1
- package/components/auth/window-flow.d.ts +3 -3
- package/components/auth/window-flow.js +7 -7
- package/components/auth-dialog/auth-dialog.css +2 -2
- package/components/auth-dialog/auth-dialog.js +1 -1
- package/components/auth-dialog-service/auth-dialog-service.d.ts +1 -1
- package/components/avatar/avatar-info.d.ts +1 -1
- package/components/avatar/avatar.css +1 -1
- package/components/avatar/avatar.d.ts +1 -1
- package/components/avatar/avatar.figma.js +1 -1
- package/components/avatar/avatar.js +5 -7
- package/components/avatar/fallback-avatar.js +4 -8
- package/components/avatar-stack/avatar-stack.css +1 -1
- package/components/avatar-stack/avatar-stack.d.ts +3 -3
- package/components/avatar-stack/avatar-stack.figma.js +1 -1
- package/components/avatar-stack/avatar-stack.js +1 -1
- package/components/banner/banner.css +2 -2
- package/components/banner/banner.js +1 -1
- package/components/breadcrumbs/breadcrumbs.d.ts +1 -1
- package/components/breadcrumbs/breadcrumbs.figma.js +1 -1
- package/components/button/{button__classes.d.ts → button.classes.d.ts} +1 -1
- package/components/button/button.css +19 -16
- package/components/button/button.d.ts +4 -4
- package/components/button/button.figma.js +1 -1
- package/components/button/button.js +6 -6
- package/components/button-group/button-group.css +6 -6
- package/components/button-group/button-group.d.ts +1 -1
- package/components/button-group/button-group.js +1 -1
- package/components/button-group/caption.d.ts +1 -1
- package/components/button-set/button-set.css +2 -2
- package/components/button-set/button-set.d.ts +1 -1
- package/components/button-toolbar/button-toolbar.css +2 -2
- package/components/button-toolbar/button-toolbar.d.ts +1 -1
- package/components/caret/caret.js +23 -18
- package/components/checkbox/checkbox-group.figma.js +1 -1
- package/components/checkbox/checkbox.css +1 -1
- package/components/checkbox/checkbox.d.ts +1 -1
- package/components/checkbox/checkbox.figma.js +1 -1
- package/components/checkbox/checkbox.js +5 -5
- package/components/clipboard/clipboard.js +2 -2
- package/components/code/code.css +1 -1
- package/components/code/code.d.ts +1 -1
- package/components/code/code.js +5 -3
- package/components/collapse/collapse-content.d.ts +3 -3
- package/components/collapse/collapse-control.d.ts +2 -2
- package/components/collapse/collapse.css +1 -1
- package/components/collapse/collapse.d.ts +3 -3
- package/components/confirm/confirm.d.ts +1 -1
- package/components/confirm/confirm.js +1 -1
- package/components/confirm-service/confirm-service.d.ts +3 -3
- package/components/content-layout/content-layout.css +2 -2
- package/components/content-layout/content-layout.d.ts +1 -1
- package/components/content-layout/content-layout.js +2 -2
- package/components/content-layout/sidebar.d.ts +1 -1
- package/components/contenteditable/contenteditable.d.ts +1 -1
- package/components/contenteditable/contenteditable.js +2 -1
- package/components/control-help/control-help.css +1 -1
- package/components/control-help/control-help.d.ts +1 -1
- package/components/control-label/control-label.d.ts +1 -1
- package/components/data-list/data-list.css +1 -1
- package/components/data-list/data-list.d.ts +5 -5
- package/components/data-list/data-list.js +2 -2
- package/components/data-list/data-list.mock.d.ts +2 -2
- package/components/data-list/data-list.mock.js +20 -20
- package/components/data-list/item.d.ts +3 -3
- package/components/data-list/item.js +2 -2
- package/components/data-list/selection.d.ts +1 -1
- package/components/data-list/selection.js +8 -1
- package/components/data-list/title.d.ts +2 -2
- package/components/date-picker/consts.d.ts +1 -1
- package/components/date-picker/date-input.d.ts +1 -1
- package/components/date-picker/date-input.js +2 -2
- package/components/date-picker/date-picker.css +15 -15
- package/components/date-picker/date-picker.d.ts +5 -5
- package/components/date-picker/date-picker.js +17 -19
- package/components/date-picker/date-popup.d.ts +1 -1
- package/components/date-picker/date-popup.js +5 -3
- package/components/date-picker/day.d.ts +2 -2
- package/components/date-picker/day.js +4 -5
- package/components/date-picker/formats.js +1 -0
- package/components/date-picker/month-names.d.ts +1 -1
- package/components/date-picker/month-names.js +1 -1
- package/components/date-picker/month-slider.d.ts +2 -2
- package/components/date-picker/month-slider.js +1 -1
- package/components/date-picker/month.d.ts +1 -1
- package/components/date-picker/months.d.ts +1 -1
- package/components/date-picker/months.js +2 -2
- package/components/date-picker/years.d.ts +1 -1
- package/components/date-picker/years.js +2 -2
- package/components/dialog/{dialog__body-scroll-preventer.js → dialog-body-scroll-preventer.js} +6 -2
- package/components/dialog/dialog.css +5 -5
- package/components/dialog/dialog.d.ts +1 -1
- package/components/dialog/dialog.js +7 -7
- package/components/dropdown/anchor.d.ts +1 -1
- package/components/dropdown/dropdown.css +1 -1
- package/components/dropdown/dropdown.d.ts +2 -2
- package/components/dropdown/dropdown.js +2 -2
- package/components/dropdown-menu/dropdown-menu.d.ts +5 -5
- package/components/dropdown-menu/dropdown-menu.js +1 -1
- package/components/editable-heading/editable-heading.css +6 -8
- package/components/editable-heading/editable-heading.d.ts +1 -1
- package/components/editable-heading/editable-heading.js +3 -2
- package/components/error-bubble/error-bubble-legacy.css +3 -3
- package/components/error-bubble/error-bubble.css +5 -5
- package/components/error-bubble/error-bubble.d.ts +1 -1
- package/components/error-bubble/error-bubble.figma.js +1 -1
- package/components/error-bubble/error-bubble.js +2 -2
- package/components/error-message/error-message.css +1 -1
- package/components/error-message/error-message.d.ts +2 -2
- package/components/error-message/error-message.js +2 -2
- package/components/error-page/error-page.css +3 -3
- package/components/footer/footer.css +2 -2
- package/components/footer/footer.d.ts +1 -1
- package/components/footer/footer.js +1 -1
- package/components/form/form.css +3 -3
- package/components/global/compose-refs.d.ts +2 -0
- package/components/global/compose-refs.js +14 -0
- package/components/global/composeRefs.d.ts +6 -2
- package/components/global/composeRefs.js +7 -14
- package/components/global/create-stateful-context.d.ts +1 -1
- package/components/global/dom.d.ts +1 -1
- package/components/global/dom.js +2 -4
- package/components/global/focus-sensor-hoc.d.ts +1 -1
- package/components/global/focus-sensor-hoc.js +2 -2
- package/components/global/fuzzy-highlight.d.ts +2 -2
- package/components/global/get-event-key.d.ts +1 -1
- package/components/global/global.css +2 -2
- package/components/global/memoize.js +1 -1
- package/components/global/rerender-hoc.d.ts +1 -1
- package/components/global/rerender-hoc.js +2 -2
- package/components/global/theme.d.ts +1 -1
- package/components/global/theme.js +2 -2
- package/components/global/url.js +3 -3
- package/components/global/use-event-callback.js +1 -1
- package/components/global/variables.css +1 -1
- package/components/grid/col.d.ts +1 -1
- package/components/grid/col.js +1 -1
- package/components/grid/grid.css +4 -4
- package/components/grid/grid.d.ts +1 -1
- package/components/grid/grid.js +1 -1
- package/components/grid/row.d.ts +1 -1
- package/components/grid/row.js +1 -1
- package/components/group/group.css +1 -1
- package/components/group/group.d.ts +1 -1
- package/components/group/group.js +1 -1
- package/components/header/header-icon.d.ts +2 -2
- package/components/header/header.css +4 -4
- package/components/header/header.d.ts +1 -1
- package/components/header/links.d.ts +1 -1
- package/components/header/logo.d.ts +1 -1
- package/components/header/profile.d.ts +5 -5
- package/components/header/profile.js +3 -3
- package/components/header/services-link.d.ts +1 -1
- package/components/header/services-link.js +3 -3
- package/components/header/services.css +1 -1
- package/components/header/services.d.ts +2 -2
- package/components/header/services.js +3 -3
- package/components/header/smart-profile.d.ts +3 -3
- package/components/header/smart-profile.js +2 -1
- package/components/header/smart-services.d.ts +3 -3
- package/components/header/tray.d.ts +1 -1
- package/components/heading/heading.css +2 -2
- package/components/heading/heading.d.ts +1 -1
- package/components/http/http.mock.d.ts +1 -1
- package/components/hub-source/{hub-source__user.d.ts → hub-source-user.d.ts} +3 -2
- package/components/hub-source/{hub-source__users-groups.d.ts → hub-source-users-groups.d.ts} +3 -2
- package/components/hub-source/hub-source.d.ts +2 -2
- package/components/icon/{icon__svg.d.ts → icon-svg.d.ts} +1 -1
- package/components/icon/icon.css +5 -5
- package/components/icon/icon.d.ts +2 -2
- package/components/icon/icon.js +3 -3
- package/components/input/input-legacy.css +2 -2
- package/components/input/input.css +5 -5
- package/components/input/input.d.ts +3 -3
- package/components/input/input.figma.js +1 -1
- package/components/input/input.js +8 -8
- package/components/input-size/input-size.css +1 -1
- package/components/island/adaptive-island-hoc.d.ts +1 -1
- package/components/island/content.d.ts +1 -1
- package/components/island/content.js +2 -2
- package/components/island/header.d.ts +1 -1
- package/components/island/header.js +4 -4
- package/components/island/island.css +3 -3
- package/components/island/island.d.ts +1 -1
- package/components/line/line.css +1 -1
- package/components/link/clickable-link.d.ts +12 -0
- package/components/link/clickable-link.js +25 -0
- package/components/link/clickableLink.d.ts +11 -12
- package/components/link/clickableLink.js +4 -25
- package/components/link/link.css +1 -1
- package/components/link/link.d.ts +2 -2
- package/components/link/link.js +4 -4
- package/components/list/consts.d.ts +4 -5
- package/components/list/{list__custom.d.ts → list-custom.d.ts} +1 -1
- package/components/list/{list__custom.js → list-custom.js} +1 -1
- package/components/list/{list__hint.d.ts → list-hint.d.ts} +1 -1
- package/components/list/{list__hint.js → list-hint.js} +1 -1
- package/components/list/{list__item.d.ts → list-item.d.ts} +2 -2
- package/components/list/{list__item.js → list-item.js} +6 -5
- package/components/list/{list__separator.d.ts → list-separator.d.ts} +1 -1
- package/components/list/{list__separator.js → list-separator.js} +1 -1
- package/components/list/{list__title.d.ts → list-title.d.ts} +1 -1
- package/components/list/{list__title.js → list-title.js} +1 -1
- package/components/list/{list__users-groups-source.d.ts → list-users-groups-source.d.ts} +3 -2
- package/components/list/{list__users-groups-source.js → list-users-groups-source.js} +1 -1
- package/components/list/{list__classes.d.ts → list.classes.d.ts} +1 -1
- package/components/list/list.css +5 -5
- package/components/list/list.d.ts +7 -7
- package/components/list/list.js +34 -28
- package/components/loader/{loader__core.js → loader-core.js} +2 -2
- package/components/loader/loader.css +1 -1
- package/components/loader/loader.d.ts +2 -2
- package/components/loader/loader.js +1 -1
- package/components/loader-inline/loader-inline.css +2 -2
- package/components/loader-inline/loader-inline.d.ts +1 -1
- package/components/loader-screen/loader-screen.css +2 -2
- package/components/loader-screen/loader-screen.d.ts +1 -1
- package/components/login-dialog/login-dialog.css +2 -2
- package/components/login-dialog/login-dialog.d.ts +1 -1
- package/components/login-dialog/login-dialog.js +1 -1
- package/components/login-dialog/service.d.ts +1 -1
- package/components/markdown/markdown.css +3 -3
- package/components/markdown/markdown.d.ts +1 -1
- package/components/markdown/markdown.js +1 -1
- package/components/message/message.css +3 -3
- package/components/message/message.d.ts +4 -4
- package/components/message/message.js +3 -3
- package/components/old-browsers-message/old-browsers-message.css +2 -2
- package/components/old-browsers-message/old-browsers-message.js +1 -1
- package/components/pager/pager.css +1 -1
- package/components/pager/pager.d.ts +2 -2
- package/components/pager/pager.js +11 -12
- package/components/panel/panel.css +1 -1
- package/components/panel/panel.d.ts +1 -1
- package/components/panel/panel.js +1 -1
- package/components/permissions/{permissions__cache.js → permissions-cache.js} +4 -5
- package/components/permissions/permissions.d.ts +2 -2
- package/components/permissions/permissions.js +2 -4
- package/components/popup/popup.css +3 -3
- package/components/popup/popup.d.ts +2 -2
- package/components/popup/popup.js +6 -5
- package/components/popup/popup.target.d.ts +1 -1
- package/components/popup/position-css.js +6 -10
- package/components/popup/position.js +10 -10
- package/components/popup-menu/popup-menu.d.ts +4 -4
- package/components/progress-bar/progress-bar.css +6 -8
- package/components/progress-bar/progress-bar.d.ts +1 -1
- package/components/progress-bar/progress-bar.js +1 -1
- package/components/query-assist/{query-assist__suggestions.d.ts → query-assist-suggestions.d.ts} +1 -1
- package/components/query-assist/query-assist.css +11 -11
- package/components/query-assist/query-assist.d.ts +4 -4
- package/components/query-assist/query-assist.js +11 -11
- package/components/radio/{radio__item.d.ts → radio-item.d.ts} +1 -1
- package/components/radio/{radio__item.js → radio-item.js} +2 -2
- package/components/radio/radio.css +2 -2
- package/components/radio/radio.d.ts +2 -2
- package/components/radio/radio.js +1 -1
- package/components/scrollable-section/scrollable-section.d.ts +1 -1
- package/components/scrollable-section/scrollable-section.js +1 -1
- package/components/select/{select__filter.d.ts → select-filter.d.ts} +2 -2
- package/components/select/{select__filter.js → select-filter.js} +1 -1
- package/components/select/select-popup.css +5 -5
- package/components/select/{select__popup.d.ts → select-popup.d.ts} +8 -8
- package/components/select/{select__popup.js → select-popup.js} +11 -7
- package/components/select/select.css +10 -9
- package/components/select/select.d.ts +6 -6
- package/components/select/select.js +27 -25
- package/components/shortcuts/core.js +7 -7
- package/components/shortcuts/shortcuts-hoc.d.ts +2 -2
- package/components/shortcuts/shortcuts.d.ts +1 -1
- package/components/sidebar/sidebar.css +1 -1
- package/components/slider/slider.css +2 -2
- package/components/slider/slider.d.ts +5 -5
- package/components/slider/slider.js +5 -5
- package/components/slider/slider.utils.d.ts +1 -1
- package/components/slider/slider.utils.js +2 -4
- package/components/storage/{storage__local.d.ts → storage-local.d.ts} +1 -1
- package/components/storage/{storage__local.js → storage-local.js} +7 -7
- package/components/storage/storage.d.ts +1 -1
- package/components/storage/storage.js +1 -1
- package/components/tab-trap/tab-trap.css +1 -1
- package/components/tab-trap/tab-trap.d.ts +1 -1
- package/components/tab-trap/tab-trap.js +2 -5
- package/components/table/cell.d.ts +1 -1
- package/components/table/disable-hover-hoc.d.ts +1 -1
- package/components/table/header-cell.d.ts +1 -1
- package/components/table/header-cell.js +1 -1
- package/components/table/header.d.ts +2 -2
- package/components/table/header.js +2 -2
- package/components/table/multitable.d.ts +3 -3
- package/components/table/multitable.js +1 -1
- package/components/table/row-with-focus-sensor.d.ts +3 -3
- package/components/table/row.d.ts +4 -4
- package/components/table/row.js +1 -1
- package/components/table/selection-adapter.d.ts +2 -1
- package/components/table/selection-shortcuts-hoc.d.ts +4 -3
- package/components/table/selection-shortcuts-hoc.js +1 -3
- package/components/table/selection.js +4 -8
- package/components/table/simple-table.d.ts +2 -2
- package/components/table/smart-table.d.ts +2 -2
- package/components/table/table.css +6 -6
- package/components/table/table.d.ts +7 -7
- package/components/table/table.js +3 -3
- package/components/tabs/collapsible-more.d.ts +3 -3
- package/components/tabs/collapsible-more.js +2 -2
- package/components/tabs/collapsible-tab.d.ts +2 -2
- package/components/tabs/collapsible-tab.js +1 -1
- package/components/tabs/collapsible-tabs.d.ts +2 -2
- package/components/tabs/collapsible-tabs.js +6 -8
- package/components/tabs/custom-item.d.ts +2 -2
- package/components/tabs/dumb-tabs.d.ts +3 -3
- package/components/tabs/dumb-tabs.js +3 -3
- package/components/tabs/smart-tabs.d.ts +1 -1
- package/components/tabs/tab-link.d.ts +2 -2
- package/components/tabs/tab.d.ts +2 -2
- package/components/tabs/tabs.css +6 -6
- package/components/tag/tag.css +5 -5
- package/components/tag/tag.d.ts +2 -2
- package/components/tag/tag.js +2 -2
- package/components/tags-input/tags-input.css +3 -3
- package/components/tags-input/tags-input.d.ts +8 -8
- package/components/tags-input/tags-input.js +13 -7
- package/components/tags-list/tags-list.d.ts +2 -2
- package/components/tags-list/tags-list.js +1 -1
- package/components/text/text.css +1 -1
- package/components/text/text.d.ts +1 -1
- package/components/toggle/toggle.css +2 -2
- package/components/toggle/toggle.d.ts +1 -1
- package/components/toggle/toggle.js +1 -1
- package/components/tooltip/tooltip.css +1 -1
- package/components/tooltip/tooltip.d.ts +2 -2
- package/components/tooltip/tooltip.js +1 -1
- package/components/upload/upload.css +1 -1
- package/components/upload/upload.d.ts +3 -3
- package/components/upload/upload.js +2 -2
- package/components/user-agreement/service.d.ts +2 -2
- package/components/user-agreement/service.js +3 -5
- package/components/user-agreement/user-agreement.css +2 -2
- package/components/user-agreement/user-agreement.d.ts +1 -1
- package/components/user-agreement/user-agreement.js +1 -1
- package/components/user-card/card.d.ts +1 -1
- package/components/user-card/card.js +3 -2
- package/components/user-card/smart-user-card-tooltip.d.ts +2 -2
- package/components/user-card/smart-user-card-tooltip.js +1 -1
- package/components/user-card/tooltip.d.ts +3 -3
- package/components/user-card/user-card.css +1 -1
- package/package.json +4 -1
- /package/components/button/{button__classes.js → button.classes.js} +0 -0
- /package/components/dialog/{dialog__body-scroll-preventer.d.ts → dialog-body-scroll-preventer.d.ts} +0 -0
- /package/components/global/{variables.d.ts → variables.interface.d.ts} +0 -0
- /package/components/global/{variables.js → variables.interface.js} +0 -0
- /package/components/hub-source/{hub-source__user.js → hub-source-user.js} +0 -0
- /package/components/hub-source/{hub-source__users-groups.js → hub-source-users-groups.js} +0 -0
- /package/components/icon/{icon__svg.js → icon-svg.js} +0 -0
- /package/components/icon/{icon__constants.d.ts → icon.constants.d.ts} +0 -0
- /package/components/icon/{icon__constants.js → icon.constants.js} +0 -0
- /package/components/list/{list__classes.js → list.classes.js} +0 -0
- /package/components/loader/{loader__core.d.ts → loader-core.d.ts} +0 -0
- /package/components/old-browsers-message/{old-browsers-message__stop.d.ts → old-browsers-message-stop.d.ts} +0 -0
- /package/components/old-browsers-message/{old-browsers-message__stop.js → old-browsers-message-stop.js} +0 -0
- /package/components/permissions/{permissions__cache.d.ts → permissions-cache.d.ts} +0 -0
- /package/components/query-assist/{query-assist__suggestions.js → query-assist-suggestions.js} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable max-lines */
|
|
2
3
|
import { Component } from 'react';
|
|
3
4
|
import debounce from 'just-debounce-it';
|
|
4
5
|
import classNames from 'classnames';
|
|
@@ -20,7 +21,7 @@ import { ControlsHeight, ControlsHeightContext } from '../global/controls-height
|
|
|
20
21
|
import { Size } from '../input/input';
|
|
21
22
|
import inputStyles from '../input/input.css';
|
|
22
23
|
import { I18nContext } from '../i18n/i18n-context';
|
|
23
|
-
import QueryAssistSuggestions from './query-
|
|
24
|
+
import QueryAssistSuggestions from './query-assist-suggestions';
|
|
24
25
|
import styles from './query-assist.css';
|
|
25
26
|
const POPUP_COMPENSATION = PopupMenu.ListProps.Dimension.ITEM_PADDING + PopupMenu.PopupProps.Dimension.BORDER_WIDTH;
|
|
26
27
|
const ngModelStateField = 'query';
|
|
@@ -197,8 +198,9 @@ export default class QueryAssist extends Component {
|
|
|
197
198
|
this.setFocus(focusValue);
|
|
198
199
|
}
|
|
199
200
|
}
|
|
201
|
+
// eslint-disable-next-line complexity
|
|
200
202
|
setCaretPosition = (params = {}) => {
|
|
201
|
-
const queryLength = this.immediateState.query
|
|
203
|
+
const queryLength = this.immediateState.query ? this.immediateState.query.length : 0;
|
|
202
204
|
const newCaretPosition = this.immediateState.caret < queryLength ? this.immediateState.caret : queryLength;
|
|
203
205
|
if (params.fromContentEditable) {
|
|
204
206
|
this.immediateState.selection = this.immediateState.selection
|
|
@@ -226,9 +228,9 @@ export default class QueryAssist extends Component {
|
|
|
226
228
|
scrollInput() {
|
|
227
229
|
const caretOffset = this.caret?.getOffset();
|
|
228
230
|
if (this.input?.clientWidth !== this.input?.scrollWidth &&
|
|
229
|
-
caretOffset
|
|
230
|
-
this.input?.clientWidth
|
|
231
|
-
caretOffset > this.input
|
|
231
|
+
caretOffset &&
|
|
232
|
+
this.input?.clientWidth &&
|
|
233
|
+
caretOffset > this.input?.clientWidth) {
|
|
232
234
|
this.input.scrollLeft += caretOffset;
|
|
233
235
|
}
|
|
234
236
|
}
|
|
@@ -500,9 +502,7 @@ export default class QueryAssist extends Component {
|
|
|
500
502
|
if (caret === 0) {
|
|
501
503
|
return minOffset;
|
|
502
504
|
}
|
|
503
|
-
|
|
504
|
-
offset = caret;
|
|
505
|
-
}
|
|
505
|
+
offset = caret;
|
|
506
506
|
}
|
|
507
507
|
const result = offset - POPUP_COMPENSATION;
|
|
508
508
|
return result < minOffset ? minOffset : result;
|
|
@@ -674,7 +674,7 @@ export default class QueryAssist extends Component {
|
|
|
674
674
|
const actions = [...(this.props.actions || [])];
|
|
675
675
|
const renderClear = this.props.clear && !!this.state.query;
|
|
676
676
|
if (renderClear) {
|
|
677
|
-
actions.push(_jsx(I18nContext.Consumer, { children: ({ translate }) => (_jsx(Button, { icon: closeIcon, className: styles.clear, title: this.props.translations?.clearTitle ?? translate('clearTitle'), ref: this.clearRef, onClick: this.clearQuery, "data-test":
|
|
677
|
+
actions.push(_jsx(I18nContext.Consumer, { children: ({ translate }) => (_jsx(Button, { icon: closeIcon, className: styles.clear, title: this.props.translations?.clearTitle ?? translate('clearTitle'), ref: this.clearRef, onClick: this.clearQuery, "data-test": 'query-assist-clear-icon' })) }, 'clearAction'));
|
|
678
678
|
}
|
|
679
679
|
return actions;
|
|
680
680
|
}
|
|
@@ -701,10 +701,10 @@ export default class QueryAssist extends Component {
|
|
|
701
701
|
[styles.hugePlaceholder]: huge,
|
|
702
702
|
[styles.withoutGlass]: !glass || (!renderLoader && huge),
|
|
703
703
|
});
|
|
704
|
-
return (_jsx(ControlsHeightContext.Provider, { value: ControlsHeight.M, children: _jsx(I18nContext.Consumer, { children: ({ translate }) => (_jsxs("div", { "data-test": dataTests('ring-query-assist', dataTest), className: containerClasses, role:
|
|
704
|
+
return (_jsx(ControlsHeightContext.Provider, { value: ControlsHeight.M, children: _jsx(I18nContext.Consumer, { children: ({ translate }) => (_jsxs("div", { "data-test": dataTests('ring-query-assist', dataTest), className: containerClasses, role: 'presentation', ref: this.nodeRef, children: [this.state.shortcuts && _jsx(Shortcuts, { map: this.shortcutsMap, scope: this.shortcutsScope }), renderGlass && !huge && (_jsx(Icon, { glyph: searchIcon, className: styles.icon, title: translations?.searchTitle ?? translate('searchTitle'), ref: this.glassRef, "data-test": 'query-assist-search-icon' })), renderLoader && (_jsx("div", { className: classNames(styles.icon, styles.loader, {
|
|
705
705
|
[styles.loaderOnTheRight]: !glass && !huge,
|
|
706
706
|
[styles.loaderActive]: renderLoader,
|
|
707
|
-
}), ref: this.loaderRef, children: _jsx(LoaderInline, {}) })), _jsx(ContentEditable, { "aria-label": translations?.searchTitle ?? translate('searchTitle'), className: inputClasses, "data-test":
|
|
707
|
+
}), ref: this.loaderRef, children: _jsx(LoaderInline, {}) })), _jsx(ContentEditable, { "aria-label": translations?.searchTitle ?? translate('searchTitle'), className: inputClasses, "data-test": 'ring-query-assist-input', inputRef: this.inputRef, disabled: this.props.disabled, onComponentUpdate: () => this.setCaretPosition({ fromContentEditable: true }), onBlur: this.handleFocusChange, onClick: this.handleCaretMove, onCompositionStart: this.trackCompositionState, onCompositionEnd: this.trackCompositionState, onFocus: this.handleFocusChange, onInput: this.handleInput, onKeyUp: this.handleInput, onKeyDown: this.handleEnter, onPaste: this.handlePaste, spellCheck: 'false', children: this.state.query && _jsx("span", { children: this.renderQuery() }) }), renderPlaceholder && (_jsx("button", { type: 'button', className: placeholderStyles, ref: this.placeholderRef, onClick: this.handleCaretMove, "data-test": 'query-assist-placeholder', disabled: this.props.disabled, tabIndex: -1, children: this.props.placeholder })), actions.length ? (_jsx("div", { "data-test": 'ring-query-assist-actions', className: styles.actions, children: actions })) : null, _jsx(PopupMenu, { hidden: !this.state.showPopup, onCloseAttempt: this.closePopup, ref: this.popupRef, anchorElement: this.node, keepMounted: true, attached: true, className: this.props.popupClassName, directions: [PopupMenu.PopupProps.Directions.BOTTOM_RIGHT], data: useCustomItemRender ? this.state.suggestions : this.renderSuggestions(), "data-test": 'ring-query-assist-popup', hint: this.props.hint, shortcutsMap: this.listShortcutsMap, hintOnSelection: this.props.hintOnSelection, left: this.getPopupOffset(this.state.suggestions), maxHeight: PopupMenu.PopupProps.MaxHeight.SCREEN, onMouseDown: this.trackPopupMouseState, onMouseUp: this.trackPopupMouseState, onSelect: item => this.handleComplete(item) }), glass && huge && (_jsx("div", { className: styles.rightSearchButton, "data-test": 'query-assist-search-button', children: _jsx(Icon, { glyph: searchIcon, className: styles.rightSearchIcon, title: translations?.searchTitle ?? translate('searchTitle'), onClick: this.handleApply, ref: this.glassRef, "data-test": 'query-assist-search-icon' }) }))] })) }) }));
|
|
708
708
|
}
|
|
709
709
|
}
|
|
710
710
|
export const RerenderableQueryAssist = rerenderHOC(QueryAssist);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, InputHTMLAttributes, ReactNode } from 'react';
|
|
1
|
+
import { Component, type InputHTMLAttributes, type ReactNode } from 'react';
|
|
2
2
|
export interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'> {
|
|
3
3
|
value?: string | undefined;
|
|
4
4
|
onChange?: ((value: string) => void) | null | undefined;
|
|
@@ -18,10 +18,10 @@ export class RadioItemInner extends Component {
|
|
|
18
18
|
render() {
|
|
19
19
|
const { className, children, help, ...restProps } = this.props;
|
|
20
20
|
const classes = classNames(styles.radio, className);
|
|
21
|
-
return (_jsxs("label", { ref: this.labelRef, className: classes, htmlFor: this.uid, children: [_jsx("input", { id: this.uid, ...restProps, ref: this.inputRef, className: styles.input, type:
|
|
21
|
+
return (_jsxs("label", { ref: this.labelRef, className: classes, htmlFor: this.uid, children: [_jsx("input", { id: this.uid, ...restProps, ref: this.inputRef, className: styles.input, type: 'radio' }), _jsx("span", { className: styles.circle }), _jsxs("span", { className: styles.label, children: [children, help && _jsx(ControlHelp, { children: help })] })] }));
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
const RadioItem = forwardRef(function RadioItem(props, ref) {
|
|
25
|
-
return (_jsx(RadioContext.Consumer, { children: ({ value, onChange, ...restContext }) => (_jsx(RadioItemInner, { ref: ref, ...restContext, checked: value
|
|
25
|
+
return (_jsx(RadioContext.Consumer, { children: ({ value, onChange, ...restContext }) => (_jsx(RadioItemInner, { ref: ref, ...restContext, checked: value ? value === props.value : undefined, onChange: onChange ? () => onChange(props.value) : undefined, ...props })) }));
|
|
26
26
|
});
|
|
27
27
|
export default RadioItem;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@import
|
|
1
|
+
@import '../global/variables.css';
|
|
2
2
|
|
|
3
3
|
.radio {
|
|
4
4
|
position: relative;
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
width: var(--ring-unit);
|
|
49
49
|
height: var(--ring-unit);
|
|
50
50
|
|
|
51
|
-
content:
|
|
51
|
+
content: '';
|
|
52
52
|
|
|
53
53
|
transition:
|
|
54
54
|
opacity var(--ring-fast-ease),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
|
-
import { RadioProps } from './
|
|
2
|
+
import { type RadioProps } from './radio-item';
|
|
3
3
|
/**
|
|
4
4
|
* @name Radio
|
|
5
5
|
*/
|
|
6
6
|
export default class Radio extends Component<RadioProps> {
|
|
7
|
-
static Item: import("react").ForwardRefExoticComponent<import("./
|
|
7
|
+
static Item: import("react").ForwardRefExoticComponent<import("./radio-item").RadioItemProps & import("react").RefAttributes<import("./radio-item").RadioItemInner>>;
|
|
8
8
|
uid: string;
|
|
9
9
|
render(): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Component } from 'react';
|
|
3
3
|
import getUID from '../global/get-uid';
|
|
4
|
-
import RadioItem, { RadioContext } from './
|
|
4
|
+
import RadioItem, { RadioContext } from './radio-item';
|
|
5
5
|
/**
|
|
6
6
|
* @name Radio
|
|
7
7
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { HTMLAttributes } from 'react';
|
|
1
|
+
import { type HTMLAttributes } from 'react';
|
|
2
2
|
export default function ScrollableSection({ className, ...restProps }: HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -9,7 +9,7 @@ export default function ScrollableSection({ className, ...restProps }) {
|
|
|
9
9
|
const [scrolledToLeft, setScrolledToLeft] = useState(false);
|
|
10
10
|
const ref = useRef(null);
|
|
11
11
|
const calculateScrollPosition = useCallback(() => {
|
|
12
|
-
if (ref.current
|
|
12
|
+
if (ref.current) {
|
|
13
13
|
const { scrollTop, scrollLeft, scrollHeight, scrollWidth, offsetHeight, offsetWidth } = ref.current;
|
|
14
14
|
setScrolledToTop(scrollTop === 0);
|
|
15
15
|
setScrolledToRight(offsetWidth + scrollLeft >= scrollWidth);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Component, RefCallback } from 'react';
|
|
2
|
-
import { InputAttrs } from '../input/input';
|
|
1
|
+
import { Component, type RefCallback } from 'react';
|
|
2
|
+
import { type InputAttrs } from '../input/input';
|
|
3
3
|
declare function noop(): void;
|
|
4
4
|
type SelectFilterProps = InputAttrs & {
|
|
5
5
|
inputRef: RefCallback<HTMLInputElement | HTMLTextAreaElement>;
|
|
@@ -35,6 +35,6 @@ export default class SelectFilter extends Component {
|
|
|
35
35
|
render() {
|
|
36
36
|
const { className, listId, ...restProps } = this.props;
|
|
37
37
|
const classes = classNames(styles.filter, className);
|
|
38
|
-
return (_jsx(ActiveItemContext.ValueContext.Consumer, { children: activeItemId => (_jsx(I18nContext.Consumer, { children: ({ translate }) => (_jsx(Input, { ...restProps, placeholder: restProps.placeholder ?? translate('filterItems'), "aria-owns": listId, "aria-activedescendant": activeItemId, autoComplete:
|
|
38
|
+
return (_jsx(ActiveItemContext.ValueContext.Consumer, { children: activeItemId => (_jsx(I18nContext.Consumer, { children: ({ translate }) => (_jsx(Input, { ...restProps, placeholder: restProps.placeholder ?? translate('filterItems'), "aria-owns": listId, "aria-activedescendant": activeItemId, autoComplete: 'off', autoFocus: true, borderless: true, inputRef: this.inputRef, className: classes })) })) }));
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@import
|
|
1
|
+
@import '../global/variables.css';
|
|
2
2
|
|
|
3
3
|
.filterWithTags {
|
|
4
4
|
overflow: hidden;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
padding-right: 0;
|
|
16
16
|
padding-left: 0;
|
|
17
17
|
|
|
18
|
-
border-bottom:
|
|
18
|
+
border-bottom: 0;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
&:hover {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
.filterWithTagsInput {
|
|
32
32
|
padding: 0;
|
|
33
33
|
|
|
34
|
-
border:
|
|
34
|
+
border: 0;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
.filter {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
|
|
56
56
|
border-bottom: 1px solid var(--ring-borders-color);
|
|
57
57
|
|
|
58
|
-
[dir=
|
|
58
|
+
[dir='rtl'] & {
|
|
59
59
|
padding-right: calc(var(--ring-unit) * 5.5);
|
|
60
60
|
padding-left: var(--ring-unit);
|
|
61
61
|
}
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
|
|
69
69
|
color: var(--ring-secondary-color);
|
|
70
70
|
|
|
71
|
-
[dir=
|
|
71
|
+
[dir='rtl'] & {
|
|
72
72
|
right: calc(var(--ring-unit) * 2);
|
|
73
73
|
left: auto;
|
|
74
74
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @description Displays a popup with select's options.
|
|
3
3
|
*/
|
|
4
|
-
import { ComponentType, CSSProperties, PureComponent, ReactNode, Ref, SyntheticEvent } from 'react';
|
|
4
|
+
import { type ComponentType, type CSSProperties, PureComponent, type ReactNode, type Ref, type SyntheticEvent } from 'react';
|
|
5
5
|
import * as React from 'react';
|
|
6
|
-
import { IconType } from '../icon/icon';
|
|
6
|
+
import { type IconType } from '../icon/icon';
|
|
7
7
|
import Popup from '../popup/popup';
|
|
8
|
-
import { Directions } from '../popup/position';
|
|
9
|
-
import List, { SelectHandlerParams } from '../list/list';
|
|
8
|
+
import { type Directions } from '../popup/position';
|
|
9
|
+
import List, { type SelectHandlerParams } from '../list/list';
|
|
10
10
|
import Caret from '../caret/caret';
|
|
11
|
-
import { ListDataItem } from '../list/consts';
|
|
12
|
-
import { ShortcutsMap } from '../shortcuts/core';
|
|
13
|
-
import { TagAttrs } from '../tag/tag';
|
|
14
|
-
import { SelectItem } from './select';
|
|
11
|
+
import { type ListDataItem } from '../list/consts';
|
|
12
|
+
import { type ShortcutsMap } from '../shortcuts/core';
|
|
13
|
+
import { type TagAttrs } from '../tag/tag';
|
|
14
|
+
import { type SelectItem } from './select';
|
|
15
15
|
export type FilterFn<T> = (itemToCheck: SelectItem<T>, checkString: string, data: readonly SelectItem<T>[]) => boolean;
|
|
16
16
|
export interface Filter<T = unknown> {
|
|
17
17
|
fn?: FilterFn<T> | null | undefined;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable max-lines */
|
|
2
3
|
/**
|
|
3
4
|
* @description Displays a popup with select's options.
|
|
4
5
|
*/
|
|
5
|
-
import { PureComponent } from 'react';
|
|
6
|
+
import { PureComponent, } from 'react';
|
|
6
7
|
import classNames from 'classnames';
|
|
7
8
|
import searchIcon from '@jetbrains/icons/search';
|
|
8
9
|
import memoizeOne from 'memoize-one';
|
|
@@ -22,9 +23,9 @@ import Shortcuts from '../shortcuts/shortcuts';
|
|
|
22
23
|
import Button from '../button/button';
|
|
23
24
|
import Text from '../text/text';
|
|
24
25
|
import { ControlsHeight } from '../global/controls-height';
|
|
25
|
-
import { createComposedRef } from '../global/
|
|
26
|
+
import { createComposedRef } from '../global/compose-refs';
|
|
26
27
|
import { DEFAULT_DIRECTIONS } from '../popup/popup.consts';
|
|
27
|
-
import SelectFilter from './
|
|
28
|
+
import SelectFilter from './select-filter';
|
|
28
29
|
import styles from './select-popup.css';
|
|
29
30
|
const FILTER_HEIGHT = 35;
|
|
30
31
|
const TOOLBAR_HEIGHT = 49;
|
|
@@ -80,7 +81,7 @@ export default class SelectPopup extends PureComponent {
|
|
|
80
81
|
}
|
|
81
82
|
caret;
|
|
82
83
|
handleNavigation(event, navigateLeft) {
|
|
83
|
-
if ((this.isEventTargetFilter(event) && this.caret
|
|
84
|
+
if ((this.isEventTargetFilter(event) && this.caret && Number(this.caret?.getPosition()) > 0) ||
|
|
84
85
|
!Array.isArray(this.props.selected)) {
|
|
85
86
|
return;
|
|
86
87
|
}
|
|
@@ -103,6 +104,7 @@ export default class SelectPopup extends PureComponent {
|
|
|
103
104
|
if (!Array.isArray(this.props.selected)) {
|
|
104
105
|
return;
|
|
105
106
|
}
|
|
107
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
106
108
|
const _tag = tag || this.props.selected.slice(0)[this.props.selected.length - 1];
|
|
107
109
|
if (_tag) {
|
|
108
110
|
this.onListSelect(_tag, event, { tryKeepOpen: true });
|
|
@@ -113,7 +115,9 @@ export default class SelectPopup extends PureComponent {
|
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
117
|
removeSelectedTag() {
|
|
116
|
-
if (Array.isArray(this.props.selected) &&
|
|
118
|
+
if (Array.isArray(this.props.selected) &&
|
|
119
|
+
this.state.tagsActiveIndex !== null &&
|
|
120
|
+
this.state.tagsActiveIndex !== undefined) {
|
|
117
121
|
this.removeTag(this.props.selected[this.state.tagsActiveIndex]);
|
|
118
122
|
return false;
|
|
119
123
|
}
|
|
@@ -179,7 +183,7 @@ export default class SelectPopup extends PureComponent {
|
|
|
179
183
|
onClickHandler = () => this.filter?.focus();
|
|
180
184
|
getFilter() {
|
|
181
185
|
if (this.props.filter || this.props.tags) {
|
|
182
|
-
return (_jsxs("div", { className: styles.filterWrapper, "data-test":
|
|
186
|
+
return (_jsxs("div", { className: styles.filterWrapper, "data-test": 'ring-select-popup-filter', children: [!this.props.tags && (_jsx(Icon, { glyph: this.props.filterIcon ?? searchIcon, className: styles.filterIcon, "data-test-custom": 'ring-select-popup-filter-icon' })), _jsx(FilterWithShortcuts, { rgShortcutsOptions: this.state.popupFilterShortcutsOptions, rgShortcutsMap: this.popupFilterShortcutsMap, value: this.props.filterValue, inputRef: this.composedFilterRef(this.filterRef, this.props.filterRef), onBlur: this.popupFilterOnBlur, onFocus: this.onFilterFocus, className: 'ring-js-shortcuts', inputClassName: classNames({ [styles.filterWithTagsInput]: this.props.tags }), placeholder: typeof this.props.filter === 'object' ? this.props.filter.placeholder : undefined, height: this.props.tags ? ControlsHeight.S : ControlsHeight.L, onChange: this.props.onFilter, onClick: this.onClickHandler, onClear: this.props.tags ? undefined : this.props.onClear, "data-test-custom": 'ring-select-popup-filter-input', listId: this.props.listId, enableShortcuts: Object.keys(this.popupFilterShortcutsMap) })] }));
|
|
183
187
|
}
|
|
184
188
|
return null;
|
|
185
189
|
}
|
|
@@ -268,7 +272,7 @@ export default class SelectPopup extends PureComponent {
|
|
|
268
272
|
// render the list would be a better way
|
|
269
273
|
const anchorNode = this.props.anchorElement;
|
|
270
274
|
const containerNode = getPopupContainer(ringPopupTarget) || document.documentElement;
|
|
271
|
-
return anchorNode
|
|
275
|
+
return anchorNode !== null
|
|
272
276
|
? Math.min(directions.reduce((maxHeight, direction) => Math.max(maxHeight, maxHeightForDirection(direction, anchorNode, getStyles(containerNode).position !== 'static' ? containerNode : null) ?? 0), minMaxHeight), userDefinedMaxHeight)
|
|
273
277
|
: userDefinedMaxHeight;
|
|
274
278
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@import
|
|
1
|
+
@import '../global/variables.css';
|
|
2
2
|
|
|
3
3
|
.select {
|
|
4
4
|
position: relative;
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
text-align: left;
|
|
22
22
|
|
|
23
|
-
[dir=
|
|
23
|
+
[dir='rtl'] & {
|
|
24
24
|
text-align: right;
|
|
25
25
|
direction: ltr;
|
|
26
26
|
}
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
.selectedIcon {
|
|
66
|
-
composes: resetButton from
|
|
66
|
+
composes: resetButton from '../global/global.css';
|
|
67
67
|
|
|
68
68
|
position: relative;
|
|
69
69
|
top: 3px;
|
|
@@ -112,8 +112,8 @@
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
.value {
|
|
115
|
-
composes: ellipsis from
|
|
116
|
-
composes: font from
|
|
115
|
+
composes: ellipsis from '../global/global.css';
|
|
116
|
+
composes: font from '../global/global.css';
|
|
117
117
|
|
|
118
118
|
display: inline-block;
|
|
119
119
|
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
|
|
132
132
|
color: var(--ring-text-color);
|
|
133
133
|
|
|
134
|
-
border:
|
|
134
|
+
border: 0;
|
|
135
135
|
border-bottom: 1px solid var(--ring-borders-color);
|
|
136
136
|
outline: none;
|
|
137
137
|
background: transparent;
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
.buttonValue {
|
|
163
|
-
composes: ellipsis from
|
|
163
|
+
composes: ellipsis from '../global/global.css';
|
|
164
164
|
|
|
165
165
|
display: block;
|
|
166
166
|
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
.buttonValueEmpty.buttonValueEmpty {
|
|
183
|
-
color: var(--ring-
|
|
183
|
+
color: var(--ring-secondary-color);
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
.heightS .buttonValue {
|
|
@@ -211,7 +211,8 @@
|
|
|
211
211
|
|
|
212
212
|
color: var(--ring-disabled-color);
|
|
213
213
|
|
|
214
|
-
& .value
|
|
214
|
+
& .value,
|
|
215
|
+
& .buttonValueEmpty {
|
|
215
216
|
color: var(--ring-disabled-color);
|
|
216
217
|
border-bottom-style: dashed;
|
|
217
218
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ButtonHTMLAttributes, Component, ComponentType, CSSProperties, HTMLAttributes, ReactNode, Ref, RefCallback, SyntheticEvent } from 'react';
|
|
1
|
+
import { type ButtonHTMLAttributes, Component, type ComponentType, type CSSProperties, type HTMLAttributes, type ReactNode, type Ref, type RefCallback, type SyntheticEvent } from 'react';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { SelectHandlerParams } from '../list/list';
|
|
3
|
+
import { type SelectHandlerParams } from '../list/list';
|
|
4
4
|
import { Size } from '../input/input';
|
|
5
|
-
import { LabelType } from '../control-label/control-label';
|
|
6
|
-
import { ListDataItem } from '../list/consts';
|
|
7
|
-
import { Directions } from '../popup/popup.consts';
|
|
5
|
+
import { type LabelType } from '../control-label/control-label';
|
|
6
|
+
import { type ListDataItem } from '../list/consts';
|
|
7
|
+
import { type Directions } from '../popup/popup.consts';
|
|
8
8
|
import { ControlsHeight, ControlsHeightContext } from '../global/controls-height';
|
|
9
|
-
import SelectPopup, { Filter, FilterFn, Multiple, Tags } from './
|
|
9
|
+
import SelectPopup, { type Filter, type FilterFn, type Multiple, type Tags } from './select-popup';
|
|
10
10
|
/**
|
|
11
11
|
* @name Select
|
|
12
12
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable max-lines */
|
|
2
3
|
import { Component, Fragment, } from 'react';
|
|
3
4
|
import classNames from 'classnames';
|
|
4
5
|
import chevronDownIcon from '@jetbrains/icons/chevron-down';
|
|
@@ -18,11 +19,11 @@ import rerenderHOC from '../global/rerender-hoc';
|
|
|
18
19
|
import fuzzyHighlight from '../global/fuzzy-highlight';
|
|
19
20
|
import memoize from '../global/memoize';
|
|
20
21
|
import { I18nContext } from '../i18n/i18n-context';
|
|
21
|
-
import { createComposedRef } from '../global/
|
|
22
|
+
import { createComposedRef } from '../global/compose-refs';
|
|
22
23
|
import { isArray } from '../global/typescript-utils';
|
|
23
24
|
import { ControlsHeight, ControlsHeightContext } from '../global/controls-height';
|
|
24
25
|
import inputStyles from '../input/input.css';
|
|
25
|
-
import SelectPopup from './
|
|
26
|
+
import SelectPopup from './select-popup';
|
|
26
27
|
import styles from './select.css';
|
|
27
28
|
/**
|
|
28
29
|
* @name Select
|
|
@@ -55,7 +56,7 @@ function getLowerCaseLabel(item) {
|
|
|
55
56
|
}
|
|
56
57
|
function doesLabelMatch(itemToCheck, fn) {
|
|
57
58
|
const lowerCaseLabel = getLowerCaseLabel(itemToCheck);
|
|
58
|
-
if (lowerCaseLabel
|
|
59
|
+
if (lowerCaseLabel === null || lowerCaseLabel === undefined) {
|
|
59
60
|
return true;
|
|
60
61
|
}
|
|
61
62
|
return fn(lowerCaseLabel);
|
|
@@ -77,6 +78,7 @@ function buildMultipleMap(selected) {
|
|
|
77
78
|
return acc;
|
|
78
79
|
}, {});
|
|
79
80
|
}
|
|
81
|
+
// eslint-disable-next-line complexity
|
|
80
82
|
function getListItems(props, state, rawFilterString, data = props.data) {
|
|
81
83
|
let filterString = rawFilterString.trim();
|
|
82
84
|
if (isInputMode(props.type) &&
|
|
@@ -136,7 +138,7 @@ function getListItems(props, state, rawFilterString, data = props.data) {
|
|
|
136
138
|
return { filteredData, addButton };
|
|
137
139
|
}
|
|
138
140
|
const getItemLabel = ({ selectedLabel, label }) => {
|
|
139
|
-
if (selectedLabel
|
|
141
|
+
if (selectedLabel !== null && selectedLabel !== undefined) {
|
|
140
142
|
return selectedLabel;
|
|
141
143
|
}
|
|
142
144
|
return typeof label === 'string' ? label : '';
|
|
@@ -236,7 +238,9 @@ export default class Select extends Component {
|
|
|
236
238
|
const { filteredData, addButton } = getListItems(nextProps, nextState, filterValue, data);
|
|
237
239
|
Object.assign(nextState, { shownData: filteredData, addButton });
|
|
238
240
|
}
|
|
239
|
-
const isSelectionEmpty = nextProps.selected
|
|
241
|
+
const isSelectionEmpty = nextProps.selected === null ||
|
|
242
|
+
nextProps.selected === undefined ||
|
|
243
|
+
(Array.isArray(nextProps.selected) && nextProps.selected.length === 0);
|
|
240
244
|
if (isSelectionEmpty) {
|
|
241
245
|
nextState.lastInteractedKey = null;
|
|
242
246
|
}
|
|
@@ -333,7 +337,7 @@ export default class Select extends Component {
|
|
|
333
337
|
if (!this._popup?.isVisible()) {
|
|
334
338
|
return true;
|
|
335
339
|
}
|
|
336
|
-
|
|
340
|
+
if (this.props.multiple || !this.props.getInitial) {
|
|
337
341
|
return false;
|
|
338
342
|
}
|
|
339
343
|
const selected = {
|
|
@@ -360,7 +364,7 @@ export default class Select extends Component {
|
|
|
360
364
|
_getActiveIndex(items) {
|
|
361
365
|
const { selected, lastInteractedKey } = this.state;
|
|
362
366
|
const isNonOptionItem = (item) => item.isResetItem || List.isItemType(List.ListProps.Type.SEPARATOR, item);
|
|
363
|
-
if (lastInteractedKey
|
|
367
|
+
if (lastInteractedKey !== null && lastInteractedKey !== undefined) {
|
|
364
368
|
const index = items.findIndex(item => item.key === lastInteractedKey && !isNonOptionItem(item));
|
|
365
369
|
if (index >= 0)
|
|
366
370
|
return index;
|
|
@@ -404,7 +408,7 @@ export default class Select extends Component {
|
|
|
404
408
|
separator: reset.separator,
|
|
405
409
|
key: reset.label,
|
|
406
410
|
rgItemType: List.ListProps.Type.CUSTOM,
|
|
407
|
-
template: (_jsx(Button, { inline: true, className: styles.button, "data-test":
|
|
411
|
+
template: (_jsx(Button, { inline: true, className: styles.button, "data-test": 'ring-select-reset-tags-button', height: ControlsHeight.S, children: reset.label })),
|
|
408
412
|
glyph: reset.glyph,
|
|
409
413
|
onClick: resetHandler,
|
|
410
414
|
};
|
|
@@ -425,6 +429,7 @@ export default class Select extends Component {
|
|
|
425
429
|
_renderPopup() {
|
|
426
430
|
const anchorElement = this.props.targetElement || this.node;
|
|
427
431
|
const { showPopup, shownData } = this.state;
|
|
432
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
428
433
|
const _shownData = this._prependResetOption(shownData);
|
|
429
434
|
const activeIndex = this._getActiveIndex(_shownData);
|
|
430
435
|
return (_jsx(I18nContext.Consumer, { children: ({ translate }) => {
|
|
@@ -474,7 +479,7 @@ export default class Select extends Component {
|
|
|
474
479
|
}
|
|
475
480
|
return (_jsxs("div", { className: classNames({
|
|
476
481
|
[styles.toolbar]: Boolean(this.state.addButton || renderBottomToolbar),
|
|
477
|
-
}), "data-test":
|
|
482
|
+
}), "data-test": 'ring-select-toolbar', children: [renderBottomToolbar && renderBottomToolbar(), this.state.addButton && (_jsx(Button, { inline: true, delayed: delayed, className: classNames(styles.button, styles.buttonSpaced), onClick: this.addHandler, "data-test": 'ring-select-toolbar-button', children: prefix ? `${prefix} ${label}` : label })), hint && _jsx(List.ListHint, { label: hint, "data-test": 'ring-select-toolbar-hint' })] }));
|
|
478
483
|
}
|
|
479
484
|
getTopbar() {
|
|
480
485
|
return this.props.renderTopToolbar?.();
|
|
@@ -494,9 +499,7 @@ export default class Select extends Component {
|
|
|
494
499
|
this.setState({ filterValue: setValue });
|
|
495
500
|
return undefined;
|
|
496
501
|
}
|
|
497
|
-
|
|
498
|
-
return this.state.filterValue;
|
|
499
|
-
}
|
|
502
|
+
return this.state.filterValue;
|
|
500
503
|
}
|
|
501
504
|
isInputMode() {
|
|
502
505
|
return isInputMode(this.props.type);
|
|
@@ -597,7 +600,7 @@ export default class Select extends Component {
|
|
|
597
600
|
if (!tryKeepOpen) {
|
|
598
601
|
this._hidePopup(isSelectItemEvent);
|
|
599
602
|
}
|
|
600
|
-
if (selected.key
|
|
603
|
+
if (selected.key === null || selected.key === undefined) {
|
|
601
604
|
throw new Error('Multiple selection requires each item to have the "key" property');
|
|
602
605
|
}
|
|
603
606
|
this.setState(prevState => {
|
|
@@ -729,9 +732,7 @@ export default class Select extends Component {
|
|
|
729
732
|
}
|
|
730
733
|
return labels.filter(Boolean).join(', ');
|
|
731
734
|
}
|
|
732
|
-
|
|
733
|
-
return this.state.selected != null ? getItemLabel(this.state.selected) : null;
|
|
734
|
-
}
|
|
735
|
+
return this.state.selected !== null && this.state.selected !== undefined ? getItemLabel(this.state.selected) : null;
|
|
735
736
|
}
|
|
736
737
|
getHeight() {
|
|
737
738
|
return this.props.height || (typeof this.context === 'function' ? this.context() : this.context);
|
|
@@ -742,13 +743,13 @@ export default class Select extends Component {
|
|
|
742
743
|
const icons = [];
|
|
743
744
|
const height = this.getHeight();
|
|
744
745
|
if (!Array.isArray(selected) && selected?.icon) {
|
|
745
|
-
icons.push(_jsx("button", { title:
|
|
746
|
+
icons.push(_jsx("button", { title: 'Toggle options popup', type: 'button', className: styles.selectedIcon, disabled: this.props.disabled, onClick: this._clickHandler, style: { backgroundImage: `url(${selected.icon})` } }, 'selected'));
|
|
746
747
|
}
|
|
747
748
|
if (clear && !disabled && !this._selectionIsEmpty()) {
|
|
748
|
-
icons.push(_jsx(Button, { title:
|
|
749
|
+
icons.push(_jsx(Button, { title: 'Clear selection', "data-test": 'ring-clear-select', className: styles.clearIcon, disabled: this.props.disabled, onClick: this.clear, height: height, icon: closeIcon }, 'close'));
|
|
749
750
|
}
|
|
750
751
|
if (!hideArrow) {
|
|
751
|
-
icons.push(_jsx(Button, { title:
|
|
752
|
+
icons.push(_jsx(Button, { title: 'Toggle options popup', className: styles.chevron, iconClassName: styles.chevronIcon, icon: chevronDownIcon, disabled: this.props.disabled, height: height, onClick: this._clickHandler }, 'hide'));
|
|
752
753
|
}
|
|
753
754
|
return icons;
|
|
754
755
|
}
|
|
@@ -774,6 +775,7 @@ export default class Select extends Component {
|
|
|
774
775
|
space: noop,
|
|
775
776
|
};
|
|
776
777
|
}
|
|
778
|
+
// eslint-disable-next-line complexity
|
|
777
779
|
renderSelect(activeItemId) {
|
|
778
780
|
const dataTest = this.props['data-test'];
|
|
779
781
|
const { selectedLabel } = this.props;
|
|
@@ -799,10 +801,10 @@ export default class Select extends Component {
|
|
|
799
801
|
switch (this.props.type) {
|
|
800
802
|
case Type.INPUT_WITHOUT_CONTROLS:
|
|
801
803
|
case Type.INPUT:
|
|
802
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { ref: this.nodeRef, className: classNames(classes, styles.inputMode), "data-test": dataTests('ring-select', dataTest), role:
|
|
803
|
-
, onMouseDown: this.mouseDownHandler, onMouseUp: this.mouseUpHandler, children: [shortcutsEnabled && _jsx(Shortcuts, { map: this.getShortcutsMap(), scope: this.shortcutsScope }), _jsx(Input, { ...ariaProps, height: this.props.height, autoComplete:
|
|
804
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { ref: this.nodeRef, className: classNames(classes, styles.inputMode), "data-test": dataTests('ring-select', dataTest), role: 'presentation' // has interactive elements inside
|
|
805
|
+
, onMouseDown: this.mouseDownHandler, onMouseUp: this.mouseUpHandler, children: [shortcutsEnabled && _jsx(Shortcuts, { map: this.getShortcutsMap(), scope: this.shortcutsScope }), _jsx(Input, { ...ariaProps, height: this.props.height, autoComplete: 'off', id: this.props.id, onClick: this._clickHandler, inputRef: this.composedFilterRef(this.filterRef, this.props.filterRef), disabled: this.props.disabled, value: this.state.filterValue, borderless: this.props.type === Type.INPUT_WITHOUT_CONTROLS, style: style, size: Size.FULL, onChange: this._filterChangeHandler, onFocus: this._focusHandler, onBlur: this._blurHandler,
|
|
804
806
|
// Input with error style without description
|
|
805
|
-
error: this.props.error
|
|
807
|
+
error: this.props.error ? '' : null, label: this.props.type === Type.INPUT ? this._getLabel() : null, placeholder: this.props.inputPlaceholder, onKeyDown: this.props.onKeyDown, "data-test": 'ring-select__focus', enableShortcuts: shortcutsEnabled
|
|
806
808
|
? Object.keys({
|
|
807
809
|
...this.getShortcutsMap(),
|
|
808
810
|
...this._popup?.list?.shortcutsMap,
|
|
@@ -812,9 +814,9 @@ export default class Select extends Component {
|
|
|
812
814
|
return (_jsxs("div", { ref: this.nodeRef, className: classNames(classes, styles.buttonMode), "data-test": dataTests('ring-select', dataTest), children: [selectedLabel && (_jsx(ControlLabel, { type: this.props.labelType, disabled: this.props.disabled, htmlFor: this.props.id, children: selectedLabel })), shortcutsEnabled && _jsx(Shortcuts, { map: this.getShortcutsMap(), scope: this.shortcutsScope }), _jsxs("div", { className: styles.buttonContainer, children: [_jsxs(Button, { ...ariaProps, height: this.props.height, id: this.props.id, onClick: this._clickHandler, className: classNames(this.props.buttonClassName, styles.buttonValue, {
|
|
813
815
|
[styles.buttonValueOpen]: this.state.showPopup,
|
|
814
816
|
[styles.buttonValueEmpty]: this._selectionIsEmpty(),
|
|
815
|
-
}), disabled: this.props.disabled, style: style, "data-test":
|
|
817
|
+
}), disabled: this.props.disabled, style: style, "data-test": 'ring-select__button ring-select__focus', children: [this._getAvatar(), this._getPlaceholder()] }), iconsNode] }), this._renderPopup()] }));
|
|
816
818
|
case Type.INLINE:
|
|
817
|
-
return (_jsxs("div", { className: classes, ref: this.nodeRef, "data-test": dataTests('ring-select', dataTest), children: [shortcutsEnabled && _jsx(Shortcuts, { map: this.getShortcutsMap(), scope: this.shortcutsScope }), _jsx(Anchor, { ...ariaProps, className: this.props.buttonClassName ?? undefined, id: this.props.id, onClick: this._clickHandler, "data-test":
|
|
819
|
+
return (_jsxs("div", { className: classes, ref: this.nodeRef, "data-test": dataTests('ring-select', dataTest), children: [shortcutsEnabled && _jsx(Shortcuts, { map: this.getShortcutsMap(), scope: this.shortcutsScope }), _jsx(Anchor, { ...ariaProps, className: this.props.buttonClassName ?? undefined, id: this.props.id, onClick: this._clickHandler, "data-test": 'ring-select__focus', disabled: this.props.disabled, active: this.state.showPopup, children: this._getPlaceholder() }), this._renderPopup()] }));
|
|
818
820
|
default:
|
|
819
821
|
if (this.props.customAnchor) {
|
|
820
822
|
return (_jsxs(Fragment, { children: [shortcutsEnabled && _jsx(Shortcuts, { map: this.getShortcutsMap(), scope: this.shortcutsScope }), this.props.customAnchor({
|
|
@@ -833,7 +835,7 @@ export default class Select extends Component {
|
|
|
833
835
|
popup: this._renderPopup(),
|
|
834
836
|
})] }));
|
|
835
837
|
}
|
|
836
|
-
return (_jsx("span", { id: this.props.id, ref: this.nodeRef, "data-test":
|
|
838
|
+
return (_jsx("span", { id: this.props.id, ref: this.nodeRef, "data-test": 'ring-select', children: this._renderPopup() }));
|
|
837
839
|
}
|
|
838
840
|
}
|
|
839
841
|
render() {
|