Bundled output for commit 8c331038da9e3fda99a68ea2e0495b9a6160dde1

Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
This commit is contained in:
flarum-bot 2024-11-08 16:24:42 +00:00
parent 8c331038da
commit 845228f251
18 changed files with 220 additions and 53 deletions

View File

@ -1,5 +1,5 @@
import type Mithril from 'mithril';
import type { SearchSource } from './Search';
import type { GlobalSearchSource } from './GlobalSearch';
import { GeneralIndexData } from '../states/GeneralSearchIndex';
import { ExtensionConfig } from '../utils/AdminRegistry';
export declare class GeneralSearchResult {
@ -20,7 +20,7 @@ export declare class GeneralSearchResult {
/**
* Finds and displays settings, permissions and installed extensions (i.e. general search results) in the search dropdown.
*/
export default class GeneralSearchSource implements SearchSource {
export default class GeneralSearchSource implements GlobalSearchSource {
protected results: Map<string, GeneralSearchResult[]>;
resource: string;
title(): string;

View File

@ -0,0 +1,8 @@
import ItemList from '../../common/utils/ItemList';
import AbstractGlobalSearch, { type SearchAttrs, type GlobalSearchSource as BaseGlobalSearchSource } from '../../common/components/AbstractGlobalSearch';
export interface GlobalSearchSource extends BaseGlobalSearchSource {
}
export default class GlobalSearch extends AbstractGlobalSearch {
static initAttrs(attrs: SearchAttrs): void;
sourceItems(): ItemList<GlobalSearchSource>;
}

View File

@ -1,8 +0,0 @@
import ItemList from '../../common/utils/ItemList';
import AbstractSearch, { type SearchAttrs, type SearchSource as BaseSearchSource } from '../../common/components/AbstractSearch';
export interface SearchSource extends BaseSearchSource {
}
export default class Search extends AbstractSearch {
static initAttrs(attrs: SearchAttrs): void;
sourceItems(): ItemList<SearchSource>;
}

View File

@ -9,16 +9,16 @@ export interface SearchAttrs extends ComponentAttrs {
a11yRoleLabel: string;
}
/**
* The `SearchSource` interface defines a section of search results in the
* search dropdown.
* The `SearchSource` interface defines a tab of search results in the
* search modal.
*
* Search sources should be registered with the `Search` component class
* Search sources should be registered with the `GlobalSearch` component class
* by extending the `sourceItems` method. When the user types a
* query, each search source will be prompted to load search results via the
* `search` method. When the dropdown is redrawn, it will be constructed by
* `search` method. When the search modal's dropdown is redrawn, it will be constructed by
* putting together the output from the `view` method of each source.
*/
export interface SearchSource {
export interface GlobalSearchSource {
/**
* The resource type that this search source is responsible for.
*/
@ -61,7 +61,7 @@ export interface SearchSource {
*
* Must be extended and the abstract methods implemented per-frontend.
*/
export default abstract class AbstractSearch<T extends SearchAttrs = SearchAttrs> extends Component<T, SearchState> {
export default abstract class AbstractGlobalSearch<T extends SearchAttrs = SearchAttrs> extends Component<T, SearchState> {
/**
* The instance of `SearchState` for this component.
*/
@ -71,5 +71,5 @@ export default abstract class AbstractSearch<T extends SearchAttrs = SearchAttrs
/**
* A list of search sources that can be used to query for search results.
*/
abstract sourceItems(): ItemList<SearchSource>;
abstract sourceItems(): ItemList<GlobalSearchSource>;
}

View File

@ -6,11 +6,11 @@ import KeyboardNavigatable from '../utils/KeyboardNavigatable';
import Stream from '../utils/Stream';
import ItemList from '../utils/ItemList';
import GambitsAutocomplete from '../utils/GambitsAutocomplete';
import type { SearchSource } from './AbstractSearch';
import type { GlobalSearchSource } from './AbstractGlobalSearch';
export interface ISearchModalAttrs extends IFormModalAttrs {
onchange: (value: string) => void;
searchState: SearchState;
sources: SearchSource[];
sources: GlobalSearchSource[];
}
export default class SearchModal<CustomAttrs extends ISearchModalAttrs = ISearchModalAttrs> extends FormModal<CustomAttrs> {
static LIMIT: number;
@ -19,11 +19,11 @@ export default class SearchModal<CustomAttrs extends ISearchModalAttrs = ISearch
/**
* An array of SearchSources.
*/
protected sources: SearchSource[];
protected sources: GlobalSearchSource[];
/**
* The key of the currently-active search source.
*/
protected activeSource: Stream<SearchSource>;
protected activeSource: Stream<GlobalSearchSource>;
/**
* The sources that are still loading results.
*/
@ -46,7 +46,7 @@ export default class SearchModal<CustomAttrs extends ISearchModalAttrs = ISearch
tabs(): JSX.Element;
tabItems(): ItemList<Mithril.Children>;
activeTabItems(): ItemList<Mithril.Children>;
switchSource(source: SearchSource): void;
switchSource(source: GlobalSearchSource): void;
gambits(): JSX.Element[];
/**
* Transforms a simple search text to wrap valid gambits in a mark tag.

View File

@ -0,0 +1,20 @@
import Component, { ComponentAttrs } from '../../common/Component';
import Discussion from '../../common/models/Discussion';
import Post from '../../common/models/Post';
import type Mithril from 'mithril';
import ItemList from '../../common/utils/ItemList';
export interface DiscussionsSearchItemAttrs extends ComponentAttrs {
query: string;
discussion: Discussion;
mostRelevantPost: Post;
}
export default class DiscussionsSearchItem extends Component<DiscussionsSearchItemAttrs> {
query: string;
discussion: Discussion;
mostRelevantPost: Post | null | undefined;
oninit(vnode: Mithril.Vnode<DiscussionsSearchItemAttrs, this>): void;
view(): JSX.Element;
discussionTitle(): string;
mostRelevantPostContent(): string | null | undefined;
viewItems(): ItemList<Mithril.Children>;
}

View File

@ -1,18 +1,17 @@
import { SearchSource } from './Search';
import type Mithril from 'mithril';
import type Discussion from '../../common/models/Discussion';
import type { SearchSource } from './Search';
import Discussion from '../../common/models/Discussion';
/**
* The `DiscussionsSearchSource` finds and displays discussion search results in
* the search dropdown.
*/
export default class DiscussionsSearchSource implements SearchSource {
protected results: Map<string, Discussion[]>;
resource: string;
title(): string;
isCached(query: string): boolean;
search(query: string, limit: number): Promise<void>;
queryString: string | null;
search(query: string): Promise<void>;
view(query: string): Array<Mithril.Vnode>;
customGrouping(): boolean;
fullPage(query: string): Mithril.Vnode;
gotoItem(id: string): string | null;
includes(): string[];
limit(): number;
queryMutators(): string[];
setQueryString(query: string): void;
}

View File

@ -0,0 +1,18 @@
import type Mithril from 'mithril';
import type Discussion from '../../common/models/Discussion';
import type { GlobalSearchSource } from './GlobalSearch';
/**
* The `DiscussionsSearchSource` finds and displays discussion search results in
* the search dropdown.
*/
export default class GlobalDiscussionsSearchSource implements GlobalSearchSource {
protected results: Map<string, Discussion[]>;
resource: string;
title(): string;
isCached(query: string): boolean;
search(query: string, limit: number): Promise<void>;
view(query: string): Array<Mithril.Vnode>;
customGrouping(): boolean;
fullPage(query: string): Mithril.Vnode;
gotoItem(id: string): string | null;
}

View File

@ -1,11 +1,11 @@
import type Mithril from 'mithril';
import type Post from '../../common/models/Post';
import type { SearchSource } from './Search';
import type { GlobalSearchSource } from './GlobalSearch';
/**
* The `PostsSearchSource` finds and displays post search results in
* the search dropdown.
*/
export default class PostsSearchSource implements SearchSource {
export default class GlobalPostsSearchSource implements GlobalSearchSource {
protected results: Map<string, Post[]>;
resource: string;
title(): string;

View File

@ -0,0 +1,10 @@
import ItemList from '../../common/utils/ItemList';
import AbstractGlobalSearch, { type SearchAttrs as BaseSearchAttrs, type GlobalSearchSource as BaseGlobalSearchSource } from '../../common/components/AbstractGlobalSearch';
export interface GlobalSearchSource extends BaseGlobalSearchSource {
}
export interface SearchAttrs extends BaseSearchAttrs {
}
export default class GlobalSearch<Attrs extends SearchAttrs = SearchAttrs> extends AbstractGlobalSearch<Attrs> {
static initAttrs(attrs: SearchAttrs): void;
sourceItems(): ItemList<GlobalSearchSource>;
}

View File

@ -0,0 +1,18 @@
import type Mithril from 'mithril';
import type User from '../../common/models/User';
import type { GlobalSearchSource } from './GlobalSearch';
/**
* The `UsersSearchSource` finds and displays user search results in the search
* dropdown.
*/
export default class GlobalUsersSearchSource implements GlobalSearchSource {
protected results: Map<string, User[]>;
resource: string;
title(): string;
isCached(query: string): boolean;
search(query: string, limit: number): Promise<void>;
view(query: string): Array<Mithril.Vnode>;
customGrouping(): boolean;
fullPage(query: string): null;
gotoItem(id: string): string | null;
}

View File

@ -1,8 +1,115 @@
import Component, { ComponentAttrs } from '../../common/Component';
import ItemList from '../../common/utils/ItemList';
import AbstractSearch, { type SearchAttrs, type SearchSource as BaseSearchSource } from '../../common/components/AbstractSearch';
export interface SearchSource extends BaseSearchSource {
import KeyboardNavigatable from '../../common/utils/KeyboardNavigatable';
import SearchState from '../../common/states/SearchState';
import type Mithril from 'mithril';
/**
* The `SearchSource` interface defines a section of search results in the
* search dropdown.
*
* Search sources should be registered with the `Search` component class
* by extending the `sourceItems` method. When the user types a
* query, each search source will be prompted to load search results via the
* `search` method. When the dropdown is redrawn, it will be constructed by
* putting together the output from the `view` method of each source.
*/
export interface SearchSource {
/**
* Make a request to get results for the given query.
* The results will be updated internally in the search source, not exposed.
*/
search(query: string): Promise<void>;
/**
* Get an array of virtual <li>s that list the search results for the given
* query.
*/
view(query: string): Array<Mithril.Vnode>;
}
export default class Search extends AbstractSearch {
static initAttrs(attrs: SearchAttrs): void;
export interface SearchAttrs extends ComponentAttrs {
/** The type of alert this is. Will be used to give the alert a class name of `Alert--{type}`. */
state: SearchState;
}
/**
* @todo: 2.0 refactored the global search UI and no longer uses this component, now we use the GlobalSearch component.
* The component was kept to support extension usage of it on a local scope.
* We need to extract this component into a separate UI package instead as it is no longer needed by core.
*
* The `Search` component displays a menu of as-you-type results from a variety
* of sources.
*
* The search box will be 'activated' if the app's search state's
* getInitialSearch() value is a truthy value. If this is the case, an 'x'
* button will be shown next to the search field, and clicking it will clear the search.
*
* ATTRS:
*
* - state: SearchState instance.
*/
export default class Search<T extends SearchAttrs = SearchAttrs> extends Component<T, SearchState> {
/**
* The minimum query length before sources are searched.
*/
protected static MIN_SEARCH_LEN: number;
/**
* The instance of `SearchState` for this component.
*/
protected searchState: SearchState;
/**
* Whether or not the search input has focus.
*/
protected hasFocus: boolean;
/**
* An array of SearchSources.
*/
protected sources?: SearchSource[];
/**
* The number of sources that are still loading results.
*/
protected loadingSources: number;
/**
* The index of the currently-selected <li> in the results list. This can be
* a unique string (to account for the fact that an item's position may jump
* around as new results load), but otherwise it will be numeric (the
* sequential position within the list).
*/
protected index: number;
protected navigator: KeyboardNavigatable;
protected searchTimeout?: number;
private updateMaxHeightHandler?;
oninit(vnode: Mithril.Vnode<T, this>): void;
view(): JSX.Element;
updateMaxHeight(): void;
onupdate(vnode: Mithril.VnodeDOM<T, this>): void;
oncreate(vnode: Mithril.VnodeDOM<T, this>): void;
onremove(vnode: Mithril.VnodeDOM<T, this>): void;
/**
* Navigate to the currently selected search result and close the list.
*/
selectResult(): void;
/**
* Clear the search
*/
clear(): void;
/**
* Build an item list of SearchSources.
*/
sourceItems(): ItemList<SearchSource>;
/**
* Get all of the search result items that are selectable.
*/
selectableItems(): JQuery;
/**
* Get the position of the currently selected search result item.
* Returns zero if not found.
*/
getCurrentNumericIndex(): number;
/**
* Get the <li> in the search results with the given index (numeric or named).
*/
getItem(index: number): JQuery;
/**
* Set the currently-selected search result item to the one with the given
* index.
*/
setIndex(index: number, scrollToItem?: boolean): void;
}

View File

@ -1,18 +1,12 @@
import type Mithril from 'mithril';
import type User from '../../common/models/User';
import type { SearchSource } from './Search';
import { SearchSource } from './Search';
import User from '../../common/models/User';
/**
* The `UsersSearchSource` finds and displays user search results in the search
* dropdown.
*/
export default class UsersSearchSource implements SearchSource {
export default class UsersSearchResults implements SearchSource {
protected results: Map<string, User[]>;
resource: string;
title(): string;
isCached(query: string): boolean;
search(query: string, limit: number): Promise<void>;
search(query: string): Promise<void>;
view(query: string): Array<Mithril.Vnode>;
customGrouping(): boolean;
fullPage(query: string): null;
gotoItem(id: string): string | null;
}

View File

@ -21,7 +21,7 @@ import './components/HeaderPrimary';
import './components/PostEdited';
import './components/IndexPage';
import './components/DiscussionRenamedNotification';
import './components/DiscussionsSearchSource';
import './components/GlobalDiscussionsSearchSource';
import './components/HeaderSecondary';
import './components/DiscussionList';
import './components/AvatarEditor';
@ -32,7 +32,7 @@ import './components/NotificationsDropdown';
import './components/UserPage';
import './components/PostUser';
import './components/UserCard';
import './components/UsersSearchSource';
import './components/GlobalUsersSearchSource';
import './components/PostPreview';
import './components/EventPost';
import './components/DiscussionHero';
@ -44,6 +44,7 @@ import './components/WelcomeHero';
import './components/CommentPost';
import './components/ComposerPostPreview';
import './components/RenameDiscussionModal';
import './components/GlobalSearch';
import './components/Search';
import './components/DiscussionListItem';
import './components/PostsUserPage';

2
framework/core/js/dist/admin.js generated vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
framework/core/js/dist/forum.js generated vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long