@verdaccio/ui-components 5.0.0-next-9.20 → 5.0.0-next-9.21
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/build/api/use-data-mutation.js +1 -4
- package/build/api/use-data-mutation.js.map +1 -1
- package/build/api/use-data-mutation.mjs +1 -4
- package/build/api/use-data-mutation.mjs.map +1 -1
- package/build/api/use-data.d.ts +1 -0
- package/build/api/use-data.js +3 -2
- package/build/api/use-data.js.map +1 -1
- package/build/api/use-data.mjs +3 -3
- package/build/api/use-data.mjs.map +1 -1
- package/build/components/ActionBar/ActionBar.js +4 -2
- package/build/components/ActionBar/ActionBar.js.map +1 -1
- package/build/components/ActionBar/ActionBar.mjs +4 -2
- package/build/components/ActionBar/ActionBar.mjs.map +1 -1
- package/build/components/ActionBar/ActionBarAction.js +1 -1
- package/build/components/ActionBar/ActionBarAction.mjs +1 -1
- package/build/components/Author/Author.js +1 -1
- package/build/components/Author/Author.mjs +1 -1
- package/build/components/CopyClipboard/CopyToClipBoard.js +5 -0
- package/build/components/CopyClipboard/CopyToClipBoard.js.map +1 -1
- package/build/components/CopyClipboard/CopyToClipBoard.mjs +5 -0
- package/build/components/CopyClipboard/CopyToClipBoard.mjs.map +1 -1
- package/build/components/CopyClipboard/utils.js +14 -1
- package/build/components/CopyClipboard/utils.js.map +1 -1
- package/build/components/CopyClipboard/utils.mjs +14 -1
- package/build/components/CopyClipboard/utils.mjs.map +1 -1
- package/build/components/Dependencies/Dependencies.js +2 -1
- package/build/components/Dependencies/Dependencies.js.map +1 -1
- package/build/components/Dependencies/Dependencies.mjs +2 -1
- package/build/components/Dependencies/Dependencies.mjs.map +1 -1
- package/build/components/Dependencies/DependencyBlock.js +1 -1
- package/build/components/Dependencies/DependencyBlock.mjs +1 -1
- package/build/components/Developers/Title.js +1 -1
- package/build/components/Developers/Title.mjs +1 -1
- package/build/components/Developers/get-unique-developer-values.js +2 -1
- package/build/components/Developers/get-unique-developer-values.js.map +1 -1
- package/build/components/Developers/get-unique-developer-values.mjs +2 -1
- package/build/components/Developers/get-unique-developer-values.mjs.map +1 -1
- package/build/components/Distribution/Dist.js +3 -3
- package/build/components/Distribution/Dist.js.map +1 -1
- package/build/components/Distribution/Dist.mjs +3 -3
- package/build/components/Distribution/Dist.mjs.map +1 -1
- package/build/components/Engines/Engines.js +1 -1
- package/build/components/Engines/Engines.mjs +1 -1
- package/build/components/Forbidden/Forbidden.js +1 -1
- package/build/components/Forbidden/Forbidden.mjs +1 -1
- package/build/components/FundButton/FundButton.js +4 -3
- package/build/components/FundButton/FundButton.js.map +1 -1
- package/build/components/FundButton/FundButton.mjs +4 -3
- package/build/components/FundButton/FundButton.mjs.map +1 -1
- package/build/components/GenericError/GenericError.d.ts +3 -0
- package/build/components/GenericError/GenericError.js +60 -0
- package/build/components/GenericError/GenericError.js.map +1 -0
- package/build/components/GenericError/GenericError.mjs +54 -0
- package/build/components/GenericError/GenericError.mjs.map +1 -0
- package/build/components/GenericError/index.d.ts +1 -0
- package/build/components/GenericError/index.js +2 -0
- package/build/components/GenericError/index.mjs +2 -0
- package/build/components/Help/Help.js +1 -1
- package/build/components/Help/Help.mjs +1 -1
- package/build/components/Install/Install.js +1 -1
- package/build/components/Install/Install.mjs +1 -1
- package/build/components/Install/InstallListItem.js +2 -2
- package/build/components/Install/InstallListItem.js.map +1 -1
- package/build/components/Install/InstallListItem.mjs +2 -2
- package/build/components/Install/InstallListItem.mjs.map +1 -1
- package/build/components/Keywords/KeywordListItems.js +1 -1
- package/build/components/Keywords/KeywordListItems.js.map +1 -1
- package/build/components/Keywords/KeywordListItems.mjs +1 -1
- package/build/components/Keywords/KeywordListItems.mjs.map +1 -1
- package/build/components/Keywords/Keywords.js +2 -2
- package/build/components/Keywords/Keywords.js.map +1 -1
- package/build/components/Keywords/Keywords.mjs +2 -2
- package/build/components/Keywords/Keywords.mjs.map +1 -1
- package/build/components/LoginDialog/LoginDialogCloseButton.js +1 -1
- package/build/components/LoginDialog/LoginDialogCloseButton.mjs +1 -1
- package/build/components/LoginDialog/LoginDialogForm.js +2 -1
- package/build/components/LoginDialog/LoginDialogForm.js.map +1 -1
- package/build/components/LoginDialog/LoginDialogForm.mjs +2 -1
- package/build/components/LoginDialog/LoginDialogForm.mjs.map +1 -1
- package/build/components/LoginForm/Login.d.ts +1 -0
- package/build/components/LoginForm/Login.js +6 -4
- package/build/components/LoginForm/Login.js.map +1 -1
- package/build/components/LoginForm/Login.mjs +9 -7
- package/build/components/LoginForm/Login.mjs.map +1 -1
- package/build/components/LoginForm/PasswordField.js +4 -6
- package/build/components/LoginForm/PasswordField.js.map +1 -1
- package/build/components/LoginForm/PasswordField.mjs +4 -6
- package/build/components/LoginForm/PasswordField.mjs.map +1 -1
- package/build/components/LoginForm/UsernameField.js +4 -6
- package/build/components/LoginForm/UsernameField.js.map +1 -1
- package/build/components/LoginForm/UsernameField.mjs +4 -6
- package/build/components/LoginForm/UsernameField.mjs.map +1 -1
- package/build/components/LoginForm/styles.js +1 -1
- package/build/components/LoginForm/styles.mjs +1 -1
- package/build/components/LoginForm/useLoginForm.js +13 -3
- package/build/components/LoginForm/useLoginForm.js.map +1 -1
- package/build/components/LoginForm/useLoginForm.mjs +14 -4
- package/build/components/LoginForm/useLoginForm.mjs.map +1 -1
- package/build/components/NoItems/NoItems.js +2 -2
- package/build/components/NoItems/NoItems.mjs +1 -1
- package/build/components/NotFound/NotFound.js +1 -1
- package/build/components/NotFound/NotFound.mjs +1 -1
- package/build/components/Package/Package.d.ts +1 -1
- package/build/components/Package/Package.js +28 -29
- package/build/components/Package/Package.js.map +1 -1
- package/build/components/Package/Package.mjs +29 -30
- package/build/components/Package/Package.mjs.map +1 -1
- package/build/components/Person/Person.js +1 -1
- package/build/components/Person/Person.js.map +1 -1
- package/build/components/Person/Person.mjs +1 -1
- package/build/components/Person/Person.mjs.map +1 -1
- package/build/components/RawViewer/RawViewer.js +1 -1
- package/build/components/RawViewer/RawViewer.mjs +1 -1
- package/build/components/RegistryInfoDialog/RegistryInfoDialog.js +1 -1
- package/build/components/RegistryInfoDialog/RegistryInfoDialog.mjs +1 -1
- package/build/components/Repository/Repository.js +5 -8
- package/build/components/Repository/Repository.js.map +1 -1
- package/build/components/Repository/Repository.mjs +5 -8
- package/build/components/Repository/Repository.mjs.map +1 -1
- package/build/components/Search/AutoComplete/AutoComplete.d.ts +1 -0
- package/build/components/Search/AutoComplete/AutoComplete.js +4 -4
- package/build/components/Search/AutoComplete/AutoComplete.js.map +1 -1
- package/build/components/Search/AutoComplete/AutoComplete.mjs +4 -4
- package/build/components/Search/AutoComplete/AutoComplete.mjs.map +1 -1
- package/build/components/Search/Search.js +12 -4
- package/build/components/Search/Search.js.map +1 -1
- package/build/components/Search/Search.mjs +13 -5
- package/build/components/Search/Search.mjs.map +1 -1
- package/build/components/Search/SearchItem.js +1 -1
- package/build/components/Search/SearchItem.mjs +1 -1
- package/build/components/SettingsMenu/SettingsMenu.js +1 -1
- package/build/components/SettingsMenu/SettingsMenu.mjs +1 -1
- package/build/components/SideBarTitle/SideBarTitle.js +2 -2
- package/build/components/SideBarTitle/SideBarTitle.js.map +1 -1
- package/build/components/SideBarTitle/SideBarTitle.mjs +2 -2
- package/build/components/SideBarTitle/SideBarTitle.mjs.map +1 -1
- package/build/components/UpLinks/UpLinks.js +1 -1
- package/build/components/UpLinks/UpLinks.mjs +1 -1
- package/build/components/Versions/HistoryList.js +2 -2
- package/build/components/Versions/HistoryList.js.map +1 -1
- package/build/components/Versions/HistoryList.mjs +2 -2
- package/build/components/Versions/HistoryList.mjs.map +1 -1
- package/build/components/Versions/Versions.js +22 -21
- package/build/components/Versions/Versions.js.map +1 -1
- package/build/components/Versions/Versions.mjs +22 -21
- package/build/components/Versions/Versions.mjs.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +4 -0
- package/build/index.mjs +4 -2
- package/build/pages/Version/Version.js +4 -1
- package/build/pages/Version/Version.js.map +1 -1
- package/build/pages/Version/Version.mjs +4 -1
- package/build/pages/Version/Version.mjs.map +1 -1
- package/build/providers/AuthProvider/AuthProvider.js +9 -7
- package/build/providers/AuthProvider/AuthProvider.js.map +1 -1
- package/build/providers/AuthProvider/AuthProvider.mjs +10 -8
- package/build/providers/AuthProvider/AuthProvider.mjs.map +1 -1
- package/build/providers/AuthProvider/utils.d.ts +12 -0
- package/build/providers/AuthProvider/utils.js +22 -0
- package/build/providers/AuthProvider/utils.js.map +1 -1
- package/build/providers/AuthProvider/utils.mjs +21 -2
- package/build/providers/AuthProvider/utils.mjs.map +1 -1
- package/build/providers/DownloadProvider/DownloadProvider.d.ts +1 -0
- package/build/providers/DownloadProvider/DownloadProvider.js +27 -4
- package/build/providers/DownloadProvider/DownloadProvider.js.map +1 -1
- package/build/providers/DownloadProvider/DownloadProvider.mjs +27 -6
- package/build/providers/DownloadProvider/DownloadProvider.mjs.map +1 -1
- package/build/providers/ManifestsProvider/ManifestsProvider.js +1 -1
- package/build/providers/ManifestsProvider/ManifestsProvider.js.map +1 -1
- package/build/providers/ManifestsProvider/ManifestsProvider.mjs +1 -1
- package/build/providers/ManifestsProvider/ManifestsProvider.mjs.map +1 -1
- package/build/providers/SearchProvider/SearchProvider.d.ts +1 -0
- package/build/providers/SearchProvider/SearchProvider.js +8 -6
- package/build/providers/SearchProvider/SearchProvider.js.map +1 -1
- package/build/providers/SearchProvider/SearchProvider.mjs +8 -6
- package/build/providers/SearchProvider/SearchProvider.mjs.map +1 -1
- package/build/providers/TranslatorProvider/TranslatorProvider.js +5 -3
- package/build/providers/TranslatorProvider/TranslatorProvider.js.map +1 -1
- package/build/providers/TranslatorProvider/TranslatorProvider.mjs +5 -3
- package/build/providers/TranslatorProvider/TranslatorProvider.mjs.map +1 -1
- package/build/providers/VersionProvider/VersionProvider.js +3 -3
- package/build/providers/VersionProvider/VersionProvider.js.map +1 -1
- package/build/providers/VersionProvider/VersionProvider.mjs +3 -3
- package/build/providers/VersionProvider/VersionProvider.mjs.map +1 -1
- package/build/sections/Detail/Tabs.js +1 -1
- package/build/sections/Detail/Tabs.mjs +1 -1
- package/build/sections/Footer/Footer.js +1 -1
- package/build/sections/Footer/Footer.mjs +1 -1
- package/build/sections/Header/Header.d.ts +0 -1
- package/build/sections/Header/Header.js +16 -14
- package/build/sections/Header/Header.js.map +1 -1
- package/build/sections/Header/Header.mjs +17 -15
- package/build/sections/Header/Header.mjs.map +1 -1
- package/build/sections/Header/HeaderGreetings.js +1 -1
- package/build/sections/Header/HeaderGreetings.mjs +1 -1
- package/build/sections/Header/HeaderMenu.js +1 -1
- package/build/sections/Header/HeaderMenu.mjs +1 -1
- package/build/sections/Header/HeaderRight.js +1 -1
- package/build/sections/Header/HeaderRight.mjs +1 -1
- package/build/sections/Header/HeaderSettingsDialog.js +1 -1
- package/build/sections/Header/HeaderSettingsDialog.mjs +1 -1
- package/build/sections/Header/LanguageSwitch.js +1 -1
- package/build/sections/Header/LanguageSwitch.mjs +1 -1
- package/build/sections/Header/RegistryInfoContent/RegistryInfoContent.js +1 -1
- package/build/sections/Header/RegistryInfoContent/RegistryInfoContent.mjs +1 -1
- package/build/sections/Home/Home.js +4 -3
- package/build/sections/Home/Home.js.map +1 -1
- package/build/sections/Home/Home.mjs +5 -4
- package/build/sections/Home/Home.mjs.map +1 -1
- package/build/sections/Security/AddUser.js +33 -18
- package/build/sections/Security/AddUser.js.map +1 -1
- package/build/sections/Security/AddUser.mjs +37 -22
- package/build/sections/Security/AddUser.mjs.map +1 -1
- package/build/sections/Security/ChangePassword.js +17 -15
- package/build/sections/Security/ChangePassword.js.map +1 -1
- package/build/sections/Security/ChangePassword.mjs +19 -17
- package/build/sections/Security/ChangePassword.mjs.map +1 -1
- package/build/sections/Security/Login.js +51 -35
- package/build/sections/Security/Login.js.map +1 -1
- package/build/sections/Security/Login.mjs +54 -38
- package/build/sections/Security/Login.mjs.map +1 -1
- package/build/sections/Security/Success.js +28 -24
- package/build/sections/Security/Success.js.map +1 -1
- package/build/sections/Security/Success.mjs +29 -25
- package/build/sections/Security/Success.mjs.map +1 -1
- package/build/sections/Stage/StageActions.js +1 -1
- package/build/sections/Stage/StageActions.mjs +1 -1
- package/build/sections/Stage/StageDetail.js +1 -1
- package/build/sections/Stage/StageDetail.mjs +1 -1
- package/build/sections/Stage/StageList.js +15 -2
- package/build/sections/Stage/StageList.js.map +1 -1
- package/build/sections/Stage/StageList.mjs +15 -2
- package/build/sections/Stage/StageList.mjs.map +1 -1
- package/build/store/api.js +7 -4
- package/build/store/api.js.map +1 -1
- package/build/store/api.mjs +7 -4
- package/build/store/api.mjs.map +1 -1
- package/build/types/packageMeta.d.ts +3 -2
- package/build/utils/cli-utils.js +2 -2
- package/build/utils/cli-utils.js.map +1 -1
- package/build/utils/cli-utils.mjs +2 -2
- package/build/utils/cli-utils.mjs.map +1 -1
- package/build/utils/index.js +1 -0
- package/build/utils/index.mjs +2 -2
- package/build/utils/routes.d.ts +1 -0
- package/build/utils/routes.js +1 -0
- package/build/utils/routes.js.map +1 -1
- package/build/utils/routes.mjs +1 -0
- package/build/utils/routes.mjs.map +1 -1
- package/build/utils/schemas.d.ts +1 -0
- package/build/utils/schemas.js +4 -4
- package/build/utils/schemas.js.map +1 -1
- package/build/utils/schemas.mjs +4 -4
- package/build/utils/schemas.mjs.map +1 -1
- package/build/utils/session-id.d.ts +8 -0
- package/build/utils/session-id.js +26 -0
- package/build/utils/session-id.js.map +1 -0
- package/build/utils/session-id.mjs +26 -0
- package/build/utils/session-id.mjs.map +1 -0
- package/build/utils/token.d.ts +1 -0
- package/build/utils/token.js +12 -8
- package/build/utils/token.js.map +1 -1
- package/build/utils/token.mjs +12 -9
- package/build/utils/token.mjs.map +1 -1
- package/build/utils/url.js +1 -1
- package/build/utils/url.js.map +1 -1
- package/build/utils/url.mjs +1 -1
- package/build/utils/url.mjs.map +1 -1
- package/build/utils/utils.d.ts +10 -0
- package/build/utils/utils.js +26 -0
- package/build/utils/utils.js.map +1 -1
- package/build/utils/utils.mjs +25 -1
- package/build/utils/utils.mjs.map +1 -1
- package/package.json +6 -6
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Wrapper } from "./styles.mjs";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
3
|
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import Autocomplete from "@mui/material/Autocomplete";
|
|
6
6
|
//#region src/components/Search/AutoComplete/AutoComplete.tsx
|
|
7
|
-
var AutoComplete = ({ suggestions = [], onSuggestionsFetch, onCleanSuggestions, renderInput, renderOption, getOptionLabel, onSelectItem, suggestionsLoading = false }) => {
|
|
7
|
+
var AutoComplete = ({ suggestions = [], onSuggestionsFetch, onCleanSuggestions, renderInput, renderOption, getOptionLabel, onSelectItem, suggestionsLoading = false, hasError = false }) => {
|
|
8
8
|
const { t } = useTranslation();
|
|
9
9
|
const [inputValue, setInputValue] = useState("");
|
|
10
10
|
const handleOnInputChange = (event, value, reason) => {
|
|
@@ -31,11 +31,11 @@ var AutoComplete = ({ suggestions = [], onSuggestionsFetch, onCleanSuggestions,
|
|
|
31
31
|
inputValue,
|
|
32
32
|
loading: suggestionsLoading,
|
|
33
33
|
loadingText: t("autoComplete.loading"),
|
|
34
|
-
noOptionsText: t("autoComplete.no-results-found"),
|
|
34
|
+
noOptionsText: hasError ? t("autoComplete.error") : t("autoComplete.no-results-found"),
|
|
35
35
|
onChange: onSelectItem,
|
|
36
36
|
onClose: handleOnClose,
|
|
37
37
|
onInputChange: handleOnInputChange,
|
|
38
|
-
options: suggestions,
|
|
38
|
+
options: hasError ? [] : suggestions,
|
|
39
39
|
renderInput,
|
|
40
40
|
renderOption,
|
|
41
41
|
renderTags: () => null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoComplete.mjs","names":[],"sources":["../../../../src/components/Search/AutoComplete/AutoComplete.tsx"],"sourcesContent":["import Autocomplete from '@mui/material/Autocomplete';\nimport type { FC } from 'react';\nimport React, { useState } from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport type { SearchResultWeb } from '@verdaccio/types';\n\nimport { Wrapper } from './styles';\n\nexport type OnSelecItem = (\n event: React.SyntheticEvent,\n value: SearchResultWeb,\n reason: string,\n details?: string\n) => void;\ninterface Props {\n suggestions?: SearchResultWeb[];\n suggestionsLoading?: boolean;\n placeholder: string;\n renderOption?: (props: any, option: any) => React.JSX.Element;\n renderInput: (params: any) => React.JSX.Element;\n onSuggestionsFetch: any;\n getOptionLabel: (option: any) => any;\n onCleanSuggestions: (event: React.SyntheticEvent) => void;\n onSelectItem: OnSelecItem;\n}\n\nconst AutoComplete: FC<Props> = ({\n suggestions = [],\n onSuggestionsFetch,\n onCleanSuggestions,\n renderInput,\n renderOption,\n getOptionLabel,\n onSelectItem,\n suggestionsLoading = false,\n}: Props) => {\n const { t } = useTranslation();\n const [inputValue, setInputValue] = useState('');\n\n const handleOnInputChange = (event: React.SyntheticEvent, value: string, reason: string) => {\n if (reason === 'input') {\n event.preventDefault();\n onSuggestionsFetch({ value });\n setInputValue(value);\n } else if (reason === 'clear') {\n onCleanSuggestions(event);\n setInputValue('');\n }\n };\n\n const handleOnClose = (event) => {\n onCleanSuggestions(event);\n setInputValue('');\n };\n\n // @ts-ignore\n return (\n <Wrapper>\n <Autocomplete\n /* @ts-ignore */\n clearOnBlur={true}\n disablePortal={true}\n filterOptions={(options, state) => (state.inputValue.trim() ? options : [])}\n fullWidth={true}\n getOptionLabel={getOptionLabel}\n id=\"search-header-suggest\"\n inputValue={inputValue}\n loading={suggestionsLoading}\n loadingText={t('autoComplete.loading')}\n noOptionsText={t('autoComplete.no-results-found')}\n onChange={onSelectItem as any}\n onClose={handleOnClose}\n onInputChange={handleOnInputChange}\n options={suggestions}\n renderInput={renderInput}\n renderOption={renderOption}\n renderTags={() => null}\n />\n </Wrapper>\n );\n};\n\nexport default AutoComplete;\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"AutoComplete.mjs","names":[],"sources":["../../../../src/components/Search/AutoComplete/AutoComplete.tsx"],"sourcesContent":["import Autocomplete from '@mui/material/Autocomplete';\nimport type { FC } from 'react';\nimport React, { useState } from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport type { SearchResultWeb } from '@verdaccio/types';\n\nimport { Wrapper } from './styles';\n\nexport type OnSelecItem = (\n event: React.SyntheticEvent,\n value: SearchResultWeb,\n reason: string,\n details?: string\n) => void;\ninterface Props {\n suggestions?: SearchResultWeb[];\n suggestionsLoading?: boolean;\n hasError?: boolean;\n placeholder: string;\n renderOption?: (props: any, option: any) => React.JSX.Element;\n renderInput: (params: any) => React.JSX.Element;\n onSuggestionsFetch: any;\n getOptionLabel: (option: any) => any;\n onCleanSuggestions: (event: React.SyntheticEvent) => void;\n onSelectItem: OnSelecItem;\n}\n\nconst AutoComplete: FC<Props> = ({\n suggestions = [],\n onSuggestionsFetch,\n onCleanSuggestions,\n renderInput,\n renderOption,\n getOptionLabel,\n onSelectItem,\n suggestionsLoading = false,\n hasError = false,\n}: Props) => {\n const { t } = useTranslation();\n const [inputValue, setInputValue] = useState('');\n\n const handleOnInputChange = (event: React.SyntheticEvent, value: string, reason: string) => {\n if (reason === 'input') {\n event.preventDefault();\n onSuggestionsFetch({ value });\n setInputValue(value);\n } else if (reason === 'clear') {\n onCleanSuggestions(event);\n setInputValue('');\n }\n };\n\n const handleOnClose = (event) => {\n onCleanSuggestions(event);\n setInputValue('');\n };\n\n // @ts-ignore\n return (\n <Wrapper>\n <Autocomplete\n /* @ts-ignore */\n clearOnBlur={true}\n disablePortal={true}\n filterOptions={(options, state) => (state.inputValue.trim() ? options : [])}\n fullWidth={true}\n getOptionLabel={getOptionLabel}\n id=\"search-header-suggest\"\n inputValue={inputValue}\n loading={suggestionsLoading}\n loadingText={t('autoComplete.loading')}\n // a failed search must not read as \"no results found\"\n noOptionsText={hasError ? t('autoComplete.error') : t('autoComplete.no-results-found')}\n onChange={onSelectItem as any}\n onClose={handleOnClose}\n onInputChange={handleOnInputChange}\n options={hasError ? [] : suggestions}\n renderInput={renderInput}\n renderOption={renderOption}\n renderTags={() => null}\n />\n </Wrapper>\n );\n};\n\nexport default AutoComplete;\n"],"mappings":";;;;;;AA4BA,IAAM,gBAA2B,EAC/B,cAAc,CAAC,GACf,oBACA,oBACA,aACA,cACA,gBACA,cACA,qBAAqB,OACrB,WAAW,YACA;CACX,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,CAAC,YAAY,iBAAiB,SAAS,EAAE;CAE/C,MAAM,uBAAuB,OAA6B,OAAe,WAAmB;EAC1F,IAAI,WAAW,SAAS;GACtB,MAAM,eAAe;GACrB,mBAAmB,EAAE,MAAM,CAAC;GAC5B,cAAc,KAAK;EACrB,OAAO,IAAI,WAAW,SAAS;GAC7B,mBAAmB,KAAK;GACxB,cAAc,EAAE;EAClB;CACF;CAEA,MAAM,iBAAiB,UAAU;EAC/B,mBAAmB,KAAK;EACxB,cAAc,EAAE;CAClB;CAGA,OACE,oBAAC,SAAD,EAAA,UACE,oBAAC,cAAD;EAEE,aAAa;EACb,eAAe;EACf,gBAAgB,SAAS,UAAW,MAAM,WAAW,KAAK,IAAI,UAAU,CAAC;EACzE,WAAW;EACK;EAChB,IAAG;EACS;EACZ,SAAS;EACT,aAAa,EAAE,sBAAsB;EAErC,eAAe,WAAW,EAAE,oBAAoB,IAAI,EAAE,+BAA+B;EACrF,UAAU;EACV,SAAS;EACT,eAAe;EACf,SAAS,WAAW,CAAC,IAAI;EACZ;EACC;EACd,kBAAkB;CACnB,CAAA,EACM,CAAA;AAEb"}
|
|
@@ -10,9 +10,9 @@ const require_styles = require("./styles.js");
|
|
|
10
10
|
require("../../index.js");
|
|
11
11
|
let react = require("react");
|
|
12
12
|
react = require_runtime.__toESM(react);
|
|
13
|
+
let react_i18next = require("react-i18next");
|
|
13
14
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
14
15
|
let lodash_es = require("lodash-es");
|
|
15
|
-
let react_i18next = require("react-i18next");
|
|
16
16
|
let react_router = require("react-router");
|
|
17
17
|
let _mui_icons_material_Search = require("@mui/icons-material/Search");
|
|
18
18
|
_mui_icons_material_Search = require_runtime.__toESM(_mui_icons_material_Search);
|
|
@@ -24,7 +24,7 @@ var CONSTANTS = {
|
|
|
24
24
|
var Search = () => {
|
|
25
25
|
const { t } = (0, react_i18next.useTranslation)();
|
|
26
26
|
const navigate = (0, react_router.useNavigate)();
|
|
27
|
-
const { searchResults, isLoading, doSearch } = require_SearchProvider.useSearch();
|
|
27
|
+
const { searchResults, isLoading, isError, doSearch, resetSearch } = require_SearchProvider.useSearch();
|
|
28
28
|
const abortControllerRef = (0, react.useRef)(null);
|
|
29
29
|
const cancelAllSearchRequests = (0, react.useCallback)(() => {
|
|
30
30
|
if (abortControllerRef.current) {
|
|
@@ -45,11 +45,13 @@ var Search = () => {
|
|
|
45
45
|
}, [navigate]);
|
|
46
46
|
const doSearchRef = (0, react.useRef)(doSearch);
|
|
47
47
|
doSearchRef.current = doSearch;
|
|
48
|
+
const [isDebouncing, setIsDebouncing] = (0, react.useState)(false);
|
|
48
49
|
/**
|
|
49
50
|
* Stable fetch function that reads the latest doSearch from a ref,
|
|
50
51
|
* avoiding dependency changes that would break the debounce.
|
|
51
52
|
*/
|
|
52
53
|
const handleFetchPackages = (0, react.useCallback)(async ({ value }) => {
|
|
54
|
+
setIsDebouncing(false);
|
|
53
55
|
if (value?.trim() !== "") {
|
|
54
56
|
cancelAllSearchRequests();
|
|
55
57
|
const controller = new AbortController();
|
|
@@ -66,6 +68,11 @@ var Search = () => {
|
|
|
66
68
|
}
|
|
67
69
|
}, [cancelAllSearchRequests]);
|
|
68
70
|
const debouncedFetch = (0, react.useMemo)(() => (0, lodash_es.debounce)(handleFetchPackages, CONSTANTS.API_DELAY), [handleFetchPackages]);
|
|
71
|
+
const handleSuggestionsFetch = (0, react.useCallback)(({ value }) => {
|
|
72
|
+
resetSearch?.();
|
|
73
|
+
if (value?.trim() !== "") setIsDebouncing(true);
|
|
74
|
+
debouncedFetch({ value });
|
|
75
|
+
}, [resetSearch, debouncedFetch]);
|
|
69
76
|
(0, react.useEffect)(() => {
|
|
70
77
|
return () => {
|
|
71
78
|
debouncedFetch.cancel?.();
|
|
@@ -105,14 +112,15 @@ var Search = () => {
|
|
|
105
112
|
};
|
|
106
113
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AutoComplete.default, {
|
|
107
114
|
getOptionLabel,
|
|
115
|
+
hasError: isError,
|
|
108
116
|
onCleanSuggestions: handleOnBlur,
|
|
109
117
|
onSelectItem: handleClickSearch,
|
|
110
|
-
onSuggestionsFetch:
|
|
118
|
+
onSuggestionsFetch: handleSuggestionsFetch,
|
|
111
119
|
placeholder: t("search.packages"),
|
|
112
120
|
renderInput,
|
|
113
121
|
renderOption,
|
|
114
122
|
suggestions: searchResults,
|
|
115
|
-
suggestionsLoading: isLoading
|
|
123
|
+
suggestionsLoading: isLoading || isDebouncing
|
|
116
124
|
});
|
|
117
125
|
};
|
|
118
126
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Search.js","names":[],"sources":["../../../src/components/Search/Search.tsx"],"sourcesContent":["import SearchMui from '@mui/icons-material/Search';\nimport { debounce } from 'lodash-es';\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useNavigate } from 'react-router';\n\nimport { useSearch } from '../../';\nimport { Route } from '../../utils';\nimport AutoComplete from './AutoComplete';\nimport SearchItem from './SearchItem';\nimport { StyledInputAdornment, StyledTextField } from './styles';\nimport { normalizeSearchOption } from './utils';\n\nconst CONSTANTS = {\n API_DELAY: 300,\n ABORT_ERROR: 'AbortError',\n};\n\nconst Search: React.FC = () => {\n const { t } = useTranslation();\n const navigate = useNavigate();\n const { searchResults, isLoading, doSearch } = useSearch();\n\n const abortControllerRef = useRef<AbortController | null>(null);\n\n const cancelAllSearchRequests = useCallback(() => {\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n abortControllerRef.current = null;\n }\n }, []);\n\n const handleOnBlur = useCallback(\n (event: React.SyntheticEvent) => {\n event.stopPropagation();\n cancelAllSearchRequests();\n },\n [cancelAllSearchRequests]\n );\n\n const handleClickSearch = useCallback(\n (event: React.SyntheticEvent, value: any, reason: string): void => {\n event.stopPropagation();\n if (reason === 'selectOption') {\n const { name } = normalizeSearchOption(value);\n if (name) {\n navigate(`${Route.DETAIL}${name}`);\n }\n }\n },\n [navigate]\n );\n\n // Use a ref to always access the latest doSearch without re-creating the debounced function\n const doSearchRef = useRef(doSearch);\n doSearchRef.current = doSearch;\n\n /**\n * Stable fetch function that reads the latest doSearch from a ref,\n * avoiding dependency changes that would break the debounce.\n */\n const handleFetchPackages = useCallback(\n async ({ value }: { value: string }) => {\n if (value?.trim() !== '') {\n // Abort any previous pending request before starting a new one\n cancelAllSearchRequests();\n\n // Create a new controller for the current request\n const controller = new AbortController();\n abortControllerRef.current = controller;\n\n try {\n await doSearchRef.current?.({\n text: value,\n signal: controller.signal,\n });\n } catch (err: any) {\n if (err.name === CONSTANTS.ABORT_ERROR) {\n console.warn('Search request aborted');\n } else {\n console.error('Search error:', err);\n }\n }\n }\n },\n [cancelAllSearchRequests]\n );\n\n // Memoize the debounced function so a single instance is reused across renders,\n // ensuring the debounce timer works correctly instead of creating a new timer per render.\n const debouncedFetch = useMemo(\n () => debounce(handleFetchPackages, CONSTANTS.API_DELAY),\n [handleFetchPackages]\n );\n\n useEffect(() => {\n return () => {\n debouncedFetch.cancel?.();\n cancelAllSearchRequests();\n };\n }, [debouncedFetch, cancelAllSearchRequests]);\n\n const renderOption = (props, option) => {\n const { key, ...otherProps } = props;\n const { name, version, description, isPrivate, isCached, isRemote } =\n normalizeSearchOption(option);\n return (\n <SearchItem\n key={key}\n {...otherProps}\n description={description}\n isCached={isCached}\n isPrivate={isPrivate}\n isRemote={isRemote}\n name={name}\n version={version}\n />\n );\n };\n\n const renderInput = (params) => {\n return (\n <StyledTextField\n {...params}\n InputProps={{\n ...params.InputProps,\n startAdornment: (\n <StyledInputAdornment position=\"start\">\n <SearchMui />\n </StyledInputAdornment>\n ),\n }}\n label=\"\"\n placeholder={t('search.packages')}\n variant=\"standard\"\n />\n );\n };\n\n const getOptionLabel = (option) => {\n return normalizeSearchOption(option).name;\n };\n\n return (\n <AutoComplete\n getOptionLabel={getOptionLabel}\n onCleanSuggestions={handleOnBlur}\n onSelectItem={handleClickSearch}\n onSuggestionsFetch={
|
|
1
|
+
{"version":3,"file":"Search.js","names":[],"sources":["../../../src/components/Search/Search.tsx"],"sourcesContent":["import SearchMui from '@mui/icons-material/Search';\nimport { debounce } from 'lodash-es';\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useNavigate } from 'react-router';\n\nimport { useSearch } from '../../';\nimport { Route } from '../../utils';\nimport AutoComplete from './AutoComplete';\nimport SearchItem from './SearchItem';\nimport { StyledInputAdornment, StyledTextField } from './styles';\nimport { normalizeSearchOption } from './utils';\n\nconst CONSTANTS = {\n API_DELAY: 300,\n ABORT_ERROR: 'AbortError',\n};\n\nconst Search: React.FC = () => {\n const { t } = useTranslation();\n const navigate = useNavigate();\n const { searchResults, isLoading, isError, doSearch, resetSearch } = useSearch();\n\n const abortControllerRef = useRef<AbortController | null>(null);\n\n const cancelAllSearchRequests = useCallback(() => {\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n abortControllerRef.current = null;\n }\n }, []);\n\n const handleOnBlur = useCallback(\n (event: React.SyntheticEvent) => {\n event.stopPropagation();\n cancelAllSearchRequests();\n },\n [cancelAllSearchRequests]\n );\n\n const handleClickSearch = useCallback(\n (event: React.SyntheticEvent, value: any, reason: string): void => {\n event.stopPropagation();\n if (reason === 'selectOption') {\n const { name } = normalizeSearchOption(value);\n if (name) {\n navigate(`${Route.DETAIL}${name}`);\n }\n }\n },\n [navigate]\n );\n\n // Use a ref to always access the latest doSearch without re-creating the debounced function\n const doSearchRef = useRef(doSearch);\n doSearchRef.current = doSearch;\n\n // shows the dropdown as loading during the debounce window; without it the\n // immediate reset below reads as \"no results found\" on every keystroke\n const [isDebouncing, setIsDebouncing] = useState(false);\n\n /**\n * Stable fetch function that reads the latest doSearch from a ref,\n * avoiding dependency changes that would break the debounce.\n */\n const handleFetchPackages = useCallback(\n async ({ value }: { value: string }) => {\n setIsDebouncing(false);\n if (value?.trim() !== '') {\n // Abort any previous pending request before starting a new one\n cancelAllSearchRequests();\n\n // Create a new controller for the current request\n const controller = new AbortController();\n abortControllerRef.current = controller;\n\n try {\n await doSearchRef.current?.({\n text: value,\n signal: controller.signal,\n });\n } catch (err: any) {\n if (err.name === CONSTANTS.ABORT_ERROR) {\n console.warn('Search request aborted');\n } else {\n console.error('Search error:', err);\n }\n }\n }\n },\n [cancelAllSearchRequests]\n );\n\n // Memoize the debounced function so a single instance is reused across renders,\n // ensuring the debounce timer works correctly instead of creating a new timer per render.\n const debouncedFetch = useMemo(\n () => debounce(handleFetchPackages, CONSTANTS.API_DELAY),\n [handleFetchPackages]\n );\n\n // clear the previous query's results right away so the dropdown never lists\n // stale suggestions under the new input while the debounce timer runs\n const handleSuggestionsFetch = useCallback(\n ({ value }: { value: string }) => {\n resetSearch?.();\n if (value?.trim() !== '') {\n setIsDebouncing(true);\n }\n debouncedFetch({ value });\n },\n [resetSearch, debouncedFetch]\n );\n\n useEffect(() => {\n return () => {\n debouncedFetch.cancel?.();\n cancelAllSearchRequests();\n };\n }, [debouncedFetch, cancelAllSearchRequests]);\n\n const renderOption = (props, option) => {\n const { key, ...otherProps } = props;\n const { name, version, description, isPrivate, isCached, isRemote } =\n normalizeSearchOption(option);\n return (\n <SearchItem\n key={key}\n {...otherProps}\n description={description}\n isCached={isCached}\n isPrivate={isPrivate}\n isRemote={isRemote}\n name={name}\n version={version}\n />\n );\n };\n\n const renderInput = (params) => {\n return (\n <StyledTextField\n {...params}\n InputProps={{\n ...params.InputProps,\n startAdornment: (\n <StyledInputAdornment position=\"start\">\n <SearchMui />\n </StyledInputAdornment>\n ),\n }}\n label=\"\"\n placeholder={t('search.packages')}\n variant=\"standard\"\n />\n );\n };\n\n const getOptionLabel = (option) => {\n return normalizeSearchOption(option).name;\n };\n\n return (\n <AutoComplete\n getOptionLabel={getOptionLabel}\n hasError={isError}\n onCleanSuggestions={handleOnBlur}\n onSelectItem={handleClickSearch}\n onSuggestionsFetch={handleSuggestionsFetch}\n placeholder={t('search.packages')}\n renderInput={renderInput}\n renderOption={renderOption}\n suggestions={searchResults}\n suggestionsLoading={isLoading || isDebouncing}\n />\n );\n};\n\nexport default Search;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAaA,IAAM,YAAY;CAChB,WAAW;CACX,aAAa;AACf;AAEA,IAAM,eAAyB;CAC7B,MAAM,EAAE,OAAA,GAAM,cAAA,eAAA,CAAe;CAC7B,MAAM,YAAA,GAAW,aAAA,YAAA,CAAY;CAC7B,MAAM,EAAE,eAAe,WAAW,SAAS,UAAU,gBAAgB,uBAAA,UAAU;CAE/E,MAAM,sBAAA,GAAqB,MAAA,OAAA,CAA+B,IAAI;CAE9D,MAAM,2BAAA,GAA0B,MAAA,YAAA,OAAkB;EAChD,IAAI,mBAAmB,SAAS;GAC9B,mBAAmB,QAAQ,MAAM;GACjC,mBAAmB,UAAU;EAC/B;CACF,GAAG,CAAC,CAAC;CAEL,MAAM,gBAAA,GAAe,MAAA,YAAA,EAClB,UAAgC;EAC/B,MAAM,gBAAgB;EACtB,wBAAwB;CAC1B,GACA,CAAC,uBAAuB,CAC1B;CAEA,MAAM,qBAAA,GAAoB,MAAA,YAAA,EACvB,OAA6B,OAAY,WAAyB;EACjE,MAAM,gBAAgB;EACtB,IAAI,WAAW,gBAAgB;GAC7B,MAAM,EAAE,SAAS,cAAA,sBAAsB,KAAK;GAC5C,IAAI,MACF,SAAS,GAAG,eAAA,MAAM,SAAS,MAAM;EAErC;CACF,GACA,CAAC,QAAQ,CACX;CAGA,MAAM,eAAA,GAAc,MAAA,OAAA,CAAO,QAAQ;CACnC,YAAY,UAAU;CAItB,MAAM,CAAC,cAAc,oBAAA,GAAmB,MAAA,SAAA,CAAS,KAAK;;;;;CAMtD,MAAM,uBAAA,GAAsB,MAAA,YAAA,CAC1B,OAAO,EAAE,YAA+B;EACtC,gBAAgB,KAAK;EACrB,IAAI,OAAO,KAAK,MAAM,IAAI;GAExB,wBAAwB;GAGxB,MAAM,aAAa,IAAI,gBAAgB;GACvC,mBAAmB,UAAU;GAE7B,IAAI;IACF,MAAM,YAAY,UAAU;KAC1B,MAAM;KACN,QAAQ,WAAW;IACrB,CAAC;GACH,SAAS,KAAU;IACjB,IAAI,IAAI,SAAS,UAAU,aACzB,QAAQ,KAAK,wBAAwB;SAErC,QAAQ,MAAM,iBAAiB,GAAG;GAEtC;EACF;CACF,GACA,CAAC,uBAAuB,CAC1B;CAIA,MAAM,kBAAA,GAAiB,MAAA,QAAA,QAAA,GACf,UAAA,SAAA,CAAS,qBAAqB,UAAU,SAAS,GACvD,CAAC,mBAAmB,CACtB;CAIA,MAAM,0BAAA,GAAyB,MAAA,YAAA,EAC5B,EAAE,YAA+B;EAChC,cAAc;EACd,IAAI,OAAO,KAAK,MAAM,IACpB,gBAAgB,IAAI;EAEtB,eAAe,EAAE,MAAM,CAAC;CAC1B,GACA,CAAC,aAAa,cAAc,CAC9B;CAEA,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,aAAa;GACX,eAAe,SAAS;GACxB,wBAAwB;EAC1B;CACF,GAAG,CAAC,gBAAgB,uBAAuB,CAAC;CAE5C,MAAM,gBAAgB,OAAO,WAAW;EACtC,MAAM,EAAE,KAAK,GAAG,eAAe;EAC/B,MAAM,EAAE,MAAM,SAAS,aAAa,WAAW,UAAU,aACvD,cAAA,sBAAsB,MAAM;EAC9B,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,mBAAA,SAAD;GAEE,GAAI;GACS;GACH;GACC;GACD;GACJ;GACG;EACV,GARM,GAQN;CAEL;CAEA,MAAM,eAAe,WAAW;EAC9B,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAA,iBAAD;GACE,GAAI;GACJ,YAAY;IACV,GAAG,OAAO;IACV,gBACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAA,sBAAD;KAAsB,UAAS;KAC7B,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,2BAAA,SAAD,CAAY,CAAA;IACQ,CAAA;GAE1B;GACA,OAAM;GACN,aAAa,EAAE,iBAAiB;GAChC,SAAQ;EACT,CAAA;CAEL;CAEA,MAAM,kBAAkB,WAAW;EACjC,OAAO,cAAA,sBAAsB,MAAM,CAAC,CAAC;CACvC;CAEA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,qBAAA,SAAD;EACkB;EAChB,UAAU;EACV,oBAAoB;EACpB,cAAc;EACd,oBAAoB;EACpB,aAAa,EAAE,iBAAiB;EACnB;EACC;EACd,aAAa;EACb,oBAAoB,aAAa;CAClC,CAAA;AAEL"}
|
|
@@ -7,10 +7,10 @@ import { normalizeSearchOption } from "./utils.mjs";
|
|
|
7
7
|
import SearchItem from "./SearchItem.mjs";
|
|
8
8
|
import { StyledInputAdornment, StyledTextField } from "./styles.mjs";
|
|
9
9
|
import "../../index.mjs";
|
|
10
|
-
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
10
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
11
|
+
import { useTranslation } from "react-i18next";
|
|
11
12
|
import { jsx } from "react/jsx-runtime";
|
|
12
13
|
import { debounce } from "lodash-es";
|
|
13
|
-
import { useTranslation } from "react-i18next";
|
|
14
14
|
import { useNavigate } from "react-router";
|
|
15
15
|
import SearchMui from "@mui/icons-material/Search";
|
|
16
16
|
//#region src/components/Search/Search.tsx
|
|
@@ -21,7 +21,7 @@ var CONSTANTS = {
|
|
|
21
21
|
var Search = () => {
|
|
22
22
|
const { t } = useTranslation();
|
|
23
23
|
const navigate = useNavigate();
|
|
24
|
-
const { searchResults, isLoading, doSearch } = useSearch();
|
|
24
|
+
const { searchResults, isLoading, isError, doSearch, resetSearch } = useSearch();
|
|
25
25
|
const abortControllerRef = useRef(null);
|
|
26
26
|
const cancelAllSearchRequests = useCallback(() => {
|
|
27
27
|
if (abortControllerRef.current) {
|
|
@@ -42,11 +42,13 @@ var Search = () => {
|
|
|
42
42
|
}, [navigate]);
|
|
43
43
|
const doSearchRef = useRef(doSearch);
|
|
44
44
|
doSearchRef.current = doSearch;
|
|
45
|
+
const [isDebouncing, setIsDebouncing] = useState(false);
|
|
45
46
|
/**
|
|
46
47
|
* Stable fetch function that reads the latest doSearch from a ref,
|
|
47
48
|
* avoiding dependency changes that would break the debounce.
|
|
48
49
|
*/
|
|
49
50
|
const handleFetchPackages = useCallback(async ({ value }) => {
|
|
51
|
+
setIsDebouncing(false);
|
|
50
52
|
if (value?.trim() !== "") {
|
|
51
53
|
cancelAllSearchRequests();
|
|
52
54
|
const controller = new AbortController();
|
|
@@ -63,6 +65,11 @@ var Search = () => {
|
|
|
63
65
|
}
|
|
64
66
|
}, [cancelAllSearchRequests]);
|
|
65
67
|
const debouncedFetch = useMemo(() => debounce(handleFetchPackages, CONSTANTS.API_DELAY), [handleFetchPackages]);
|
|
68
|
+
const handleSuggestionsFetch = useCallback(({ value }) => {
|
|
69
|
+
resetSearch?.();
|
|
70
|
+
if (value?.trim() !== "") setIsDebouncing(true);
|
|
71
|
+
debouncedFetch({ value });
|
|
72
|
+
}, [resetSearch, debouncedFetch]);
|
|
66
73
|
useEffect(() => {
|
|
67
74
|
return () => {
|
|
68
75
|
debouncedFetch.cancel?.();
|
|
@@ -102,14 +109,15 @@ var Search = () => {
|
|
|
102
109
|
};
|
|
103
110
|
return /* @__PURE__ */ jsx(AutoComplete, {
|
|
104
111
|
getOptionLabel,
|
|
112
|
+
hasError: isError,
|
|
105
113
|
onCleanSuggestions: handleOnBlur,
|
|
106
114
|
onSelectItem: handleClickSearch,
|
|
107
|
-
onSuggestionsFetch:
|
|
115
|
+
onSuggestionsFetch: handleSuggestionsFetch,
|
|
108
116
|
placeholder: t("search.packages"),
|
|
109
117
|
renderInput,
|
|
110
118
|
renderOption,
|
|
111
119
|
suggestions: searchResults,
|
|
112
|
-
suggestionsLoading: isLoading
|
|
120
|
+
suggestionsLoading: isLoading || isDebouncing
|
|
113
121
|
});
|
|
114
122
|
};
|
|
115
123
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Search.mjs","names":[],"sources":["../../../src/components/Search/Search.tsx"],"sourcesContent":["import SearchMui from '@mui/icons-material/Search';\nimport { debounce } from 'lodash-es';\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useNavigate } from 'react-router';\n\nimport { useSearch } from '../../';\nimport { Route } from '../../utils';\nimport AutoComplete from './AutoComplete';\nimport SearchItem from './SearchItem';\nimport { StyledInputAdornment, StyledTextField } from './styles';\nimport { normalizeSearchOption } from './utils';\n\nconst CONSTANTS = {\n API_DELAY: 300,\n ABORT_ERROR: 'AbortError',\n};\n\nconst Search: React.FC = () => {\n const { t } = useTranslation();\n const navigate = useNavigate();\n const { searchResults, isLoading, doSearch } = useSearch();\n\n const abortControllerRef = useRef<AbortController | null>(null);\n\n const cancelAllSearchRequests = useCallback(() => {\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n abortControllerRef.current = null;\n }\n }, []);\n\n const handleOnBlur = useCallback(\n (event: React.SyntheticEvent) => {\n event.stopPropagation();\n cancelAllSearchRequests();\n },\n [cancelAllSearchRequests]\n );\n\n const handleClickSearch = useCallback(\n (event: React.SyntheticEvent, value: any, reason: string): void => {\n event.stopPropagation();\n if (reason === 'selectOption') {\n const { name } = normalizeSearchOption(value);\n if (name) {\n navigate(`${Route.DETAIL}${name}`);\n }\n }\n },\n [navigate]\n );\n\n // Use a ref to always access the latest doSearch without re-creating the debounced function\n const doSearchRef = useRef(doSearch);\n doSearchRef.current = doSearch;\n\n /**\n * Stable fetch function that reads the latest doSearch from a ref,\n * avoiding dependency changes that would break the debounce.\n */\n const handleFetchPackages = useCallback(\n async ({ value }: { value: string }) => {\n if (value?.trim() !== '') {\n // Abort any previous pending request before starting a new one\n cancelAllSearchRequests();\n\n // Create a new controller for the current request\n const controller = new AbortController();\n abortControllerRef.current = controller;\n\n try {\n await doSearchRef.current?.({\n text: value,\n signal: controller.signal,\n });\n } catch (err: any) {\n if (err.name === CONSTANTS.ABORT_ERROR) {\n console.warn('Search request aborted');\n } else {\n console.error('Search error:', err);\n }\n }\n }\n },\n [cancelAllSearchRequests]\n );\n\n // Memoize the debounced function so a single instance is reused across renders,\n // ensuring the debounce timer works correctly instead of creating a new timer per render.\n const debouncedFetch = useMemo(\n () => debounce(handleFetchPackages, CONSTANTS.API_DELAY),\n [handleFetchPackages]\n );\n\n useEffect(() => {\n return () => {\n debouncedFetch.cancel?.();\n cancelAllSearchRequests();\n };\n }, [debouncedFetch, cancelAllSearchRequests]);\n\n const renderOption = (props, option) => {\n const { key, ...otherProps } = props;\n const { name, version, description, isPrivate, isCached, isRemote } =\n normalizeSearchOption(option);\n return (\n <SearchItem\n key={key}\n {...otherProps}\n description={description}\n isCached={isCached}\n isPrivate={isPrivate}\n isRemote={isRemote}\n name={name}\n version={version}\n />\n );\n };\n\n const renderInput = (params) => {\n return (\n <StyledTextField\n {...params}\n InputProps={{\n ...params.InputProps,\n startAdornment: (\n <StyledInputAdornment position=\"start\">\n <SearchMui />\n </StyledInputAdornment>\n ),\n }}\n label=\"\"\n placeholder={t('search.packages')}\n variant=\"standard\"\n />\n );\n };\n\n const getOptionLabel = (option) => {\n return normalizeSearchOption(option).name;\n };\n\n return (\n <AutoComplete\n getOptionLabel={getOptionLabel}\n onCleanSuggestions={handleOnBlur}\n onSelectItem={handleClickSearch}\n onSuggestionsFetch={
|
|
1
|
+
{"version":3,"file":"Search.mjs","names":[],"sources":["../../../src/components/Search/Search.tsx"],"sourcesContent":["import SearchMui from '@mui/icons-material/Search';\nimport { debounce } from 'lodash-es';\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useNavigate } from 'react-router';\n\nimport { useSearch } from '../../';\nimport { Route } from '../../utils';\nimport AutoComplete from './AutoComplete';\nimport SearchItem from './SearchItem';\nimport { StyledInputAdornment, StyledTextField } from './styles';\nimport { normalizeSearchOption } from './utils';\n\nconst CONSTANTS = {\n API_DELAY: 300,\n ABORT_ERROR: 'AbortError',\n};\n\nconst Search: React.FC = () => {\n const { t } = useTranslation();\n const navigate = useNavigate();\n const { searchResults, isLoading, isError, doSearch, resetSearch } = useSearch();\n\n const abortControllerRef = useRef<AbortController | null>(null);\n\n const cancelAllSearchRequests = useCallback(() => {\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n abortControllerRef.current = null;\n }\n }, []);\n\n const handleOnBlur = useCallback(\n (event: React.SyntheticEvent) => {\n event.stopPropagation();\n cancelAllSearchRequests();\n },\n [cancelAllSearchRequests]\n );\n\n const handleClickSearch = useCallback(\n (event: React.SyntheticEvent, value: any, reason: string): void => {\n event.stopPropagation();\n if (reason === 'selectOption') {\n const { name } = normalizeSearchOption(value);\n if (name) {\n navigate(`${Route.DETAIL}${name}`);\n }\n }\n },\n [navigate]\n );\n\n // Use a ref to always access the latest doSearch without re-creating the debounced function\n const doSearchRef = useRef(doSearch);\n doSearchRef.current = doSearch;\n\n // shows the dropdown as loading during the debounce window; without it the\n // immediate reset below reads as \"no results found\" on every keystroke\n const [isDebouncing, setIsDebouncing] = useState(false);\n\n /**\n * Stable fetch function that reads the latest doSearch from a ref,\n * avoiding dependency changes that would break the debounce.\n */\n const handleFetchPackages = useCallback(\n async ({ value }: { value: string }) => {\n setIsDebouncing(false);\n if (value?.trim() !== '') {\n // Abort any previous pending request before starting a new one\n cancelAllSearchRequests();\n\n // Create a new controller for the current request\n const controller = new AbortController();\n abortControllerRef.current = controller;\n\n try {\n await doSearchRef.current?.({\n text: value,\n signal: controller.signal,\n });\n } catch (err: any) {\n if (err.name === CONSTANTS.ABORT_ERROR) {\n console.warn('Search request aborted');\n } else {\n console.error('Search error:', err);\n }\n }\n }\n },\n [cancelAllSearchRequests]\n );\n\n // Memoize the debounced function so a single instance is reused across renders,\n // ensuring the debounce timer works correctly instead of creating a new timer per render.\n const debouncedFetch = useMemo(\n () => debounce(handleFetchPackages, CONSTANTS.API_DELAY),\n [handleFetchPackages]\n );\n\n // clear the previous query's results right away so the dropdown never lists\n // stale suggestions under the new input while the debounce timer runs\n const handleSuggestionsFetch = useCallback(\n ({ value }: { value: string }) => {\n resetSearch?.();\n if (value?.trim() !== '') {\n setIsDebouncing(true);\n }\n debouncedFetch({ value });\n },\n [resetSearch, debouncedFetch]\n );\n\n useEffect(() => {\n return () => {\n debouncedFetch.cancel?.();\n cancelAllSearchRequests();\n };\n }, [debouncedFetch, cancelAllSearchRequests]);\n\n const renderOption = (props, option) => {\n const { key, ...otherProps } = props;\n const { name, version, description, isPrivate, isCached, isRemote } =\n normalizeSearchOption(option);\n return (\n <SearchItem\n key={key}\n {...otherProps}\n description={description}\n isCached={isCached}\n isPrivate={isPrivate}\n isRemote={isRemote}\n name={name}\n version={version}\n />\n );\n };\n\n const renderInput = (params) => {\n return (\n <StyledTextField\n {...params}\n InputProps={{\n ...params.InputProps,\n startAdornment: (\n <StyledInputAdornment position=\"start\">\n <SearchMui />\n </StyledInputAdornment>\n ),\n }}\n label=\"\"\n placeholder={t('search.packages')}\n variant=\"standard\"\n />\n );\n };\n\n const getOptionLabel = (option) => {\n return normalizeSearchOption(option).name;\n };\n\n return (\n <AutoComplete\n getOptionLabel={getOptionLabel}\n hasError={isError}\n onCleanSuggestions={handleOnBlur}\n onSelectItem={handleClickSearch}\n onSuggestionsFetch={handleSuggestionsFetch}\n placeholder={t('search.packages')}\n renderInput={renderInput}\n renderOption={renderOption}\n suggestions={searchResults}\n suggestionsLoading={isLoading || isDebouncing}\n />\n );\n};\n\nexport default Search;\n"],"mappings":";;;;;;;;;;;;;;;;AAaA,IAAM,YAAY;CAChB,WAAW;CACX,aAAa;AACf;AAEA,IAAM,eAAyB;CAC7B,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,WAAW,YAAY;CAC7B,MAAM,EAAE,eAAe,WAAW,SAAS,UAAU,gBAAgB,UAAU;CAE/E,MAAM,qBAAqB,OAA+B,IAAI;CAE9D,MAAM,0BAA0B,kBAAkB;EAChD,IAAI,mBAAmB,SAAS;GAC9B,mBAAmB,QAAQ,MAAM;GACjC,mBAAmB,UAAU;EAC/B;CACF,GAAG,CAAC,CAAC;CAEL,MAAM,eAAe,aAClB,UAAgC;EAC/B,MAAM,gBAAgB;EACtB,wBAAwB;CAC1B,GACA,CAAC,uBAAuB,CAC1B;CAEA,MAAM,oBAAoB,aACvB,OAA6B,OAAY,WAAyB;EACjE,MAAM,gBAAgB;EACtB,IAAI,WAAW,gBAAgB;GAC7B,MAAM,EAAE,SAAS,sBAAsB,KAAK;GAC5C,IAAI,MACF,SAAS,GAAG,QAAM,SAAS,MAAM;EAErC;CACF,GACA,CAAC,QAAQ,CACX;CAGA,MAAM,cAAc,OAAO,QAAQ;CACnC,YAAY,UAAU;CAItB,MAAM,CAAC,cAAc,mBAAmB,SAAS,KAAK;;;;;CAMtD,MAAM,sBAAsB,YAC1B,OAAO,EAAE,YAA+B;EACtC,gBAAgB,KAAK;EACrB,IAAI,OAAO,KAAK,MAAM,IAAI;GAExB,wBAAwB;GAGxB,MAAM,aAAa,IAAI,gBAAgB;GACvC,mBAAmB,UAAU;GAE7B,IAAI;IACF,MAAM,YAAY,UAAU;KAC1B,MAAM;KACN,QAAQ,WAAW;IACrB,CAAC;GACH,SAAS,KAAU;IACjB,IAAI,IAAI,SAAS,UAAU,aACzB,QAAQ,KAAK,wBAAwB;SAErC,QAAQ,MAAM,iBAAiB,GAAG;GAEtC;EACF;CACF,GACA,CAAC,uBAAuB,CAC1B;CAIA,MAAM,iBAAiB,cACf,SAAS,qBAAqB,UAAU,SAAS,GACvD,CAAC,mBAAmB,CACtB;CAIA,MAAM,yBAAyB,aAC5B,EAAE,YAA+B;EAChC,cAAc;EACd,IAAI,OAAO,KAAK,MAAM,IACpB,gBAAgB,IAAI;EAEtB,eAAe,EAAE,MAAM,CAAC;CAC1B,GACA,CAAC,aAAa,cAAc,CAC9B;CAEA,gBAAgB;EACd,aAAa;GACX,eAAe,SAAS;GACxB,wBAAwB;EAC1B;CACF,GAAG,CAAC,gBAAgB,uBAAuB,CAAC;CAE5C,MAAM,gBAAgB,OAAO,WAAW;EACtC,MAAM,EAAE,KAAK,GAAG,eAAe;EAC/B,MAAM,EAAE,MAAM,SAAS,aAAa,WAAW,UAAU,aACvD,sBAAsB,MAAM;EAC9B,OACE,oBAAC,YAAD;GAEE,GAAI;GACS;GACH;GACC;GACD;GACJ;GACG;EACV,GARM,GAQN;CAEL;CAEA,MAAM,eAAe,WAAW;EAC9B,OACE,oBAAC,iBAAD;GACE,GAAI;GACJ,YAAY;IACV,GAAG,OAAO;IACV,gBACE,oBAAC,sBAAD;KAAsB,UAAS;KAC7B,UAAA,oBAAC,WAAD,CAAY,CAAA;IACQ,CAAA;GAE1B;GACA,OAAM;GACN,aAAa,EAAE,iBAAiB;GAChC,SAAQ;EACT,CAAA;CAEL;CAEA,MAAM,kBAAkB,WAAW;EACjC,OAAO,sBAAsB,MAAM,CAAC,CAAC;CACvC;CAEA,OACE,oBAAC,cAAD;EACkB;EAChB,UAAU;EACV,oBAAoB;EACpB,cAAc;EACd,oBAAoB;EACpB,aAAa,EAAE,iBAAiB;EACnB;EACC;EACd,aAAa;EACb,oBAAoB,aAAa;CAClC,CAAA;AAEL"}
|
|
@@ -6,10 +6,10 @@ let _emotion_styled = require("@emotion/styled");
|
|
|
6
6
|
_emotion_styled = require_runtime.__toESM(_emotion_styled);
|
|
7
7
|
let react = require("react");
|
|
8
8
|
react = require_runtime.__toESM(react);
|
|
9
|
+
let react_i18next = require("react-i18next");
|
|
9
10
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
11
|
let _mui_material_Stack = require("@mui/material/Stack");
|
|
11
12
|
_mui_material_Stack = require_runtime.__toESM(_mui_material_Stack);
|
|
12
|
-
let react_i18next = require("react-i18next");
|
|
13
13
|
let _mui_material_Chip = require("@mui/material/Chip");
|
|
14
14
|
_mui_material_Chip = require_runtime.__toESM(_mui_material_Chip);
|
|
15
15
|
let _mui_icons_material_Cached = require("@mui/icons-material/Cached");
|
|
@@ -3,9 +3,9 @@ import { cleanDescription } from "./utils.mjs";
|
|
|
3
3
|
import "../../index.mjs";
|
|
4
4
|
import styled from "@emotion/styled";
|
|
5
5
|
import "react";
|
|
6
|
+
import { useTranslation } from "react-i18next";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import Stack from "@mui/material/Stack";
|
|
8
|
-
import { useTranslation } from "react-i18next";
|
|
9
9
|
import Chip from "@mui/material/Chip";
|
|
10
10
|
import Cached from "@mui/icons-material/Cached";
|
|
11
11
|
import HttpsIcon from "@mui/icons-material/Https";
|
|
@@ -7,8 +7,8 @@ let _mui_material_IconButton = require("@mui/material/IconButton");
|
|
|
7
7
|
_mui_material_IconButton = require_runtime.__toESM(_mui_material_IconButton);
|
|
8
8
|
let react = require("react");
|
|
9
9
|
react = require_runtime.__toESM(react);
|
|
10
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
10
|
let react_i18next = require("react-i18next");
|
|
11
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
12
|
let _mui_icons_material_Check = require("@mui/icons-material/Check");
|
|
13
13
|
_mui_icons_material_Check = require_runtime.__toESM(_mui_icons_material_Check);
|
|
14
14
|
let _mui_icons_material_Settings = require("@mui/icons-material/Settings");
|
|
@@ -4,8 +4,8 @@ import "../../providers/PersistenceSettingProvider/index.mjs";
|
|
|
4
4
|
import "../../providers/index.mjs";
|
|
5
5
|
import IconButton from "@mui/material/IconButton";
|
|
6
6
|
import React from "react";
|
|
7
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
7
|
import { useTranslation } from "react-i18next";
|
|
8
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import Check from "@mui/icons-material/Check";
|
|
10
10
|
import Settings from "@mui/icons-material/Settings";
|
|
11
11
|
import ListItemIcon from "@mui/material/ListItemIcon";
|
|
@@ -10,10 +10,10 @@ let _emotion_styled = require("@emotion/styled");
|
|
|
10
10
|
_emotion_styled = require_runtime.__toESM(_emotion_styled);
|
|
11
11
|
let react = require("react");
|
|
12
12
|
react = require_runtime.__toESM(react);
|
|
13
|
+
let react_i18next = require("react-i18next");
|
|
13
14
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
14
15
|
let _mui_material_Box = require("@mui/material/Box");
|
|
15
16
|
_mui_material_Box = require_runtime.__toESM(_mui_material_Box);
|
|
16
|
-
let react_i18next = require("react-i18next");
|
|
17
17
|
//#region src/components/SideBarTitle/SideBarTitle.tsx
|
|
18
18
|
var Icon = _emotion_styled.default.div(({ theme }) => ({ marginLeft: theme.spacing(1) }));
|
|
19
19
|
var ModuleJS = ({ module }) => {
|
|
@@ -36,7 +36,7 @@ var DetailSidebarTitle = ({ description, packageName, version, isLatest, hasType
|
|
|
36
36
|
] }) }) }),
|
|
37
37
|
description && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: description }),
|
|
38
38
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledBoxVersion, {
|
|
39
|
-
title: require_utils.formatDate(time),
|
|
39
|
+
title: time ? require_utils.formatDate(time) : void 0,
|
|
40
40
|
children: [isLatest ? t("sidebar.detail.latest-version", { version }) : t("sidebar.detail.version", { version }), time ? " - " + t("sidebar.detail.published") + " " + require_utils.formatDateDistance(time) : t("versions.not-available")]
|
|
41
41
|
})
|
|
42
42
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SideBarTitle.js","names":[],"sources":["../../../src/components/SideBarTitle/SideBarTitle.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport Box from '@mui/material/Box';\nimport React from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport type { Theme } from '../../Theme';\nimport Heading from '../Heading';\nimport { CommonJS, ES6Modules, TypeScript } from '../Icons';\nimport { formatDate, formatDateDistance } from './utils';\n\nexport type ModuleType = 'commonjs' | 'module';\n\ninterface Props {\n packageName: string;\n description?: string;\n version: string;\n isLatest: boolean;\n hasTypes?: boolean;\n moduleTypes: ModuleType[];\n time: string;\n}\n\nconst Icon = styled.div<{ theme?: Theme }>(({ theme }) => ({\n marginLeft: theme.spacing(1),\n}));\n\nconst ModuleJS: React.FC<{ module: ModuleType | void }> = ({ module }) => {\n if (module === 'commonjs') {\n return (\n <Icon>\n <CommonJS />\n </Icon>\n );\n } else if (module === 'module') {\n return (\n <Icon>\n <ES6Modules />\n </Icon>\n );\n } else {\n return null;\n }\n};\n\nconst DetailSidebarTitle: React.FC<Props> = ({\n description,\n packageName,\n version,\n isLatest,\n hasTypes,\n moduleTypes,\n time,\n}) => {\n const { t } = useTranslation();\n return (\n <Box className={'detail-info'} display=\"flex\" flexDirection=\"column\" marginBottom=\"8px\">\n <StyledHeading>\n <TitleWrapper>\n <>\n {packageName}\n {hasTypes && (\n <Icon>\n <TypeScript />\n </Icon>\n )}\n {moduleTypes.map((module, index) => (\n <ModuleJS key={index} module={module} />\n ))}\n </>\n </TitleWrapper>\n </StyledHeading>\n {description && <div>{description}</div>}\n <StyledBoxVersion title={formatDate(time)}>\n {isLatest\n ? t('sidebar.detail.latest-version', { version })\n : t('sidebar.detail.version', { version })}\n {time\n ? ' - ' + t('sidebar.detail.published') + ' ' + formatDateDistance(time)\n : t('versions.not-available')}\n </StyledBoxVersion>\n </Box>\n );\n};\n\nexport default DetailSidebarTitle;\n\nconst TitleWrapper = styled.div({\n display: 'flex',\n alignItems: 'center',\n});\n\nconst StyledHeading = styled(Heading)({\n fontSize: '1rem',\n fontWeight: 700,\n});\n\nconst StyledBoxVersion = styled(Box)<{ theme?: Theme }>(({ theme }) => ({\n color: theme.palette.text.secondary,\n fontSize: theme.fontSize.sm,\n}));\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,IAAM,OAAO,gBAAA,QAAO,KAAwB,EAAE,aAAa,EACzD,YAAY,MAAM,QAAQ,CAAC,EAC7B,EAAE;AAEF,IAAM,YAAqD,EAAE,aAAa;CACxE,IAAI,WAAW,YACb,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,iBAAA,UAAD,CAAW,CAAA,EACP,CAAA;MAEH,IAAI,WAAW,UACpB,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,kBAAA,YAAD,CAAa,CAAA,EACT,CAAA;MAGR,OAAO;AAEX;AAEA,IAAM,sBAAuC,EAC3C,aACA,aACA,SACA,UACA,UACA,aACA,WACI;CACJ,MAAM,EAAE,OAAA,GAAM,cAAA,eAAA,CAAe;CAC7B,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,kBAAA,SAAD;EAAK,WAAW;EAAe,SAAQ;EAAO,eAAc;EAAS,cAAa;EAAlF,UAAA;GACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA;IACG;IACA,YACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,mBAAA,YAAD,CAAa,CAAA,EACT,CAAA;IAEP,YAAY,KAAK,QAAQ,UACxB,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD,EAA8B,OAAS,GAAxB,KAAwB,CACxC;GACD,EAAA,CAAA,EACU,CAAA,EACD,CAAA;GACd,eAAe,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD,EAAA,UAAM,YAAiB,CAAA;GACvC,iBAAA,GAAA,kBAAA,KAAA,CAAC,kBAAD;IAAkB,OAAO,cAAA,WAAW,IAAI;
|
|
1
|
+
{"version":3,"file":"SideBarTitle.js","names":[],"sources":["../../../src/components/SideBarTitle/SideBarTitle.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport Box from '@mui/material/Box';\nimport React from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport type { Theme } from '../../Theme';\nimport Heading from '../Heading';\nimport { CommonJS, ES6Modules, TypeScript } from '../Icons';\nimport { formatDate, formatDateDistance } from './utils';\n\nexport type ModuleType = 'commonjs' | 'module';\n\ninterface Props {\n packageName: string;\n description?: string;\n version: string;\n isLatest: boolean;\n hasTypes?: boolean;\n moduleTypes: ModuleType[];\n time: string;\n}\n\nconst Icon = styled.div<{ theme?: Theme }>(({ theme }) => ({\n marginLeft: theme.spacing(1),\n}));\n\nconst ModuleJS: React.FC<{ module: ModuleType | void }> = ({ module }) => {\n if (module === 'commonjs') {\n return (\n <Icon>\n <CommonJS />\n </Icon>\n );\n } else if (module === 'module') {\n return (\n <Icon>\n <ES6Modules />\n </Icon>\n );\n } else {\n return null;\n }\n};\n\nconst DetailSidebarTitle: React.FC<Props> = ({\n description,\n packageName,\n version,\n isLatest,\n hasTypes,\n moduleTypes,\n time,\n}) => {\n const { t } = useTranslation();\n return (\n <Box className={'detail-info'} display=\"flex\" flexDirection=\"column\" marginBottom=\"8px\">\n <StyledHeading>\n <TitleWrapper>\n <>\n {packageName}\n {hasTypes && (\n <Icon>\n <TypeScript />\n </Icon>\n )}\n {moduleTypes.map((module, index) => (\n <ModuleJS key={index} module={module} />\n ))}\n </>\n </TitleWrapper>\n </StyledHeading>\n {description && <div>{description}</div>}\n <StyledBoxVersion title={time ? formatDate(time) : undefined}>\n {isLatest\n ? t('sidebar.detail.latest-version', { version })\n : t('sidebar.detail.version', { version })}\n {time\n ? ' - ' + t('sidebar.detail.published') + ' ' + formatDateDistance(time)\n : t('versions.not-available')}\n </StyledBoxVersion>\n </Box>\n );\n};\n\nexport default DetailSidebarTitle;\n\nconst TitleWrapper = styled.div({\n display: 'flex',\n alignItems: 'center',\n});\n\nconst StyledHeading = styled(Heading)({\n fontSize: '1rem',\n fontWeight: 700,\n});\n\nconst StyledBoxVersion = styled(Box)<{ theme?: Theme }>(({ theme }) => ({\n color: theme.palette.text.secondary,\n fontSize: theme.fontSize.sm,\n}));\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,IAAM,OAAO,gBAAA,QAAO,KAAwB,EAAE,aAAa,EACzD,YAAY,MAAM,QAAQ,CAAC,EAC7B,EAAE;AAEF,IAAM,YAAqD,EAAE,aAAa;CACxE,IAAI,WAAW,YACb,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,iBAAA,UAAD,CAAW,CAAA,EACP,CAAA;MAEH,IAAI,WAAW,UACpB,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,kBAAA,YAAD,CAAa,CAAA,EACT,CAAA;MAGR,OAAO;AAEX;AAEA,IAAM,sBAAuC,EAC3C,aACA,aACA,SACA,UACA,UACA,aACA,WACI;CACJ,MAAM,EAAE,OAAA,GAAM,cAAA,eAAA,CAAe;CAC7B,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,kBAAA,SAAD;EAAK,WAAW;EAAe,SAAQ;EAAO,eAAc;EAAS,cAAa;EAAlF,UAAA;GACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA;IACG;IACA,YACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,mBAAA,YAAD,CAAa,CAAA,EACT,CAAA;IAEP,YAAY,KAAK,QAAQ,UACxB,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD,EAA8B,OAAS,GAAxB,KAAwB,CACxC;GACD,EAAA,CAAA,EACU,CAAA,EACD,CAAA;GACd,eAAe,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD,EAAA,UAAM,YAAiB,CAAA;GACvC,iBAAA,GAAA,kBAAA,KAAA,CAAC,kBAAD;IAAkB,OAAO,OAAO,cAAA,WAAW,IAAI,IAAI,KAAA;IAAnD,UAAA,CACG,WACG,EAAE,iCAAiC,EAAE,QAAQ,CAAC,IAC9C,EAAE,0BAA0B,EAAE,QAAQ,CAAC,GAC1C,OACG,QAAQ,EAAE,0BAA0B,IAAI,MAAM,cAAA,mBAAmB,IAAI,IACrE,EAAE,wBAAwB,CACd;;EACf;;AAET;AAIA,IAAM,eAAe,gBAAA,QAAO,IAAI;CAC9B,SAAS;CACT,YAAY;AACd,CAAC;AAED,IAAM,iBAAA,GAAgB,gBAAA,QAAA,CAAO,gBAAA,OAAO,CAAC,CAAC;CACpC,UAAU;CACV,YAAY;AACd,CAAC;AAED,IAAM,oBAAA,GAAmB,gBAAA,QAAA,CAAO,kBAAA,OAAG,CAAC,EAAqB,EAAE,aAAa;CACtE,OAAO,MAAM,QAAQ,KAAK;CAC1B,UAAU,MAAM,SAAS;AAC3B,EAAE"}
|
|
@@ -7,9 +7,9 @@ import "../Heading/index.mjs";
|
|
|
7
7
|
import { formatDate, formatDateDistance } from "./utils.mjs";
|
|
8
8
|
import styled from "@emotion/styled";
|
|
9
9
|
import "react";
|
|
10
|
+
import { useTranslation } from "react-i18next";
|
|
10
11
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
12
|
import Box from "@mui/material/Box";
|
|
12
|
-
import { useTranslation } from "react-i18next";
|
|
13
13
|
//#region src/components/SideBarTitle/SideBarTitle.tsx
|
|
14
14
|
var Icon = styled.div(({ theme }) => ({ marginLeft: theme.spacing(1) }));
|
|
15
15
|
var ModuleJS = ({ module }) => {
|
|
@@ -32,7 +32,7 @@ var DetailSidebarTitle = ({ description, packageName, version, isLatest, hasType
|
|
|
32
32
|
] }) }) }),
|
|
33
33
|
description && /* @__PURE__ */ jsx("div", { children: description }),
|
|
34
34
|
/* @__PURE__ */ jsxs(StyledBoxVersion, {
|
|
35
|
-
title: formatDate(time),
|
|
35
|
+
title: time ? formatDate(time) : void 0,
|
|
36
36
|
children: [isLatest ? t("sidebar.detail.latest-version", { version }) : t("sidebar.detail.version", { version }), time ? " - " + t("sidebar.detail.published") + " " + formatDateDistance(time) : t("versions.not-available")]
|
|
37
37
|
})
|
|
38
38
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SideBarTitle.mjs","names":[],"sources":["../../../src/components/SideBarTitle/SideBarTitle.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport Box from '@mui/material/Box';\nimport React from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport type { Theme } from '../../Theme';\nimport Heading from '../Heading';\nimport { CommonJS, ES6Modules, TypeScript } from '../Icons';\nimport { formatDate, formatDateDistance } from './utils';\n\nexport type ModuleType = 'commonjs' | 'module';\n\ninterface Props {\n packageName: string;\n description?: string;\n version: string;\n isLatest: boolean;\n hasTypes?: boolean;\n moduleTypes: ModuleType[];\n time: string;\n}\n\nconst Icon = styled.div<{ theme?: Theme }>(({ theme }) => ({\n marginLeft: theme.spacing(1),\n}));\n\nconst ModuleJS: React.FC<{ module: ModuleType | void }> = ({ module }) => {\n if (module === 'commonjs') {\n return (\n <Icon>\n <CommonJS />\n </Icon>\n );\n } else if (module === 'module') {\n return (\n <Icon>\n <ES6Modules />\n </Icon>\n );\n } else {\n return null;\n }\n};\n\nconst DetailSidebarTitle: React.FC<Props> = ({\n description,\n packageName,\n version,\n isLatest,\n hasTypes,\n moduleTypes,\n time,\n}) => {\n const { t } = useTranslation();\n return (\n <Box className={'detail-info'} display=\"flex\" flexDirection=\"column\" marginBottom=\"8px\">\n <StyledHeading>\n <TitleWrapper>\n <>\n {packageName}\n {hasTypes && (\n <Icon>\n <TypeScript />\n </Icon>\n )}\n {moduleTypes.map((module, index) => (\n <ModuleJS key={index} module={module} />\n ))}\n </>\n </TitleWrapper>\n </StyledHeading>\n {description && <div>{description}</div>}\n <StyledBoxVersion title={formatDate(time)}>\n {isLatest\n ? t('sidebar.detail.latest-version', { version })\n : t('sidebar.detail.version', { version })}\n {time\n ? ' - ' + t('sidebar.detail.published') + ' ' + formatDateDistance(time)\n : t('versions.not-available')}\n </StyledBoxVersion>\n </Box>\n );\n};\n\nexport default DetailSidebarTitle;\n\nconst TitleWrapper = styled.div({\n display: 'flex',\n alignItems: 'center',\n});\n\nconst StyledHeading = styled(Heading)({\n fontSize: '1rem',\n fontWeight: 700,\n});\n\nconst StyledBoxVersion = styled(Box)<{ theme?: Theme }>(({ theme }) => ({\n color: theme.palette.text.secondary,\n fontSize: theme.fontSize.sm,\n}));\n"],"mappings":";;;;;;;;;;;;;AAsBA,IAAM,OAAO,OAAO,KAAwB,EAAE,aAAa,EACzD,YAAY,MAAM,QAAQ,CAAC,EAC7B,EAAE;AAEF,IAAM,YAAqD,EAAE,aAAa;CACxE,IAAI,WAAW,YACb,OACE,oBAAC,MAAD,EAAA,UACE,oBAAC,UAAD,CAAW,CAAA,EACP,CAAA;MAEH,IAAI,WAAW,UACpB,OACE,oBAAC,MAAD,EAAA,UACE,oBAAC,YAAD,CAAa,CAAA,EACT,CAAA;MAGR,OAAO;AAEX;AAEA,IAAM,sBAAuC,EAC3C,aACA,aACA,SACA,UACA,UACA,aACA,WACI;CACJ,MAAM,EAAE,MAAM,eAAe;CAC7B,OACE,qBAAC,KAAD;EAAK,WAAW;EAAe,SAAQ;EAAO,eAAc;EAAS,cAAa;EAAlF,UAAA;GACE,oBAAC,eAAD,EAAA,UACE,oBAAC,cAAD,EAAA,UACE,qBAAA,YAAA,EAAA,UAAA;IACG;IACA,YACC,oBAAC,MAAD,EAAA,UACE,oBAAC,YAAD,CAAa,CAAA,EACT,CAAA;IAEP,YAAY,KAAK,QAAQ,UACxB,oBAAC,UAAD,EAA8B,OAAS,GAAxB,KAAwB,CACxC;GACD,EAAA,CAAA,EACU,CAAA,EACD,CAAA;GACd,eAAe,oBAAC,OAAD,EAAA,UAAM,YAAiB,CAAA;GACvC,qBAAC,kBAAD;IAAkB,OAAO,WAAW,IAAI;
|
|
1
|
+
{"version":3,"file":"SideBarTitle.mjs","names":[],"sources":["../../../src/components/SideBarTitle/SideBarTitle.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport Box from '@mui/material/Box';\nimport React from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport type { Theme } from '../../Theme';\nimport Heading from '../Heading';\nimport { CommonJS, ES6Modules, TypeScript } from '../Icons';\nimport { formatDate, formatDateDistance } from './utils';\n\nexport type ModuleType = 'commonjs' | 'module';\n\ninterface Props {\n packageName: string;\n description?: string;\n version: string;\n isLatest: boolean;\n hasTypes?: boolean;\n moduleTypes: ModuleType[];\n time: string;\n}\n\nconst Icon = styled.div<{ theme?: Theme }>(({ theme }) => ({\n marginLeft: theme.spacing(1),\n}));\n\nconst ModuleJS: React.FC<{ module: ModuleType | void }> = ({ module }) => {\n if (module === 'commonjs') {\n return (\n <Icon>\n <CommonJS />\n </Icon>\n );\n } else if (module === 'module') {\n return (\n <Icon>\n <ES6Modules />\n </Icon>\n );\n } else {\n return null;\n }\n};\n\nconst DetailSidebarTitle: React.FC<Props> = ({\n description,\n packageName,\n version,\n isLatest,\n hasTypes,\n moduleTypes,\n time,\n}) => {\n const { t } = useTranslation();\n return (\n <Box className={'detail-info'} display=\"flex\" flexDirection=\"column\" marginBottom=\"8px\">\n <StyledHeading>\n <TitleWrapper>\n <>\n {packageName}\n {hasTypes && (\n <Icon>\n <TypeScript />\n </Icon>\n )}\n {moduleTypes.map((module, index) => (\n <ModuleJS key={index} module={module} />\n ))}\n </>\n </TitleWrapper>\n </StyledHeading>\n {description && <div>{description}</div>}\n <StyledBoxVersion title={time ? formatDate(time) : undefined}>\n {isLatest\n ? t('sidebar.detail.latest-version', { version })\n : t('sidebar.detail.version', { version })}\n {time\n ? ' - ' + t('sidebar.detail.published') + ' ' + formatDateDistance(time)\n : t('versions.not-available')}\n </StyledBoxVersion>\n </Box>\n );\n};\n\nexport default DetailSidebarTitle;\n\nconst TitleWrapper = styled.div({\n display: 'flex',\n alignItems: 'center',\n});\n\nconst StyledHeading = styled(Heading)({\n fontSize: '1rem',\n fontWeight: 700,\n});\n\nconst StyledBoxVersion = styled(Box)<{ theme?: Theme }>(({ theme }) => ({\n color: theme.palette.text.secondary,\n fontSize: theme.fontSize.sm,\n}));\n"],"mappings":";;;;;;;;;;;;;AAsBA,IAAM,OAAO,OAAO,KAAwB,EAAE,aAAa,EACzD,YAAY,MAAM,QAAQ,CAAC,EAC7B,EAAE;AAEF,IAAM,YAAqD,EAAE,aAAa;CACxE,IAAI,WAAW,YACb,OACE,oBAAC,MAAD,EAAA,UACE,oBAAC,UAAD,CAAW,CAAA,EACP,CAAA;MAEH,IAAI,WAAW,UACpB,OACE,oBAAC,MAAD,EAAA,UACE,oBAAC,YAAD,CAAa,CAAA,EACT,CAAA;MAGR,OAAO;AAEX;AAEA,IAAM,sBAAuC,EAC3C,aACA,aACA,SACA,UACA,UACA,aACA,WACI;CACJ,MAAM,EAAE,MAAM,eAAe;CAC7B,OACE,qBAAC,KAAD;EAAK,WAAW;EAAe,SAAQ;EAAO,eAAc;EAAS,cAAa;EAAlF,UAAA;GACE,oBAAC,eAAD,EAAA,UACE,oBAAC,cAAD,EAAA,UACE,qBAAA,YAAA,EAAA,UAAA;IACG;IACA,YACC,oBAAC,MAAD,EAAA,UACE,oBAAC,YAAD,CAAa,CAAA,EACT,CAAA;IAEP,YAAY,KAAK,QAAQ,UACxB,oBAAC,UAAD,EAA8B,OAAS,GAAxB,KAAwB,CACxC;GACD,EAAA,CAAA,EACU,CAAA,EACD,CAAA;GACd,eAAe,oBAAC,OAAD,EAAA,UAAM,YAAiB,CAAA;GACvC,qBAAC,kBAAD;IAAkB,OAAO,OAAO,WAAW,IAAI,IAAI,KAAA;IAAnD,UAAA,CACG,WACG,EAAE,iCAAiC,EAAE,QAAQ,CAAC,IAC9C,EAAE,0BAA0B,EAAE,QAAQ,CAAC,GAC1C,OACG,QAAQ,EAAE,0BAA0B,IAAI,MAAM,mBAAmB,IAAI,IACrE,EAAE,wBAAwB,CACd;;EACf;;AAET;AAIA,IAAM,eAAe,OAAO,IAAI;CAC9B,SAAS;CACT,YAAY;AACd,CAAC;AAED,IAAM,gBAAgB,OAAO,OAAO,CAAC,CAAC;CACpC,UAAU;CACV,YAAY;AACd,CAAC;AAED,IAAM,mBAAmB,OAAO,GAAG,CAAC,EAAqB,EAAE,aAAa;CACtE,OAAO,MAAM,QAAQ,KAAK;CAC1B,UAAU,MAAM,SAAS;AAC3B,EAAE"}
|
|
@@ -7,10 +7,10 @@ const require_UplinkLink = require("./UplinkLink.js");
|
|
|
7
7
|
const require_styles = require("./styles.js");
|
|
8
8
|
let react = require("react");
|
|
9
9
|
react = require_runtime.__toESM(react);
|
|
10
|
+
let react_i18next = require("react-i18next");
|
|
10
11
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
12
|
let _mui_material_Box = require("@mui/material/Box");
|
|
12
13
|
_mui_material_Box = require_runtime.__toESM(_mui_material_Box);
|
|
13
|
-
let react_i18next = require("react-i18next");
|
|
14
14
|
let _mui_material_List = require("@mui/material/List");
|
|
15
15
|
_mui_material_List = require_runtime.__toESM(_mui_material_List);
|
|
16
16
|
let _mui_material_ListItem = require("@mui/material/ListItem");
|
|
@@ -5,9 +5,9 @@ import "../NoItems/index.mjs";
|
|
|
5
5
|
import UpLinkLink from "./UplinkLink.mjs";
|
|
6
6
|
import { ListItemText, Spacer, StyledText } from "./styles.mjs";
|
|
7
7
|
import "react";
|
|
8
|
+
import { useTranslation } from "react-i18next";
|
|
8
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
import Box from "@mui/material/Box";
|
|
10
|
-
import { useTranslation } from "react-i18next";
|
|
11
11
|
import List from "@mui/material/List";
|
|
12
12
|
import ListItem from "@mui/material/ListItem";
|
|
13
13
|
import Card from "@mui/material/Card";
|
|
@@ -9,8 +9,8 @@ require("../Link/index.js");
|
|
|
9
9
|
const require_styles = require("./styles.js");
|
|
10
10
|
let react = require("react");
|
|
11
11
|
react = require_runtime.__toESM(react);
|
|
12
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
13
12
|
let react_i18next = require("react-i18next");
|
|
13
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
14
14
|
let _mui_material_List = require("@mui/material/List");
|
|
15
15
|
_mui_material_List = require_runtime.__toESM(_mui_material_List);
|
|
16
16
|
let _mui_material_ListItem = require("@mui/material/ListItem");
|
|
@@ -60,7 +60,7 @@ var VersionsHistoryList = ({ versions, packageName, time }) => {
|
|
|
60
60
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_styles.ListItemText, {
|
|
61
61
|
"data-testid": `version-list-text`,
|
|
62
62
|
primary: time[version] ? require_utils.formatDateDistance(time[version]) : t("versions.not-available"),
|
|
63
|
-
slotProps: { primary: { title: require_utils.formatDate(time[version]) } }
|
|
63
|
+
slotProps: { primary: { title: time[version] ? require_utils.formatDate(time[version]) : void 0 } }
|
|
64
64
|
})
|
|
65
65
|
]
|
|
66
66
|
}, version))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HistoryList.js","names":[],"sources":["../../../src/components/Versions/HistoryList.tsx"],"sourcesContent":["import Chip from '@mui/material/Chip';\nimport List from '@mui/material/List';\nimport ListItem from '@mui/material/ListItem';\nimport React from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport { useConfig } from '../../providers';\nimport type { Time, Versions } from '../../types/packageMeta';\nimport { Route, utils } from '../../utils';\nimport Link from '../Link';\nimport { ListItemText, Spacer } from './styles';\n\ninterface Props {\n versions: Versions;\n packageName: string;\n time: Time;\n}\n\nexport function filterDeprecated(versions: Versions) {\n const versionsIds = Object.keys(versions);\n return versionsIds.reduce((prev, current) => {\n if (!versions[current].deprecated) {\n prev[current] = versions[current];\n }\n\n return prev;\n }, {});\n}\n\nconst VersionsHistoryList: React.FC<Props> = ({ versions, packageName, time }) => {\n const { t } = useTranslation();\n const { configOptions } = useConfig();\n const hideDeprecatedVersions = configOptions.hideDeprecatedVersions;\n const listVersions = hideDeprecatedVersions ? filterDeprecated(versions) : versions;\n\n return (\n <List dense={true}>\n {Object.keys(listVersions)\n .sort((a, b) => {\n const timeA = time[a] ? new Date(time[a]).getTime() : 0;\n const timeB = time[b] ? new Date(time[b]).getTime() : 0;\n return timeB - timeA;\n })\n .map((version) => (\n <ListItem\n className=\"version-item\"\n data-testid={`version-${version}`}\n key={version}\n sx={{ pr: 0 }}\n >\n <Link to={`${Route.DETAIL}${packageName}/v/${version}`} variant=\"outline\">\n <ListItemText\n data-testid={`version-list-link`}\n disableTypography={false}\n primary={version}\n sx={\n typeof versions[version]?.deprecated === 'string'\n ? { textDecoration: 'line-through' }\n : undefined\n }\n />\n </Link>\n {typeof versions[version]?.deprecated === 'string' ? (\n <Chip\n color=\"warning\"\n data-testid=\"deprecated-badge\"\n label={t('versions.deprecated')}\n size=\"small\"\n sx={{ marginLeft: 1 }}\n variant=\"outlined\"\n />\n ) : null}\n <Spacer />\n <ListItemText\n data-testid={`version-list-text`}\n primary={\n time[version]\n ? utils.formatDateDistance(time[version])\n : t('versions.not-available')\n }\n slotProps={{
|
|
1
|
+
{"version":3,"file":"HistoryList.js","names":[],"sources":["../../../src/components/Versions/HistoryList.tsx"],"sourcesContent":["import Chip from '@mui/material/Chip';\nimport List from '@mui/material/List';\nimport ListItem from '@mui/material/ListItem';\nimport React from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport { useConfig } from '../../providers';\nimport type { Time, Versions } from '../../types/packageMeta';\nimport { Route, utils } from '../../utils';\nimport Link from '../Link';\nimport { ListItemText, Spacer } from './styles';\n\ninterface Props {\n versions: Versions;\n packageName: string;\n time: Time;\n}\n\nexport function filterDeprecated(versions: Versions) {\n const versionsIds = Object.keys(versions);\n return versionsIds.reduce((prev, current) => {\n if (!versions[current].deprecated) {\n prev[current] = versions[current];\n }\n\n return prev;\n }, {});\n}\n\nconst VersionsHistoryList: React.FC<Props> = ({ versions, packageName, time }) => {\n const { t } = useTranslation();\n const { configOptions } = useConfig();\n const hideDeprecatedVersions = configOptions.hideDeprecatedVersions;\n const listVersions = hideDeprecatedVersions ? filterDeprecated(versions) : versions;\n\n return (\n <List dense={true}>\n {Object.keys(listVersions)\n .sort((a, b) => {\n const timeA = time[a] ? new Date(time[a]).getTime() : 0;\n const timeB = time[b] ? new Date(time[b]).getTime() : 0;\n return timeB - timeA;\n })\n .map((version) => (\n <ListItem\n className=\"version-item\"\n data-testid={`version-${version}`}\n key={version}\n sx={{ pr: 0 }}\n >\n <Link to={`${Route.DETAIL}${packageName}/v/${version}`} variant=\"outline\">\n <ListItemText\n data-testid={`version-list-link`}\n disableTypography={false}\n primary={version}\n sx={\n typeof versions[version]?.deprecated === 'string'\n ? { textDecoration: 'line-through' }\n : undefined\n }\n />\n </Link>\n {typeof versions[version]?.deprecated === 'string' ? (\n <Chip\n color=\"warning\"\n data-testid=\"deprecated-badge\"\n label={t('versions.deprecated')}\n size=\"small\"\n sx={{ marginLeft: 1 }}\n variant=\"outlined\"\n />\n ) : null}\n <Spacer />\n <ListItemText\n data-testid={`version-list-text`}\n primary={\n time[version]\n ? utils.formatDateDistance(time[version])\n : t('versions.not-available')\n }\n slotProps={{\n primary: { title: time[version] ? utils.formatDate(time[version]) : undefined },\n }}\n />\n </ListItem>\n ))}\n </List>\n );\n};\n\nexport default VersionsHistoryList;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkBA,SAAgB,iBAAiB,UAAoB;CAEnD,OADoB,OAAO,KAAK,QACzB,CAAA,CAAY,QAAQ,MAAM,YAAY;EAC3C,IAAI,CAAC,SAAS,QAAQ,CAAC,YACrB,KAAK,WAAW,SAAS;EAG3B,OAAO;CACT,GAAG,CAAC,CAAC;AACP;AAEA,IAAM,uBAAwC,EAAE,UAAU,aAAa,WAAW;CAChF,MAAM,EAAE,OAAA,GAAM,cAAA,eAAA,CAAe;CAC7B,MAAM,EAAE,kBAAkB,iCAAA,UAAU;CAEpC,MAAM,eADyB,cAAc,yBACC,iBAAiB,QAAQ,IAAI;CAE3E,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,mBAAA,SAAD;EAAM,OAAO;EACV,UAAA,OAAO,KAAK,YAAY,CAAC,CACvB,MAAM,GAAG,MAAM;GACd,MAAM,QAAQ,KAAK,KAAK,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,QAAQ,IAAI;GAEtD,QADc,KAAK,KAAK,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,QAAQ,IAAI,KACvC;EACjB,CAAC,CAAC,CACD,KAAK,YACJ,iBAAA,GAAA,kBAAA,KAAA,CAAC,uBAAA,SAAD;GACE,WAAU;GACV,eAAa,WAAW;GAExB,IAAI,EAAE,IAAI,EAAE;GAJd,UAAA;IAME,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAA,SAAD;KAAM,IAAI,GAAG,eAAA,MAAM,SAAS,YAAY,KAAK;KAAW,SAAQ;KAC9D,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAA,cAAD;MACE,eAAa;MACb,mBAAmB;MACnB,SAAS;MACT,IACE,OAAO,SAAS,QAAQ,EAAE,eAAe,WACrC,EAAE,gBAAgB,eAAe,IACjC,KAAA;KAEP,CAAA;IACG,CAAA;IACL,OAAO,SAAS,QAAQ,EAAE,eAAe,WACxC,iBAAA,GAAA,kBAAA,IAAA,CAAC,mBAAA,SAAD;KACE,OAAM;KACN,eAAY;KACZ,OAAO,EAAE,qBAAqB;KAC9B,MAAK;KACL,IAAI,EAAE,YAAY,EAAE;KACpB,SAAQ;IACT,CAAA,IACC;IACJ,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAA,QAAD,CAAS,CAAA;IACT,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAA,cAAD;KACE,eAAa;KACb,SACE,KAAK,WAAA,cAAA,mBACwB,KAAK,QAAQ,IACtC,EAAE,wBAAwB;KAEhC,WAAW,EACT,SAAS,EAAE,OAAO,KAAK,WAAA,cAAA,WAA4B,KAAK,QAAQ,IAAI,KAAA,EAAU,EAChF;IACD,CAAA;GACO;EArCH,GAAA,OAqCG,CACX;CACC,CAAA;AAEV"}
|
|
@@ -7,8 +7,8 @@ import Link from "../Link/Link.mjs";
|
|
|
7
7
|
import "../Link/index.mjs";
|
|
8
8
|
import { ListItemText, Spacer } from "./styles.mjs";
|
|
9
9
|
import "react";
|
|
10
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
10
|
import { useTranslation } from "react-i18next";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
import List from "@mui/material/List";
|
|
13
13
|
import ListItem from "@mui/material/ListItem";
|
|
14
14
|
import Chip from "@mui/material/Chip";
|
|
@@ -55,7 +55,7 @@ var VersionsHistoryList = ({ versions, packageName, time }) => {
|
|
|
55
55
|
/* @__PURE__ */ jsx(ListItemText, {
|
|
56
56
|
"data-testid": `version-list-text`,
|
|
57
57
|
primary: time[version] ? formatDateDistance(time[version]) : t("versions.not-available"),
|
|
58
|
-
slotProps: { primary: { title: formatDate(time[version]) } }
|
|
58
|
+
slotProps: { primary: { title: time[version] ? formatDate(time[version]) : void 0 } }
|
|
59
59
|
})
|
|
60
60
|
]
|
|
61
61
|
}, version))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HistoryList.mjs","names":[],"sources":["../../../src/components/Versions/HistoryList.tsx"],"sourcesContent":["import Chip from '@mui/material/Chip';\nimport List from '@mui/material/List';\nimport ListItem from '@mui/material/ListItem';\nimport React from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport { useConfig } from '../../providers';\nimport type { Time, Versions } from '../../types/packageMeta';\nimport { Route, utils } from '../../utils';\nimport Link from '../Link';\nimport { ListItemText, Spacer } from './styles';\n\ninterface Props {\n versions: Versions;\n packageName: string;\n time: Time;\n}\n\nexport function filterDeprecated(versions: Versions) {\n const versionsIds = Object.keys(versions);\n return versionsIds.reduce((prev, current) => {\n if (!versions[current].deprecated) {\n prev[current] = versions[current];\n }\n\n return prev;\n }, {});\n}\n\nconst VersionsHistoryList: React.FC<Props> = ({ versions, packageName, time }) => {\n const { t } = useTranslation();\n const { configOptions } = useConfig();\n const hideDeprecatedVersions = configOptions.hideDeprecatedVersions;\n const listVersions = hideDeprecatedVersions ? filterDeprecated(versions) : versions;\n\n return (\n <List dense={true}>\n {Object.keys(listVersions)\n .sort((a, b) => {\n const timeA = time[a] ? new Date(time[a]).getTime() : 0;\n const timeB = time[b] ? new Date(time[b]).getTime() : 0;\n return timeB - timeA;\n })\n .map((version) => (\n <ListItem\n className=\"version-item\"\n data-testid={`version-${version}`}\n key={version}\n sx={{ pr: 0 }}\n >\n <Link to={`${Route.DETAIL}${packageName}/v/${version}`} variant=\"outline\">\n <ListItemText\n data-testid={`version-list-link`}\n disableTypography={false}\n primary={version}\n sx={\n typeof versions[version]?.deprecated === 'string'\n ? { textDecoration: 'line-through' }\n : undefined\n }\n />\n </Link>\n {typeof versions[version]?.deprecated === 'string' ? (\n <Chip\n color=\"warning\"\n data-testid=\"deprecated-badge\"\n label={t('versions.deprecated')}\n size=\"small\"\n sx={{ marginLeft: 1 }}\n variant=\"outlined\"\n />\n ) : null}\n <Spacer />\n <ListItemText\n data-testid={`version-list-text`}\n primary={\n time[version]\n ? utils.formatDateDistance(time[version])\n : t('versions.not-available')\n }\n slotProps={{
|
|
1
|
+
{"version":3,"file":"HistoryList.mjs","names":[],"sources":["../../../src/components/Versions/HistoryList.tsx"],"sourcesContent":["import Chip from '@mui/material/Chip';\nimport List from '@mui/material/List';\nimport ListItem from '@mui/material/ListItem';\nimport React from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport { useConfig } from '../../providers';\nimport type { Time, Versions } from '../../types/packageMeta';\nimport { Route, utils } from '../../utils';\nimport Link from '../Link';\nimport { ListItemText, Spacer } from './styles';\n\ninterface Props {\n versions: Versions;\n packageName: string;\n time: Time;\n}\n\nexport function filterDeprecated(versions: Versions) {\n const versionsIds = Object.keys(versions);\n return versionsIds.reduce((prev, current) => {\n if (!versions[current].deprecated) {\n prev[current] = versions[current];\n }\n\n return prev;\n }, {});\n}\n\nconst VersionsHistoryList: React.FC<Props> = ({ versions, packageName, time }) => {\n const { t } = useTranslation();\n const { configOptions } = useConfig();\n const hideDeprecatedVersions = configOptions.hideDeprecatedVersions;\n const listVersions = hideDeprecatedVersions ? filterDeprecated(versions) : versions;\n\n return (\n <List dense={true}>\n {Object.keys(listVersions)\n .sort((a, b) => {\n const timeA = time[a] ? new Date(time[a]).getTime() : 0;\n const timeB = time[b] ? new Date(time[b]).getTime() : 0;\n return timeB - timeA;\n })\n .map((version) => (\n <ListItem\n className=\"version-item\"\n data-testid={`version-${version}`}\n key={version}\n sx={{ pr: 0 }}\n >\n <Link to={`${Route.DETAIL}${packageName}/v/${version}`} variant=\"outline\">\n <ListItemText\n data-testid={`version-list-link`}\n disableTypography={false}\n primary={version}\n sx={\n typeof versions[version]?.deprecated === 'string'\n ? { textDecoration: 'line-through' }\n : undefined\n }\n />\n </Link>\n {typeof versions[version]?.deprecated === 'string' ? (\n <Chip\n color=\"warning\"\n data-testid=\"deprecated-badge\"\n label={t('versions.deprecated')}\n size=\"small\"\n sx={{ marginLeft: 1 }}\n variant=\"outlined\"\n />\n ) : null}\n <Spacer />\n <ListItemText\n data-testid={`version-list-text`}\n primary={\n time[version]\n ? utils.formatDateDistance(time[version])\n : t('versions.not-available')\n }\n slotProps={{\n primary: { title: time[version] ? utils.formatDate(time[version]) : undefined },\n }}\n />\n </ListItem>\n ))}\n </List>\n );\n};\n\nexport default VersionsHistoryList;\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,SAAgB,iBAAiB,UAAoB;CAEnD,OADoB,OAAO,KAAK,QACzB,CAAA,CAAY,QAAQ,MAAM,YAAY;EAC3C,IAAI,CAAC,SAAS,QAAQ,CAAC,YACrB,KAAK,WAAW,SAAS;EAG3B,OAAO;CACT,GAAG,CAAC,CAAC;AACP;AAEA,IAAM,uBAAwC,EAAE,UAAU,aAAa,WAAW;CAChF,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,EAAE,kBAAkB,UAAU;CAEpC,MAAM,eADyB,cAAc,yBACC,iBAAiB,QAAQ,IAAI;CAE3E,OACE,oBAAC,MAAD;EAAM,OAAO;EACV,UAAA,OAAO,KAAK,YAAY,CAAC,CACvB,MAAM,GAAG,MAAM;GACd,MAAM,QAAQ,KAAK,KAAK,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,QAAQ,IAAI;GAEtD,QADc,KAAK,KAAK,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,QAAQ,IAAI,KACvC;EACjB,CAAC,CAAC,CACD,KAAK,YACJ,qBAAC,UAAD;GACE,WAAU;GACV,eAAa,WAAW;GAExB,IAAI,EAAE,IAAI,EAAE;GAJd,UAAA;IAME,oBAAC,MAAD;KAAM,IAAI,GAAG,MAAM,SAAS,YAAY,KAAK;KAAW,SAAQ;KAC9D,UAAA,oBAAC,cAAD;MACE,eAAa;MACb,mBAAmB;MACnB,SAAS;MACT,IACE,OAAO,SAAS,QAAQ,EAAE,eAAe,WACrC,EAAE,gBAAgB,eAAe,IACjC,KAAA;KAEP,CAAA;IACG,CAAA;IACL,OAAO,SAAS,QAAQ,EAAE,eAAe,WACxC,oBAAC,MAAD;KACE,OAAM;KACN,eAAY;KACZ,OAAO,EAAE,qBAAqB;KAC9B,MAAK;KACL,IAAI,EAAE,YAAY,EAAE;KACpB,SAAQ;IACT,CAAA,IACC;IACJ,oBAAC,QAAD,CAAS,CAAA;IACT,oBAAC,cAAD;KACE,eAAa;KACb,SACE,KAAK,WACD,mBAAyB,KAAK,QAAQ,IACtC,EAAE,wBAAwB;KAEhC,WAAW,EACT,SAAS,EAAE,OAAO,KAAK,WAAW,WAAiB,KAAK,QAAQ,IAAI,KAAA,EAAU,EAChF;IACD,CAAA;GACO;EArCH,GAAA,OAqCG,CACX;CACC,CAAA;AAEV"}
|
|
@@ -7,19 +7,19 @@ let _emotion_styled = require("@emotion/styled");
|
|
|
7
7
|
_emotion_styled = require_runtime.__toESM(_emotion_styled);
|
|
8
8
|
let react = require("react");
|
|
9
9
|
react = require_runtime.__toESM(react);
|
|
10
|
+
let react_i18next = require("react-i18next");
|
|
10
11
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
12
|
let _mui_material_Box = require("@mui/material/Box");
|
|
12
13
|
_mui_material_Box = require_runtime.__toESM(_mui_material_Box);
|
|
13
14
|
let lodash_es = require("lodash-es");
|
|
14
|
-
let
|
|
15
|
+
let _mui_material_Alert = require("@mui/material/Alert");
|
|
16
|
+
_mui_material_Alert = require_runtime.__toESM(_mui_material_Alert);
|
|
15
17
|
let _mui_material_Typography = require("@mui/material/Typography");
|
|
16
18
|
_mui_material_Typography = require_runtime.__toESM(_mui_material_Typography);
|
|
17
19
|
let _mui_material_Card = require("@mui/material/Card");
|
|
18
20
|
_mui_material_Card = require_runtime.__toESM(_mui_material_Card);
|
|
19
21
|
let _mui_material_CardContent = require("@mui/material/CardContent");
|
|
20
22
|
_mui_material_CardContent = require_runtime.__toESM(_mui_material_CardContent);
|
|
21
|
-
let _mui_material_Alert = require("@mui/material/Alert");
|
|
22
|
-
_mui_material_Alert = require_runtime.__toESM(_mui_material_Alert);
|
|
23
23
|
let _mui_material_TextField = require("@mui/material/TextField");
|
|
24
24
|
_mui_material_TextField = require_runtime.__toESM(_mui_material_TextField);
|
|
25
25
|
let semver = require("semver");
|
|
@@ -32,26 +32,27 @@ var StyledText = (0, _emotion_styled.default)(_mui_material_Typography.default)(
|
|
|
32
32
|
var Versions = ({ packageMeta, packageName }) => {
|
|
33
33
|
const { t } = (0, react_i18next.useTranslation)();
|
|
34
34
|
const { configOptions } = require_AppConfigurationProvider.useConfig();
|
|
35
|
-
const { versions = {}, time = {}, ["dist-tags"]: distTags = {} } = packageMeta;
|
|
36
|
-
const [
|
|
35
|
+
const { versions = {}, time = {}, ["dist-tags"]: distTags = {} } = packageMeta ?? {};
|
|
36
|
+
const [textSearch, setTextSearch] = (0, react.useState)("");
|
|
37
|
+
(0, react.useEffect)(() => {
|
|
38
|
+
setTextSearch("");
|
|
39
|
+
}, [packageName]);
|
|
40
|
+
const packageVersions = (0, react.useMemo)(() => {
|
|
41
|
+
if (textSearch === "") return versions;
|
|
42
|
+
return Object.keys(versions).reduce((acc, version) => {
|
|
43
|
+
if (typeof versions[version] !== "undefined") {
|
|
44
|
+
if (semver.default.satisfies(version, textSearch, {
|
|
45
|
+
includePrerelease: true,
|
|
46
|
+
loose: true
|
|
47
|
+
})) acc[version] = versions[version];
|
|
48
|
+
}
|
|
49
|
+
return acc;
|
|
50
|
+
}, {});
|
|
51
|
+
}, [versions, textSearch]);
|
|
37
52
|
if (!packageMeta || Object.keys(packageMeta).length === 0) return null;
|
|
38
53
|
const hideDeprecatedVersions = configOptions.hideDeprecatedVersions;
|
|
39
54
|
const hasDistTags = distTags && Object.keys(distTags).length > 0 && packageName;
|
|
40
55
|
const hasVersionHistory = packageVersions && Object.keys(packageVersions).length > 0 && packageName;
|
|
41
|
-
const filterVersions = (textSearch) => {
|
|
42
|
-
const filteredVersions = Object.keys(versions).reduce((acc, version) => {
|
|
43
|
-
if (textSearch !== "") {
|
|
44
|
-
if (typeof versions[version] !== "undefined") {
|
|
45
|
-
if (semver.default.satisfies(version, textSearch, {
|
|
46
|
-
includePrerelease: true,
|
|
47
|
-
loose: true
|
|
48
|
-
})) acc[version] = versions[version];
|
|
49
|
-
}
|
|
50
|
-
} else acc[version] = versions[version];
|
|
51
|
-
return acc;
|
|
52
|
-
}, {});
|
|
53
|
-
setPackageVersions(filteredVersions);
|
|
54
|
-
};
|
|
55
56
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mui_material_Card.default, {
|
|
56
57
|
sx: { mb: 2 },
|
|
57
58
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mui_material_CardContent.default, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_mui_material_Box.default, {
|
|
@@ -72,12 +73,12 @@ var Versions = ({ packageMeta, packageName }) => {
|
|
|
72
73
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mui_material_TextField.default, {
|
|
73
74
|
helperText: t("versions.search.placeholder"),
|
|
74
75
|
onChange: (0, lodash_es.debounce)((e) => {
|
|
75
|
-
|
|
76
|
+
setTextSearch(e.target.value);
|
|
76
77
|
}, 200),
|
|
77
78
|
size: "small",
|
|
78
79
|
variant: "standard",
|
|
79
80
|
sx: { width: "50%" }
|
|
80
|
-
})] }),
|
|
81
|
+
}, packageName)] }),
|
|
81
82
|
hasVersionHistory ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [hideDeprecatedVersions === true && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mui_material_Alert.default, {
|
|
82
83
|
severity: "info",
|
|
83
84
|
sx: {
|