-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Criação do componente de filtro
- Loading branch information
Showing
11 changed files
with
260 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from "react"; | ||
import { InputFilterCoreProps, InputFilterOptionsMap } from "../types"; | ||
import { AutoComplete as AutocompletePrimeReact } from "primereact/autocomplete"; | ||
import { handleGetValueAutocomplete, handleSetValueAutocomplete } from "../function/handle"; | ||
|
||
/** | ||
* Core - `Autocomplete` | ||
* Campo do filtro tipo autocomplete | ||
*/ | ||
export function Autocomplete<T extends keyof InputFilterOptionsMap>(props: InputFilterCoreProps<"autocomplete">) { | ||
const value = handleGetValueAutocomplete(props.value, props.options, props.data); | ||
|
||
return ( | ||
<AutocompletePrimeReact multiple | ||
completeMethod={event => { | ||
let ids = value.map(item => item.id); | ||
props.onSearch(event.query, ids); | ||
}} | ||
appendTo="self" | ||
className="w-100" | ||
disabled={props.disabled} | ||
emptyMessage="Não encontramos dados." | ||
field="label" | ||
id={(props.id ?? "input-filter") + "-" + "autocomplete"} | ||
inputClassName="form-control" | ||
name={(props.name ?? "input-filter") + "-" + "autocomplete"} | ||
panelClassName="input-filter-autocomplete-panel" | ||
placeholder={props.placeholder} | ||
required={props.required} | ||
scrollHeight={props.autocompleteScrollHeight} | ||
selectionLimit={props.autocompleteSelectLimit} | ||
suggestions={props.data} | ||
value={value} | ||
onChange={event => props.onChange(handleSetValueAutocomplete(event.value, props.select))}/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
import React from "react"; | ||
import { handleGetValueText } from "../function/handle"; | ||
import { InputFilterOptionsMap, InputFilterProps } from "../types"; | ||
import { InputFilterCoreProps, InputFilterOptionsMap } from "../types"; | ||
|
||
/** | ||
* Core - `Text` | ||
* Campo do filtro tipo texto | ||
*/ | ||
export function Text<T extends keyof InputFilterOptionsMap = "text">(props: InputFilterProps<T> & { | ||
options: any[] | ||
select: string | ||
}) { | ||
return (!props.type || props.type === "text") && ( | ||
export function Text<T extends keyof InputFilterOptionsMap>(props: InputFilterCoreProps<T>) { | ||
return ( | ||
<input className="form-control input-filter-field" | ||
disabled={props.disabled} | ||
id={(props.id ?? "input-filter") + "-text"} | ||
name={(props.name ?? "input-filter") + "-text"} | ||
placeholder={props.placeholder} | ||
value={handleGetValueText<T>(props.value, props.options)} | ||
value={handleGetValueText(props.value, props.options) ?? ""} | ||
onChange={event => props.onChange(event.target.value + props.select)}/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.