@verdaccio/ui-theme 3.1.0 → 6.0.0-6-next.11
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/.babelrc +33 -0
- package/.eslintrc +115 -0
- package/.stylelintrc +40 -0
- package/CHANGELOG.md +152 -554
- package/LICENSE +1 -1
- package/README.md +22 -95
- package/config/env.js +9 -0
- package/jest/api/packages.json +42 -0
- package/jest/identity.js +29 -0
- package/jest/jest.config.js +39 -0
- package/jest/jestEnvironment.js +1 -0
- package/jest/server-handlers.ts +9 -0
- package/jest/server.ts +6 -0
- package/jest/setup-env.ts +15 -0
- package/jest/setup.ts +31 -0
- package/jest/unit/components/__mocks__/api.ts +47 -0
- package/jest/unit/components/__mocks__/token.ts +31 -0
- package/jest/unit/components/store/login.ts +23 -0
- package/jest/unit/components/store/logo.ts +7 -0
- package/jest/unit/components/store/package.ts +174 -0
- package/jest/unit/components/store/packageMeta.ts +592 -0
- package/jest/unit/empty.ts +1 -0
- package/lib/constants.ts +9 -0
- package/package.json +153 -228
- package/src/App/App.test.tsx +123 -0
- package/src/App/App.tsx +54 -0
- package/src/App/AppError.tsx +38 -0
- package/src/App/AppRoute.tsx +63 -0
- package/src/App/Footer/Footer.test.tsx +20 -0
- package/src/App/Footer/Footer.tsx +111 -0
- package/src/App/Footer/__snapshots__/Footer.test.tsx.snap +456 -0
- package/src/App/Footer/index.ts +1 -0
- package/src/App/Footer/styles.ts +44 -0
- package/src/App/Header/Header.test.tsx +152 -0
- package/src/App/Header/Header.tsx +74 -0
- package/src/App/Header/HeaderGreetings.tsx +22 -0
- package/src/App/Header/HeaderInfoDialog.tsx +19 -0
- package/src/App/Header/HeaderLeft.tsx +31 -0
- package/src/App/Header/HeaderMenu.tsx +65 -0
- package/src/App/Header/HeaderRight.tsx +118 -0
- package/src/App/Header/HeaderToolTip.tsx +19 -0
- package/src/App/Header/HeaderToolTipIcon.tsx +75 -0
- package/src/App/Header/LanguageSwitch.tsx +125 -0
- package/src/App/Header/LoginDialog/LoginDialog.test.tsx +112 -0
- package/src/App/Header/LoginDialog/LoginDialog.tsx +81 -0
- package/src/App/Header/LoginDialog/LoginDialogCloseButton.tsx +32 -0
- package/src/App/Header/LoginDialog/LoginDialogForm.tsx +97 -0
- package/src/App/Header/LoginDialog/LoginDialogFormError.tsx +43 -0
- package/src/App/Header/LoginDialog/LoginDialogHeader.tsx +48 -0
- package/src/App/Header/LoginDialog/__snapshots__/LoginDialog.test.tsx.snap +3 -0
- package/src/App/Header/LoginDialog/index.ts +1 -0
- package/src/App/Header/RegistryInfoContent/RegistryInfoContent.test.tsx +27 -0
- package/src/App/Header/RegistryInfoContent/RegistryInfoContent.tsx +155 -0
- package/src/App/Header/RegistryInfoContent/index.ts +1 -0
- package/src/App/Header/RegistryInfoDialog/RegistryInfoDialog.tsx +30 -0
- package/src/App/Header/RegistryInfoDialog/index.ts +1 -0
- package/src/App/Header/RegistryInfoDialog/styles.ts +16 -0
- package/src/App/Header/RegistryInfoDialog/types.ts +7 -0
- package/src/App/Header/Search/Search.test.tsx +168 -0
- package/src/App/Header/Search/Search.tsx +127 -0
- package/src/App/Header/Search/SearchAdornment.tsx +18 -0
- package/src/App/Header/Search/__snapshots__/Search.test.tsx.snap +101 -0
- package/src/App/Header/Search/index.ts +1 -0
- package/src/App/Header/index.ts +1 -0
- package/src/App/Header/styles.ts +89 -0
- package/src/App/index.ts +1 -0
- package/src/App/utils/loadable.tsx +10 -0
- package/src/components/.eslintrc +7 -0
- package/src/components/ActionBar/ActionBar.test.tsx +91 -0
- package/src/components/ActionBar/ActionBar.tsx +45 -0
- package/src/components/ActionBar/ActionBarAction.tsx +75 -0
- package/src/components/ActionBar/__snapshots__/ActionBar.test.tsx.snap +122 -0
- package/src/components/ActionBar/index.ts +1 -0
- package/src/components/AppBar.tsx +10 -0
- package/src/components/Author/Author.test.tsx +75 -0
- package/src/components/Author/Author.tsx +47 -0
- package/src/components/Author/__snapshots__/Author.test.tsx.snap +353 -0
- package/src/components/Author/index.ts +1 -0
- package/src/components/Author/styles.ts +23 -0
- package/src/components/AutoComplete/AutoComplete.tsx +179 -0
- package/src/components/AutoComplete/AutoCompleteV2.tsx +296 -0
- package/src/components/AutoComplete/index.ts +1 -0
- package/src/components/AutoComplete/styles.tsx +58 -0
- package/src/components/AutoComplete/useAutoComplete.tsx +61 -0
- package/src/components/Avatar.tsx +3 -0
- package/src/components/Box.tsx +8 -0
- package/src/components/Button.tsx +10 -0
- package/src/components/Card.tsx +10 -0
- package/src/components/CardActions.tsx +13 -0
- package/src/components/CardContent.tsx +10 -0
- package/src/components/Chip.tsx +10 -0
- package/src/components/CircularProgress.tsx +15 -0
- package/src/components/CopyToClipBoard.tsx +45 -0
- package/src/components/Dialog.tsx +10 -0
- package/src/components/DialogActions.tsx +16 -0
- package/src/components/DialogContent.tsx +16 -0
- package/src/components/DialogTitle.tsx +10 -0
- package/src/components/Divider.tsx +10 -0
- package/src/components/FloatingActionButton.tsx +12 -0
- package/src/components/FormControl.tsx +10 -0
- package/src/components/FormHelperText.tsx +16 -0
- package/src/components/Grid.tsx +10 -0
- package/src/components/Heading.tsx +15 -0
- package/src/components/IconButton.tsx +10 -0
- package/src/components/Icons/.eslintrc +5 -0
- package/src/components/Icons/Earth.tsx +36 -0
- package/src/components/Icons/FileBinary.tsx +20 -0
- package/src/components/Icons/Law.tsx +20 -0
- package/src/components/Icons/License.tsx +18 -0
- package/src/components/Icons/Time.tsx +19 -0
- package/src/components/Icons/Version.tsx +20 -0
- package/src/components/Icons/index.ts +5 -0
- package/src/components/Input.tsx +10 -0
- package/src/components/InputAdornment/InputAdornment.tsx +16 -0
- package/src/components/InputAdornment/index.ts +1 -0
- package/src/components/InputLabel.tsx +10 -0
- package/src/components/Label/Label.test.tsx +15 -0
- package/src/components/Label/Label.tsx +35 -0
- package/src/components/Label/__snapshots__/Label.test.tsx.snap +14 -0
- package/src/components/Label/index.ts +1 -0
- package/src/components/Link.tsx +39 -0
- package/src/components/List.tsx +10 -0
- package/src/components/ListItem.tsx +23 -0
- package/src/components/ListItemText.tsx +16 -0
- package/src/components/Loading/Loading.test.tsx +12 -0
- package/src/components/Loading/Loading.tsx +17 -0
- package/src/components/Loading/Spinner/Spinner.test.tsx +14 -0
- package/src/components/Loading/Spinner/Spinner.tsx +35 -0
- package/src/components/Loading/Spinner/__snapshots__/Spinner.test.tsx.snap +148 -0
- package/src/components/Loading/Spinner/index.tsx +1 -0
- package/src/components/Loading/__snapshots__/Loading.test.tsx.snap +86 -0
- package/src/components/Loading/index.ts +1 -0
- package/src/components/Loading/styles.ts +17 -0
- package/src/components/Logo/Logo.test.tsx +12 -0
- package/src/components/Logo/Logo.tsx +55 -0
- package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +19 -0
- package/src/components/Logo/img/logo-black-and-white.svg +1 -0
- package/src/components/Logo/img/logo.svg +1 -0
- package/src/components/Logo/index.ts +1 -0
- package/src/components/Menu.tsx +10 -0
- package/src/components/MenuItem.tsx +25 -0
- package/src/components/NotFound/NotFound.tsx +52 -0
- package/src/components/NotFound/Notfound.test.tsx +37 -0
- package/src/components/NotFound/__snapshots__/Notfound.test.tsx.snap +44 -0
- package/src/components/NotFound/img/package.svg +1 -0
- package/src/components/NotFound/index.ts +1 -0
- package/src/components/NotFound/styles.ts +40 -0
- package/src/components/Paper.tsx +10 -0
- package/src/components/SnackbarContent.tsx +15 -0
- package/src/components/SvgIcon.tsx +38 -0
- package/src/components/Tab.tsx +10 -0
- package/src/components/Tabs.tsx +14 -0
- package/src/components/Text/Text.tsx +17 -0
- package/src/components/Text/TextConfig.ts +7 -0
- package/src/components/Text/index.ts +2 -0
- package/src/components/TextField/TextField.test.tsx +16 -0
- package/src/components/TextField/TextField.tsx +23 -0
- package/src/components/TextField/__snapshots__/TextField.test.tsx.snap +19 -0
- package/src/components/TextField/index.ts +1 -0
- package/src/components/Toolbar.tsx +10 -0
- package/src/components/Tooltip.tsx +25 -0
- package/src/design-tokens/ResetStyles.tsx +44 -0
- package/src/design-tokens/StyleBaseline.tsx +14 -0
- package/src/design-tokens/ThemeContext.ts +13 -0
- package/src/design-tokens/ThemeProvider.tsx +44 -0
- package/src/design-tokens/emotion.ts +5 -0
- package/src/design-tokens/load-dayjs-locale.ts +98 -0
- package/src/design-tokens/theme.ts +159 -0
- package/src/design-tokens/useLocalStorage.ts +40 -0
- package/src/design-tokens/useOnClickOutside.ts +28 -0
- package/src/design-tokens/useTheme.ts +7 -0
- package/src/i18n/ABOUT_TRANSLATIONS.md +13 -0
- package/src/i18n/config.ts +52 -0
- package/src/i18n/crowdin/ui.json +170 -0
- package/src/i18n/deprecated_translations_dont_use/cs-CZ.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/de-DE.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/en-US.json +170 -0
- package/src/i18n/deprecated_translations_dont_use/es-ES.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/fr-FR.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/ja-JP.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/km-KH.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/pt-BR.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/ru-RU.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/tr-TR.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/uk-UA.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/zh-CN.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/zh-TW.json +165 -0
- package/src/i18n/enabledLanguages.ts +35 -0
- package/src/index.tsx +36 -0
- package/src/lib/constants.ts +9 -0
- package/src/pages/Version/DetailContainer/Dependencies/Dependencies.test.tsx +93 -0
- package/src/pages/Version/DetailContainer/Dependencies/Dependencies.tsx +100 -0
- package/src/pages/Version/DetailContainer/Dependencies/index.ts +1 -0
- package/src/pages/Version/DetailContainer/Dependencies/styles.ts +26 -0
- package/src/pages/Version/DetailContainer/Dependencies/types.ts +7 -0
- package/src/pages/Version/DetailContainer/Deprecated/Deprecated.test.tsx +34 -0
- package/src/pages/Version/DetailContainer/Deprecated/Deprecated.tsx +31 -0
- package/src/pages/Version/DetailContainer/Deprecated/index.ts +1 -0
- package/src/pages/Version/DetailContainer/DetailContainer.test.tsx +13 -0
- package/src/pages/Version/DetailContainer/DetailContainer.tsx +37 -0
- package/src/pages/Version/DetailContainer/DetailContainerContent.tsx +41 -0
- package/src/pages/Version/DetailContainer/DetailContainerContentReadme.tsx +19 -0
- package/src/pages/Version/DetailContainer/DetailContainerTabs.tsx +36 -0
- package/src/pages/Version/DetailContainer/NoItems/NoItems.tsx +16 -0
- package/src/pages/Version/DetailContainer/NoItems/Noitems.test.tsx +16 -0
- package/src/pages/Version/DetailContainer/NoItems/__snapshots__/Noitems.test.tsx.snap +9 -0
- package/src/pages/Version/DetailContainer/NoItems/index.ts +1 -0
- package/src/pages/Version/DetailContainer/Readme/Readme.spec.tsx +19 -0
- package/src/pages/Version/DetailContainer/Readme/Readme.tsx +22 -0
- package/src/pages/Version/DetailContainer/Readme/__snapshots__/Readme.spec.tsx.snap +94 -0
- package/src/pages/Version/DetailContainer/Readme/index.ts +1 -0
- package/src/pages/Version/DetailContainer/Readme/types.ts +3 -0
- package/src/pages/Version/DetailContainer/UpLinks/UpLinks.test.tsx +58 -0
- package/src/pages/Version/DetailContainer/UpLinks/UpLinks.tsx +45 -0
- package/src/pages/Version/DetailContainer/UpLinks/__snapshots__/UpLinks.test.tsx.snap +247 -0
- package/src/pages/Version/DetailContainer/UpLinks/index.ts +1 -0
- package/src/pages/Version/DetailContainer/UpLinks/styles.ts +24 -0
- package/src/pages/Version/DetailContainer/Versions/Versions.test.tsx +60 -0
- package/src/pages/Version/DetailContainer/Versions/Versions.tsx +41 -0
- package/src/pages/Version/DetailContainer/Versions/VersionsHistoryList.tsx +40 -0
- package/src/pages/Version/DetailContainer/Versions/VersionsTagList.tsx +28 -0
- package/src/pages/Version/DetailContainer/Versions/__partials__/data.json +5984 -0
- package/src/pages/Version/DetailContainer/Versions/__snapshots__/Versions.test.tsx.snap +3 -0
- package/src/pages/Version/DetailContainer/Versions/index.ts +1 -0
- package/src/pages/Version/DetailContainer/Versions/styles.ts +30 -0
- package/src/pages/Version/DetailContainer/__snapshots__/DetailContainer.test.tsx.snap +103 -0
- package/src/pages/Version/DetailContainer/index.ts +1 -0
- package/src/pages/Version/DetailSidebar/DetailSidebar.tsx +55 -0
- package/src/pages/Version/DetailSidebar/DetailSidebarFundButton.test.tsx +111 -0
- package/src/pages/Version/DetailSidebar/DetailSidebarFundButton.tsx +53 -0
- package/src/pages/Version/DetailSidebar/DetailSidebarTitle.tsx +40 -0
- package/src/pages/Version/DetailSidebar/Developers/Developers.test.tsx +117 -0
- package/src/pages/Version/DetailSidebar/Developers/Developers.tsx +90 -0
- package/src/pages/Version/DetailSidebar/Developers/DevelopersTitle.tsx +32 -0
- package/src/pages/Version/DetailSidebar/Developers/__snapshots__/Developers.test.tsx.snap +380 -0
- package/src/pages/Version/DetailSidebar/Developers/get-unique-developer-values.ts +16 -0
- package/src/pages/Version/DetailSidebar/Developers/index.ts +1 -0
- package/src/pages/Version/DetailSidebar/Developers/styles.ts +31 -0
- package/src/pages/Version/DetailSidebar/Dist/Dist.test.tsx +78 -0
- package/src/pages/Version/DetailSidebar/Dist/Dist.tsx +49 -0
- package/src/pages/Version/DetailSidebar/Dist/__snapshots__/Dist.test.tsx.snap +602 -0
- package/src/pages/Version/DetailSidebar/Dist/index.ts +1 -0
- package/src/pages/Version/DetailSidebar/Dist/styles.ts +27 -0
- package/src/pages/Version/DetailSidebar/Engines/Engines.test.tsx +71 -0
- package/src/pages/Version/DetailSidebar/Engines/Engines.tsx +58 -0
- package/src/pages/Version/DetailSidebar/Engines/img/node.png +0 -0
- package/src/pages/Version/DetailSidebar/Engines/index.ts +1 -0
- package/src/pages/Version/DetailSidebar/Engines/styles.ts +14 -0
- package/src/pages/Version/DetailSidebar/Install/Install.test.tsx +64 -0
- package/src/pages/Version/DetailSidebar/Install/Install.tsx +52 -0
- package/src/pages/Version/DetailSidebar/Install/InstallListItem.tsx +97 -0
- package/src/pages/Version/DetailSidebar/Install/__partials__/data.json +5984 -0
- package/src/pages/Version/DetailSidebar/Install/img/npm.svg +15 -0
- package/src/pages/Version/DetailSidebar/Install/img/pnpm.svg +1 -0
- package/src/pages/Version/DetailSidebar/Install/img/yarn.svg +1 -0
- package/src/pages/Version/DetailSidebar/Install/index.ts +1 -0
- package/src/pages/Version/DetailSidebar/Repository/Repository.test.tsx +78 -0
- package/src/pages/Version/DetailSidebar/Repository/Repository.tsx +93 -0
- package/src/pages/Version/DetailSidebar/Repository/__partials__/data.json +5984 -0
- package/src/pages/Version/DetailSidebar/Repository/__snapshots__/Repository.test.tsx.snap +3 -0
- package/src/pages/Version/DetailSidebar/Repository/img/git.png +0 -0
- package/src/pages/Version/DetailSidebar/Repository/index.ts +1 -0
- package/src/pages/Version/DetailSidebar/index.ts +1 -0
- package/src/pages/Version/Version.test.tsx +68 -0
- package/src/pages/Version/Version.tsx +41 -0
- package/src/pages/Version/VersionContextProvider.tsx +43 -0
- package/src/pages/Version/VersionLayout.tsx +20 -0
- package/src/pages/Version/__partials__/data.json +5984 -0
- package/src/pages/Version/context.ts +10 -0
- package/src/pages/Version/get-route-package-name.ts +9 -0
- package/src/pages/Version/index.ts +4 -0
- package/src/pages/Version/version-config.ts +19 -0
- package/src/pages/home/Home.tsx +25 -0
- package/src/pages/home/PackageList/Help/Help.test.tsx +12 -0
- package/src/pages/home/PackageList/Help/Help.tsx +56 -0
- package/src/pages/home/PackageList/Help/__snapshots__/Help.test.tsx.snap +159 -0
- package/src/pages/home/PackageList/Help/index.ts +1 -0
- package/src/pages/home/PackageList/Help/styles.ts +13 -0
- package/src/pages/home/PackageList/Package/Package.test.tsx +56 -0
- package/src/pages/home/PackageList/Package/Package.tsx +253 -0
- package/src/pages/home/PackageList/Package/Tag/Tag.test.tsx +16 -0
- package/src/pages/home/PackageList/Package/Tag/Tag.tsx +11 -0
- package/src/pages/home/PackageList/Package/Tag/__snapshots__/Tag.test.tsx.snap +21 -0
- package/src/pages/home/PackageList/Package/Tag/index.ts +1 -0
- package/src/pages/home/PackageList/Package/Tag/styles.ts +11 -0
- package/src/pages/home/PackageList/Package/index.ts +1 -0
- package/src/pages/home/PackageList/Package/styles.ts +112 -0
- package/src/pages/home/PackageList/PackageList.tsx +81 -0
- package/src/pages/home/PackageList/Packagelist.test.tsx +60 -0
- package/src/pages/home/PackageList/index.ts +1 -0
- package/src/pages/home/index.ts +1 -0
- package/src/providers/API/api.test.ts +136 -0
- package/src/providers/API/api.ts +73 -0
- package/src/providers/API/storage.ts +12 -0
- package/src/providers/config/AppConfigurationProvider.tsx +57 -0
- package/src/providers/config/index.ts +1 -0
- package/src/store/index.ts +1 -0
- package/src/store/models/configuration.ts +42 -0
- package/src/store/models/download.ts +31 -0
- package/src/store/models/index.ts +17 -0
- package/src/store/models/login.ts +90 -0
- package/src/store/models/manifest.ts +91 -0
- package/src/store/models/packages.ts +36 -0
- package/src/store/models/search.ts +81 -0
- package/src/store/store.ts +15 -0
- package/src/template/favicon.ico +0 -0
- package/src/template/index.html +21 -0
- package/src/utils/.eslintrc +5 -0
- package/src/utils/cli-utils.test.ts +66 -0
- package/src/utils/cli-utils.ts +38 -0
- package/src/utils/colors.ts +1 -0
- package/src/utils/constants.ts +5 -0
- package/src/utils/file-size.ts +13 -0
- package/src/utils/i18nForTests.ts +25 -0
- package/src/utils/login.test.ts +71 -0
- package/src/utils/login.ts +44 -0
- package/src/utils/package.test.ts +101 -0
- package/src/utils/package.ts +105 -0
- package/src/utils/sec-utils.ts +15 -0
- package/src/utils/storage.ts +12 -0
- package/src/utils/test-react-testing-library.tsx +38 -0
- package/src/utils/url.test.ts +28 -0
- package/src/utils/url.ts +58 -0
- package/src/utils/windows.ts +3 -0
- package/static/favicon.ico +0 -0
- package/static/index.html +21 -0
- package/static/main.c57129036f278d0c7acf.js +2 -0
- package/static/main.c57129036f278d0c7acf.js.LICENSE.txt +1456 -0
- package/static/manifest.json +5 -17
- package/static/runtime.c57129036f278d0c7acf.js +2 -0
- package/static/{runtime.f6e570dfe38870a45bf5.js.LICENSE.txt → runtime.c57129036f278d0c7acf.js.LICENSE.txt} +2 -2
- package/static/vendors.c57129036f278d0c7acf.js +2 -0
- package/static/vendors.c57129036f278d0c7acf.js.LICENSE.txt +2932 -0
- package/tools/.eslintrc +14 -0
- package/tools/_verdaccio.config.yaml +59 -0
- package/tools/dev.server.js +48 -0
- package/tools/getPackageJson.js +25 -0
- package/tools/verdaccio.js +31 -0
- package/tools/webpack.config.js +82 -0
- package/tools/webpack.dev.config.babel.js +60 -0
- package/tools/webpack.prod.config.babel.js +81 -0
- package/tsconfig.build.json +24 -0
- package/tsconfig.json +27 -0
- package/types/custom.d.ts +9 -0
- package/types/files.d.ts +9 -0
- package/types/index.ts +12 -0
- package/types/jest-dom.d.ts +1 -0
- package/types/packageMeta.ts +82 -0
- package/static/238.f6e570dfe38870a45bf5.js +0 -2
- package/static/238.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/718.f6e570dfe38870a45bf5.js +0 -2
- package/static/718.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/73.f6e570dfe38870a45bf5.js +0 -2
- package/static/73.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Dependencies.f6e570dfe38870a45bf5.js +0 -2
- package/static/Dependencies.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Dist.f6e570dfe38870a45bf5.js +0 -2
- package/static/Dist.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Engines.f6e570dfe38870a45bf5.js +0 -2
- package/static/Engines.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Home.f6e570dfe38870a45bf5.js +0 -2
- package/static/Home.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Install.f6e570dfe38870a45bf5.js +0 -2
- package/static/Install.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/NotFound.f6e570dfe38870a45bf5.js +0 -2
- package/static/NotFound.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Provider.f6e570dfe38870a45bf5.js +0 -2
- package/static/Provider.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Repository.f6e570dfe38870a45bf5.js +0 -2
- package/static/Repository.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/UpLinks.f6e570dfe38870a45bf5.js +0 -2
- package/static/UpLinks.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Version.f6e570dfe38870a45bf5.js +0 -2
- package/static/Version.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Versions.f6e570dfe38870a45bf5.js +0 -2
- package/static/Versions.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/main.f6e570dfe38870a45bf5.js +0 -2
- package/static/main.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/runtime.f6e570dfe38870a45bf5.js +0 -2
- package/static/vendors.f6e570dfe38870a45bf5.js +0 -2
- package/static/vendors.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -98
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
import Accordion from '@material-ui/core/Accordion';
|
|
3
|
+
import AccordionDetails from '@material-ui/core/AccordionDetails';
|
|
4
|
+
import AccordionSummary from '@material-ui/core/AccordionSummary';
|
|
5
|
+
import Box from '@material-ui/core/Box';
|
|
6
|
+
import Link from '@material-ui/core/Link';
|
|
7
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
8
|
+
import Typography from '@material-ui/core/Typography';
|
|
9
|
+
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
|
10
|
+
import React, { FC } from 'react';
|
|
11
|
+
import { useTranslation } from 'react-i18next';
|
|
12
|
+
|
|
13
|
+
import CopyToClipBoard from 'verdaccio-ui/components/CopyToClipBoard';
|
|
14
|
+
import { useConfig } from 'verdaccio-ui/providers/config';
|
|
15
|
+
import {
|
|
16
|
+
getCLISetRegistry,
|
|
17
|
+
getCLIChangePassword,
|
|
18
|
+
getCLISetConfigRegistry,
|
|
19
|
+
} from 'verdaccio-ui/utils/cli-utils';
|
|
20
|
+
import { NODE_MANAGER } from 'verdaccio-ui/utils/constants';
|
|
21
|
+
|
|
22
|
+
const renderNpmTab = (scope: string, registryUrl: string): JSX.Element => {
|
|
23
|
+
return (
|
|
24
|
+
<Box display="flex" flexDirection="column" p={1}>
|
|
25
|
+
<CopyToClipBoard
|
|
26
|
+
text={getCLISetConfigRegistry(`${NODE_MANAGER.npm} set`, scope, registryUrl)}
|
|
27
|
+
/>
|
|
28
|
+
<CopyToClipBoard text={getCLISetRegistry(`${NODE_MANAGER.npm} adduser`, registryUrl)} />
|
|
29
|
+
<CopyToClipBoard text={getCLIChangePassword(NODE_MANAGER.npm, registryUrl)} />
|
|
30
|
+
</Box>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const renderPnpmTab = (scope: string, registryUrl: string): JSX.Element => {
|
|
35
|
+
return (
|
|
36
|
+
<Box display="flex" flexDirection="column" p={1}>
|
|
37
|
+
<CopyToClipBoard
|
|
38
|
+
text={getCLISetConfigRegistry(`${NODE_MANAGER.pnpm} set`, scope, registryUrl)}
|
|
39
|
+
/>
|
|
40
|
+
<CopyToClipBoard text={getCLISetRegistry(`${NODE_MANAGER.pnpm} adduser`, registryUrl)} />
|
|
41
|
+
<CopyToClipBoard text={getCLIChangePassword(NODE_MANAGER.pnpm, registryUrl)} />
|
|
42
|
+
</Box>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const renderYarnTab = (scope: string, registryUrl: string): JSX.Element => {
|
|
47
|
+
return (
|
|
48
|
+
<Box display="flex" flexDirection="column" p={1}>
|
|
49
|
+
<CopyToClipBoard
|
|
50
|
+
text={getCLISetConfigRegistry(`${NODE_MANAGER.yarn} config set`, scope, registryUrl)}
|
|
51
|
+
/>
|
|
52
|
+
</Box>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const useStyles = makeStyles((theme) => ({
|
|
57
|
+
root: {
|
|
58
|
+
width: '100%',
|
|
59
|
+
},
|
|
60
|
+
heading: {
|
|
61
|
+
fontSize: theme.typography.pxToRem(15),
|
|
62
|
+
fontWeight: theme.typography.fontWeightBold,
|
|
63
|
+
},
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
export const AccordionContainer = styled('div')({
|
|
67
|
+
padding: 30,
|
|
68
|
+
paddingLeft: 0,
|
|
69
|
+
paddingRight: 0,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export const CommandContainer = styled('div')({
|
|
73
|
+
padding: 5,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export const LinkContainer = styled('div')({
|
|
77
|
+
margin: 10,
|
|
78
|
+
marginLeft: 0,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export type Props = {
|
|
82
|
+
registryUrl: string;
|
|
83
|
+
scope: string;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const RegistryInfoContent: FC<Props> = ({ scope, registryUrl }) => {
|
|
87
|
+
const { t } = useTranslation();
|
|
88
|
+
const classes = useStyles();
|
|
89
|
+
const { configOptions } = useConfig();
|
|
90
|
+
|
|
91
|
+
const hasNpm = configOptions?.pkgManagers?.includes('npm');
|
|
92
|
+
const hasYarn = configOptions?.pkgManagers?.includes('yarn');
|
|
93
|
+
const hasPnpm = configOptions?.pkgManagers?.includes('pnpm');
|
|
94
|
+
const hasPkgManagers = hasNpm | hasPnpm | hasYarn;
|
|
95
|
+
if (!hasPkgManagers || !scope || !registryUrl) {
|
|
96
|
+
return <AccordionContainer>{t('header.registry-no-conf')}</AccordionContainer>;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return hasPkgManagers ? (
|
|
100
|
+
<AccordionContainer>
|
|
101
|
+
{hasNpm && (
|
|
102
|
+
<Accordion>
|
|
103
|
+
<AccordionSummary
|
|
104
|
+
aria-controls="panel1a-content"
|
|
105
|
+
expandIcon={<ExpandMoreIcon />}
|
|
106
|
+
id="panel1a-header">
|
|
107
|
+
<Typography className={classes.heading}>{'npm'}</Typography>
|
|
108
|
+
</AccordionSummary>
|
|
109
|
+
<AccordionDetails>
|
|
110
|
+
<CommandContainer data-testid={'tab-content'}>
|
|
111
|
+
{renderNpmTab(scope, registryUrl)}
|
|
112
|
+
</CommandContainer>
|
|
113
|
+
</AccordionDetails>
|
|
114
|
+
</Accordion>
|
|
115
|
+
)}
|
|
116
|
+
{hasYarn && (
|
|
117
|
+
<Accordion>
|
|
118
|
+
<AccordionSummary
|
|
119
|
+
aria-controls="panel2a-content"
|
|
120
|
+
expandIcon={<ExpandMoreIcon />}
|
|
121
|
+
id="panel2a-header">
|
|
122
|
+
<Typography className={classes.heading}>{'yarn'}</Typography>
|
|
123
|
+
</AccordionSummary>
|
|
124
|
+
<AccordionDetails>
|
|
125
|
+
<CommandContainer data-testid={'tab-content'}>
|
|
126
|
+
{renderYarnTab(scope, registryUrl)}
|
|
127
|
+
</CommandContainer>
|
|
128
|
+
</AccordionDetails>
|
|
129
|
+
</Accordion>
|
|
130
|
+
)}
|
|
131
|
+
{hasPnpm && (
|
|
132
|
+
<Accordion>
|
|
133
|
+
<AccordionSummary
|
|
134
|
+
aria-controls="panel3a-content"
|
|
135
|
+
expandIcon={<ExpandMoreIcon />}
|
|
136
|
+
id="panel3a-header">
|
|
137
|
+
{'pnpm'}
|
|
138
|
+
</AccordionSummary>
|
|
139
|
+
<AccordionDetails>
|
|
140
|
+
<CommandContainer data-testid={'tab-content'}>
|
|
141
|
+
{renderPnpmTab(scope, registryUrl)}
|
|
142
|
+
</CommandContainer>
|
|
143
|
+
</AccordionDetails>
|
|
144
|
+
</Accordion>
|
|
145
|
+
)}
|
|
146
|
+
<LinkContainer>
|
|
147
|
+
<Link href="https://verdaccio.org/docs/en/cli-registry" target="_blank">
|
|
148
|
+
<Typography>{t('header.registry-info-link')}</Typography>
|
|
149
|
+
</Link>
|
|
150
|
+
</LinkContainer>
|
|
151
|
+
</AccordionContainer>
|
|
152
|
+
) : null;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export default RegistryInfoContent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './RegistryInfoContent';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
|
|
4
|
+
import Button from 'verdaccio-ui/components/Button';
|
|
5
|
+
import Dialog from 'verdaccio-ui/components/Dialog';
|
|
6
|
+
import DialogActions from 'verdaccio-ui/components/DialogActions';
|
|
7
|
+
|
|
8
|
+
import { Title, Content } from './styles';
|
|
9
|
+
import { Props } from './types';
|
|
10
|
+
|
|
11
|
+
const RegistryInfoDialog: React.FC<Props> = ({ open = false, children, onClose }) => {
|
|
12
|
+
const { t } = useTranslation();
|
|
13
|
+
return (
|
|
14
|
+
<Dialog
|
|
15
|
+
data-testid={'registryInfo--dialog'}
|
|
16
|
+
id="registryInfo--dialog-container"
|
|
17
|
+
onClose={onClose}
|
|
18
|
+
open={open}>
|
|
19
|
+
<Title disableTypography={true}>{t('dialog.registry-info.title')}</Title>
|
|
20
|
+
<Content>{children}</Content>
|
|
21
|
+
<DialogActions>
|
|
22
|
+
<Button color="inherit" id="registryInfo--dialog-close" onClick={onClose}>
|
|
23
|
+
{t('button.close')}
|
|
24
|
+
</Button>
|
|
25
|
+
</DialogActions>
|
|
26
|
+
</Dialog>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default RegistryInfoDialog;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './RegistryInfoDialog';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
|
|
3
|
+
import DialogContent from 'verdaccio-ui/components/DialogContent';
|
|
4
|
+
import DialogTitle from 'verdaccio-ui/components/DialogTitle';
|
|
5
|
+
import { Theme } from 'verdaccio-ui/design-tokens/theme';
|
|
6
|
+
|
|
7
|
+
export const Title = styled(DialogTitle)<{ theme?: Theme }>((props) => ({
|
|
8
|
+
backgroundColor: props.theme?.palette.primary.main,
|
|
9
|
+
color: props.theme?.palette.white,
|
|
10
|
+
fontSize: props.theme?.fontSize.lg,
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
export const Content = styled(DialogContent)<{ theme?: Theme }>(({ theme }) => ({
|
|
14
|
+
padding: '0 24px',
|
|
15
|
+
backgroundColor: theme?.palette.background.default,
|
|
16
|
+
}));
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BrowserRouter as Router } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
import api from 'verdaccio-ui/providers/API/api';
|
|
5
|
+
import { renderWithStore, fireEvent, waitFor } from 'verdaccio-ui/utils/test-react-testing-library';
|
|
6
|
+
|
|
7
|
+
import { store } from '../../../store/store';
|
|
8
|
+
|
|
9
|
+
jest.mock('lodash/debounce', () =>
|
|
10
|
+
jest.fn((fn) => {
|
|
11
|
+
fn.cancel = jest.fn();
|
|
12
|
+
return fn;
|
|
13
|
+
})
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
import Search from './Search';
|
|
17
|
+
|
|
18
|
+
/* eslint-disable verdaccio/jsx-spread */
|
|
19
|
+
const ComponentToBeRendered: React.FC = () => (
|
|
20
|
+
<Router>
|
|
21
|
+
<Search />
|
|
22
|
+
</Router>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
describe('<Search /> component', () => {
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
jest.spyOn(api, 'request').mockImplementation(() =>
|
|
28
|
+
Promise.resolve([
|
|
29
|
+
{
|
|
30
|
+
name: 'verdaccio-ui/types',
|
|
31
|
+
version: '8.4.2',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'verdaccio',
|
|
35
|
+
version: '4.3.5',
|
|
36
|
+
},
|
|
37
|
+
])
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
afterEach(() => {
|
|
42
|
+
jest.clearAllMocks();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('should load the component in default state', () => {
|
|
46
|
+
const { container } = renderWithStore(<ComponentToBeRendered />, store);
|
|
47
|
+
expect(container.firstChild).toMatchSnapshot();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('handleSearch: when user type package name in search component, show suggestions', async () => {
|
|
51
|
+
const { getByPlaceholderText, getAllByText } = renderWithStore(
|
|
52
|
+
<ComponentToBeRendered />,
|
|
53
|
+
store
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const autoCompleteInput = getByPlaceholderText('Search Packages');
|
|
57
|
+
|
|
58
|
+
fireEvent.focus(autoCompleteInput);
|
|
59
|
+
fireEvent.change(autoCompleteInput, { target: { value: 'verdaccio' } });
|
|
60
|
+
|
|
61
|
+
expect(autoCompleteInput).toHaveAttribute('value', 'verdaccio');
|
|
62
|
+
|
|
63
|
+
const suggestionsElements = await waitFor(() => getAllByText('verdaccio', { exact: true }));
|
|
64
|
+
|
|
65
|
+
expect(suggestionsElements).toHaveLength(2);
|
|
66
|
+
expect(api.request).toHaveBeenCalledTimes(1);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('onBlur: should cancel all search requests', async () => {
|
|
70
|
+
const { getByPlaceholderText, getByRole, getAllByText } = renderWithStore(
|
|
71
|
+
<ComponentToBeRendered />,
|
|
72
|
+
store
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const autoCompleteInput = getByPlaceholderText('Search Packages');
|
|
76
|
+
|
|
77
|
+
fireEvent.focus(autoCompleteInput);
|
|
78
|
+
fireEvent.change(autoCompleteInput, { target: { value: 'verdaccio' } });
|
|
79
|
+
expect(autoCompleteInput).toHaveAttribute('value', 'verdaccio');
|
|
80
|
+
|
|
81
|
+
const suggestionsElements = await waitFor(() => getAllByText('verdaccio', { exact: true }));
|
|
82
|
+
expect(suggestionsElements).toHaveLength(2);
|
|
83
|
+
expect(api.request).toHaveBeenCalledTimes(1);
|
|
84
|
+
|
|
85
|
+
fireEvent.blur(autoCompleteInput);
|
|
86
|
+
const listBoxElement = await waitFor(() => getByRole('listbox'));
|
|
87
|
+
expect(listBoxElement).toBeEmptyDOMElement();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('handleSearch: cancel all search requests when there is no value in search component with type method', async () => {
|
|
91
|
+
const { getByPlaceholderText, getByRole } = renderWithStore(<ComponentToBeRendered />, store);
|
|
92
|
+
|
|
93
|
+
const autoCompleteInput = getByPlaceholderText('Search Packages');
|
|
94
|
+
fireEvent.focus(autoCompleteInput);
|
|
95
|
+
fireEvent.change(autoCompleteInput, { target: { value: ' ', method: 'type' } });
|
|
96
|
+
expect(autoCompleteInput).toHaveAttribute('value', '');
|
|
97
|
+
const listBoxElement = await waitFor(() => getByRole('listbox'));
|
|
98
|
+
expect(listBoxElement.innerHTML).toEqual('');
|
|
99
|
+
expect(api.request).toHaveBeenCalledTimes(0);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('handleSearch: when method is not type method', async () => {
|
|
103
|
+
const { getByPlaceholderText, getByRole } = renderWithStore(<ComponentToBeRendered />, store);
|
|
104
|
+
|
|
105
|
+
const autoCompleteInput = getByPlaceholderText('Search Packages');
|
|
106
|
+
|
|
107
|
+
fireEvent.focus(autoCompleteInput);
|
|
108
|
+
fireEvent.change(autoCompleteInput, { target: { value: ' ', method: 'click' } });
|
|
109
|
+
expect(autoCompleteInput).toHaveAttribute('value', '');
|
|
110
|
+
const listBoxElement = await waitFor(() => getByRole('listbox'));
|
|
111
|
+
expect(listBoxElement.innerHTML).toEqual('');
|
|
112
|
+
expect(api.request).toHaveBeenCalledTimes(0);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test('handleSearch: loading is been displayed', async () => {
|
|
116
|
+
const { getByPlaceholderText, getByText } = renderWithStore(<ComponentToBeRendered />, store);
|
|
117
|
+
const autoCompleteInput = getByPlaceholderText('Search Packages');
|
|
118
|
+
|
|
119
|
+
fireEvent.focus(autoCompleteInput);
|
|
120
|
+
fireEvent.change(autoCompleteInput, { target: { value: 'verdaccio' } });
|
|
121
|
+
expect(autoCompleteInput).toHaveAttribute('value', 'verdaccio');
|
|
122
|
+
|
|
123
|
+
const loadingElement = await waitFor(() => getByText('Loading...'));
|
|
124
|
+
expect(loadingElement).toBeTruthy();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test('handlePackagesClearRequested: should clear suggestions', async () => {
|
|
128
|
+
const { getByPlaceholderText, getAllByText, getByRole } = renderWithStore(
|
|
129
|
+
<ComponentToBeRendered />,
|
|
130
|
+
store
|
|
131
|
+
);
|
|
132
|
+
const autoCompleteInput = getByPlaceholderText('Search Packages');
|
|
133
|
+
|
|
134
|
+
fireEvent.focus(autoCompleteInput);
|
|
135
|
+
fireEvent.change(autoCompleteInput, { target: { value: 'verdaccio' } });
|
|
136
|
+
expect(autoCompleteInput).toHaveAttribute('value', 'verdaccio');
|
|
137
|
+
|
|
138
|
+
const suggestionsElements = await waitFor(() => getAllByText('verdaccio', { exact: true }));
|
|
139
|
+
expect(suggestionsElements).toHaveLength(2);
|
|
140
|
+
|
|
141
|
+
fireEvent.change(autoCompleteInput, { target: { value: ' ' } });
|
|
142
|
+
const listBoxElement = await waitFor(() => getByRole('listbox'));
|
|
143
|
+
expect(listBoxElement.innerHTML).toEqual('');
|
|
144
|
+
|
|
145
|
+
expect(api.request).toHaveBeenCalledTimes(1);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('handleClickSearch: should change the window location on click or return key', async () => {
|
|
149
|
+
const { getByPlaceholderText, getAllByText, getByRole } = renderWithStore(
|
|
150
|
+
<ComponentToBeRendered />,
|
|
151
|
+
store
|
|
152
|
+
);
|
|
153
|
+
const autoCompleteInput = getByPlaceholderText('Search Packages');
|
|
154
|
+
|
|
155
|
+
fireEvent.focus(autoCompleteInput);
|
|
156
|
+
fireEvent.change(autoCompleteInput, { target: { value: 'verdaccio' } });
|
|
157
|
+
expect(autoCompleteInput).toHaveAttribute('value', 'verdaccio');
|
|
158
|
+
|
|
159
|
+
const suggestionsElements = await waitFor(() => getAllByText('verdaccio', { exact: true }));
|
|
160
|
+
expect(suggestionsElements).toHaveLength(2);
|
|
161
|
+
|
|
162
|
+
// click on the second suggestion
|
|
163
|
+
fireEvent.click(suggestionsElements[1]);
|
|
164
|
+
const listBoxElement = await waitFor(() => getByRole('listbox'));
|
|
165
|
+
// when the page redirects, the list box should be empty again
|
|
166
|
+
expect(listBoxElement.innerHTML).toEqual('');
|
|
167
|
+
});
|
|
168
|
+
});
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import debounce from 'lodash/debounce';
|
|
2
|
+
import React, { useState, FormEvent, useCallback } from 'react';
|
|
3
|
+
import { SuggestionSelectedEventData } from 'react-autosuggest';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
6
|
+
import { RouteComponentProps, withRouter } from 'react-router';
|
|
7
|
+
|
|
8
|
+
import AutoComplete from 'verdaccio-ui/components/AutoComplete';
|
|
9
|
+
|
|
10
|
+
import { Dispatch, RootState } from '../../../store/store';
|
|
11
|
+
|
|
12
|
+
import SearchAdornment from './SearchAdornment';
|
|
13
|
+
|
|
14
|
+
const CONSTANTS = {
|
|
15
|
+
API_DELAY: 300,
|
|
16
|
+
ABORT_ERROR: 'AbortError',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const Search: React.FC<RouteComponentProps> = ({ history }) => {
|
|
20
|
+
const { t } = useTranslation();
|
|
21
|
+
const [loaded, setLoaded] = useState(false);
|
|
22
|
+
const [search, setSearch] = useState('');
|
|
23
|
+
// const mountedRef = useRef(true);
|
|
24
|
+
const { isError, suggestions } = useSelector((state: RootState) => state.search);
|
|
25
|
+
const isLoading = useSelector((state: RootState) => state?.loading?.models.search);
|
|
26
|
+
const dispatch = useDispatch<Dispatch>();
|
|
27
|
+
/**
|
|
28
|
+
* Cancel all the requests which are in pending state.
|
|
29
|
+
*/
|
|
30
|
+
const cancelAllSearchRequests = useCallback(() => {
|
|
31
|
+
dispatch.search.clearRequestQueue();
|
|
32
|
+
}, [dispatch]);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* As user focuses out from input, we cancel all the request from requestList
|
|
36
|
+
* and set the API state parameters to default boolean values.
|
|
37
|
+
*/
|
|
38
|
+
const handleOnBlur = useCallback(
|
|
39
|
+
(event: FormEvent<HTMLInputElement>) => {
|
|
40
|
+
// stops event bubbling
|
|
41
|
+
event.stopPropagation();
|
|
42
|
+
cancelAllSearchRequests();
|
|
43
|
+
},
|
|
44
|
+
[cancelAllSearchRequests]
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* onChange method for the input element.
|
|
49
|
+
*/
|
|
50
|
+
const handleSearch = useCallback(
|
|
51
|
+
(event: FormEvent<HTMLInputElement>, { newValue, method }) => {
|
|
52
|
+
// stops event bubbling
|
|
53
|
+
event.stopPropagation();
|
|
54
|
+
if (method === 'type') {
|
|
55
|
+
const value = newValue.trim();
|
|
56
|
+
setSearch(value);
|
|
57
|
+
setLoaded(false);
|
|
58
|
+
/**
|
|
59
|
+
* A use case where User keeps adding and removing value in input field,
|
|
60
|
+
* so we cancel all the existing requests when input is empty.
|
|
61
|
+
*/
|
|
62
|
+
if (value?.length === 0) {
|
|
63
|
+
cancelAllSearchRequests();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
[cancelAllSearchRequests]
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Cancel all the request from list and make request list empty.
|
|
72
|
+
*/
|
|
73
|
+
const handlePackagesClearRequested = useCallback(() => {
|
|
74
|
+
dispatch.search.saveSearch({ suggestions: [] });
|
|
75
|
+
}, [dispatch]);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* When an user select any package by clicking or pressing return key.
|
|
79
|
+
*/
|
|
80
|
+
const handleClickSearch = useCallback(
|
|
81
|
+
(
|
|
82
|
+
event: FormEvent<HTMLInputElement>,
|
|
83
|
+
{ suggestionValue, method }: SuggestionSelectedEventData<unknown>
|
|
84
|
+
): void | undefined => {
|
|
85
|
+
// stops event bubbling
|
|
86
|
+
event.stopPropagation();
|
|
87
|
+
switch (method) {
|
|
88
|
+
case 'click':
|
|
89
|
+
case 'enter':
|
|
90
|
+
setSearch('');
|
|
91
|
+
history.push(`/-/web/detail/${suggestionValue}`);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
[history]
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Fetch packages from API.
|
|
100
|
+
* For AbortController see: https://developer.mozilla.org/en-US/docs/Web/API/AbortController
|
|
101
|
+
*/
|
|
102
|
+
const handleFetchPackages = useCallback(
|
|
103
|
+
({ value }: { value: string }) => {
|
|
104
|
+
dispatch.search.getSuggestions({ value });
|
|
105
|
+
},
|
|
106
|
+
[dispatch]
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<AutoComplete
|
|
111
|
+
onBlur={handleOnBlur}
|
|
112
|
+
onChange={handleSearch}
|
|
113
|
+
onCleanSuggestions={handlePackagesClearRequested}
|
|
114
|
+
onClick={handleClickSearch}
|
|
115
|
+
onSuggestionsFetch={debounce(handleFetchPackages, CONSTANTS.API_DELAY)}
|
|
116
|
+
placeholder={t('search.packages')}
|
|
117
|
+
startAdornment={<SearchAdornment />}
|
|
118
|
+
suggestions={suggestions}
|
|
119
|
+
suggestionsError={isError}
|
|
120
|
+
suggestionsLoaded={loaded}
|
|
121
|
+
suggestionsLoading={isLoading}
|
|
122
|
+
value={search}
|
|
123
|
+
/>
|
|
124
|
+
);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export default withRouter(Search);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
import Search from '@material-ui/icons/Search';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import InputAdornment from 'verdaccio-ui/components/InputAdornment';
|
|
6
|
+
import { Theme } from 'verdaccio-ui/design-tokens/theme';
|
|
7
|
+
|
|
8
|
+
const StyledInputAdornment = styled(InputAdornment)<{ theme?: Theme }>((props) => ({
|
|
9
|
+
color: props.theme?.palette.white,
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
const SearchAdornment: React.FC = () => (
|
|
13
|
+
<StyledInputAdornment position={'start'}>
|
|
14
|
+
<Search />
|
|
15
|
+
</StyledInputAdornment>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export default SearchAdornment;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`<Search /> component should load the component in default state 1`] = `
|
|
4
|
+
.emotion-0 {
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 32px;
|
|
7
|
+
position: relative;
|
|
8
|
+
z-index: 1;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.emotion-2 .MuiInputBase-root:before {
|
|
12
|
+
content: '';
|
|
13
|
+
border: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.emotion-2 .MuiInputBase-root:after {
|
|
17
|
+
border-color: #fff;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.emotion-2 .MuiInputBase-root:hover:before {
|
|
21
|
+
content: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.emotion-2 .MuiInputBase-root:hover:after {
|
|
25
|
+
content: none;
|
|
26
|
+
-webkit-transform: scaleX(1);
|
|
27
|
+
-ms-transform: scaleX(1);
|
|
28
|
+
transform: scaleX(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@media screen and (min-width:768px) {
|
|
32
|
+
.emotion-2 .MuiInputBase-root:hover:after {
|
|
33
|
+
content: '';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@media screen and (min-width:768px) {
|
|
38
|
+
.emotion-2 .MuiInputBase-input {
|
|
39
|
+
color: #fff;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.emotion-4 {
|
|
44
|
+
color: #fff;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.emotion-6 {
|
|
48
|
+
max-height: 500px;
|
|
49
|
+
overflow-y: auto;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
<div
|
|
53
|
+
class="emotion-0 emotion-1"
|
|
54
|
+
>
|
|
55
|
+
<div
|
|
56
|
+
aria-expanded="false"
|
|
57
|
+
aria-haspopup="listbox"
|
|
58
|
+
aria-owns="react-autowhatever-1"
|
|
59
|
+
class="react-autosuggest__container"
|
|
60
|
+
role="combobox"
|
|
61
|
+
>
|
|
62
|
+
<div
|
|
63
|
+
aria-autocomplete="list"
|
|
64
|
+
aria-controls="react-autowhatever-1"
|
|
65
|
+
class="MuiFormControl-root MuiTextField-root react-autosuggest__input emotion-2 emotion-3 MuiFormControl-fullWidth"
|
|
66
|
+
>
|
|
67
|
+
<div
|
|
68
|
+
class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl MuiInputBase-adornedStart"
|
|
69
|
+
>
|
|
70
|
+
<div
|
|
71
|
+
class="MuiInputAdornment-root emotion-4 emotion-5 MuiInputAdornment-positionStart"
|
|
72
|
+
>
|
|
73
|
+
<svg
|
|
74
|
+
aria-hidden="true"
|
|
75
|
+
class="MuiSvgIcon-root"
|
|
76
|
+
focusable="false"
|
|
77
|
+
viewBox="0 0 24 24"
|
|
78
|
+
>
|
|
79
|
+
<path
|
|
80
|
+
d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"
|
|
81
|
+
/>
|
|
82
|
+
</svg>
|
|
83
|
+
</div>
|
|
84
|
+
<input
|
|
85
|
+
aria-invalid="false"
|
|
86
|
+
autocomplete="off"
|
|
87
|
+
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedStart"
|
|
88
|
+
placeholder="Search Packages"
|
|
89
|
+
type="text"
|
|
90
|
+
value=""
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
<div
|
|
95
|
+
class="MuiPaper-root react-autosuggest__suggestions-container emotion-6 emotion-7 MuiPaper-elevation1"
|
|
96
|
+
id="react-autowhatever-1"
|
|
97
|
+
role="listbox"
|
|
98
|
+
/>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Search';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Header';
|