@verdaccio/ui-components 2.0.0-6-next.8 → 2.0.0-6-next.10
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 +1 -9
- package/CHANGELOG.md +12 -0
- package/build/Theme/ResetStyles.js +34 -37
- package/build/Theme/StyleBaseline.js +4 -6
- package/build/Theme/ThemeProvider.js +24 -34
- package/build/Theme/colors.js +1 -1
- package/build/Theme/index.js +9 -10
- package/build/Theme/theme.js +26 -28
- package/build/__mocks__/react-markdown.js +6 -5
- package/build/__mocks__/remark-plugin.js +1 -1
- package/build/components/ActionBar/ActionBar.js +23 -36
- package/build/components/ActionBar/ActionBarAction.js +45 -58
- package/build/components/ActionBar/index.js +3 -3
- package/build/components/Author/Author.js +26 -21
- package/build/components/Author/index.js +3 -3
- package/build/components/Author/styles.js +5 -5
- package/build/components/CopyClipboard/CopyToClipBoard.js +21 -23
- package/build/components/CopyClipboard/index.js +4 -4
- package/build/components/CopyClipboard/utils.js +14 -16
- package/build/components/Dependencies/Dependencies.js +68 -66
- package/build/components/Dependencies/index.js +3 -3
- package/build/components/Dependencies/styles.js +9 -11
- package/build/components/Deprecated/Deprecated.js +12 -15
- package/build/components/Deprecated/index.js +3 -3
- package/build/components/Developers/Developers.js +30 -45
- package/build/components/Developers/Title.js +22 -21
- package/build/components/Developers/get-unique-developer-values.js +3 -13
- package/build/components/Developers/index.js +5 -6
- package/build/components/Developers/styles.js +7 -7
- package/build/components/Distribution/Dist.js +28 -23
- package/build/components/Distribution/index.js +3 -3
- package/build/components/Distribution/styles.js +7 -7
- package/build/components/Distribution/utils.js +0 -1
- package/build/components/Distribution/utilts.spec.js +18 -0
- package/build/components/Engines/Engines.js +46 -36
- package/build/components/Engines/index.js +3 -3
- package/build/components/Engines/styles.js +4 -4
- package/build/components/ErrorBoundary/ErrorBoundary.js +29 -50
- package/build/components/ErrorBoundary/index.js +3 -3
- package/build/components/FundButton/FundButton.js +28 -29
- package/build/components/FundButton/index.js +3 -3
- package/build/components/HeaderInfoDialog/HeaderInfoDialog.js +33 -44
- package/build/components/HeaderInfoDialog/index.js +3 -3
- package/build/components/Heading/Heading.js +10 -14
- package/build/components/Heading/index.js +3 -3
- package/build/components/Help/Help.js +22 -21
- package/build/components/Help/index.js +3 -3
- package/build/components/Help/styles.js +2 -2
- package/build/components/Icons/DevsIcons/CommonJS.js +9 -10
- package/build/components/Icons/DevsIcons/ES6Module.js +9 -10
- package/build/components/Icons/DevsIcons/Git.js +9 -10
- package/build/components/Icons/DevsIcons/NodeJS.js +9 -10
- package/build/components/Icons/DevsIcons/TypeScript.js +9 -10
- package/build/components/Icons/DevsIcons/index.js +5 -5
- package/build/components/Icons/Earth.js +11 -11
- package/build/components/Icons/FileBinary.js +4 -4
- package/build/components/Icons/Law.js +4 -4
- package/build/components/Icons/License.js +5 -5
- package/build/components/Icons/License.js.map +1 -1
- package/build/components/Icons/Managers/Npm.js +9 -10
- package/build/components/Icons/Managers/Pnpm.js +9 -10
- package/build/components/Icons/Managers/Yarn.js +9 -10
- package/build/components/Icons/Managers/index.js +3 -3
- package/build/components/Icons/SvgIcon.js +14 -22
- package/build/components/Icons/Time.js +6 -6
- package/build/components/Icons/Version.js +4 -4
- package/build/components/Icons/index.js +8 -8
- package/build/components/Install/Install.js +40 -26
- package/build/components/Install/InstallListItem.js +49 -40
- package/build/components/Install/index.js +3 -3
- package/build/components/Label/Label.js +13 -18
- package/build/components/Label/index.js +3 -3
- package/build/components/Link/Link.js +16 -15
- package/build/components/Link/index.js +3 -3
- package/build/components/Loading/Loading.js +10 -12
- package/build/components/Loading/Spinner/Spinner.js +27 -37
- package/build/components/Loading/Spinner/index.js +3 -3
- package/build/components/Loading/index.js +3 -3
- package/build/components/Loading/styles.js +11 -12
- package/build/components/LoginDialog/LoginDialog.js +44 -83
- package/build/components/LoginDialog/LoginDialogCloseButton.js +20 -19
- package/build/components/LoginDialog/LoginDialogForm.js +41 -40
- package/build/components/LoginDialog/LoginDialogFormError.js +26 -28
- package/build/components/LoginDialog/LoginDialogHeader.js +29 -29
- package/build/components/LoginDialog/index.js +3 -3
- package/build/components/Logo/Logo.js +35 -36
- package/build/components/Logo/index.js +3 -3
- package/build/components/MenuItem/MenuItem.js +8 -9
- package/build/components/MenuItem/index.js +3 -3
- package/build/components/NoItems/NoItems.js +10 -21
- package/build/components/NoItems/index.js +3 -3
- package/build/components/NotFound/NotFound.js +25 -26
- package/build/components/NotFound/index.js +3 -3
- package/build/components/Package/Package.js +112 -152
- package/build/components/Package/Tag/Tag.js +6 -7
- package/build/components/Package/Tag/index.js +3 -3
- package/build/components/Package/Tag/styles.js +2 -2
- package/build/components/Package/index.js +5 -6
- package/build/components/Package/styles.js +65 -70
- package/build/components/PackageList/PackageList.js +56 -52
- package/build/components/PackageList/index.js +3 -3
- package/build/components/RawViewer/RawViewer.js +23 -22
- package/build/components/RawViewer/index.js +3 -3
- package/build/components/Readme/Readme.js +21 -21
- package/build/components/Readme/Readme.js.map +1 -1
- package/build/components/Readme/Readme.spec.js +6 -6
- package/build/components/Readme/Readme.spec.js.map +1 -1
- package/build/components/Readme/index.js +3 -3
- package/build/components/Readme/utils.js +7 -8
- package/build/components/RegistryInfoDialog/RegistryInfoDialog.js +14 -14
- package/build/components/RegistryInfoDialog/index.js +3 -3
- package/build/components/RegistryInfoDialog/styles.js +17 -19
- package/build/components/Repository/Repository.js +37 -36
- package/build/components/Repository/index.js +3 -3
- package/build/components/Search/AutoComplete/AutoComplete.js +26 -35
- package/build/components/Search/AutoComplete/index.js +3 -3
- package/build/components/Search/AutoComplete/styles.js +15 -16
- package/build/components/Search/Search.js +54 -54
- package/build/components/Search/SearchItem.js +57 -65
- package/build/components/Search/index.js +3 -3
- package/build/components/Search/styles.js +16 -17
- package/build/components/SettingsMenu/SettingsMenu.js +68 -0
- package/build/components/SettingsMenu/index.js +14 -0
- package/build/components/SideBarTittle/SideBarTittle.js +33 -31
- package/build/components/SideBarTittle/index.js +3 -3
- package/build/components/SideBarTittle/utils.js +4 -4
- package/build/components/TextField/TextField.js +18 -23
- package/build/components/TextField/index.js +3 -3
- package/build/components/UpLinks/UpLinks.js +18 -16
- package/build/components/UpLinks/index.js +3 -3
- package/build/components/UpLinks/styles.js +20 -22
- package/build/components/Versions/HistoryList.js +25 -25
- package/build/components/Versions/TagList.js +19 -22
- package/build/components/Versions/Versions.js +21 -20
- package/build/components/Versions/index.js +3 -3
- package/build/components/Versions/styles.js +19 -21
- package/build/hooks/index.js +5 -5
- package/build/hooks/useLocalStorage.js +18 -27
- package/build/hooks/useOnClickOutside.js +5 -5
- package/build/index.js +104 -97
- package/build/layouts/Version/Version.js +8 -8
- package/build/layouts/Version/index.js +3 -3
- package/build/providers/AppConfigurationProvider/AppConfigurationProvider.js +18 -31
- package/build/providers/AppConfigurationProvider/index.js +5 -6
- package/build/providers/PersistenceSettingProvider/PersistenceSettingProvider.js +38 -0
- package/build/providers/PersistenceSettingProvider/index.js +21 -0
- package/build/providers/TranslatorProvider/TranslatorProvider.js +26 -51
- package/build/providers/TranslatorProvider/TranslatorProvider.spec.js +54 -0
- package/build/providers/TranslatorProvider/index.js +6 -7
- package/build/providers/VersionProvider/VersionProvider.js +32 -34
- package/build/providers/VersionProvider/index.js +5 -6
- package/build/providers/index.js +3 -3
- package/build/sections/Detail/ContainerContent.js +24 -35
- package/build/sections/Detail/Detail.js +21 -30
- package/build/sections/Detail/ReadmeSection.js +7 -6
- package/build/sections/Detail/Tabs.js +16 -14
- package/build/sections/Detail/index.js +3 -3
- package/build/sections/Footer/Footer.js +55 -57
- package/build/sections/Footer/index.js +3 -3
- package/build/sections/Footer/styles.js +41 -47
- package/build/sections/Header/Header.js +36 -70
- package/build/sections/Header/HeaderGreetings.js +10 -8
- package/build/sections/Header/HeaderLeft.js +11 -12
- package/build/sections/Header/HeaderMenu.js +18 -17
- package/build/sections/Header/HeaderRight.js +41 -51
- package/build/sections/Header/HeaderSettingsDialog.js +48 -57
- package/build/sections/Header/HeaderToolTip.js +10 -11
- package/build/sections/Header/HeaderToolTipIcon.js +19 -19
- package/build/sections/Header/LanguageSwitch.js +51 -56
- package/build/sections/Header/RegistryInfoContent/RegistryInfoContent.js +72 -71
- package/build/sections/Header/RegistryInfoContent/index.js +3 -3
- package/build/sections/Header/RegistryInfoContent/styles.js +13 -16
- package/build/sections/Header/RegistryInfoDialog/RegistryInfoDialog.js +14 -14
- package/build/sections/Header/RegistryInfoDialog/index.js +3 -3
- package/build/sections/Header/RegistryInfoDialog/styles.js +17 -19
- package/build/sections/Header/index.js +3 -3
- package/build/sections/Header/styles.js +35 -38
- package/build/sections/Home/Home.js +11 -14
- package/build/sections/Home/index.js +3 -3
- package/build/sections/SideBar/Sidebar.js +38 -54
- package/build/sections/SideBar/index.js +3 -3
- package/build/sections/index.js +5 -5
- package/build/src/components/ActionBar/ActionBar.stories.d.ts +11 -6
- package/build/src/components/ActionBar/ActionBarAction.d.ts +1 -34
- package/build/src/components/Author/styles.d.ts +1 -20
- package/build/src/components/Dependencies/Dependencies.stories.d.ts +8 -6
- package/build/src/components/Dependencies/styles.d.ts +2 -30
- package/build/src/components/Deprecated/Deprecated.d.ts +1 -11
- package/build/src/components/Developers/Developers.d.ts +1 -34
- package/build/src/components/Developers/styles.d.ts +1 -34
- package/build/src/components/Distribution/Dist.stories.d.ts +4 -1
- package/build/src/components/Distribution/styles.d.ts +3 -76
- package/build/src/components/Distribution/utils.d.ts +2 -1
- package/build/src/components/Engines/styles.d.ts +1 -21
- package/build/src/components/FundButton/FundButton.stories.d.ts +7 -5
- package/build/src/components/Help/styles.d.ts +1 -10
- package/build/src/components/Icons/Earth.d.ts +2 -2
- package/build/src/components/Icons/FileBinary.d.ts +2 -2
- package/build/src/components/Icons/Law.d.ts +2 -2
- package/build/src/components/Icons/License.d.ts +2 -2
- package/build/src/components/Icons/SvgIcon.d.ts +1 -1
- package/build/src/components/Icons/Time.d.ts +2 -2
- package/build/src/components/Icons/Version.d.ts +2 -2
- package/build/src/components/Install/Install.stories.d.ts +9 -5
- package/build/src/components/MenuItem/MenuItem.d.ts +1 -1
- package/build/src/components/NoItems/NoItems.d.ts +0 -1
- package/build/src/components/Package/styles.d.ts +3 -61
- package/build/src/components/RegistryInfoDialog/styles.d.ts +1 -11
- package/build/src/components/Repository/Repository.stories.d.ts +8 -6
- package/build/src/components/Search/AutoComplete/styles.d.ts +1 -1
- package/build/src/components/Search/Search.d.ts +1 -1
- package/build/src/components/Search/styles.d.ts +2 -16
- package/build/src/components/SettingsMenu/SettingsMenu.d.ts +6 -0
- package/build/src/components/SettingsMenu/index.d.ts +1 -0
- package/build/src/components/SideBarTittle/SideBarTittle.stories.d.ts +9 -0
- package/build/src/components/TextField/TextField.d.ts +1 -1
- package/build/src/components/Versions/types.d.ts +0 -2
- package/build/src/index.d.ts +1 -0
- package/build/src/layouts/Version/Version.stories.d.ts +7 -6
- package/build/src/providers/PersistenceSettingProvider/PersistenceSettingProvider.d.ts +6 -0
- package/build/src/providers/PersistenceSettingProvider/index.d.ts +1 -0
- package/build/src/providers/TranslatorProvider/TranslatorProvider.d.ts +2 -1
- package/build/src/providers/TranslatorProvider/TranslatorProvider.spec.d.ts +1 -0
- package/build/src/providers/VersionProvider/VersionProvider.d.ts +0 -2
- package/build/src/sections/Header/LanguageSwitch.d.ts +3 -23
- package/build/src/sections/Header/RegistryInfoDialog/styles.d.ts +1 -11
- package/build/src/sections/Header/styles.d.ts +8 -166
- package/build/src/types/packageMeta.d.ts +6 -6
- package/build/store/api.js +35 -52
- package/build/store/index.js +9 -9
- package/build/store/models/configuration.js +12 -34
- package/build/store/models/download.js +22 -46
- package/build/store/models/index.js +1 -1
- package/build/store/models/login.js +55 -79
- package/build/store/models/manifest.js +52 -78
- package/build/store/models/packages.js +22 -51
- package/build/store/models/search.js +59 -87
- package/build/store/storage.js +5 -5
- package/build/store/store.js +3 -3
- package/build/test/i18n-config.js +5 -5
- package/build/test/test-react-testing-library.js +19 -24
- package/build/utils/__partials__/packageMeta.js +1 -1
- package/build/utils/cli-utils.js +27 -20
- package/build/utils/index.js +10 -11
- package/build/utils/loadable.js +9 -12
- package/build/utils/routes.js +4 -4
- package/build/utils/url.js +9 -9
- package/build/utils/utils.js +18 -22
- package/package.json +22 -19
- package/src/Theme/ThemeProvider.tsx +0 -1
- package/src/components/ActionBar/ActionBar.stories.tsx +60 -46
- package/src/components/Author/Author.stories.tsx +1 -1
- package/src/components/CopyClipboard/CopyToClipBoard.stories.tsx +1 -1
- package/src/components/CopyClipboard/CopyToClipBoard.tsx +2 -2
- package/src/components/Dependencies/Dependencies.stories.tsx +151 -51
- package/src/components/Dependencies/Dependencies.tsx +61 -51
- package/src/components/Deprecated/Deprecated.stories.tsx +1 -1
- package/src/components/Deprecated/Deprecated.tsx +1 -1
- package/src/components/Developers/Developers.stories.tsx +1 -1
- package/src/components/Distribution/Dist.stories.tsx +46 -3
- package/src/components/Distribution/Dist.test.tsx +33 -6
- package/src/components/Distribution/Dist.tsx +13 -5
- package/src/components/Distribution/utils.ts +3 -2
- package/src/components/Distribution/utilts.spec.ts +17 -0
- package/src/components/Engines/Engines.stories.tsx +1 -1
- package/src/components/FundButton/FundButton.stories.tsx +48 -17
- package/src/components/Help/Help.stories.tsx +1 -1
- package/src/components/Icons/Icons.stories.tsx +1 -1
- package/src/components/Install/Install.stories.tsx +79 -26
- package/src/components/Install/Install.tsx +28 -14
- package/src/components/Install/InstallListItem.tsx +24 -8
- package/src/components/Loading/Loading.stories.tsx +1 -1
- package/src/components/LoginDialog/LoginDialog.stories.tsx +1 -1
- package/src/components/NoItems/NoItems.stories.tsx +1 -1
- package/src/components/NoItems/NoItems.tsx +5 -6
- package/src/components/Package/Package.tsx +1 -1
- package/src/components/Repository/Repository.stories.tsx +39 -12
- package/src/components/Repository/Repository.tsx +2 -4
- package/src/components/Search/Search.stories.tsx +1 -1
- package/src/components/SettingsMenu/SettingsMenu.tsx +67 -0
- package/src/components/SettingsMenu/index.ts +1 -0
- package/src/components/SideBarTittle/SideBarTittle.stories.tsx +68 -0
- package/src/components/UpLinks/Uplinks.stories.tsx +1 -1
- package/src/components/Versions/types.ts +0 -2
- package/src/index.ts +2 -0
- package/src/layouts/Version/Version.stories.tsx +35 -20
- package/src/providers/AppConfigurationProvider/AppConfigurationProvider.tsx +0 -1
- package/src/providers/PersistenceSettingProvider/PersistenceSettingProvider.tsx +57 -0
- package/src/providers/PersistenceSettingProvider/index.ts +1 -0
- package/src/providers/TranslatorProvider/TranslatorProvider.spec.tsx +52 -0
- package/src/providers/TranslatorProvider/TranslatorProvider.tsx +2 -1
- package/src/providers/VersionProvider/VersionProvider.test.tsx +1 -1
- package/src/providers/VersionProvider/VersionProvider.tsx +0 -2
- package/src/sections/Detail/Detail.stories.tsx +1 -1
- package/src/sections/Header/Header.stories.tsx +1 -1
- package/src/sections/Home/Home.stories.tsx +1 -1
- package/src/sections/SideBar/Sidebar.stories.tsx +1 -1
- package/src/sections/SideBar/Sidebar.test.tsx +0 -1
- package/src/test/test-react-testing-library.tsx +17 -12
- package/src/types/index.d.ts +2 -0
- package/src/types/packageMeta.ts +6 -6
- package/src/utils/url.test.ts +4 -0
- package/src/utils/url.ts +1 -1
- package/tsconfig.build.json +1 -0
- package/tsconfig.json +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { PackageMetaInterface } from '../../types/packageMeta';
|
|
2
2
|
|
|
3
3
|
export interface DetailContextProps {
|
|
4
|
-
enableLoading: () => void;
|
|
5
4
|
hasNotBeenFound: boolean;
|
|
6
5
|
isLoading: boolean;
|
|
7
6
|
packageMeta: PackageMetaInterface;
|
|
@@ -11,7 +10,6 @@ export interface DetailContextProps {
|
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
export interface VersionPageConsumerProps {
|
|
14
|
-
enableLoading: () => void;
|
|
15
13
|
packageMeta: PackageMetaInterface;
|
|
16
14
|
packageName: string;
|
|
17
15
|
packageVersion?: string;
|
package/src/index.ts
CHANGED
|
@@ -42,6 +42,8 @@ export { VersionLayout } from './layouts/Version';
|
|
|
42
42
|
|
|
43
43
|
// providers
|
|
44
44
|
export { default as AppConfigurationProvider } from './providers/AppConfigurationProvider';
|
|
45
|
+
export { default as PersistenceSettingProvider } from './providers/PersistenceSettingProvider';
|
|
46
|
+
|
|
45
47
|
export * from './providers/AppConfigurationProvider';
|
|
46
48
|
export { TranslatorProvider, useLanguage, LanguageItem } from './providers/TranslatorProvider';
|
|
47
49
|
export * from './providers/TranslatorProvider';
|
|
@@ -1,29 +1,44 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { MemoryRouter, Route } from 'react-router';
|
|
3
4
|
|
|
4
5
|
import { VersionProvider } from '../../providers';
|
|
5
6
|
import VersionLayout from './Version';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
title: '
|
|
8
|
+
const meta: Meta<typeof VersionLayout> = {
|
|
9
|
+
title: 'Layout/Version',
|
|
10
|
+
component: VersionLayout,
|
|
9
11
|
};
|
|
10
12
|
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
<Route exact={true} path="/-/web/detail/:package">
|
|
14
|
-
<VersionProvider>
|
|
15
|
-
<VersionLayout />
|
|
16
|
-
</VersionProvider>
|
|
17
|
-
</Route>
|
|
18
|
-
</MemoryRouter>
|
|
19
|
-
);
|
|
13
|
+
export default meta;
|
|
14
|
+
type Story = StoryObj<typeof VersionLayout>;
|
|
20
15
|
|
|
21
|
-
export const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
export const Primary: Story = {
|
|
17
|
+
name: 'Storybook',
|
|
18
|
+
render: () => {
|
|
19
|
+
return (
|
|
20
|
+
<MemoryRouter initialEntries={[`/-/web/detail/storybook`]}>
|
|
21
|
+
<Route exact={true} path="/-/web/detail/:package">
|
|
22
|
+
<VersionProvider>
|
|
23
|
+
<VersionLayout />
|
|
24
|
+
</VersionProvider>
|
|
25
|
+
</Route>
|
|
26
|
+
</MemoryRouter>
|
|
27
|
+
);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const jQuery: Story = {
|
|
32
|
+
name: 'jQuery',
|
|
33
|
+
render: () => {
|
|
34
|
+
return (
|
|
35
|
+
<MemoryRouter initialEntries={[`/-/web/detail/jquery`]}>
|
|
36
|
+
<Route exact={true} path="/-/web/detail/:package">
|
|
37
|
+
<VersionProvider>
|
|
38
|
+
<VersionLayout />
|
|
39
|
+
</VersionProvider>
|
|
40
|
+
</Route>
|
|
41
|
+
</MemoryRouter>
|
|
42
|
+
);
|
|
43
|
+
},
|
|
44
|
+
};
|
|
@@ -54,7 +54,6 @@ const AppConfigurationContext = createContext<ConfigProviderProps>(defaultValues
|
|
|
54
54
|
const AppConfigurationProvider: FunctionComponent<{ children: React.ReactElement<any> }> = ({
|
|
55
55
|
children,
|
|
56
56
|
}) => {
|
|
57
|
-
// Read only
|
|
58
57
|
const [configOptions] = useState<TemplateUIOptions>(getConfiguration());
|
|
59
58
|
|
|
60
59
|
const value = useMemo(
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
FunctionComponent,
|
|
3
|
+
createContext,
|
|
4
|
+
useCallback,
|
|
5
|
+
useContext,
|
|
6
|
+
useMemo,
|
|
7
|
+
useState,
|
|
8
|
+
} from 'react';
|
|
9
|
+
|
|
10
|
+
import useLocalStorage from '../../hooks/useLocalStorage';
|
|
11
|
+
|
|
12
|
+
type PersistenceSettingsProps = {
|
|
13
|
+
isGlobal?: boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const defaultValues: PersistenceSettingsProps = {
|
|
17
|
+
isGlobal: false,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const PersistenceSettingContext = createContext<any>(defaultValues);
|
|
21
|
+
|
|
22
|
+
const PersistenceSettingProvider: FunctionComponent<{ children: React.ReactElement<any> }> = ({
|
|
23
|
+
children,
|
|
24
|
+
}) => {
|
|
25
|
+
// get the initial state from the local storage
|
|
26
|
+
const [settings, setSettings] = useLocalStorage(`settings-ui-verdaccio`, {});
|
|
27
|
+
|
|
28
|
+
const [localSettings, setLocalSettings] = useState<PersistenceSettingsProps>(
|
|
29
|
+
settings ? settings : {}
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const updateSettings = useCallback(
|
|
33
|
+
(newSettings: React.SetStateAction<PersistenceSettingsProps>) => {
|
|
34
|
+
setLocalSettings(newSettings);
|
|
35
|
+
setSettings(newSettings);
|
|
36
|
+
},
|
|
37
|
+
[setSettings]
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const value = useMemo(
|
|
41
|
+
() => ({
|
|
42
|
+
localSettings: localSettings ? localSettings : {},
|
|
43
|
+
updateSettings,
|
|
44
|
+
}),
|
|
45
|
+
[localSettings, updateSettings]
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<PersistenceSettingContext.Provider value={value}>
|
|
50
|
+
{children}
|
|
51
|
+
</PersistenceSettingContext.Provider>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default PersistenceSettingProvider;
|
|
56
|
+
|
|
57
|
+
export const useSettings = () => useContext(PersistenceSettingContext);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, useSettings } from './PersistenceSettingProvider';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { render } from '@testing-library/react';
|
|
2
|
+
import i18n from 'i18next';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { initReactI18next } from 'react-i18next';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
|
|
7
|
+
import TranslatorProvider, { useLanguage } from './TranslatorProvider';
|
|
8
|
+
|
|
9
|
+
i18n.use(initReactI18next).init({
|
|
10
|
+
lng: 'en-US',
|
|
11
|
+
fallbackLng: 'en-US',
|
|
12
|
+
whitelist: ['en-US'],
|
|
13
|
+
load: 'currentOnly',
|
|
14
|
+
react: {
|
|
15
|
+
useSuspense: false,
|
|
16
|
+
},
|
|
17
|
+
resources: {
|
|
18
|
+
'en-US': {
|
|
19
|
+
translation: {
|
|
20
|
+
'copy-to-clipboard': 'Copy to clipboard',
|
|
21
|
+
'author-anonymous': 'Anonymous',
|
|
22
|
+
'author-unknown': 'Unknown',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
debug: false,
|
|
27
|
+
interpolation: {
|
|
28
|
+
escapeValue: false,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const RandomComponent = () => {
|
|
33
|
+
const { language } = useLanguage();
|
|
34
|
+
const { t } = useTranslation();
|
|
35
|
+
return (
|
|
36
|
+
<div>
|
|
37
|
+
<div>{language}</div>
|
|
38
|
+
<div>{t('copy-to-clipboard')}</div>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
test('should provide translation', () => {
|
|
44
|
+
const mount = jest.fn();
|
|
45
|
+
const { getByText } = render(
|
|
46
|
+
<TranslatorProvider i18n={i18n} listLanguages={[]} onMount={mount}>
|
|
47
|
+
<RandomComponent />
|
|
48
|
+
</TranslatorProvider>
|
|
49
|
+
);
|
|
50
|
+
expect(getByText('en-US')).toBeInTheDocument();
|
|
51
|
+
expect(getByText('Copy to clipboard')).toBeInTheDocument();
|
|
52
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { i18n } from 'i18next';
|
|
1
2
|
import React, { FunctionComponent, createContext, useCallback, useContext, useEffect } from 'react';
|
|
2
3
|
import { I18nextProvider } from 'react-i18next';
|
|
3
4
|
|
|
@@ -24,7 +25,7 @@ const I18nTranslatorContext = createContext<TranslatorProviderProps>({
|
|
|
24
25
|
*/
|
|
25
26
|
const TranslatorProvider: FunctionComponent<{
|
|
26
27
|
children: React.ReactElement<any>;
|
|
27
|
-
i18n:
|
|
28
|
+
i18n: i18n;
|
|
28
29
|
listLanguages: any;
|
|
29
30
|
onMount: () => {};
|
|
30
31
|
}> = ({ children, onMount, i18n, listLanguages }) => {
|
|
@@ -16,7 +16,7 @@ function CustomComponent() {
|
|
|
16
16
|
const { packageMeta, packageName, packageVersion } = useVersion();
|
|
17
17
|
return (
|
|
18
18
|
<div>
|
|
19
|
-
<div>{packageMeta?.latest?.license}</div>
|
|
19
|
+
<div>{packageMeta?.latest?.license as string}</div>
|
|
20
20
|
<div>{packageName}</div>
|
|
21
21
|
<div>{packageVersion}</div>
|
|
22
22
|
</div>
|
|
@@ -15,7 +15,6 @@ function getRouterPackageName(packageName: string, scope?: string): string {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export interface DetailContextProps {
|
|
18
|
-
enableLoading: () => void;
|
|
19
18
|
hasNotBeenFound: boolean;
|
|
20
19
|
isLoading: boolean;
|
|
21
20
|
packageMeta: PackageMetaInterface;
|
|
@@ -25,7 +24,6 @@ export interface DetailContextProps {
|
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
export interface VersionPageConsumerProps {
|
|
28
|
-
enableLoading: () => void;
|
|
29
27
|
packageMeta: PackageMetaInterface;
|
|
30
28
|
packageName: string;
|
|
31
29
|
packageVersion?: string;
|
|
@@ -6,6 +6,7 @@ import { Provider } from 'react-redux';
|
|
|
6
6
|
|
|
7
7
|
import { ThemeProvider } from '../Theme';
|
|
8
8
|
import AppConfigurationProvider from '../providers/AppConfigurationProvider';
|
|
9
|
+
import PersistenceSettingProvider from '../providers/PersistenceSettingProvider';
|
|
9
10
|
import { Store } from '../store/store';
|
|
10
11
|
import i18nConfig from './i18n-config';
|
|
11
12
|
|
|
@@ -13,13 +14,15 @@ const renderWithStore = (ui: React.ReactElement<any>, store: Store) =>
|
|
|
13
14
|
render(ui, {
|
|
14
15
|
wrapper: ({ children }) => (
|
|
15
16
|
<Provider store={store}>
|
|
16
|
-
<
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
<PersistenceSettingProvider>
|
|
18
|
+
<AppConfigurationProvider>
|
|
19
|
+
<StyledEngineProvider injectFirst={true}>
|
|
20
|
+
<ThemeProvider>
|
|
21
|
+
<I18nextProvider i18n={i18nConfig}>{children}</I18nextProvider>
|
|
22
|
+
</ThemeProvider>
|
|
23
|
+
</StyledEngineProvider>
|
|
24
|
+
</AppConfigurationProvider>
|
|
25
|
+
</PersistenceSettingProvider>
|
|
23
26
|
</Provider>
|
|
24
27
|
),
|
|
25
28
|
});
|
|
@@ -27,11 +30,13 @@ const renderWithStore = (ui: React.ReactElement<any>, store: Store) =>
|
|
|
27
30
|
const customRender = (node: React.ReactElement, ...options: any) => {
|
|
28
31
|
return render(
|
|
29
32
|
<AppConfigurationProvider>
|
|
30
|
-
<
|
|
31
|
-
<
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
<PersistenceSettingProvider>
|
|
34
|
+
<StyledEngineProvider injectFirst={true}>
|
|
35
|
+
<ThemeProvider>
|
|
36
|
+
<I18nextProvider i18n={i18nConfig}>{node}</I18nextProvider>
|
|
37
|
+
</ThemeProvider>
|
|
38
|
+
</StyledEngineProvider>
|
|
39
|
+
</PersistenceSettingProvider>
|
|
35
40
|
</AppConfigurationProvider>,
|
|
36
41
|
...options
|
|
37
42
|
);
|
package/src/types/packageMeta.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type Latest = {
|
|
|
4
4
|
author?: Author;
|
|
5
5
|
deprecated?: string;
|
|
6
6
|
name: string;
|
|
7
|
-
dist
|
|
7
|
+
dist?: {
|
|
8
8
|
fileCount: number;
|
|
9
9
|
unpackedSize: number;
|
|
10
10
|
tarball?: string;
|
|
@@ -15,7 +15,7 @@ export type Latest = {
|
|
|
15
15
|
pnpm?: string;
|
|
16
16
|
yarn?: string;
|
|
17
17
|
};
|
|
18
|
-
license?:
|
|
18
|
+
license?: undefined | LicenseInterface | string;
|
|
19
19
|
version: string;
|
|
20
20
|
homepage?: string;
|
|
21
21
|
bugs?: {
|
|
@@ -50,12 +50,12 @@ export interface Developer {
|
|
|
50
50
|
|
|
51
51
|
interface Funding {
|
|
52
52
|
type?: string;
|
|
53
|
-
url
|
|
53
|
+
url?: string;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
interface LicenseInterface {
|
|
57
|
-
type
|
|
58
|
-
url
|
|
56
|
+
export interface LicenseInterface {
|
|
57
|
+
type?: string;
|
|
58
|
+
url?: string;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export interface DistTags {
|
package/src/utils/url.test.ts
CHANGED
|
@@ -16,6 +16,10 @@ describe('utils', () => {
|
|
|
16
16
|
test('isEmail() - should return false if invalid', () => {
|
|
17
17
|
expect(isEmail('')).toBeFalsy();
|
|
18
18
|
});
|
|
19
|
+
|
|
20
|
+
test('git repo is valid', () => {
|
|
21
|
+
expect(isURL('git://github.com/verdaccio/ui.git')).toBeTruthy();
|
|
22
|
+
});
|
|
19
23
|
});
|
|
20
24
|
|
|
21
25
|
describe('extractFileName', () => {
|
package/src/utils/url.ts
CHANGED
|
@@ -3,7 +3,7 @@ import isURLValidator from 'validator/lib/isURL';
|
|
|
3
3
|
|
|
4
4
|
export function isURL(url: string): boolean {
|
|
5
5
|
return isURLValidator(url || '', {
|
|
6
|
-
protocols: ['http', 'https', 'git+https'],
|
|
6
|
+
protocols: ['http', 'https', 'git+https', 'git'],
|
|
7
7
|
require_protocol: true,
|
|
8
8
|
require_tld: false,
|
|
9
9
|
});
|
package/tsconfig.build.json
CHANGED