@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,44 @@
|
|
|
1
|
+
import { makeStyles } from '@material-ui/styles';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import { Theme } from './theme';
|
|
5
|
+
|
|
6
|
+
const resetStyles = makeStyles(({ theme }: { theme?: Theme }) => ({
|
|
7
|
+
'@global': {
|
|
8
|
+
// eslint-disable-next-line max-len
|
|
9
|
+
'html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video':
|
|
10
|
+
{
|
|
11
|
+
fontFamily: '"Roboto", Helvetica Neue, Arial, sans-serif',
|
|
12
|
+
},
|
|
13
|
+
strong: {
|
|
14
|
+
fontWeight: theme?.fontWeight.semiBold,
|
|
15
|
+
},
|
|
16
|
+
'html, body, #root': {
|
|
17
|
+
height: '100%',
|
|
18
|
+
},
|
|
19
|
+
ul: {
|
|
20
|
+
margin: 0,
|
|
21
|
+
padding: 0,
|
|
22
|
+
listStyle: 'none',
|
|
23
|
+
},
|
|
24
|
+
'.container': {
|
|
25
|
+
padding: 15,
|
|
26
|
+
flex: 1,
|
|
27
|
+
height: '100%',
|
|
28
|
+
|
|
29
|
+
[`@media screen and (min-width: ${theme?.breakPoints.container}px)`]: {
|
|
30
|
+
maxWidth: theme?.breakPoints.container,
|
|
31
|
+
width: '100%',
|
|
32
|
+
marginLeft: 'auto',
|
|
33
|
+
marginRight: 'auto',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
const ResetStyles: React.FC = ({ children }) => {
|
|
40
|
+
resetStyles();
|
|
41
|
+
return <>{children}</>;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default ResetStyles;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import CssBaseline from '@material-ui/core/CssBaseline';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import 'normalize.css';
|
|
4
|
+
|
|
5
|
+
import ResetCSS from './ResetStyles';
|
|
6
|
+
|
|
7
|
+
const StyleBaseline: React.FC = () => (
|
|
8
|
+
<>
|
|
9
|
+
<CssBaseline />
|
|
10
|
+
<ResetCSS />
|
|
11
|
+
</>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export default StyleBaseline;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
import { Language } from 'src/i18n/enabledLanguages';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
isDarkMode: boolean;
|
|
6
|
+
setIsDarkMode: (isDarkMode: boolean) => void;
|
|
7
|
+
language: Language;
|
|
8
|
+
setLanguage: (language: Language) => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const ThemeContext = createContext<undefined | Props>(undefined);
|
|
12
|
+
|
|
13
|
+
export default ThemeContext;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ThemeProvider as MuiThemeProvider } from '@material-ui/core/styles';
|
|
2
|
+
import { ThemeProvider as EmotionThemeProvider } from 'emotion-theming';
|
|
3
|
+
import i18next from 'i18next';
|
|
4
|
+
import React, { useEffect, useCallback } from 'react';
|
|
5
|
+
|
|
6
|
+
import { useConfig } from 'verdaccio-ui/providers/config';
|
|
7
|
+
|
|
8
|
+
import loadDayJSLocale from './load-dayjs-locale';
|
|
9
|
+
import { getTheme, ThemeMode } from './theme';
|
|
10
|
+
import ThemeContext from './ThemeContext';
|
|
11
|
+
import useLocalStorage from './useLocalStorage';
|
|
12
|
+
|
|
13
|
+
const ThemeProvider: React.FC = ({ children }) => {
|
|
14
|
+
const prefersDarkMode = window.matchMedia?.('(prefers-color-scheme:dark)').matches;
|
|
15
|
+
const isDarkModeDefault = window?.__VERDACCIO_BASENAME_UI_OPTIONS?.darkMode || prefersDarkMode;
|
|
16
|
+
const currentLanguage = i18next.languages?.[0];
|
|
17
|
+
const { configOptions } = useConfig();
|
|
18
|
+
|
|
19
|
+
const [isDarkMode, setIsDarkMode] = useLocalStorage('darkMode', !!isDarkModeDefault);
|
|
20
|
+
const [language, setLanguage] = useLocalStorage('language', currentLanguage);
|
|
21
|
+
|
|
22
|
+
const themeMode: ThemeMode = isDarkMode ? 'dark' : 'light';
|
|
23
|
+
|
|
24
|
+
const changeLanguage = useCallback(async () => {
|
|
25
|
+
await i18next.changeLanguage(language);
|
|
26
|
+
}, [language]);
|
|
27
|
+
|
|
28
|
+
const currentTheme = getTheme(themeMode, configOptions?.primaryColor);
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
changeLanguage();
|
|
32
|
+
loadDayJSLocale();
|
|
33
|
+
}, [language, changeLanguage]);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<ThemeContext.Provider value={{ isDarkMode, setIsDarkMode, language, setLanguage }}>
|
|
37
|
+
<EmotionThemeProvider theme={currentTheme}>
|
|
38
|
+
<MuiThemeProvider theme={currentTheme}>{children}</MuiThemeProvider>
|
|
39
|
+
</EmotionThemeProvider>
|
|
40
|
+
</ThemeContext.Provider>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default ThemeProvider;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import i18n from 'i18next';
|
|
3
|
+
|
|
4
|
+
function getFallFackLanguage(): string | undefined {
|
|
5
|
+
const fallbackLanguage = i18n.options.fallbackLng;
|
|
6
|
+
|
|
7
|
+
if (Array.isArray(fallbackLanguage)) {
|
|
8
|
+
return fallbackLanguage[0];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (typeof fallbackLanguage === 'string') {
|
|
12
|
+
return fallbackLanguage;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function loadDayJSLocale() {
|
|
19
|
+
const fallbackLanguage = getFallFackLanguage();
|
|
20
|
+
const locale = i18n.language || fallbackLanguage;
|
|
21
|
+
|
|
22
|
+
switch (locale?.toLowerCase()) {
|
|
23
|
+
case 'pt-br':
|
|
24
|
+
{
|
|
25
|
+
require('dayjs/locale/pt-br');
|
|
26
|
+
dayjs.locale('pt-br');
|
|
27
|
+
}
|
|
28
|
+
break;
|
|
29
|
+
case 'de-de':
|
|
30
|
+
{
|
|
31
|
+
require('dayjs/locale/de');
|
|
32
|
+
dayjs.locale('de');
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
case 'es-es':
|
|
36
|
+
{
|
|
37
|
+
require('dayjs/locale/es');
|
|
38
|
+
dayjs.locale('es');
|
|
39
|
+
}
|
|
40
|
+
break;
|
|
41
|
+
case 'fr-fr':
|
|
42
|
+
{
|
|
43
|
+
require('dayjs/locale/fr');
|
|
44
|
+
dayjs.locale('fr');
|
|
45
|
+
}
|
|
46
|
+
break;
|
|
47
|
+
case 'zh-cn':
|
|
48
|
+
{
|
|
49
|
+
require('dayjs/locale/zh-cn');
|
|
50
|
+
dayjs.locale('zh-cn');
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
case 'ja-jp':
|
|
54
|
+
{
|
|
55
|
+
require('dayjs/locale/ja');
|
|
56
|
+
dayjs.locale('ja');
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
case 'ru-ru':
|
|
60
|
+
{
|
|
61
|
+
require('dayjs/locale/ru');
|
|
62
|
+
dayjs.locale('ru');
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
case 'tr-tr':
|
|
66
|
+
{
|
|
67
|
+
require('dayjs/locale/tr');
|
|
68
|
+
dayjs.locale('tr');
|
|
69
|
+
}
|
|
70
|
+
break;
|
|
71
|
+
case 'uk-ua':
|
|
72
|
+
{
|
|
73
|
+
require('dayjs/locale/uk');
|
|
74
|
+
dayjs.locale('uk');
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
case 'zh-tw':
|
|
78
|
+
{
|
|
79
|
+
require('dayjs/locale/zh-tw');
|
|
80
|
+
dayjs.locale('zh-tw');
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
case 'cs-cz':
|
|
84
|
+
{
|
|
85
|
+
require('dayjs/locale/cs');
|
|
86
|
+
dayjs.locale('cs');
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
{
|
|
91
|
+
require('dayjs/locale/en');
|
|
92
|
+
dayjs.locale('en');
|
|
93
|
+
}
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default loadDayJSLocale;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import createMuiTheme from '@material-ui/core/styles/createMuiTheme';
|
|
2
|
+
|
|
3
|
+
import { PRIMARY_COLOR } from 'verdaccio-ui/utils/colors';
|
|
4
|
+
|
|
5
|
+
const colors = {
|
|
6
|
+
black: '#000',
|
|
7
|
+
white: '#fff',
|
|
8
|
+
red: '#d32f2f',
|
|
9
|
+
orange: '#CD4000',
|
|
10
|
+
greySuperLight: '#f5f5f5',
|
|
11
|
+
greyLight: '#d3d3d3',
|
|
12
|
+
greyLight2: '#908ba1',
|
|
13
|
+
greyLight3: '#f3f4f240',
|
|
14
|
+
greyDark: '#a9a9a9',
|
|
15
|
+
greyDark2: '#586069',
|
|
16
|
+
greyChateau: '#95989a',
|
|
17
|
+
greyGainsboro: '#e3e3e3',
|
|
18
|
+
greyAthens: '#d3dddd',
|
|
19
|
+
eclipse: '#3c3c3c',
|
|
20
|
+
paleNavy: '#e4e8f1',
|
|
21
|
+
saltpan: '#f7f8f6',
|
|
22
|
+
snow: '#f9f9f9',
|
|
23
|
+
love: '#e25555',
|
|
24
|
+
nobel01: '#999999',
|
|
25
|
+
nobel02: '#9f9f9f',
|
|
26
|
+
primary: PRIMARY_COLOR,
|
|
27
|
+
secondary: '#20232a',
|
|
28
|
+
background: '#fff',
|
|
29
|
+
dodgerBlue: '#1ba1f2',
|
|
30
|
+
cyanBlue: '#253341',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const themeModes = {
|
|
34
|
+
light: {
|
|
35
|
+
...colors,
|
|
36
|
+
},
|
|
37
|
+
dark: {
|
|
38
|
+
...colors,
|
|
39
|
+
primary: '#24394e',
|
|
40
|
+
secondary: '#424242',
|
|
41
|
+
background: '#1A202C',
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
function applyPrimaryColor(mode: ThemeMode, primaryColor: string): any {
|
|
46
|
+
if (mode === 'light') {
|
|
47
|
+
themeModes['light'].primary = primaryColor;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return themeModes[mode];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type ThemeMode = keyof typeof themeModes;
|
|
54
|
+
|
|
55
|
+
const fontSize = {
|
|
56
|
+
xxl: 26,
|
|
57
|
+
xl: 24,
|
|
58
|
+
lg: 21,
|
|
59
|
+
md: 18,
|
|
60
|
+
default: 16,
|
|
61
|
+
sm: 14,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type FontSize = keyof typeof fontSize;
|
|
65
|
+
|
|
66
|
+
const fontWeight = {
|
|
67
|
+
light: 300,
|
|
68
|
+
regular: 400,
|
|
69
|
+
semiBold: 500,
|
|
70
|
+
bold: 700,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type FontWeight = keyof typeof fontWeight;
|
|
74
|
+
|
|
75
|
+
export const breakPoints = {
|
|
76
|
+
small: 576,
|
|
77
|
+
medium: 768,
|
|
78
|
+
large: 1024,
|
|
79
|
+
container: 1240,
|
|
80
|
+
xlarge: 1275,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type BreakPoints = typeof breakPoints;
|
|
84
|
+
|
|
85
|
+
const customizedTheme = {
|
|
86
|
+
fontSize,
|
|
87
|
+
fontWeight,
|
|
88
|
+
breakPoints,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
type CustomizedTheme = typeof customizedTheme;
|
|
92
|
+
|
|
93
|
+
export const getTheme = (themeMode: ThemeMode, primaryColor: string) => {
|
|
94
|
+
const palette = applyPrimaryColor(themeMode, primaryColor);
|
|
95
|
+
return createMuiTheme({
|
|
96
|
+
typography: {
|
|
97
|
+
fontFamily: [
|
|
98
|
+
'-apple-system',
|
|
99
|
+
'BlinkMacSystemFont',
|
|
100
|
+
'"Helvetica Neue"',
|
|
101
|
+
'Arial',
|
|
102
|
+
'sans-serif',
|
|
103
|
+
].join(','),
|
|
104
|
+
},
|
|
105
|
+
palette: {
|
|
106
|
+
type: themeMode,
|
|
107
|
+
...palette,
|
|
108
|
+
primary: { main: palette.primary },
|
|
109
|
+
secondary: { main: palette.secondary },
|
|
110
|
+
error: { main: palette.red },
|
|
111
|
+
background: {
|
|
112
|
+
default: palette.background,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
...customizedTheme,
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export type Theme = ReturnType<typeof getTheme>;
|
|
120
|
+
|
|
121
|
+
declare module '@material-ui/core/styles/createMuiTheme' {
|
|
122
|
+
/* eslint-disable-next-line @typescript-eslint/no-empty-interface */
|
|
123
|
+
interface Theme extends CustomizedTheme {}
|
|
124
|
+
/* eslint-disable-next-line @typescript-eslint/no-empty-interface */
|
|
125
|
+
interface ThemeOptions extends CustomizedTheme {}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
declare module '@material-ui/core/styles/createPalette' {
|
|
129
|
+
interface CustomPalette {
|
|
130
|
+
black: string;
|
|
131
|
+
white: string;
|
|
132
|
+
red: string;
|
|
133
|
+
orange: string;
|
|
134
|
+
greySuperLight: string;
|
|
135
|
+
greyLight: string;
|
|
136
|
+
greyLight2: string;
|
|
137
|
+
greyLight3: string;
|
|
138
|
+
greyDark: string;
|
|
139
|
+
greyDark2: string;
|
|
140
|
+
greyChateau: string;
|
|
141
|
+
greyGainsboro: string;
|
|
142
|
+
greyAthens: string;
|
|
143
|
+
eclipse: string;
|
|
144
|
+
paleNavy: string;
|
|
145
|
+
saltpan: string;
|
|
146
|
+
snow: string;
|
|
147
|
+
love: string;
|
|
148
|
+
nobel01: string;
|
|
149
|
+
nobel02: string;
|
|
150
|
+
background: string;
|
|
151
|
+
dodgerBlue: string;
|
|
152
|
+
cyanBlue: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* eslint-disable-next-line @typescript-eslint/no-empty-interface */
|
|
156
|
+
interface Palette extends CustomPalette {}
|
|
157
|
+
/* eslint-disable-next-line @typescript-eslint/no-empty-interface */
|
|
158
|
+
interface PaletteOptions extends Partial<CustomPalette> {}
|
|
159
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
// based on https://usehooks.com/useLocalStorage/
|
|
4
|
+
const useLocalStorage = <V>(key: string, initialValue: V) => {
|
|
5
|
+
// State to store our value
|
|
6
|
+
// Pass initial state function to useState so logic is only executed once
|
|
7
|
+
const [storedValue, setStoredValue] = useState(() => {
|
|
8
|
+
try {
|
|
9
|
+
// Get from local storage by key
|
|
10
|
+
const item = window.localStorage.getItem(key);
|
|
11
|
+
// Parse stored json or if none return initialValue
|
|
12
|
+
return item ? JSON.parse(item) : initialValue;
|
|
13
|
+
} catch (error: any) {
|
|
14
|
+
// If error also return initialValue
|
|
15
|
+
// eslint-disable-next-line no-console
|
|
16
|
+
console.error('An error occurred getting a sessionStorage key', error);
|
|
17
|
+
return initialValue;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Return a wrapped version of useState's setter function that ...
|
|
22
|
+
// ... persists the new value to localStorage.
|
|
23
|
+
const setValue = (value: V) => {
|
|
24
|
+
try {
|
|
25
|
+
// Allow value to be a function so we have same API as useState
|
|
26
|
+
const valueToStore = value instanceof Function ? value(storedValue) : value;
|
|
27
|
+
// Save state
|
|
28
|
+
setStoredValue(valueToStore);
|
|
29
|
+
// Save to local storage
|
|
30
|
+
window.localStorage.setItem(key, JSON.stringify(valueToStore));
|
|
31
|
+
} catch (error: any) {
|
|
32
|
+
// eslint-disable-next-line no-console
|
|
33
|
+
console.error('An error occurred writing to sessionStorage', error);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return [storedValue, setValue];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default useLocalStorage;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
// based on https://usehooks.com/useOnClickOutside/
|
|
4
|
+
function useOnClickOutside<R extends HTMLElementTagNameMap[keyof HTMLElementTagNameMap]>(
|
|
5
|
+
ref: React.RefObject<R>,
|
|
6
|
+
handler: (event: MouseEvent | TouchEvent) => void
|
|
7
|
+
) {
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const listener = (event: MouseEvent | TouchEvent) => {
|
|
10
|
+
// Do nothing if clicking ref's element or descendent elements
|
|
11
|
+
if (!ref.current || ref.current.contains(event.target as HTMLElement)) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
handler(event);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
document.addEventListener('mousedown', listener);
|
|
19
|
+
document.addEventListener('touchstart', listener);
|
|
20
|
+
|
|
21
|
+
return () => {
|
|
22
|
+
document.removeEventListener('mousedown', listener);
|
|
23
|
+
document.removeEventListener('touchstart', listener);
|
|
24
|
+
};
|
|
25
|
+
}, [ref, handler]);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { useOnClickOutside };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## Translate UI Strings
|
|
2
|
+
|
|
3
|
+
If you are willing to translate User Interfances strings, are located in the `crowdin` project which is available [here](https://crowdin.com/project/verdaccio) at `packages/plugins/src/i18n/crowdin/ui.json`.
|
|
4
|
+
|
|
5
|
+
### Requirements
|
|
6
|
+
|
|
7
|
+
- Need a crowdin account, use your GitHub account for fast access as an option.
|
|
8
|
+
|
|
9
|
+
### Adding a new language to the UI
|
|
10
|
+
|
|
11
|
+
- If the language is not available, ask in the Discord channel to enable it, that will be pretty fast.
|
|
12
|
+
- After you have translated the strings, add to `packages/plugins/ui-theme/src/i18n/enabledLanguages.ts` the configuration for the new language.
|
|
13
|
+
- In development mode the file must not be available since you need admin credentials to download translations, as a work around, create a folder withing the `crowdin` folder eg: `/packages/plugins/ui-theme/src/i18n/download_translations/fr-FR/ui.json` and then will be available for testing. If the language is not found, will fallback to `en-US`.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import i18n from 'i18next';
|
|
2
|
+
import { initReactI18next } from 'react-i18next';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_LANGUAGE,
|
|
6
|
+
LanguageConfiguration,
|
|
7
|
+
listLanguages,
|
|
8
|
+
listLanguagesAsString,
|
|
9
|
+
} from './enabledLanguages';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* In development mode translations files might be not available,
|
|
13
|
+
* crowdin translations are only available in CI.
|
|
14
|
+
*/
|
|
15
|
+
function loadTranslationFile(lng) {
|
|
16
|
+
try {
|
|
17
|
+
return require(`./download_translations/${lng}/ui.json`);
|
|
18
|
+
} catch {
|
|
19
|
+
// eslint-disable-next-line no-console
|
|
20
|
+
console.warn(`language ${lng} file not found, fallback to en-US`);
|
|
21
|
+
// in case the file is not there, fallback to en-US
|
|
22
|
+
return require(`./crowdin/ui.json`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const languages = listLanguages.reduce((acc, item: LanguageConfiguration) => {
|
|
27
|
+
acc[item.lng] = {
|
|
28
|
+
translation:
|
|
29
|
+
item.lng === DEFAULT_LANGUAGE ? require(`./crowdin/ui.json`) : loadTranslationFile(item.lng),
|
|
30
|
+
};
|
|
31
|
+
return acc;
|
|
32
|
+
}, {});
|
|
33
|
+
|
|
34
|
+
i18n
|
|
35
|
+
// pass the i18n instance to react-i18next.
|
|
36
|
+
.use(initReactI18next)
|
|
37
|
+
// init i18next
|
|
38
|
+
// for all options read: https://www.i18next.com/overview/configuration-options
|
|
39
|
+
.init({
|
|
40
|
+
// in case window.VEDACCIO_LANGUAGE is undefined,it will fall back to 'en-US'
|
|
41
|
+
lng: window?.__VERDACCIO_BASENAME_UI_OPTIONS?.language || DEFAULT_LANGUAGE,
|
|
42
|
+
fallbackLng: DEFAULT_LANGUAGE,
|
|
43
|
+
whitelist: [...listLanguagesAsString],
|
|
44
|
+
load: 'currentOnly',
|
|
45
|
+
resources: languages,
|
|
46
|
+
debug: false,
|
|
47
|
+
interpolation: {
|
|
48
|
+
escapeValue: false, // react already safes from xss
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export default i18n;
|