@jetbrains/ring-ui-built 6.0.1
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/LICENSE.txt +202 -0
- package/README.md +103 -0
- package/components/_helpers/_rollupPluginBabelHelpers.js +648 -0
- package/components/_helpers/anchor.js +31 -0
- package/components/_helpers/badge.js +3 -0
- package/components/_helpers/button__classes.js +34 -0
- package/components/_helpers/caption.js +31 -0
- package/components/_helpers/card.js +132 -0
- package/components/_helpers/date-picker.js +3 -0
- package/components/_helpers/dialog__body-scroll-preventer.js +54 -0
- package/components/_helpers/grid.js +3 -0
- package/components/_helpers/header.js +3 -0
- package/components/_helpers/heading.js +3 -0
- package/components/_helpers/icon__svg.js +75 -0
- package/components/_helpers/input.js +235 -0
- package/components/_helpers/island.js +3 -0
- package/components/_helpers/link.js +3 -0
- package/components/_helpers/list.js +3 -0
- package/components/_helpers/query-assist__suggestions.js +102 -0
- package/components/_helpers/select__filter.js +94 -0
- package/components/_helpers/services-link.js +48 -0
- package/components/_helpers/sidebar.js +123 -0
- package/components/_helpers/tab-link.js +34 -0
- package/components/_helpers/table.js +3 -0
- package/components/_helpers/theme.js +95 -0
- package/components/_helpers/title.js +103 -0
- package/components/alert/alert.d.ts +113 -0
- package/components/alert/alert.js +294 -0
- package/components/alert/container.d.ts +15 -0
- package/components/alert/container.js +52 -0
- package/components/alert-service/alert-service.d.ts +36 -0
- package/components/alert-service/alert-service.js +220 -0
- package/components/analytics/analytics.d.ts +18 -0
- package/components/analytics/analytics.js +31 -0
- package/components/analytics/analytics__custom-plugin.d.ts +28 -0
- package/components/analytics/analytics__custom-plugin.js +89 -0
- package/components/auth/auth.d.ts +3 -0
- package/components/auth/auth.js +133 -0
- package/components/auth/auth__core.d.ts +236 -0
- package/components/auth/auth__core.js +1653 -0
- package/components/auth/background-flow.d.ts +31 -0
- package/components/auth/background-flow.js +147 -0
- package/components/auth/down-notification.d.ts +15 -0
- package/components/auth/down-notification.js +157 -0
- package/components/auth/iframe-flow.d.ts +20 -0
- package/components/auth/iframe-flow.js +196 -0
- package/components/auth/request-builder.d.ts +48 -0
- package/components/auth/request-builder.js +104 -0
- package/components/auth/response-parser.d.ts +70 -0
- package/components/auth/response-parser.js +138 -0
- package/components/auth/storage.d.ts +112 -0
- package/components/auth/storage.js +429 -0
- package/components/auth/token-validator.d.ts +93 -0
- package/components/auth/token-validator.js +269 -0
- package/components/auth/window-flow.d.ts +26 -0
- package/components/auth/window-flow.js +154 -0
- package/components/auth-dialog/auth-dialog.d.ts +60 -0
- package/components/auth-dialog/auth-dialog.js +221 -0
- package/components/auth-dialog-service/auth-dialog-service.d.ts +6 -0
- package/components/auth-dialog-service/auth-dialog-service.js +92 -0
- package/components/avatar/avatar-example-datauri.d.ts +1 -0
- package/components/avatar/avatar-example-datauri.js +4 -0
- package/components/avatar/avatar.d.ts +52 -0
- package/components/avatar/avatar.js +183 -0
- package/components/avatar/fallback-avatar.d.ts +17 -0
- package/components/avatar/fallback-avatar.js +151 -0
- package/components/badge/badge.d.ts +24 -0
- package/components/badge/badge.js +59 -0
- package/components/button/button.d.ts +67 -0
- package/components/button/button.js +131 -0
- package/components/button/button__classes.d.ts +2 -0
- package/components/button/button__classes.js +2 -0
- package/components/button-group/button-group.d.ts +18 -0
- package/components/button-group/button-group.js +48 -0
- package/components/button-group/caption.d.ts +8 -0
- package/components/button-group/caption.js +5 -0
- package/components/button-set/button-set.d.ts +16 -0
- package/components/button-set/button-set.js +47 -0
- package/components/button-toolbar/button-toolbar.d.ts +16 -0
- package/components/button-toolbar/button-toolbar.js +46 -0
- package/components/caret/caret.d.ts +66 -0
- package/components/caret/caret.js +259 -0
- package/components/checkbox/checkbox.d.ts +45 -0
- package/components/checkbox/checkbox.js +130 -0
- package/components/clipboard/clipboard-fallback.d.ts +2 -0
- package/components/clipboard/clipboard-fallback.js +42 -0
- package/components/clipboard/clipboard.d.ts +5 -0
- package/components/clipboard/clipboard.js +185 -0
- package/components/code/code.d.ts +44 -0
- package/components/code/code.js +191 -0
- package/components/confirm/confirm.d.ts +48 -0
- package/components/confirm/confirm.js +153 -0
- package/components/confirm-service/confirm-service.d.ts +21 -0
- package/components/confirm-service/confirm-service.js +141 -0
- package/components/content-layout/content-layout.d.ts +26 -0
- package/components/content-layout/content-layout.js +79 -0
- package/components/content-layout/sidebar.d.ts +31 -0
- package/components/content-layout/sidebar.js +7 -0
- package/components/contenteditable/contenteditable.d.ts +47 -0
- package/components/contenteditable/contenteditable.js +84 -0
- package/components/control-label/control-label.d.ts +11 -0
- package/components/control-label/control-label.js +36 -0
- package/components/data-list/data-list.d.ts +85 -0
- package/components/data-list/data-list.js +251 -0
- package/components/data-list/data-list.mock.d.ts +16 -0
- package/components/data-list/data-list.mock.js +192 -0
- package/components/data-list/item.d.ts +50 -0
- package/components/data-list/item.js +235 -0
- package/components/data-list/selection.d.ts +16 -0
- package/components/data-list/selection.js +148 -0
- package/components/data-list/title.d.ts +26 -0
- package/components/data-list/title.js +28 -0
- package/components/date-picker/consts.d.ts +98 -0
- package/components/date-picker/consts.js +46 -0
- package/components/date-picker/date-input.d.ts +47 -0
- package/components/date-picker/date-input.js +177 -0
- package/components/date-picker/date-picker.d.ts +77 -0
- package/components/date-picker/date-picker.js +404 -0
- package/components/date-picker/date-popup.d.ts +55 -0
- package/components/date-picker/date-popup.js +488 -0
- package/components/date-picker/day.d.ts +30 -0
- package/components/date-picker/day.js +133 -0
- package/components/date-picker/formats.d.ts +2 -0
- package/components/date-picker/formats.js +3 -0
- package/components/date-picker/month-names.d.ts +13 -0
- package/components/date-picker/month-names.js +110 -0
- package/components/date-picker/month-slider.d.ts +29 -0
- package/components/date-picker/month-slider.js +93 -0
- package/components/date-picker/month.d.ts +14 -0
- package/components/date-picker/month.js +58 -0
- package/components/date-picker/months.d.ts +11 -0
- package/components/date-picker/months.js +133 -0
- package/components/date-picker/weekdays.d.ts +13 -0
- package/components/date-picker/weekdays.js +39 -0
- package/components/date-picker/years.d.ts +25 -0
- package/components/date-picker/years.js +134 -0
- package/components/dialog/dialog.d.ts +64 -0
- package/components/dialog/dialog.js +240 -0
- package/components/dialog/dialog__body-scroll-preventer.d.ts +9 -0
- package/components/dialog/dialog__body-scroll-preventer.js +6 -0
- package/components/dropdown/anchor.d.ts +11 -0
- package/components/dropdown/anchor.js +24 -0
- package/components/dropdown/dropdown.d.ts +87 -0
- package/components/dropdown/dropdown.js +247 -0
- package/components/dropdown-menu/dropdown-menu.d.ts +36 -0
- package/components/dropdown-menu/dropdown-menu.js +199 -0
- package/components/editable-heading/editable-heading.d.ts +32 -0
- package/components/editable-heading/editable-heading.js +276 -0
- package/components/error-bubble/error-bubble.d.ts +18 -0
- package/components/error-bubble/error-bubble.js +88 -0
- package/components/error-message/error-message.d.ts +27 -0
- package/components/error-message/error-message.js +78 -0
- package/components/footer/footer.d.ts +28 -0
- package/components/footer/footer.js +118 -0
- package/components/global/compose.d.ts +7 -0
- package/components/global/compose.js +17 -0
- package/components/global/composeRefs.d.ts +3 -0
- package/components/global/composeRefs.js +19 -0
- package/components/global/controls-height.d.ts +9 -0
- package/components/global/controls-height.js +19 -0
- package/components/global/create-stateful-context.d.ts +27 -0
- package/components/global/create-stateful-context.js +49 -0
- package/components/global/data-tests.d.ts +3 -0
- package/components/global/data-tests.js +30 -0
- package/components/global/dom.d.ts +37 -0
- package/components/global/dom.js +151 -0
- package/components/global/focus-sensor-hoc.d.ts +19 -0
- package/components/global/focus-sensor-hoc.js +165 -0
- package/components/global/fuzzy-highlight.d.ts +11 -0
- package/components/global/fuzzy-highlight.js +90 -0
- package/components/global/get-event-key.d.ts +2 -0
- package/components/global/get-event-key.js +101 -0
- package/components/global/get-uid.d.ts +1 -0
- package/components/global/get-uid.js +22 -0
- package/components/global/inject-styles.d.ts +3 -0
- package/components/global/inject-styles.js +22 -0
- package/components/global/linear-function.d.ts +6 -0
- package/components/global/linear-function.js +15 -0
- package/components/global/listeners.d.ts +8 -0
- package/components/global/listeners.js +58 -0
- package/components/global/memoize.d.ts +1 -0
- package/components/global/memoize.js +23 -0
- package/components/global/normalize-indent.d.ts +1 -0
- package/components/global/normalize-indent.js +60 -0
- package/components/global/promise-with-timeout.d.ts +5 -0
- package/components/global/promise-with-timeout.js +19 -0
- package/components/global/prop-types.d.ts +4 -0
- package/components/global/prop-types.js +9 -0
- package/components/global/react-dom-renderer.d.ts +16 -0
- package/components/global/react-dom-renderer.js +54 -0
- package/components/global/react-render-adapter.d.ts +1 -0
- package/components/global/react-render-adapter.js +6 -0
- package/components/global/rerender-hoc.d.ts +10 -0
- package/components/global/rerender-hoc.js +46 -0
- package/components/global/schedule-raf.d.ts +1 -0
- package/components/global/schedule-raf.js +28 -0
- package/components/global/sniffer.d.ts +3 -0
- package/components/global/sniffer.js +6 -0
- package/components/global/theme.d.ts +21 -0
- package/components/global/theme.js +42 -0
- package/components/global/trivial-template-tag.d.ts +1 -0
- package/components/global/trivial-template-tag.js +21 -0
- package/components/global/typescript-utils.d.ts +2 -0
- package/components/global/typescript-utils.js +8 -0
- package/components/global/url.d.ts +57 -0
- package/components/global/url.js +142 -0
- package/components/global/use-event-callback.d.ts +1 -0
- package/components/global/use-event-callback.js +17 -0
- package/components/global/variables.d.ts +89 -0
- package/components/global/variables.js +1 -0
- package/components/grid/col.d.ts +31 -0
- package/components/grid/col.js +80 -0
- package/components/grid/grid.d.ts +14 -0
- package/components/grid/grid.js +46 -0
- package/components/grid/row.d.ts +40 -0
- package/components/grid/row.js +75 -0
- package/components/group/group.d.ts +12 -0
- package/components/group/group.js +39 -0
- package/components/header/header.d.ts +34 -0
- package/components/header/header.js +189 -0
- package/components/header/logo.d.ts +14 -0
- package/components/header/logo.js +51 -0
- package/components/header/profile.d.ts +75 -0
- package/components/header/profile.js +258 -0
- package/components/header/services-link.d.ts +25 -0
- package/components/header/services-link.js +13 -0
- package/components/header/services.d.ts +33 -0
- package/components/header/services.js +174 -0
- package/components/header/smart-profile.d.ts +36 -0
- package/components/header/smart-profile.js +303 -0
- package/components/header/smart-services.d.ts +26 -0
- package/components/header/smart-services.js +192 -0
- package/components/header/tray-icon.d.ts +32 -0
- package/components/header/tray-icon.js +57 -0
- package/components/header/tray.d.ts +9 -0
- package/components/header/tray.js +41 -0
- package/components/heading/heading.d.ts +25 -0
- package/components/heading/heading.js +69 -0
- package/components/http/http.d.ts +61 -0
- package/components/http/http.js +386 -0
- package/components/http/http.mock.d.ts +20 -0
- package/components/http/http.mock.js +113 -0
- package/components/hub-source/hub-source.d.ts +44 -0
- package/components/hub-source/hub-source.js +217 -0
- package/components/hub-source/hub-source__user.d.ts +4 -0
- package/components/hub-source/hub-source__user.js +60 -0
- package/components/hub-source/hub-source__users-groups.d.ts +24 -0
- package/components/hub-source/hub-source__users-groups.js +86 -0
- package/components/i18n/i18n-context.d.ts +13 -0
- package/components/i18n/i18n-context.js +27 -0
- package/components/i18n/i18n.d.ts +59 -0
- package/components/i18n/i18n.js +139 -0
- package/components/icon/icon.d.ts +43 -0
- package/components/icon/icon.js +109 -0
- package/components/icon/icon__constants.d.ts +30 -0
- package/components/icon/icon__constants.js +34 -0
- package/components/icon/icon__svg.d.ts +15 -0
- package/components/icon/icon__svg.js +14 -0
- package/components/icon/index.d.ts +2 -0
- package/components/icon/index.js +17 -0
- package/components/input/input.d.ts +77 -0
- package/components/input/input.js +35 -0
- package/components/island/adaptive-island-hoc.d.ts +61 -0
- package/components/island/adaptive-island-hoc.js +53 -0
- package/components/island/content.d.ts +43 -0
- package/components/island/content.js +151 -0
- package/components/island/header.d.ts +8 -0
- package/components/island/header.js +100 -0
- package/components/island/island.d.ts +78 -0
- package/components/island/island.js +60 -0
- package/components/island-legacy/content-legacy.d.ts +10 -0
- package/components/island-legacy/content-legacy.js +34 -0
- package/components/island-legacy/header-legacy.d.ts +10 -0
- package/components/island-legacy/header-legacy.js +36 -0
- package/components/island-legacy/island-legacy.d.ts +12 -0
- package/components/island-legacy/island-legacy.js +36 -0
- package/components/link/clickableLink.d.ts +20 -0
- package/components/link/clickableLink.js +69 -0
- package/components/link/link.d.ts +138 -0
- package/components/link/link.js +86 -0
- package/components/list/consts.d.ts +77 -0
- package/components/list/consts.js +27 -0
- package/components/list/list.d.ts +205 -0
- package/components/list/list.js +802 -0
- package/components/list/list__custom.d.ts +6 -0
- package/components/list/list__custom.js +92 -0
- package/components/list/list__hint.d.ts +15 -0
- package/components/list/list__hint.js +33 -0
- package/components/list/list__item.d.ts +8 -0
- package/components/list/list__item.js +237 -0
- package/components/list/list__link.d.ts +9 -0
- package/components/list/list__link.js +76 -0
- package/components/list/list__separator.d.ts +5 -0
- package/components/list/list__separator.js +39 -0
- package/components/list/list__title.d.ts +5 -0
- package/components/list/list__title.js +48 -0
- package/components/list/list__users-groups-source.d.ts +27 -0
- package/components/list/list__users-groups-source.js +195 -0
- package/components/loader/loader.d.ts +28 -0
- package/components/loader/loader.js +93 -0
- package/components/loader/loader__core.d.ts +75 -0
- package/components/loader/loader__core.js +327 -0
- package/components/loader-inline/loader-inline.d.ts +18 -0
- package/components/loader-inline/loader-inline.js +50 -0
- package/components/loader-screen/loader-screen.d.ts +17 -0
- package/components/loader-screen/loader-screen.js +64 -0
- package/components/login-dialog/login-dialog.d.ts +47 -0
- package/components/login-dialog/login-dialog.js +216 -0
- package/components/login-dialog/service.d.ts +2 -0
- package/components/login-dialog/service.js +98 -0
- package/components/markdown/markdown.d.ts +12 -0
- package/components/markdown/markdown.js +43 -0
- package/components/message/message.d.ts +55 -0
- package/components/message/message.js +267 -0
- package/components/old-browsers-message/old-browsers-message.d.ts +2 -0
- package/components/old-browsers-message/old-browsers-message.js +92 -0
- package/components/old-browsers-message/old-browsers-message__stop.d.ts +1 -0
- package/components/old-browsers-message/old-browsers-message__stop.js +11 -0
- package/components/old-browsers-message/white-list.d.ts +2 -0
- package/components/old-browsers-message/white-list.js +37 -0
- package/components/pager/pager.d.ts +78 -0
- package/components/pager/pager.js +390 -0
- package/components/panel/panel.d.ts +12 -0
- package/components/panel/panel.js +39 -0
- package/components/permissions/permissions.d.ts +111 -0
- package/components/permissions/permissions.js +221 -0
- package/components/permissions/permissions__cache.d.ts +93 -0
- package/components/permissions/permissions__cache.js +257 -0
- package/components/popup/popup.consts.d.ts +37 -0
- package/components/popup/popup.consts.js +44 -0
- package/components/popup/popup.d.ts +147 -0
- package/components/popup/popup.js +424 -0
- package/components/popup/popup.target.d.ts +7 -0
- package/components/popup/popup.target.js +24 -0
- package/components/popup/position.d.ts +30 -0
- package/components/popup/position.js +271 -0
- package/components/popup-menu/popup-menu.d.ts +80 -0
- package/components/popup-menu/popup-menu.js +141 -0
- package/components/progress-bar/progress-bar.d.ts +64 -0
- package/components/progress-bar/progress-bar.js +120 -0
- package/components/query-assist/query-assist.d.ts +306 -0
- package/components/query-assist/query-assist.js +1098 -0
- package/components/query-assist/query-assist__suggestions.d.ts +29 -0
- package/components/query-assist/query-assist__suggestions.js +75 -0
- package/components/radio/radio.d.ts +18 -0
- package/components/radio/radio.js +48 -0
- package/components/radio/radio__item.d.ts +28 -0
- package/components/radio/radio__item.js +88 -0
- package/components/select/select.d.ts +276 -0
- package/components/select/select.js +1310 -0
- package/components/select/select__filter.d.ts +19 -0
- package/components/select/select__filter.js +85 -0
- package/components/select/select__popup.d.ts +166 -0
- package/components/select/select__popup.js +631 -0
- package/components/shortcuts/core.d.ts +74 -0
- package/components/shortcuts/core.js +249 -0
- package/components/shortcuts/shortcut-title.d.ts +1 -0
- package/components/shortcuts/shortcut-title.js +56 -0
- package/components/shortcuts/shortcuts-hoc.d.ts +65 -0
- package/components/shortcuts/shortcuts-hoc.js +61 -0
- package/components/shortcuts/shortcuts.d.ts +28 -0
- package/components/shortcuts/shortcuts.js +92 -0
- package/components/storage/storage.d.ts +18 -0
- package/components/storage/storage.js +92 -0
- package/components/storage/storage__fallback.d.ts +79 -0
- package/components/storage/storage__fallback.js +254 -0
- package/components/storage/storage__local.d.ts +38 -0
- package/components/storage/storage__local.js +217 -0
- package/components/style.css +1 -0
- package/components/tab-trap/tab-trap.d.ts +43 -0
- package/components/tab-trap/tab-trap.js +180 -0
- package/components/table/cell.d.ts +13 -0
- package/components/table/cell.js +37 -0
- package/components/table/disable-hover-hoc.d.ts +64 -0
- package/components/table/disable-hover-hoc.js +62 -0
- package/components/table/header-cell.d.ts +43 -0
- package/components/table/header-cell.js +109 -0
- package/components/table/header.d.ts +56 -0
- package/components/table/header.js +151 -0
- package/components/table/multitable.d.ts +25 -0
- package/components/table/multitable.js +140 -0
- package/components/table/row-with-focus-sensor.d.ts +18 -0
- package/components/table/row-with-focus-sensor.js +117 -0
- package/components/table/row.d.ts +59 -0
- package/components/table/row.js +299 -0
- package/components/table/selection-adapter.d.ts +5 -0
- package/components/table/selection-adapter.js +14 -0
- package/components/table/selection-shortcuts-hoc.d.ts +17 -0
- package/components/table/selection-shortcuts-hoc.js +205 -0
- package/components/table/selection.d.ts +47 -0
- package/components/table/selection.js +257 -0
- package/components/table/smart-table.d.ts +64 -0
- package/components/table/smart-table.js +149 -0
- package/components/table/table.d.ts +159 -0
- package/components/table/table.js +463 -0
- package/components/tabs/collapsible-more.d.ts +29 -0
- package/components/tabs/collapsible-more.js +222 -0
- package/components/tabs/collapsible-tab.d.ts +16 -0
- package/components/tabs/collapsible-tab.js +88 -0
- package/components/tabs/collapsible-tabs.d.ts +43 -0
- package/components/tabs/collapsible-tabs.js +354 -0
- package/components/tabs/custom-item.d.ts +9 -0
- package/components/tabs/custom-item.js +11 -0
- package/components/tabs/dumb-tabs.d.ts +35 -0
- package/components/tabs/dumb-tabs.js +189 -0
- package/components/tabs/smart-tabs.d.ts +20 -0
- package/components/tabs/smart-tabs.js +141 -0
- package/components/tabs/tab-link.d.ts +18 -0
- package/components/tabs/tab-link.js +13 -0
- package/components/tabs/tab.d.ts +27 -0
- package/components/tabs/tab.js +41 -0
- package/components/tabs/tabs.d.ts +7 -0
- package/components/tabs/tabs.js +99 -0
- package/components/tag/tag.d.ts +64 -0
- package/components/tag/tag.js +213 -0
- package/components/tags-input/tags-input.d.ts +138 -0
- package/components/tags-input/tags-input.js +534 -0
- package/components/tags-list/tags-list.d.ts +46 -0
- package/components/tags-list/tags-list.js +102 -0
- package/components/text/text.d.ts +23 -0
- package/components/text/text.js +57 -0
- package/components/toggle/toggle.d.ts +39 -0
- package/components/toggle/toggle.js +86 -0
- package/components/tooltip/tooltip.d.ts +65 -0
- package/components/tooltip/tooltip.js +229 -0
- package/components/user-agreement/service.d.ts +69 -0
- package/components/user-agreement/service.js +487 -0
- package/components/user-agreement/toolbox.eula.d.ts +2 -0
- package/components/user-agreement/toolbox.eula.js +3 -0
- package/components/user-agreement/user-agreement.d.ts +60 -0
- package/components/user-agreement/user-agreement.js +172 -0
- package/components/user-card/card.d.ts +70 -0
- package/components/user-card/card.js +80 -0
- package/components/user-card/smart-user-card-tooltip.d.ts +20 -0
- package/components/user-card/smart-user-card-tooltip.js +172 -0
- package/components/user-card/tooltip.d.ts +36 -0
- package/components/user-card/tooltip.js +144 -0
- package/components/user-card/user-card.d.ts +11 -0
- package/components/user-card/user-card.js +85 -0
- package/package.json +118 -0
- package/typings.d.ts +43 -0
@@ -0,0 +1,1310 @@
|
|
1
|
+
import { _ as _defineProperty, a as _inherits, b as _createSuper, c as _classCallCheck, k as _assertThisInitialized, g as _objectSpread2, e as _objectWithoutProperties, p as _toPropertyKey, d as _createClass, f as _extends } from '../_helpers/_rollupPluginBabelHelpers.js';
|
2
|
+
import 'core-js/modules/es.array.index-of.js';
|
3
|
+
import 'core-js/modules/es.array.reduce.js';
|
4
|
+
import 'core-js/modules/es.object.to-string.js';
|
5
|
+
import 'core-js/modules/es.string.trim.js';
|
6
|
+
import 'core-js/modules/es.array.filter.js';
|
7
|
+
import 'core-js/modules/es.regexp.exec.js';
|
8
|
+
import 'core-js/modules/es.array.find.js';
|
9
|
+
import 'core-js/modules/es.array.concat.js';
|
10
|
+
import 'core-js/modules/es.string.replace.js';
|
11
|
+
import 'core-js/modules/es.array.map.js';
|
12
|
+
import 'core-js/modules/web.dom-collections.for-each.js';
|
13
|
+
import 'core-js/modules/es.array.slice.js';
|
14
|
+
import 'core-js/modules/es.object.assign.js';
|
15
|
+
import 'core-js/modules/es.object.values.js';
|
16
|
+
import React, { Fragment, Component } from 'react';
|
17
|
+
import classNames from 'classnames';
|
18
|
+
import PropTypes from 'prop-types';
|
19
|
+
import chevronDownIcon from '@jetbrains/icons/chevron-down';
|
20
|
+
import closeIcon from '@jetbrains/icons/close-12px';
|
21
|
+
import deepEqual from 'deep-equal';
|
22
|
+
import '../dropdown/dropdown.js';
|
23
|
+
import Avatar, { Size as Size$1 } from '../avatar/avatar.js';
|
24
|
+
import Popup from '../popup/popup.js';
|
25
|
+
import List, { ActiveItemContext } from '../list/list.js';
|
26
|
+
import { S as Size, I as Input, m as modules_88cfaf40 } from '../_helpers/input.js';
|
27
|
+
import { ControlLabel } from '../control-label/control-label.js';
|
28
|
+
import Shortcuts from '../shortcuts/shortcuts.js';
|
29
|
+
import { Button } from '../button/button.js';
|
30
|
+
import joinDataTestAttributes from '../global/data-tests.js';
|
31
|
+
import getUID from '../global/get-uid.js';
|
32
|
+
import rerenderHOC from '../global/rerender-hoc.js';
|
33
|
+
import fuzzyHighlight from '../global/fuzzy-highlight.js';
|
34
|
+
import memoize from '../global/memoize.js';
|
35
|
+
import { I18nContext } from '../i18n/i18n-context.js';
|
36
|
+
import composeRefs from '../global/composeRefs.js';
|
37
|
+
import { refObject } from '../global/prop-types.js';
|
38
|
+
import { isArray } from '../global/typescript-utils.js';
|
39
|
+
import { ControlsHeight, ControlsHeightContext } from '../global/controls-height.js';
|
40
|
+
import SelectPopup from './select__popup.js';
|
41
|
+
import { A as Anchor } from '../_helpers/anchor.js';
|
42
|
+
import 'core-js/modules/es.object.entries.js';
|
43
|
+
import '@jetbrains/icons/chevron-10px';
|
44
|
+
import '../icon/icon.js';
|
45
|
+
import 'util-deprecate';
|
46
|
+
import '../icon/icon__constants.js';
|
47
|
+
import '../_helpers/icon__svg.js';
|
48
|
+
import 'core-js/modules/es.string.starts-with.js';
|
49
|
+
import 'core-js/modules/es.array.iterator.js';
|
50
|
+
import 'core-js/modules/es.map.js';
|
51
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
52
|
+
import 'core-js/modules/es.weak-map.js';
|
53
|
+
import '../link/clickableLink.js';
|
54
|
+
import '../_helpers/button__classes.js';
|
55
|
+
import '../global/url.js';
|
56
|
+
import 'core-js/modules/es.string.match.js';
|
57
|
+
import '../global/dom.js';
|
58
|
+
import 'core-js/modules/es.string.split.js';
|
59
|
+
import 'core-js/modules/es.set.js';
|
60
|
+
import '../avatar/fallback-avatar.js';
|
61
|
+
import 'core-js/modules/es.array.from.js';
|
62
|
+
import 'core-js/modules/es.regexp.to-string.js';
|
63
|
+
import 'react-dom';
|
64
|
+
import '../global/schedule-raf.js';
|
65
|
+
import '../tab-trap/tab-trap.js';
|
66
|
+
import '../popup/position.js';
|
67
|
+
import 'core-js/modules/es.array.includes.js';
|
68
|
+
import 'core-js/modules/es.string.includes.js';
|
69
|
+
import 'core-js/modules/es.array.sort.js';
|
70
|
+
import '../popup/popup.consts.js';
|
71
|
+
import '../popup/popup.target.js';
|
72
|
+
import '../shortcuts/core.js';
|
73
|
+
import 'core-js/modules/es.array.splice.js';
|
74
|
+
import 'core-js/modules/es.array.find-index.js';
|
75
|
+
import 'combokeys';
|
76
|
+
import '../global/sniffer.js';
|
77
|
+
import 'sniffr';
|
78
|
+
import 'core-js/modules/es.symbol.js';
|
79
|
+
import 'core-js/modules/es.symbol.description.js';
|
80
|
+
import 'react-virtualized/dist/es/List';
|
81
|
+
import 'react-virtualized/dist/es/AutoSizer';
|
82
|
+
import 'react-virtualized/dist/es/WindowScroller';
|
83
|
+
import 'react-virtualized/dist/es/CellMeasurer';
|
84
|
+
import 'memoize-one';
|
85
|
+
import '../global/create-stateful-context.js';
|
86
|
+
import '../list/list__link.js';
|
87
|
+
import '../link/link.js';
|
88
|
+
import '../_helpers/link.js';
|
89
|
+
import '../_helpers/list.js';
|
90
|
+
import '../list/list__item.js';
|
91
|
+
import '../checkbox/checkbox.js';
|
92
|
+
import '@jetbrains/icons/checkmark-14px';
|
93
|
+
import '@jetbrains/icons/remove-14px';
|
94
|
+
import '../list/list__custom.js';
|
95
|
+
import '../global/get-event-key.js';
|
96
|
+
import '../list/list__title.js';
|
97
|
+
import '../list/list__separator.js';
|
98
|
+
import '../list/list__hint.js';
|
99
|
+
import '../list/consts.js';
|
100
|
+
import '../i18n/i18n.js';
|
101
|
+
import '@jetbrains/icons/search';
|
102
|
+
import '../loader-inline/loader-inline.js';
|
103
|
+
import '../shortcuts/shortcuts-hoc.js';
|
104
|
+
import '../tags-list/tags-list.js';
|
105
|
+
import '../tag/tag.js';
|
106
|
+
import '../caret/caret.js';
|
107
|
+
import '../text/text.js';
|
108
|
+
import '../_helpers/select__filter.js';
|
109
|
+
|
110
|
+
var modules_9d0de074 = {"button-shadow":"i__const_button_shadow_0","select":"select_rui_11de","value":"value_rui_11de ellipsis_rui_8bff font_rui_8bff","icons":"icons_rui_11de","light":"light_rui_2ac4","toolbar":"toolbar_rui_11de","button":"button_rui_11de","buttonSpaced":"buttonSpaced_rui_11de","inputMode":"inputMode_rui_11de","selectedIcon":"selectedIcon_rui_11de resetButton_rui_8bff","clearIcon":"clearIcon_rui_11de","sizeS":"sizeS_rui_11de","sizeM":"sizeM_rui_11de","sizeL":"sizeL_rui_11de","sizeFULL":"sizeFULL_rui_11de","sizeAUTO":"sizeAUTO_rui_11de","buttonMode":"buttonMode_rui_11de","open":"open_rui_11de","buttonContainer":"buttonContainer_rui_11de","buttonValue":"buttonValue_rui_11de ellipsis_rui_8bff","buttonValueOpen":"buttonValueOpen_rui_11de","buttonValueEmpty":"buttonValueEmpty_rui_11de","heightS":"heightS_rui_11de","label":"label_rui_11de","disabled":"disabled_rui_11de","avatar":"avatar_rui_11de","popup":"popup_rui_11de","chevron":"chevron_rui_11de","chevronIcon":"chevronIcon_rui_11de"};
|
111
|
+
|
112
|
+
/**
|
113
|
+
* @name Select
|
114
|
+
*/
|
115
|
+
function noop() {}
|
116
|
+
/**
|
117
|
+
* @enum {number}
|
118
|
+
*/
|
119
|
+
var Type;
|
120
|
+
(function (Type) {
|
121
|
+
Type["BUTTON"] = "BUTTON";
|
122
|
+
Type["INPUT"] = "INPUT";
|
123
|
+
Type["CUSTOM"] = "CUSTOM";
|
124
|
+
Type["INLINE"] = "INLINE";
|
125
|
+
Type["INPUT_WITHOUT_CONTROLS"] = "INPUT_WITHOUT_CONTROLS";
|
126
|
+
})(Type || (Type = {}));
|
127
|
+
var ICONS_OFFSET = 5;
|
128
|
+
var ICON_WIDTH = 20;
|
129
|
+
var getStyle = memoize(function (iconsLength) {
|
130
|
+
return {
|
131
|
+
paddingRight: ICONS_OFFSET + iconsLength * ICON_WIDTH
|
132
|
+
};
|
133
|
+
});
|
134
|
+
var _isInputMode = function isInputMode(type) {
|
135
|
+
return type === Type.INPUT || type === Type.INPUT_WITHOUT_CONTROLS;
|
136
|
+
};
|
137
|
+
function getLowerCaseLabel(item) {
|
138
|
+
if (List.isItemType(List.ListProps.Type.SEPARATOR, item) || List.isItemType(List.ListProps.Type.HINT, item) || typeof item.label !== 'string') {
|
139
|
+
return null;
|
140
|
+
}
|
141
|
+
return item.label.toLowerCase();
|
142
|
+
}
|
143
|
+
function doesLabelMatch(itemToCheck, fn) {
|
144
|
+
var lowerCaseLabel = getLowerCaseLabel(itemToCheck);
|
145
|
+
if (lowerCaseLabel == null) {
|
146
|
+
return true;
|
147
|
+
}
|
148
|
+
return fn(lowerCaseLabel);
|
149
|
+
}
|
150
|
+
function _getFilterFn(filter) {
|
151
|
+
if (typeof filter === 'object') {
|
152
|
+
if (filter.fn) {
|
153
|
+
return filter.fn;
|
154
|
+
}
|
155
|
+
if (filter.fuzzy) {
|
156
|
+
return function (itemToCheck, checkString) {
|
157
|
+
return doesLabelMatch(itemToCheck, function (lowerCaseLabel) {
|
158
|
+
return fuzzyHighlight(checkString, lowerCaseLabel).matched;
|
159
|
+
});
|
160
|
+
};
|
161
|
+
}
|
162
|
+
}
|
163
|
+
return function (itemToCheck, checkString) {
|
164
|
+
return doesLabelMatch(itemToCheck, function (lowerCaseLabel) {
|
165
|
+
return lowerCaseLabel.indexOf(checkString) >= 0;
|
166
|
+
});
|
167
|
+
};
|
168
|
+
}
|
169
|
+
function buildMultipleMap(selected) {
|
170
|
+
return selected.reduce(function (acc, item) {
|
171
|
+
acc[item.key] = true;
|
172
|
+
return acc;
|
173
|
+
}, {});
|
174
|
+
}
|
175
|
+
function _getListItems(props, state, rawFilterString) {
|
176
|
+
var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : props.data;
|
177
|
+
var filterString = rawFilterString.trim();
|
178
|
+
if (_isInputMode(props.type) && !props.allowAny && state.selected && !Array.isArray(state.selected) && filterString === state.selected.label) {
|
179
|
+
filterString = ''; // ignore multiple if it is exactly the selected item
|
180
|
+
}
|
181
|
+
var lowerCaseString = filterString.toLowerCase();
|
182
|
+
var filteredData = [];
|
183
|
+
var exactMatch = false;
|
184
|
+
var check = _getFilterFn(props.filter);
|
185
|
+
var _loop = function _loop() {
|
186
|
+
var item = _objectSpread2({}, data[i]);
|
187
|
+
if (check(item, lowerCaseString, data)) {
|
188
|
+
var _state$multipleMap2;
|
189
|
+
exactMatch = item.label === filterString;
|
190
|
+
if (props.multiple && !(typeof props.multiple === 'object' && props.multiple.removeSelectedItems)) {
|
191
|
+
var _state$multipleMap;
|
192
|
+
item.checkbox = !!((_state$multipleMap = state.multipleMap) !== null && _state$multipleMap !== void 0 && _state$multipleMap[item.key]);
|
193
|
+
}
|
194
|
+
if (props.multiple && typeof props.multiple === 'object' && props.multiple.limit && Array.isArray(state.selected)) {
|
195
|
+
item.disabled = props.multiple.limit === state.selected.length && !state.selected.find(function (selectedItem) {
|
196
|
+
return selectedItem.key === item.key;
|
197
|
+
});
|
198
|
+
}
|
199
|
+
// Ignore item if it's multiple and is already selected
|
200
|
+
if (!(props.multiple && typeof props.multiple === 'object' && props.multiple.removeSelectedItems && (_state$multipleMap2 = state.multipleMap) !== null && _state$multipleMap2 !== void 0 && _state$multipleMap2[item.key])) {
|
201
|
+
filteredData.push(item);
|
202
|
+
}
|
203
|
+
}
|
204
|
+
};
|
205
|
+
for (var i = 0; i < data.length; i++) {
|
206
|
+
_loop();
|
207
|
+
}
|
208
|
+
var addButton = null;
|
209
|
+
var add = props.add;
|
210
|
+
if (add && filterString && !exactMatch || add && add.alwaysVisible) {
|
211
|
+
if (!(add.regexp && !add.regexp.test(filterString)) && !(add.minlength && filterString.length < +add.minlength) || add.alwaysVisible) {
|
212
|
+
var _add$delayed;
|
213
|
+
var label;
|
214
|
+
if (add.label) {
|
215
|
+
label = typeof add.label === 'function' ? add.label(filterString) : add.label;
|
216
|
+
} else {
|
217
|
+
label = filterString;
|
218
|
+
}
|
219
|
+
addButton = {
|
220
|
+
prefix: add.prefix,
|
221
|
+
label,
|
222
|
+
delayed: (_add$delayed = add.delayed) !== null && _add$delayed !== void 0 ? _add$delayed : true
|
223
|
+
};
|
224
|
+
}
|
225
|
+
}
|
226
|
+
return {
|
227
|
+
filteredData,
|
228
|
+
addButton
|
229
|
+
};
|
230
|
+
}
|
231
|
+
function getSelectedIndex(selected, data) {
|
232
|
+
var firstSelected = Array.isArray(selected) ? selected[0] : selected;
|
233
|
+
if (firstSelected == null) {
|
234
|
+
return null;
|
235
|
+
}
|
236
|
+
for (var i = 0; i < data.length; i++) {
|
237
|
+
var item = data[i];
|
238
|
+
if (item.key === undefined) {
|
239
|
+
continue;
|
240
|
+
}
|
241
|
+
if (item.key === firstSelected.key) {
|
242
|
+
return i;
|
243
|
+
}
|
244
|
+
}
|
245
|
+
return null;
|
246
|
+
}
|
247
|
+
var getItemLabel = function getItemLabel(_ref) {
|
248
|
+
var selectedLabel = _ref.selectedLabel,
|
249
|
+
label = _ref.label;
|
250
|
+
if (selectedLabel != null) {
|
251
|
+
return selectedLabel;
|
252
|
+
}
|
253
|
+
return typeof label === 'string' ? label : '';
|
254
|
+
};
|
255
|
+
var _getValueForFilter = function getValueForFilter(selected, type, filterValue) {
|
256
|
+
return selected && !isArray(selected) && _isInputMode(type) ? getItemLabel(selected) : filterValue;
|
257
|
+
};
|
258
|
+
function isSameSelected(prevSelected, selected) {
|
259
|
+
if (!prevSelected || !selected || prevSelected.length !== selected.length) {
|
260
|
+
return false;
|
261
|
+
}
|
262
|
+
var keysMap = selected.reduce(function (result, item) {
|
263
|
+
result[item.key] = true;
|
264
|
+
return result;
|
265
|
+
}, {});
|
266
|
+
return prevSelected.every(function (it) {
|
267
|
+
return keysMap[it.key];
|
268
|
+
});
|
269
|
+
}
|
270
|
+
/**
|
271
|
+
* @name Select
|
272
|
+
* @constructor
|
273
|
+
* @extends {Component}
|
274
|
+
*/
|
275
|
+
/**
|
276
|
+
* Displays a select.
|
277
|
+
*/
|
278
|
+
var Select = /*#__PURE__*/function (_Component) {
|
279
|
+
_inherits(Select, _Component);
|
280
|
+
var _super = _createSuper(Select);
|
281
|
+
function Select() {
|
282
|
+
var _this;
|
283
|
+
_classCallCheck(this, Select);
|
284
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
285
|
+
args[_key] = arguments[_key];
|
286
|
+
}
|
287
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
288
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
289
|
+
data: [],
|
290
|
+
shownData: [],
|
291
|
+
selected: _this.props.multiple ? [] : null,
|
292
|
+
selectedIndex: null,
|
293
|
+
filterValue: _this.props.filter && typeof _this.props.filter === 'object' && _this.props.filter.value || '',
|
294
|
+
shortcutsEnabled: false,
|
295
|
+
popupShortcuts: false,
|
296
|
+
showPopup: _this.props.showPopup,
|
297
|
+
prevData: _this.props.data,
|
298
|
+
prevSelected: null,
|
299
|
+
prevMultiple: _this.props.multiple,
|
300
|
+
multipleMap: {},
|
301
|
+
addButton: null
|
302
|
+
});
|
303
|
+
_defineProperty(_assertThisInitialized(_this), "id", getUID('select-'));
|
304
|
+
_defineProperty(_assertThisInitialized(_this), "shortcutsScope", _this.id);
|
305
|
+
_defineProperty(_assertThisInitialized(_this), "listId", "".concat(_this.id, ":list"));
|
306
|
+
_defineProperty(_assertThisInitialized(_this), "_focusHandler", function (e) {
|
307
|
+
_this.props.onFocus(e);
|
308
|
+
_this.setState({
|
309
|
+
shortcutsEnabled: true,
|
310
|
+
focused: true
|
311
|
+
});
|
312
|
+
});
|
313
|
+
_defineProperty(_assertThisInitialized(_this), "_blurHandler", function () {
|
314
|
+
var _this$_popup;
|
315
|
+
_this.props.onBlur();
|
316
|
+
if (_this._popup && _this._popup.isVisible() && !_this._popup.isClickingPopup) {
|
317
|
+
window.setTimeout(function () {
|
318
|
+
_this.setState({
|
319
|
+
showPopup: false
|
320
|
+
});
|
321
|
+
});
|
322
|
+
}
|
323
|
+
if (!((_this$_popup = _this._popup) !== null && _this$_popup !== void 0 && _this$_popup.isClickingPopup)) {
|
324
|
+
_this.setState({
|
325
|
+
shortcutsEnabled: false,
|
326
|
+
focused: false
|
327
|
+
});
|
328
|
+
}
|
329
|
+
});
|
330
|
+
_defineProperty(_assertThisInitialized(_this), "node", void 0);
|
331
|
+
_defineProperty(_assertThisInitialized(_this), "nodeRef", function (el) {
|
332
|
+
_this.node = el;
|
333
|
+
});
|
334
|
+
_defineProperty(_assertThisInitialized(_this), "_popup", null);
|
335
|
+
_defineProperty(_assertThisInitialized(_this), "onEmptyPopupEnter", function () {
|
336
|
+
if (_this.state.addButton) {
|
337
|
+
_this.addHandler();
|
338
|
+
}
|
339
|
+
});
|
340
|
+
_defineProperty(_assertThisInitialized(_this), "focus", function () {
|
341
|
+
var _this$node;
|
342
|
+
var focusableSelectExists = (_this$node = _this.node) === null || _this$node === void 0 ? void 0 : _this$node.querySelector('[data-test~=ring-select__focus]');
|
343
|
+
var restoreFocusNode = _this.props.targetElement || focusableSelectExists;
|
344
|
+
restoreFocusNode === null || restoreFocusNode === void 0 || restoreFocusNode.focus();
|
345
|
+
});
|
346
|
+
_defineProperty(_assertThisInitialized(_this), "_onEnter", function () {
|
347
|
+
var _this$_popup2;
|
348
|
+
if (_this.state.addButton && _this.state.shownData.length === 0) {
|
349
|
+
_this.addHandler();
|
350
|
+
}
|
351
|
+
_this.props.onDone();
|
352
|
+
if (!((_this$_popup2 = _this._popup) !== null && _this$_popup2 !== void 0 && _this$_popup2.isVisible()) && _this.props.allowAny) {
|
353
|
+
return true;
|
354
|
+
}
|
355
|
+
return undefined;
|
356
|
+
});
|
357
|
+
_defineProperty(_assertThisInitialized(_this), "_onEsc", function (event) {
|
358
|
+
var _this$_popup3;
|
359
|
+
if (!((_this$_popup3 = _this._popup) !== null && _this$_popup3 !== void 0 && _this$_popup3.isVisible())) {
|
360
|
+
return true;
|
361
|
+
} else if (_this.props.multiple || !_this.props.getInitial) {
|
362
|
+
return false;
|
363
|
+
}
|
364
|
+
var selected = {
|
365
|
+
key: Math.random(),
|
366
|
+
label: _this.props.getInitial()
|
367
|
+
};
|
368
|
+
_this.setState({
|
369
|
+
selected,
|
370
|
+
filterValue: _this.getValueForFilter(selected)
|
371
|
+
}, function () {
|
372
|
+
_this.props.onChange(selected, event);
|
373
|
+
_this.props.onReset();
|
374
|
+
});
|
375
|
+
return undefined;
|
376
|
+
});
|
377
|
+
_defineProperty(_assertThisInitialized(_this), "_inputShortcutHandler", function () {
|
378
|
+
if (_this.state.focused && _this._popup && !_this._popup.isVisible()) {
|
379
|
+
_this._clickHandler();
|
380
|
+
}
|
381
|
+
});
|
382
|
+
_defineProperty(_assertThisInitialized(_this), "popupRef", function (el) {
|
383
|
+
_this._popup = el;
|
384
|
+
});
|
385
|
+
_defineProperty(_assertThisInitialized(_this), "addHandler", function () {
|
386
|
+
var value = _this.filterValue();
|
387
|
+
_this._hidePopup();
|
388
|
+
_this.props.onAdd(value);
|
389
|
+
});
|
390
|
+
_defineProperty(_assertThisInitialized(_this), "getLowerCaseLabel", getLowerCaseLabel);
|
391
|
+
_defineProperty(_assertThisInitialized(_this), "doesLabelMatch", doesLabelMatch);
|
392
|
+
_defineProperty(_assertThisInitialized(_this), "_clickHandler", function () {
|
393
|
+
if (!_this.props.disabled) {
|
394
|
+
if (_this.state.showPopup) {
|
395
|
+
_this._hidePopup();
|
396
|
+
} else {
|
397
|
+
_this.props.onBeforeOpen();
|
398
|
+
_this._showPopup();
|
399
|
+
}
|
400
|
+
}
|
401
|
+
});
|
402
|
+
_defineProperty(_assertThisInitialized(_this), "_openPopupIfClosed", function () {
|
403
|
+
if (_this.props.disabled || _this.state.showPopup) {
|
404
|
+
return;
|
405
|
+
}
|
406
|
+
_this.props.onBeforeOpen();
|
407
|
+
_this._showPopup();
|
408
|
+
});
|
409
|
+
_defineProperty(_assertThisInitialized(_this), "_filterChangeHandler", function (e) {
|
410
|
+
_this._setFilter(e.currentTarget.value, e);
|
411
|
+
});
|
412
|
+
_defineProperty(_assertThisInitialized(_this), "_setFilter", function (value, event) {
|
413
|
+
var _this$_popup4;
|
414
|
+
if (_this.isInputMode() && !_this.state.focused) {
|
415
|
+
return;
|
416
|
+
}
|
417
|
+
if (value === _this.state.filterValue) {
|
418
|
+
return;
|
419
|
+
}
|
420
|
+
var filterValue = value.replace(/^\s+/g, '');
|
421
|
+
_this.props.onFilter(filterValue);
|
422
|
+
if (_this.props.allowAny) {
|
423
|
+
var fakeSelected = {
|
424
|
+
key: Math.random(),
|
425
|
+
label: filterValue
|
426
|
+
};
|
427
|
+
_this.setState({
|
428
|
+
selected: filterValue === '' ? null : fakeSelected,
|
429
|
+
selectedIndex: null
|
430
|
+
}, function () {
|
431
|
+
_this.props.onSelect(fakeSelected, event);
|
432
|
+
_this.props.onChange(fakeSelected, event);
|
433
|
+
});
|
434
|
+
}
|
435
|
+
!((_this$_popup4 = _this._popup) !== null && _this$_popup4 !== void 0 && _this$_popup4.isVisible()) && _this.props.onBeforeOpen();
|
436
|
+
_this.setState({
|
437
|
+
filterValue
|
438
|
+
}, function () {
|
439
|
+
_this._showPopup();
|
440
|
+
});
|
441
|
+
});
|
442
|
+
_defineProperty(_assertThisInitialized(_this), "_redrawPopup", function () {
|
443
|
+
if (_this.props.multiple) {
|
444
|
+
setTimeout(function () {
|
445
|
+
_this.isInputMode() && _this.clearFilter();
|
446
|
+
_this._showPopup();
|
447
|
+
}, 0);
|
448
|
+
}
|
449
|
+
});
|
450
|
+
_defineProperty(_assertThisInitialized(_this), "_listSelectHandler", function (selected, event) {
|
451
|
+
var _this$props$tryKeepOp;
|
452
|
+
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
453
|
+
var isItem = function isItem(item) {
|
454
|
+
return List.isItemType(List.ListProps.Type.ITEM, item);
|
455
|
+
};
|
456
|
+
var isCustomItem = function isCustomItem(item) {
|
457
|
+
return List.isItemType(List.ListProps.Type.CUSTOM, item);
|
458
|
+
};
|
459
|
+
var isSelectItemEvent = event && (event.type === 'select' || event.type === 'keydown');
|
460
|
+
if (isSelectItemEvent) {
|
461
|
+
event.preventDefault();
|
462
|
+
}
|
463
|
+
if (!isItem(selected) && !isCustomItem(selected) || selected.disabled || selected.isResetItem) {
|
464
|
+
return;
|
465
|
+
}
|
466
|
+
var tryKeepOpen = (_this$props$tryKeepOp = _this.props.tryKeepOpen) !== null && _this$props$tryKeepOp !== void 0 ? _this$props$tryKeepOp : opts.tryKeepOpen;
|
467
|
+
if (!_this.props.multiple) {
|
468
|
+
if (!tryKeepOpen) {
|
469
|
+
_this._hidePopup(isSelectItemEvent);
|
470
|
+
}
|
471
|
+
_this.setState({
|
472
|
+
selected,
|
473
|
+
selectedIndex: _this._getSelectedIndex(selected, _this.props.data)
|
474
|
+
}, function () {
|
475
|
+
var newFilterValue = _this.isInputMode() && !_this.props.hideSelected ? getItemLabel(selected) : '';
|
476
|
+
_this.filterValue(newFilterValue);
|
477
|
+
_this.props.onFilter(newFilterValue);
|
478
|
+
_this.props.onSelect(selected, event);
|
479
|
+
_this.props.onChange(selected, event);
|
480
|
+
});
|
481
|
+
} else {
|
482
|
+
if (!tryKeepOpen) {
|
483
|
+
_this._hidePopup(isSelectItemEvent);
|
484
|
+
}
|
485
|
+
if (selected.key == null) {
|
486
|
+
throw new Error('Multiple selection requires each item to have the "key" property');
|
487
|
+
}
|
488
|
+
_this.setState(function (prevState) {
|
489
|
+
var currentSelection = prevState.selected;
|
490
|
+
var nextSelection;
|
491
|
+
if (!prevState.multipleMap[selected.key]) {
|
492
|
+
nextSelection = currentSelection.concat(selected);
|
493
|
+
_this.props.onSelect && _this.props.onSelect(selected, event);
|
494
|
+
} else {
|
495
|
+
nextSelection = currentSelection.filter(function (item) {
|
496
|
+
return item.key !== selected.key;
|
497
|
+
});
|
498
|
+
_this.props.onDeselect && _this.props.onDeselect(selected);
|
499
|
+
}
|
500
|
+
_this.props.onChange(nextSelection, event);
|
501
|
+
var nextState = {
|
502
|
+
filterValue: '',
|
503
|
+
selected: nextSelection,
|
504
|
+
selectedIndex: _this._getSelectedIndex(selected, _this.props.data)
|
505
|
+
};
|
506
|
+
if (typeof _this.props.multiple === 'object' && _this.props.multiple.limit && nextSelection.length === _this.props.multiple.limit) {
|
507
|
+
nextState.shownData = prevState.shownData.map(function (item) {
|
508
|
+
return nextSelection.find(function (selectedItem) {
|
509
|
+
return selectedItem.key === item.key;
|
510
|
+
}) ? item : _objectSpread2(_objectSpread2({}, item), {}, {
|
511
|
+
disabled: true
|
512
|
+
});
|
513
|
+
});
|
514
|
+
}
|
515
|
+
if (!prevState.multipleMap[selected.key]) {
|
516
|
+
nextState.multipleMap = _objectSpread2(_objectSpread2({}, prevState.multipleMap), {}, {
|
517
|
+
[selected.key]: true
|
518
|
+
});
|
519
|
+
} else {
|
520
|
+
var _prevState$multipleMa = prevState.multipleMap,
|
521
|
+
_selected$key = selected.key;
|
522
|
+
_prevState$multipleMa[_selected$key];
|
523
|
+
var restMultipleMap = _objectWithoutProperties(_prevState$multipleMa, [_selected$key].map(_toPropertyKey));
|
524
|
+
nextState.multipleMap = restMultipleMap;
|
525
|
+
}
|
526
|
+
return _objectSpread2(_objectSpread2({}, prevState), nextState);
|
527
|
+
}, function () {
|
528
|
+
if (tryKeepOpen) {
|
529
|
+
_this._redrawPopup();
|
530
|
+
}
|
531
|
+
});
|
532
|
+
}
|
533
|
+
});
|
534
|
+
_defineProperty(_assertThisInitialized(_this), "_listSelectAllHandler", function () {
|
535
|
+
var isSelectAll = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
536
|
+
var isItem = function isItem(item) {
|
537
|
+
return List.isItemType(List.ListProps.Type.ITEM, item);
|
538
|
+
};
|
539
|
+
var isCustomItem = function isCustomItem(item) {
|
540
|
+
return List.isItemType(List.ListProps.Type.CUSTOM, item);
|
541
|
+
};
|
542
|
+
_this.setState(function (prevState) {
|
543
|
+
var currentSelection = prevState.selected;
|
544
|
+
var nextSelection;
|
545
|
+
if (isSelectAll) {
|
546
|
+
nextSelection = _this.props.data.filter(function (item) {
|
547
|
+
return (isItem(item) || isCustomItem(item)) && !item.disabled;
|
548
|
+
});
|
549
|
+
nextSelection.filter(function (item) {
|
550
|
+
return !_this.props.selected.find(function (selectedItem) {
|
551
|
+
return item.key === selectedItem.key;
|
552
|
+
});
|
553
|
+
}).forEach(function (item) {
|
554
|
+
_this.props.onSelect && _this.props.onSelect(item);
|
555
|
+
});
|
556
|
+
} else {
|
557
|
+
nextSelection = [];
|
558
|
+
currentSelection.forEach(function (item) {
|
559
|
+
_this.props.onDeselect && _this.props.onDeselect(item);
|
560
|
+
});
|
561
|
+
}
|
562
|
+
_this.props.onChange(nextSelection, event);
|
563
|
+
return {
|
564
|
+
filterValue: '',
|
565
|
+
selected: nextSelection,
|
566
|
+
selectedIndex: isSelectAll ? _this._getSelectedIndex(nextSelection, _this.props.data) : null,
|
567
|
+
shownData: prevState.shownData.map(function (item) {
|
568
|
+
return _objectSpread2(_objectSpread2({}, item), {}, {
|
569
|
+
checkbox: isSelectAll
|
570
|
+
});
|
571
|
+
}),
|
572
|
+
multipleMap: isSelectAll ? buildMultipleMap(_this.props.data.filter(function (item) {
|
573
|
+
return !item.disabled;
|
574
|
+
})) : {}
|
575
|
+
};
|
576
|
+
}, _this._redrawPopup);
|
577
|
+
});
|
578
|
+
_defineProperty(_assertThisInitialized(_this), "_onCloseAttempt", function (event, isEsc) {
|
579
|
+
if (_this.isInputMode()) {
|
580
|
+
if (!_this.props.allowAny) {
|
581
|
+
if (_this.props.hideSelected || !_this.state.selected || _this.props.multiple) {
|
582
|
+
_this.clearFilter();
|
583
|
+
} else if (_this.state.selected && !Array.isArray(_this.state.selected)) {
|
584
|
+
_this.filterValue(getItemLabel(_this.state.selected));
|
585
|
+
}
|
586
|
+
}
|
587
|
+
}
|
588
|
+
var isTagRemoved = _this.props.tags && event && event.target && event.target instanceof Element && event.target.matches('[data-test="ring-tag-remove"]');
|
589
|
+
if (!isTagRemoved) {
|
590
|
+
_this._hidePopup(isEsc);
|
591
|
+
}
|
592
|
+
});
|
593
|
+
_defineProperty(_assertThisInitialized(_this), "clearFilter", function (e) {
|
594
|
+
_this._setFilter('', e);
|
595
|
+
});
|
596
|
+
_defineProperty(_assertThisInitialized(_this), "clear", function (event) {
|
597
|
+
if (event) {
|
598
|
+
event.stopPropagation();
|
599
|
+
}
|
600
|
+
var empty = _this.props.multiple ? [] : null;
|
601
|
+
_this.setState({
|
602
|
+
selected: empty,
|
603
|
+
selectedIndex: null,
|
604
|
+
filterValue: ''
|
605
|
+
}, function () {
|
606
|
+
if (_this.props.onChange) {
|
607
|
+
_this.props.onChange(empty, event);
|
608
|
+
}
|
609
|
+
});
|
610
|
+
return false;
|
611
|
+
});
|
612
|
+
_defineProperty(_assertThisInitialized(_this), "filter", void 0);
|
613
|
+
_defineProperty(_assertThisInitialized(_this), "filterRef", function (el) {
|
614
|
+
_this.filter = el;
|
615
|
+
});
|
616
|
+
return _this;
|
617
|
+
}
|
618
|
+
_createClass(Select, [{
|
619
|
+
key: "componentDidUpdate",
|
620
|
+
value: function componentDidUpdate(prevProps, prevState) {
|
621
|
+
var _this$state = this.state,
|
622
|
+
showPopup = _this$state.showPopup,
|
623
|
+
selected = _this$state.selected;
|
624
|
+
var _this$props = this.props,
|
625
|
+
onClose = _this$props.onClose,
|
626
|
+
onOpen = _this$props.onOpen,
|
627
|
+
onChange = _this$props.onChange,
|
628
|
+
multiple = _this$props.multiple;
|
629
|
+
if (prevState.showPopup && !showPopup) {
|
630
|
+
onClose(selected);
|
631
|
+
} else if (!prevState.showPopup && showPopup) {
|
632
|
+
onOpen();
|
633
|
+
}
|
634
|
+
if (multiple !== prevProps.multiple && !deepEqual(multiple, prevProps.multiple)) {
|
635
|
+
onChange(selected);
|
636
|
+
}
|
637
|
+
}
|
638
|
+
}, {
|
639
|
+
key: "getValueForFilter",
|
640
|
+
value: function getValueForFilter(selected) {
|
641
|
+
return _getValueForFilter(selected, this.props.type, this.state.filterValue);
|
642
|
+
}
|
643
|
+
}, {
|
644
|
+
key: "_getSelectedIndex",
|
645
|
+
value: function _getSelectedIndex(selected, data) {
|
646
|
+
return getSelectedIndex(selected, data);
|
647
|
+
}
|
648
|
+
}, {
|
649
|
+
key: "_getResetOption",
|
650
|
+
value: function _getResetOption() {
|
651
|
+
var _this2 = this;
|
652
|
+
var isOptionsSelected = Array.isArray(this.state.selected) && this.state.selected.length;
|
653
|
+
var reset = this.props.tags && typeof this.props.tags === 'object' ? this.props.tags.reset : null;
|
654
|
+
if (!isOptionsSelected || !reset) {
|
655
|
+
return null;
|
656
|
+
}
|
657
|
+
var resetHandler = function resetHandler(item, event) {
|
658
|
+
_this2.clear(event);
|
659
|
+
_this2.clearFilter();
|
660
|
+
_this2.props.onFilter('');
|
661
|
+
_this2.setState(function (prevState) {
|
662
|
+
return {
|
663
|
+
shownData: prevState.shownData.slice(reset.separator ? 2 : 1),
|
664
|
+
multipleMap: {}
|
665
|
+
};
|
666
|
+
});
|
667
|
+
_this2._redrawPopup();
|
668
|
+
};
|
669
|
+
return {
|
670
|
+
isResetItem: true,
|
671
|
+
separator: reset.separator,
|
672
|
+
key: reset.label,
|
673
|
+
rgItemType: List.ListProps.Type.CUSTOM,
|
674
|
+
template: /*#__PURE__*/React.createElement(Button, {
|
675
|
+
text: true,
|
676
|
+
className: modules_9d0de074.button,
|
677
|
+
"data-test": "ring-select-reset-tags-button",
|
678
|
+
height: ControlsHeight.S
|
679
|
+
}, reset.label),
|
680
|
+
glyph: reset.glyph,
|
681
|
+
onClick: resetHandler
|
682
|
+
};
|
683
|
+
}
|
684
|
+
}, {
|
685
|
+
key: "_prependResetOption",
|
686
|
+
value: function _prependResetOption(shownData) {
|
687
|
+
var resetOption = this._getResetOption();
|
688
|
+
if (resetOption) {
|
689
|
+
var resetItems = [resetOption];
|
690
|
+
if (resetOption.separator) {
|
691
|
+
resetItems.push({
|
692
|
+
rgItemType: List.ListProps.Type.SEPARATOR
|
693
|
+
});
|
694
|
+
}
|
695
|
+
return resetItems.concat(shownData);
|
696
|
+
}
|
697
|
+
return shownData;
|
698
|
+
}
|
699
|
+
}, {
|
700
|
+
key: "_renderPopup",
|
701
|
+
value: function _renderPopup() {
|
702
|
+
var _this3 = this;
|
703
|
+
var anchorElement = this.props.targetElement || this.node;
|
704
|
+
var _this$state2 = this.state,
|
705
|
+
showPopup = _this$state2.showPopup,
|
706
|
+
shownData = _this$state2.shownData;
|
707
|
+
var _shownData = this._prependResetOption(shownData);
|
708
|
+
return /*#__PURE__*/React.createElement(I18nContext.Consumer, null, function (_ref2) {
|
709
|
+
var translate = _ref2.translate;
|
710
|
+
var message;
|
711
|
+
if (_this3.props.loading) {
|
712
|
+
var _this3$props$loadingM;
|
713
|
+
message = (_this3$props$loadingM = _this3.props.loadingMessage) !== null && _this3$props$loadingM !== void 0 ? _this3$props$loadingM : translate('loading');
|
714
|
+
} else if (!shownData.length) {
|
715
|
+
var _this3$props$notFound;
|
716
|
+
message = (_this3$props$notFound = _this3.props.notFoundMessage) !== null && _this3$props$notFound !== void 0 ? _this3$props$notFound : translate('noOptionsFound');
|
717
|
+
}
|
718
|
+
return /*#__PURE__*/React.createElement(SelectPopup, {
|
719
|
+
data: _shownData,
|
720
|
+
message: message,
|
721
|
+
toolbar: showPopup && _this3.getToolbar(),
|
722
|
+
topbar: _this3.getTopbar(),
|
723
|
+
loading: _this3.props.loading,
|
724
|
+
activeIndex: _this3.state.selectedIndex,
|
725
|
+
hidden: !showPopup,
|
726
|
+
ref: _this3.popupRef,
|
727
|
+
maxHeight: _this3.props.maxHeight,
|
728
|
+
minWidth: _this3.props.minWidth,
|
729
|
+
directions: _this3.props.directions,
|
730
|
+
className: _this3.props.popupClassName,
|
731
|
+
style: _this3.props.popupStyle,
|
732
|
+
top: _this3.props.top,
|
733
|
+
left: _this3.props.left,
|
734
|
+
filter: _this3.isInputMode() ? false : _this3.props.filter // disable popup filter in INPUT mode
|
735
|
+
,
|
736
|
+
filterIcon: _this3.props.filterIcon,
|
737
|
+
filterRef: _this3.props.filterRef,
|
738
|
+
multiple: _this3.props.multiple,
|
739
|
+
filterValue: _this3.state.filterValue,
|
740
|
+
anchorElement: anchorElement,
|
741
|
+
onCloseAttempt: _this3._onCloseAttempt,
|
742
|
+
onOutsideClick: _this3.props.onOutsideClick,
|
743
|
+
onSelect: _this3._listSelectHandler,
|
744
|
+
onSelectAll: _this3._listSelectAllHandler,
|
745
|
+
onFilter: _this3._filterChangeHandler,
|
746
|
+
onClear: _this3.clearFilter,
|
747
|
+
onLoadMore: _this3.props.onLoadMore,
|
748
|
+
isInputMode: _this3.isInputMode(),
|
749
|
+
selected: _this3.state.selected,
|
750
|
+
tags: _this3.props.tags,
|
751
|
+
compact: _this3.props.compact,
|
752
|
+
renderOptimization: _this3.props.renderOptimization,
|
753
|
+
ringPopupTarget: _this3.props.ringPopupTarget,
|
754
|
+
disableMoveOverflow: _this3.props.disableMoveOverflow,
|
755
|
+
disableScrollToActive: _this3.props.disableScrollToActive,
|
756
|
+
dir: _this3.props.dir,
|
757
|
+
onEmptyPopupEnter: _this3.onEmptyPopupEnter,
|
758
|
+
listId: _this3.listId
|
759
|
+
});
|
760
|
+
});
|
761
|
+
}
|
762
|
+
}, {
|
763
|
+
key: "_showPopup",
|
764
|
+
value: function _showPopup() {
|
765
|
+
if (!this.node) {
|
766
|
+
return;
|
767
|
+
}
|
768
|
+
var shownData = this.getListItems(this.filterValue());
|
769
|
+
this.setState({
|
770
|
+
showPopup: true,
|
771
|
+
shownData
|
772
|
+
});
|
773
|
+
}
|
774
|
+
}, {
|
775
|
+
key: "_hidePopup",
|
776
|
+
value: function _hidePopup(tryFocusAnchor) {
|
777
|
+
var _this4 = this;
|
778
|
+
if (this.node && this.state.showPopup) {
|
779
|
+
this.setState(function (prevState) {
|
780
|
+
return {
|
781
|
+
showPopup: false,
|
782
|
+
filterValue: _this4.props.allowAny ? prevState.filterValue : ''
|
783
|
+
};
|
784
|
+
});
|
785
|
+
if (tryFocusAnchor) {
|
786
|
+
this.focus();
|
787
|
+
}
|
788
|
+
}
|
789
|
+
}
|
790
|
+
}, {
|
791
|
+
key: "getToolbar",
|
792
|
+
value: function getToolbar() {
|
793
|
+
var _this$props2 = this.props,
|
794
|
+
hint = _this$props2.hint,
|
795
|
+
renderBottomToolbar = _this$props2.renderBottomToolbar;
|
796
|
+
var _ref3 = this.state.addButton || {},
|
797
|
+
prefix = _ref3.prefix,
|
798
|
+
label = _ref3.label,
|
799
|
+
delayed = _ref3.delayed;
|
800
|
+
var isToolbarHasElements = this.state.addButton || hint || renderBottomToolbar;
|
801
|
+
if (!isToolbarHasElements) {
|
802
|
+
return null;
|
803
|
+
}
|
804
|
+
return /*#__PURE__*/React.createElement("div", {
|
805
|
+
className: classNames({
|
806
|
+
[modules_9d0de074.toolbar]: Boolean(this.state.addButton || renderBottomToolbar)
|
807
|
+
}),
|
808
|
+
"data-test": "ring-select-toolbar"
|
809
|
+
}, renderBottomToolbar && renderBottomToolbar(), this.state.addButton && /*#__PURE__*/React.createElement(Button, {
|
810
|
+
text: true,
|
811
|
+
delayed: delayed,
|
812
|
+
className: classNames(modules_9d0de074.button, modules_9d0de074.buttonSpaced),
|
813
|
+
onClick: this.addHandler,
|
814
|
+
"data-test": "ring-select-toolbar-button"
|
815
|
+
}, prefix ? "".concat(prefix, " ").concat(label) : label), hint && /*#__PURE__*/React.createElement(List.ListHint, {
|
816
|
+
label: hint,
|
817
|
+
"data-test": "ring-select-toolbar-hint"
|
818
|
+
}));
|
819
|
+
}
|
820
|
+
}, {
|
821
|
+
key: "getTopbar",
|
822
|
+
value: function getTopbar() {
|
823
|
+
var _this$props$renderTop, _this$props3;
|
824
|
+
return (_this$props$renderTop = (_this$props3 = this.props).renderTopToolbar) === null || _this$props$renderTop === void 0 ? void 0 : _this$props$renderTop.call(_this$props3);
|
825
|
+
}
|
826
|
+
}, {
|
827
|
+
key: "getFilterFn",
|
828
|
+
value: function getFilterFn() {
|
829
|
+
return _getFilterFn(this.props.filter);
|
830
|
+
}
|
831
|
+
}, {
|
832
|
+
key: "getListItems",
|
833
|
+
value: function getListItems(rawFilterString, data) {
|
834
|
+
var _getListItems2 = _getListItems(this.props, this.state, rawFilterString, data),
|
835
|
+
filteredData = _getListItems2.filteredData,
|
836
|
+
addButton = _getListItems2.addButton;
|
837
|
+
this.setState({
|
838
|
+
addButton
|
839
|
+
});
|
840
|
+
return filteredData;
|
841
|
+
}
|
842
|
+
}, {
|
843
|
+
key: "filterValue",
|
844
|
+
value: function filterValue(setValue) {
|
845
|
+
if (typeof setValue === 'string' || typeof setValue === 'number') {
|
846
|
+
this.setState({
|
847
|
+
filterValue: setValue
|
848
|
+
});
|
849
|
+
return undefined;
|
850
|
+
} else {
|
851
|
+
return this.state.filterValue;
|
852
|
+
}
|
853
|
+
}
|
854
|
+
}, {
|
855
|
+
key: "isInputMode",
|
856
|
+
value: function isInputMode() {
|
857
|
+
return _isInputMode(this.props.type);
|
858
|
+
}
|
859
|
+
}, {
|
860
|
+
key: "_rebuildMultipleMap",
|
861
|
+
value: function _rebuildMultipleMap(selected) {
|
862
|
+
if (Array.isArray(selected)) {
|
863
|
+
this.setState({
|
864
|
+
multipleMap: buildMultipleMap(selected)
|
865
|
+
});
|
866
|
+
}
|
867
|
+
}
|
868
|
+
}, {
|
869
|
+
key: "_selectionIsEmpty",
|
870
|
+
value: function _selectionIsEmpty() {
|
871
|
+
return Array.isArray(this.state.selected) && !this.state.selected.length || !this.state.selected;
|
872
|
+
}
|
873
|
+
}, {
|
874
|
+
key: "_getLabel",
|
875
|
+
value: function _getLabel() {
|
876
|
+
var _ref4, _this$props$label;
|
877
|
+
return (_ref4 = (_this$props$label = this.props.label) !== null && _this$props$label !== void 0 ? _this$props$label : this.props.selectedLabel) !== null && _ref4 !== void 0 ? _ref4 : 'Select an option';
|
878
|
+
}
|
879
|
+
}, {
|
880
|
+
key: "_getPlaceholder",
|
881
|
+
value: function _getPlaceholder() {
|
882
|
+
if (this._selectionIsEmpty()) {
|
883
|
+
var _this$props$label2;
|
884
|
+
return (_this$props$label2 = this.props.label) !== null && _this$props$label2 !== void 0 ? _this$props$label2 : 'Select an option';
|
885
|
+
}
|
886
|
+
return this._getSelectedString();
|
887
|
+
}
|
888
|
+
}, {
|
889
|
+
key: "_getSelectedString",
|
890
|
+
value: function _getSelectedString() {
|
891
|
+
if (Array.isArray(this.state.selected)) {
|
892
|
+
var labels = [];
|
893
|
+
for (var i = 0; i < this.state.selected.length; i++) {
|
894
|
+
labels.push(getItemLabel(this.state.selected[i]));
|
895
|
+
}
|
896
|
+
return labels.filter(Boolean).join(', ');
|
897
|
+
} else {
|
898
|
+
return this.state.selected != null ? getItemLabel(this.state.selected) : null;
|
899
|
+
}
|
900
|
+
}
|
901
|
+
}, {
|
902
|
+
key: "_getIcons",
|
903
|
+
value: function _getIcons() {
|
904
|
+
var selected = this.state.selected;
|
905
|
+
var _this$props4 = this.props,
|
906
|
+
disabled = _this$props4.disabled,
|
907
|
+
clear = _this$props4.clear,
|
908
|
+
hideArrow = _this$props4.hideArrow;
|
909
|
+
var icons = [];
|
910
|
+
var height = this.props.height || this.context;
|
911
|
+
if (!Array.isArray(selected) && selected !== null && selected !== void 0 && selected.icon) {
|
912
|
+
icons.push( /*#__PURE__*/React.createElement("button", {
|
913
|
+
title: "Toggle options popup",
|
914
|
+
type: "button",
|
915
|
+
className: modules_9d0de074.selectedIcon,
|
916
|
+
key: "selected",
|
917
|
+
disabled: this.props.disabled,
|
918
|
+
onClick: this._clickHandler,
|
919
|
+
style: {
|
920
|
+
backgroundImage: "url(".concat(selected.icon, ")")
|
921
|
+
}
|
922
|
+
}));
|
923
|
+
}
|
924
|
+
if (clear && !disabled && !this._selectionIsEmpty()) {
|
925
|
+
icons.push( /*#__PURE__*/React.createElement(Button, {
|
926
|
+
title: "Clear selection",
|
927
|
+
"data-test": "ring-clear-select",
|
928
|
+
className: modules_9d0de074.clearIcon,
|
929
|
+
key: "close",
|
930
|
+
disabled: this.props.disabled,
|
931
|
+
onClick: this.clear,
|
932
|
+
height: height,
|
933
|
+
icon: closeIcon
|
934
|
+
}));
|
935
|
+
}
|
936
|
+
if (!hideArrow) {
|
937
|
+
icons.push( /*#__PURE__*/React.createElement(Button, {
|
938
|
+
title: "Toggle options popup",
|
939
|
+
className: modules_9d0de074.chevron,
|
940
|
+
iconClassName: modules_9d0de074.chevronIcon,
|
941
|
+
icon: chevronDownIcon,
|
942
|
+
key: "hide",
|
943
|
+
disabled: this.props.disabled,
|
944
|
+
height: height,
|
945
|
+
onClick: this._clickHandler
|
946
|
+
}));
|
947
|
+
}
|
948
|
+
return icons;
|
949
|
+
}
|
950
|
+
}, {
|
951
|
+
key: "_getAvatar",
|
952
|
+
value: function _getAvatar() {
|
953
|
+
var _this$state$selected, _this$state$selected2;
|
954
|
+
return !Array.isArray(this.state.selected) && (((_this$state$selected = this.state.selected) === null || _this$state$selected === void 0 ? void 0 : _this$state$selected.avatar) || ((_this$state$selected2 = this.state.selected) === null || _this$state$selected2 === void 0 ? void 0 : _this$state$selected2.showGeneratedAvatar)) && /*#__PURE__*/React.createElement(Avatar, {
|
955
|
+
className: modules_9d0de074.avatar,
|
956
|
+
url: this.state.selected.avatar,
|
957
|
+
username: this.state.selected.username,
|
958
|
+
size: Size$1.Size20
|
959
|
+
});
|
960
|
+
}
|
961
|
+
}, {
|
962
|
+
key: "getShortcutsMap",
|
963
|
+
value: function getShortcutsMap() {
|
964
|
+
return {
|
965
|
+
enter: this._onEnter,
|
966
|
+
esc: this._onEsc,
|
967
|
+
up: this._inputShortcutHandler,
|
968
|
+
down: this._inputShortcutHandler,
|
969
|
+
right: noop,
|
970
|
+
left: noop,
|
971
|
+
'shift+up': noop,
|
972
|
+
'shift+down': noop,
|
973
|
+
space: noop
|
974
|
+
};
|
975
|
+
}
|
976
|
+
}, {
|
977
|
+
key: "renderSelect",
|
978
|
+
value: function renderSelect(activeItemId) {
|
979
|
+
var _this$props$label3, _this$props$label4, _this$_popup5, _this$props$buttonCla;
|
980
|
+
var dataTest = this.props['data-test'];
|
981
|
+
var selectedLabel = this.props.selectedLabel;
|
982
|
+
var shortcutsEnabled = this.state.shortcutsEnabled;
|
983
|
+
var classes = classNames(modules_9d0de074.select, 'ring-js-shortcuts', this.props.className, modules_9d0de074["height".concat(this.props.height || this.context)], {
|
984
|
+
[modules_9d0de074["size".concat(this.props.size)]]: this.props.type !== Type.INLINE,
|
985
|
+
[modules_9d0de074.disabled]: this.props.disabled
|
986
|
+
});
|
987
|
+
var icons = this._getIcons();
|
988
|
+
var style = getStyle(icons.length);
|
989
|
+
var iconsNode = /*#__PURE__*/React.createElement("div", {
|
990
|
+
className: modules_9d0de074.icons
|
991
|
+
}, icons);
|
992
|
+
var ariaProps = this.state.showPopup ? {
|
993
|
+
'aria-owns': this.listId,
|
994
|
+
'aria-activedescendant': activeItemId,
|
995
|
+
'aria-label': (_this$props$label3 = this.props.label) !== null && _this$props$label3 !== void 0 ? _this$props$label3 : undefined
|
996
|
+
} : {
|
997
|
+
'aria-label': (_this$props$label4 = this.props.label) !== null && _this$props$label4 !== void 0 ? _this$props$label4 : undefined
|
998
|
+
};
|
999
|
+
switch (this.props.type) {
|
1000
|
+
case Type.INPUT_WITHOUT_CONTROLS:
|
1001
|
+
case Type.INPUT:
|
1002
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
1003
|
+
ref: this.nodeRef,
|
1004
|
+
className: classNames(classes, modules_9d0de074.inputMode),
|
1005
|
+
"data-test": joinDataTestAttributes('ring-select', dataTest)
|
1006
|
+
}, shortcutsEnabled && /*#__PURE__*/React.createElement(Shortcuts, {
|
1007
|
+
map: this.getShortcutsMap(),
|
1008
|
+
scope: this.shortcutsScope
|
1009
|
+
}), /*#__PURE__*/React.createElement(Input, _extends({}, ariaProps, {
|
1010
|
+
height: this.props.height,
|
1011
|
+
autoComplete: "off",
|
1012
|
+
id: this.props.id,
|
1013
|
+
onClick: this._clickHandler,
|
1014
|
+
inputRef: composeRefs(this.filterRef, this.props.filterRef),
|
1015
|
+
disabled: this.props.disabled,
|
1016
|
+
value: this.state.filterValue,
|
1017
|
+
borderless: this.props.type === Type.INPUT_WITHOUT_CONTROLS,
|
1018
|
+
style: style,
|
1019
|
+
size: Size.FULL,
|
1020
|
+
onChange: this._filterChangeHandler,
|
1021
|
+
onFocus: this._focusHandler,
|
1022
|
+
onBlur: this._blurHandler
|
1023
|
+
// Input with error style without description
|
1024
|
+
,
|
1025
|
+
error: this.props.error != null ? '' : null,
|
1026
|
+
label: this.props.type === Type.INPUT ? this._getLabel() : null,
|
1027
|
+
placeholder: this.props.inputPlaceholder,
|
1028
|
+
onKeyDown: this.props.onKeyDown,
|
1029
|
+
"data-test": "ring-select__focus",
|
1030
|
+
enableShortcuts: shortcutsEnabled ? Object.keys(_objectSpread2(_objectSpread2({}, this.getShortcutsMap()), (_this$_popup5 = this._popup) === null || _this$_popup5 === void 0 || (_this$_popup5 = _this$_popup5.list) === null || _this$_popup5 === void 0 ? void 0 : _this$_popup5.shortcutsMap)) : undefined,
|
1031
|
+
icon: this.props.filterIcon,
|
1032
|
+
afterInput: this.props.type === Type.INPUT && iconsNode
|
1033
|
+
})), this._renderPopup()), this.props.error && /*#__PURE__*/React.createElement("div", {
|
1034
|
+
className: classNames(modules_88cfaf40.errorText, modules_88cfaf40["size".concat(this.props.size)])
|
1035
|
+
}, this.props.error));
|
1036
|
+
case Type.BUTTON:
|
1037
|
+
return /*#__PURE__*/React.createElement("div", {
|
1038
|
+
ref: this.nodeRef,
|
1039
|
+
className: classNames(classes, modules_9d0de074.buttonMode),
|
1040
|
+
"data-test": joinDataTestAttributes('ring-select', dataTest)
|
1041
|
+
}, selectedLabel && /*#__PURE__*/React.createElement(ControlLabel, {
|
1042
|
+
type: this.props.labelType,
|
1043
|
+
disabled: this.props.disabled,
|
1044
|
+
htmlFor: this.props.id
|
1045
|
+
}, selectedLabel), shortcutsEnabled && /*#__PURE__*/React.createElement(Shortcuts, {
|
1046
|
+
map: this.getShortcutsMap(),
|
1047
|
+
scope: this.shortcutsScope
|
1048
|
+
}), /*#__PURE__*/React.createElement("div", {
|
1049
|
+
className: modules_9d0de074.buttonContainer
|
1050
|
+
}, /*#__PURE__*/React.createElement(Button, _extends({}, ariaProps, {
|
1051
|
+
height: this.props.height,
|
1052
|
+
id: this.props.id,
|
1053
|
+
onClick: this._clickHandler,
|
1054
|
+
className: classNames(this.props.buttonClassName, modules_9d0de074.buttonValue, {
|
1055
|
+
[modules_9d0de074.buttonValueOpen]: this.state.showPopup,
|
1056
|
+
[modules_9d0de074.buttonValueEmpty]: this._selectionIsEmpty()
|
1057
|
+
}),
|
1058
|
+
disabled: this.props.disabled,
|
1059
|
+
style: style,
|
1060
|
+
"data-test": "ring-select__button ring-select__focus"
|
1061
|
+
}), this._getAvatar(), this._getPlaceholder()), iconsNode), this._renderPopup());
|
1062
|
+
case Type.INLINE:
|
1063
|
+
return /*#__PURE__*/React.createElement("div", {
|
1064
|
+
className: classes,
|
1065
|
+
ref: this.nodeRef,
|
1066
|
+
"data-test": joinDataTestAttributes('ring-select', dataTest)
|
1067
|
+
}, shortcutsEnabled && /*#__PURE__*/React.createElement(Shortcuts, {
|
1068
|
+
map: this.getShortcutsMap(),
|
1069
|
+
scope: this.shortcutsScope
|
1070
|
+
}), /*#__PURE__*/React.createElement(Anchor, _extends({}, ariaProps, {
|
1071
|
+
className: (_this$props$buttonCla = this.props.buttonClassName) !== null && _this$props$buttonCla !== void 0 ? _this$props$buttonCla : undefined,
|
1072
|
+
id: this.props.id,
|
1073
|
+
onClick: this._clickHandler,
|
1074
|
+
"data-test": "ring-select__focus",
|
1075
|
+
disabled: this.props.disabled,
|
1076
|
+
active: this.state.showPopup
|
1077
|
+
}), this._getPlaceholder()), this._renderPopup());
|
1078
|
+
default:
|
1079
|
+
if (this.props.customAnchor) {
|
1080
|
+
return /*#__PURE__*/React.createElement(Fragment, null, shortcutsEnabled && /*#__PURE__*/React.createElement(Shortcuts, {
|
1081
|
+
map: this.getShortcutsMap(),
|
1082
|
+
scope: this.shortcutsScope
|
1083
|
+
}), this.props.customAnchor({
|
1084
|
+
wrapperProps: {
|
1085
|
+
ref: this.nodeRef,
|
1086
|
+
'data-test': joinDataTestAttributes('ring-select', dataTest)
|
1087
|
+
},
|
1088
|
+
buttonProps: _objectSpread2(_objectSpread2({}, ariaProps), {}, {
|
1089
|
+
id: this.props.id,
|
1090
|
+
onClick: this._clickHandler,
|
1091
|
+
disabled: this.props.disabled,
|
1092
|
+
children: this._getPlaceholder(),
|
1093
|
+
'data-test': 'ring-select__focus'
|
1094
|
+
}),
|
1095
|
+
popup: this._renderPopup()
|
1096
|
+
}));
|
1097
|
+
}
|
1098
|
+
return /*#__PURE__*/React.createElement("span", {
|
1099
|
+
id: this.props.id,
|
1100
|
+
ref: this.nodeRef,
|
1101
|
+
"data-test": "ring-select"
|
1102
|
+
}, this._renderPopup());
|
1103
|
+
}
|
1104
|
+
}
|
1105
|
+
}, {
|
1106
|
+
key: "render",
|
1107
|
+
value: function render() {
|
1108
|
+
var _this5 = this;
|
1109
|
+
return /*#__PURE__*/React.createElement(ActiveItemContext.Provider, null, /*#__PURE__*/React.createElement(ActiveItemContext.ValueContext.Consumer, null, function (activeItemId) {
|
1110
|
+
return _this5.renderSelect(activeItemId);
|
1111
|
+
}));
|
1112
|
+
}
|
1113
|
+
}], [{
|
1114
|
+
key: "getDerivedStateFromProps",
|
1115
|
+
value: function getDerivedStateFromProps(nextProps, prevState) {
|
1116
|
+
var multiple = nextProps.multiple,
|
1117
|
+
data = nextProps.data,
|
1118
|
+
type = nextProps.type;
|
1119
|
+
var prevSelected = prevState.prevSelected,
|
1120
|
+
prevData = prevState.prevData,
|
1121
|
+
prevMultiple = prevState.prevMultiple,
|
1122
|
+
filterValue = prevState.filterValue;
|
1123
|
+
var nextState = {
|
1124
|
+
prevData: data,
|
1125
|
+
prevSelected: nextProps.selected,
|
1126
|
+
prevMultiple: multiple
|
1127
|
+
};
|
1128
|
+
if ('data' in nextProps && data !== prevData) {
|
1129
|
+
var _getListItems3 = _getListItems(nextProps, prevState, filterValue, data),
|
1130
|
+
filteredData = _getListItems3.filteredData,
|
1131
|
+
addButton = _getListItems3.addButton;
|
1132
|
+
Object.assign(nextState, {
|
1133
|
+
shownData: filteredData,
|
1134
|
+
addButton
|
1135
|
+
});
|
1136
|
+
if (prevState.selected) {
|
1137
|
+
Object.assign(nextState, {
|
1138
|
+
selectedIndex: getSelectedIndex(prevState.selected, data),
|
1139
|
+
filterValue: _getValueForFilter(prevState.selected, type, filterValue)
|
1140
|
+
});
|
1141
|
+
}
|
1142
|
+
}
|
1143
|
+
if ('selected' in nextProps && nextProps.selected !== prevSelected) {
|
1144
|
+
var _selected = nextProps.selected || (multiple ? [] : null);
|
1145
|
+
var selectedIndex = getSelectedIndex(_selected, data || prevData);
|
1146
|
+
Object.assign(nextState, {
|
1147
|
+
selected: _selected,
|
1148
|
+
filterValue: _getValueForFilter(_selected, type, filterValue)
|
1149
|
+
});
|
1150
|
+
if (!Array.isArray(prevSelected) || !Array.isArray(_selected) || !isSameSelected(prevSelected, _selected)) {
|
1151
|
+
Object.assign(nextState, {
|
1152
|
+
selectedIndex
|
1153
|
+
});
|
1154
|
+
}
|
1155
|
+
}
|
1156
|
+
if (prevMultiple !== multiple && !deepEqual(prevMultiple, multiple)) {
|
1157
|
+
nextState.selected = multiple ? [] : null;
|
1158
|
+
}
|
1159
|
+
if (multiple && !nextState.selected) {
|
1160
|
+
nextState.selected = prevState.selected;
|
1161
|
+
}
|
1162
|
+
var _prevState$nextState = _objectSpread2(_objectSpread2({}, prevState), nextState),
|
1163
|
+
selected = _prevState$nextState.selected;
|
1164
|
+
if (selected && Array.isArray(selected)) {
|
1165
|
+
nextState.multipleMap = buildMultipleMap(selected);
|
1166
|
+
var _getListItems4 = _getListItems(nextProps, nextState, filterValue, data),
|
1167
|
+
_filteredData = _getListItems4.filteredData,
|
1168
|
+
_addButton = _getListItems4.addButton;
|
1169
|
+
Object.assign(nextState, {
|
1170
|
+
shownData: _filteredData,
|
1171
|
+
addButton: _addButton
|
1172
|
+
});
|
1173
|
+
}
|
1174
|
+
return nextState;
|
1175
|
+
}
|
1176
|
+
}]);
|
1177
|
+
return Select;
|
1178
|
+
}(Component);
|
1179
|
+
_defineProperty(Select, "defaultProps", {
|
1180
|
+
data: [],
|
1181
|
+
filter: false,
|
1182
|
+
// enable filter (not in INPUT modes)
|
1183
|
+
filterIcon: null,
|
1184
|
+
filterRef: noop,
|
1185
|
+
multiple: false,
|
1186
|
+
// multiple can be an object - see demo for more information
|
1187
|
+
clear: false,
|
1188
|
+
// enable clear button that clears the "selected" state
|
1189
|
+
loading: false,
|
1190
|
+
// show a loading indicator while data is loading
|
1191
|
+
disabled: false,
|
1192
|
+
// disable select
|
1193
|
+
type: Type.BUTTON,
|
1194
|
+
size: Size.M,
|
1195
|
+
targetElement: null,
|
1196
|
+
// element to bind the popup to (select BUTTON or INPUT by default)
|
1197
|
+
hideSelected: false,
|
1198
|
+
// INPUT mode: clears the input after an option is selected (useful when the selection is displayed in some custom way elsewhere)
|
1199
|
+
allowAny: false,
|
1200
|
+
// INPUT mode: allows any value to be entered
|
1201
|
+
hideArrow: false,
|
1202
|
+
// hide dropdown arrow icon
|
1203
|
+
showPopup: false,
|
1204
|
+
maxHeight: 600,
|
1205
|
+
// height of the options list, including the filter and the 'Add' button
|
1206
|
+
directions: [Popup.PopupProps.Directions.BOTTOM_RIGHT, Popup.PopupProps.Directions.BOTTOM_LEFT, Popup.PopupProps.Directions.TOP_LEFT, Popup.PopupProps.Directions.TOP_RIGHT],
|
1207
|
+
selected: null,
|
1208
|
+
// current selection (item / array of items)
|
1209
|
+
label: null,
|
1210
|
+
// BUTTON or INPUT label (nothing selected)
|
1211
|
+
selectedLabel: null,
|
1212
|
+
// BUTTON or INPUT label (something selected)
|
1213
|
+
inputPlaceholder: '',
|
1214
|
+
// Placeholder for input modes
|
1215
|
+
hint: null,
|
1216
|
+
// hint text to display under the list
|
1217
|
+
shortcutsEnabled: false,
|
1218
|
+
onBeforeOpen: noop,
|
1219
|
+
onLoadMore: noop,
|
1220
|
+
onOpen: noop,
|
1221
|
+
onClose: noop,
|
1222
|
+
onFilter: noop,
|
1223
|
+
// search string as first argument
|
1224
|
+
onFocus: noop,
|
1225
|
+
onBlur: noop,
|
1226
|
+
onKeyDown: noop,
|
1227
|
+
onSelect: noop,
|
1228
|
+
// single + multi
|
1229
|
+
onDeselect: noop,
|
1230
|
+
// multi
|
1231
|
+
onOutsideClick: noop,
|
1232
|
+
// multi
|
1233
|
+
onChange: noop,
|
1234
|
+
// multi
|
1235
|
+
onAdd: noop,
|
1236
|
+
// search string as first argument
|
1237
|
+
onDone: noop,
|
1238
|
+
onReset: noop,
|
1239
|
+
tags: null,
|
1240
|
+
ringPopupTarget: null,
|
1241
|
+
dir: 'ltr'
|
1242
|
+
});
|
1243
|
+
_defineProperty(Select, "contextType", ControlsHeightContext);
|
1244
|
+
_defineProperty(Select, "Type", Type);
|
1245
|
+
_defineProperty(Select, "Size", Size);
|
1246
|
+
Select.propTypes = {
|
1247
|
+
className: PropTypes.string,
|
1248
|
+
buttonClassName: PropTypes.string,
|
1249
|
+
id: PropTypes.string,
|
1250
|
+
multiple: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
|
1251
|
+
allowAny: PropTypes.bool,
|
1252
|
+
filter: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
|
1253
|
+
filterIcon: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]),
|
1254
|
+
filterRef: PropTypes.oneOfType([PropTypes.func, refObject(PropTypes.instanceOf(HTMLInputElement))]),
|
1255
|
+
getInitial: PropTypes.func,
|
1256
|
+
onClose: PropTypes.func,
|
1257
|
+
onOpen: PropTypes.func,
|
1258
|
+
onDone: PropTypes.func,
|
1259
|
+
onFilter: PropTypes.func,
|
1260
|
+
onChange: PropTypes.func,
|
1261
|
+
onReset: PropTypes.func,
|
1262
|
+
onLoadMore: PropTypes.func,
|
1263
|
+
onAdd: PropTypes.func,
|
1264
|
+
onBeforeOpen: PropTypes.func,
|
1265
|
+
onSelect: PropTypes.func,
|
1266
|
+
onDeselect: PropTypes.func,
|
1267
|
+
onOutsideClick: PropTypes.func,
|
1268
|
+
onFocus: PropTypes.func,
|
1269
|
+
onBlur: PropTypes.func,
|
1270
|
+
onKeyDown: PropTypes.func,
|
1271
|
+
selected: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
1272
|
+
data: PropTypes.array,
|
1273
|
+
tags: PropTypes.object,
|
1274
|
+
targetElement: PropTypes.object,
|
1275
|
+
loading: PropTypes.bool,
|
1276
|
+
loadingMessage: PropTypes.string,
|
1277
|
+
notFoundMessage: PropTypes.string,
|
1278
|
+
maxHeight: PropTypes.number,
|
1279
|
+
minWidth: PropTypes.number,
|
1280
|
+
directions: PropTypes.array,
|
1281
|
+
popupClassName: PropTypes.string,
|
1282
|
+
popupStyle: PropTypes.object,
|
1283
|
+
top: PropTypes.number,
|
1284
|
+
left: PropTypes.number,
|
1285
|
+
renderOptimization: PropTypes.bool,
|
1286
|
+
ringPopupTarget: PropTypes.string,
|
1287
|
+
error: PropTypes.string,
|
1288
|
+
hint: List.ListHint.propTypes.label,
|
1289
|
+
add: PropTypes.object,
|
1290
|
+
type: PropTypes.oneOf(Object.values(Type)),
|
1291
|
+
disabled: PropTypes.bool,
|
1292
|
+
hideSelected: PropTypes.bool,
|
1293
|
+
label: PropTypes.string,
|
1294
|
+
selectedLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
1295
|
+
inputPlaceholder: PropTypes.string,
|
1296
|
+
clear: PropTypes.bool,
|
1297
|
+
hideArrow: PropTypes.bool,
|
1298
|
+
showPopup: PropTypes.bool,
|
1299
|
+
tryKeepOpen: PropTypes.bool,
|
1300
|
+
compact: PropTypes.bool,
|
1301
|
+
size: PropTypes.oneOf(Object.values(Size)),
|
1302
|
+
customAnchor: PropTypes.func,
|
1303
|
+
disableMoveOverflow: PropTypes.bool,
|
1304
|
+
disableScrollToActive: PropTypes.bool,
|
1305
|
+
dir: PropTypes.oneOf(['ltr', 'rtl']),
|
1306
|
+
'data-test': PropTypes.string
|
1307
|
+
};
|
1308
|
+
var RerenderableSelect = rerenderHOC(Select);
|
1309
|
+
|
1310
|
+
export { RerenderableSelect, Type, Select as default };
|