Skip to content

Commit

Permalink
docs: Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Trishu-Patel committed Dec 19, 2024
1 parent 9f432ad commit f1f240f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
30 changes: 15 additions & 15 deletions apps/docs-app/app/components/f/form/search.gts
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ export default class extends Component {
@minCharacters={{this.minCharacters}}
@noResultsLabel={{this.noResultsLabel}}
@placeholder={{this.placeholder}}
@onChange={{fn log "The value changed to"}}
@query={{this.stringQuery}}
@readonly={{this.readonly}}
@scrollable={{this.scrollable}}
@searchTimeout={{this.searchTimeout}}
@onChange={{fn log "The value changed to"}}
@onQuery={{this.stringQuery}}
/>
</:example>
<:api as |Args|>
Expand Down Expand Up @@ -234,27 +234,18 @@ export default class extends Component {
/>
<Args.String
@name="noResultsLabel"
@defaultValue={{"No results found"}}
@defaultValue="No results found"
@description="The label to display when no results are found"
@value={{this.noResultsLabel}}
@onInput={{fn this.update "noResultsLabel"}}
/>
<Args.String
@name="placeholder"
@defaultValue={{"Search"}}
@defaultValue="Search"
@description="The placeholder text"
@value={{this.placeholder}}
@onInput={{fn this.update "placeholder"}}
/>
<Args.Action
@name="query"
@description="A function that return a array of strings or objects options"
>
<CodeBlock
@lang="typescript"
@code="(string: searchString) => string[]"
/>
</Args.Action>
<Args.Bool
@name="readonly"
@defaultValue={{false}}
Expand All @@ -276,6 +267,15 @@ export default class extends Component {
@value={{this.searchTimeout}}
@onInput={{fn this.update "searchTimeout"}}
/>
<Args.Action
@name="onQuery"
@description="A function that return a array of strings or objects options"
>
<CodeBlock
@lang="typescript"
@code="(string: searchString) => string[]"
/>
</Args.Action>
</:api>
</FreestyleUsage>
</Section.subsection>
Expand All @@ -295,12 +295,12 @@ export default class extends Component {
@minCharacters={{this.minCharacters}}
@noResultsLabel={{this.noResultsLabel}}
@placeholder={{this.placeholder}}
@onChange={{fn log "The value changed to"}}
@query={{this.objectQuery}}
@readonly={{this.readonly}}
@scrollable={{this.scrollable}}
@searchTimeout={{this.searchTimeout}}
@serializationPath="key"
@onChange={{fn log "The value changed to"}}
@onQuery={{this.objectQuery}}
/>
</:example>
</FreestyleUsage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ module('Integration | Component | form/search', function (hooks) {
fruit.toLowerCase().includes(text.toLowerCase()),
);

console.log(filteredFruits);

return filteredFruits;
};

Expand Down
10 changes: 5 additions & 5 deletions packages/ember-core/src/components/form/search.gts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ export interface SearchSignature<T> {
minCharacters?: number;
noResultsLabel?: string;
placeholder?: string;
query: (searchString: string) => Promise<T[]>;
readonly?: boolean;
scrollable?: boolean;
searchTimeout?: number;
serializationPath?: string;
onQuery: (searchString: string) => Promise<T[]>;
};
Element: HTMLDivElement;
}
Expand Down Expand Up @@ -130,7 +130,7 @@ export default class Search<T> extends BoundValue<
}

get loading() {
return this.args.loading || this.onQuery.isRunning;
return this.args.loading || this.query.isRunning;
}

get minCharacters() {
Expand Down Expand Up @@ -258,9 +258,9 @@ export default class Search<T> extends BoundValue<
activeElement.scrollIntoView({ block: 'nearest' });
}

onQuery = restartableTask(async (searchString) => {
query = restartableTask(async (searchString) => {
await timeout(this.searchTimeout);
this.options = await this.args.query(searchString);
this.options = await this.args.onQuery(searchString);
this.isFocused = true;
});

Expand Down Expand Up @@ -348,7 +348,7 @@ export default class Search<T> extends BoundValue<
return;
}

this.onQuery.perform(this.searchString);
this.query.perform(this.searchString);
}

@action
Expand Down

0 comments on commit f1f240f

Please sign in to comment.