Skip to content

Commit

Permalink
Use multi-select. Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfheij-sil committed Dec 17, 2024
1 parent 7de6701 commit a847480
Show file tree
Hide file tree
Showing 16 changed files with 2,468 additions and 2,441 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
"%resources_get%": "Get",
"%resources_installed%": "Installed",
"%resources_language%": "Language",
"%resources_languageFilter%": "Filter by language",
"%resources_languages%": "Languages",
"%resources_loadingResources%": "Loading resources...",
"%resources_noResults%": "No results found",
"%resources_open%": "Open",
"%resources_remove%": "Remove",
"%resources_size%": "Size",
"%resources_type%": "Type",
"%resources_types%": "Types",
"%resources_type_DBL%": "DBL Resource",
"%resources_type_ER%": "Enhanced Resource",
"%resources_type_SLR%": "Source Language Text",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { WebViewProps } from '@papi/core';
import papi from '@papi/frontend';
import { useData, useDataProvider, useLocalizedStrings } from '@papi/frontend/react';
import type { ResourceType } from 'platform-bible-utils';
import { FilterableResourceList, FILTERABLE_RESOURCE_LIST_STRING_KEYS } from 'platform-bible-react';

globalThis.webViewComponent = function GetResourcesDialog({ useWebViewState }: WebViewProps) {
Expand All @@ -13,24 +12,24 @@ globalThis.webViewComponent = function GetResourcesDialog({ useWebViewState }: W
'platformGetResources.dblResourcesProvider',
).DblResources(undefined, []);

const [typeFilter, setTypeFilter] = useWebViewState<ResourceType[]>('typeFilter', [
const [selectedTypes, setSelectedTypes] = useWebViewState<string[]>('typeFilter', [
'DBLResource',
]);

const [languageFilter, setLanguageFilter] = useWebViewState<string[]>('languageFilter', []);
const [selectedLanguages, setSelectedLanguages] = useWebViewState<string[]>('languageFilter', []);

const openResource = (projectId: string) =>
papi.commands.sendCommand('platformScriptureEditor.openResourceViewer', projectId);

return (
<FilterableResourceList
localizedStrings={localizedStrings}
dblResources={dblResources}
isLoadingDblResources={isLoadingDblResources}
typeFilter={typeFilter}
setTypeFilter={setTypeFilter}
languageFilter={languageFilter}
setLanguageFilter={setLanguageFilter}
resources={dblResources}
isLoadingResources={isLoadingDblResources}
selectedTypes={selectedTypes}
setSelectedTypes={setSelectedTypes}
selectedLanguages={selectedLanguages}
setSelectedLanguages={setSelectedLanguages}
openResource={openResource}
installResource={dblResourcesProvider?.installDblResource}
uninstallResource={dblResourcesProvider?.uninstallDblResource}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
"%resources_get%": "Get",
"%resources_installed%": "Installed",
"%resources_language%": "Language",
"%resources_languageFilter%": "Filter by language",
"%resources_languages%": "Languages",
"%resources_loadingResources%": "Loading Projects and Resource",
"%resources_noResults%": "No results found",
"%resources_open%": "Open",
"%resources_remove%": "Remove",
"%resources_size%": "Size",
"%resources_type%": "Type",
"%resources_types%": "Types",
"%resources_type_DBL%": "DBL Resource",
"%resources_type_ER%": "Enhanced Resource",
"%resources_type_SLR%": "Source Language Text",
Expand Down
66 changes: 33 additions & 33 deletions lib/platform-bible-react/dist/index.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/platform-bible-react/dist/index.cjs.map

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions lib/platform-bible-react/dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1423,17 +1423,17 @@ export function Footer({ id, publisherDisplayName, fileSize, locales, versionHis
export declare const FILTERABLE_RESOURCE_LIST_STRING_KEYS: LocalizeKey[];
export type FilterableResourceListProps = {
localizedStrings: LanguageStrings;
dblResources: DblResourceData[];
isLoadingDblResources: boolean;
typeFilter: ResourceType[];
setTypeFilter: (stateValue: ResourceType[]) => void;
languageFilter: string[];
setLanguageFilter: (stateValue: string[]) => void;
resources: DblResourceData[];
isLoadingResources: boolean;
selectedTypes: string[];
setSelectedTypes: (stateValue: string[]) => void;
selectedLanguages: string[];
setSelectedLanguages: (stateValue: string[]) => void;
openResource: (projectId: string) => void;
installResource: ((uid: string) => Promise<void>) | undefined;
uninstallResource: ((uid: string) => Promise<void>) | undefined;
};
export declare function FilterableResourceList({ localizedStrings, dblResources, isLoadingDblResources, typeFilter, setTypeFilter, languageFilter, setLanguageFilter, openResource, installResource, uninstallResource, }: FilterableResourceListProps): import("react/jsx-runtime").JSX.Element;
export declare function FilterableResourceList({ localizedStrings, resources, isLoadingResources, selectedTypes, setSelectedTypes, selectedLanguages, setSelectedLanguages, openResource, installResource, uninstallResource, }: FilterableResourceListProps): import("react/jsx-runtime").JSX.Element;
declare const UI_LANGUAGE_SELECTOR_STRING_KEYS: readonly [
"%settings_uiLanguageSelector_selectFallbackLanguages%"
];
Expand Down
Loading

0 comments on commit a847480

Please sign in to comment.