Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete typescript doc fixes #3661

Merged
merged 1 commit into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/doc/autocomplete/basicdoc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from 'react';
import { AutoComplete } from '../../lib/autocomplete/AutoComplete';
import { DocSectionText } from '../common/docsectiontext';
import { DocSectionCode } from '../common/docsectioncode';
import { DocSectionText } from '../common/docsectiontext';

export function BasicDoc(props) {
const [value, setValue] = useState('');
Expand Down Expand Up @@ -34,7 +34,7 @@ export default function BasicDemo() {
`,
typescript: `
import { useState } from "react";
import { AutoComplete } from "primereact/autocomplete";
import { AutoComplete, AutoCompleteCompleteMethodParams } from "primereact/autocomplete";

export default function BasicDemo() {
const [value, setValue] = useState<string>('');
Expand Down
4 changes: 2 additions & 2 deletions components/doc/autocomplete/dropdowndoc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from 'react';
import { AutoComplete } from '../../lib/autocomplete/AutoComplete';
import { DocSectionText } from '../common/docsectiontext';
import { DocSectionCode } from '../common/docsectioncode';
import { DocSectionText } from '../common/docsectiontext';

export function DropdownDoc(props) {
const [value, setValue] = useState('');
Expand Down Expand Up @@ -37,7 +37,7 @@ export default function DropdownDemo() {
`,
typescript: `
import { useState } from "react";
import { AutoComplete } from "primereact/autocomplete";
import { AutoComplete, AutoCompleteCompleteMethodParams } from "primereact/autocomplete";

export default function DropdownDemo() {
const [value, setValue] = useState<string>('');
Expand Down
4 changes: 2 additions & 2 deletions components/doc/autocomplete/forceselectiondoc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from 'react';
import { AutoComplete } from '../../lib/autocomplete/AutoComplete';
import { DocSectionText } from '../common/docsectiontext';
import { DocSectionCode } from '../common/docsectioncode';
import { DocSectionText } from '../common/docsectiontext';

export function ForceSelectionDoc(props) {
const [value, setValue] = useState('');
Expand Down Expand Up @@ -34,7 +34,7 @@ export default function ForceSelectionDemo() {
`,
typescript: `
import { useState } from "react";
import { AutoComplete } from "primereact/autocomplete";
import { AutoComplete, AutoCompleteCompleteMethodParams } from "primereact/autocomplete";

export default function ForceSelectionDemo() {
const [value, setValue] = useState<string>('');
Expand Down
12 changes: 6 additions & 6 deletions components/doc/autocomplete/groupdoc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useState } from 'react';
import getConfig from 'next/config';
import { useState } from 'react';
import { AutoComplete } from '../../lib/autocomplete/AutoComplete';
import { DocSectionText } from '../common/docsectiontext';
import { DocSectionCode } from '../common/docsectioncode';
import { DocSectionText } from '../common/docsectiontext';

export function GroupDoc(props) {
const [selectedCity, setSelectedCity] = useState(null);
Expand Down Expand Up @@ -73,7 +73,7 @@ export function GroupDoc(props) {

const code = {
basic: `
<AutoComplete value={selectedCity} onChange={(e) => setSelectedCity(e.value)} suggestions={filteredCities} completeMethod={search}
<AutoComplete value={selectedCity} onChange={(e) => setSelectedCity(e.value)} suggestions={filteredCities} completeMethod={search}
field="label" optionGroupLabel="label" optionGroupChildren="items" optionGroupTemplate={groupedItemTemplate} placeholder="Hint: type 'a'" />
`,
javascript: `
Expand Down Expand Up @@ -147,14 +147,14 @@ export default function GroupDemo() {
}

return (
<AutoComplete value={selectedCity} onChange={(e) => setSelectedCity(e.value)} suggestions={filteredCities} completeMethod={search}
<AutoComplete value={selectedCity} onChange={(e) => setSelectedCity(e.value)} suggestions={filteredCities} completeMethod={search}
field="label" optionGroupLabel="label" optionGroupChildren="items" optionGroupTemplate={groupedItemTemplate} placeholder="Hint: type 'a'" />
)
}
`,
typescript: `
import { useState } from 'react';
import { AutoComplete } from "primereact/autocomplete";
import { AutoComplete, AutoCompleteCompleteMethodParams } from "primereact/autocomplete";

interface City {
label: string;
Expand Down Expand Up @@ -234,7 +234,7 @@ export default function GroupDemo() {
}

return (
<AutoComplete value={selectedCity} onChange={(e: AutoCompleteChangeParams) => setSelectedCity(e.value)} suggestions={filteredCities} completeMethod={search}
<AutoComplete value={selectedCity} onChange={(e: AutoCompleteChangeParams) => setSelectedCity(e.value)} suggestions={filteredCities} completeMethod={search}
field="label" optionGroupLabel="label" optionGroupChildren="items" optionGroupTemplate={groupedItemTemplate} placeholder="Hint: type 'a'" />
)
}
Expand Down
28 changes: 14 additions & 14 deletions components/doc/autocomplete/multipledoc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useEffect, useState } from 'react';
import { CountryService } from '../../../service/CountryService';
import { AutoComplete } from '../../lib/autocomplete/AutoComplete';
import { DocSectionText } from '../common/docsectiontext';
import { DocSectionCode } from '../common/docsectioncode';
import { CountryService } from '../../../service/CountryService';
import { DocSectionText } from '../common/docsectiontext';

export function MultipleDoc(props) {
const [countries, setCountries] = useState([]);
Expand Down Expand Up @@ -32,10 +32,10 @@ export function MultipleDoc(props) {
countryservice.getCountries().then((data) => setCountries(data));
/*
Countries is an array of objects with name, code pairs;
[
[
...
{"name": "United Kingdom", "code": "UK"},
{"name": "United States", "code": "USA"},
{"name": "United Kingdom", "code": "UK"},
{"name": "United States", "code": "USA"},
...
]
*/
Expand All @@ -62,7 +62,7 @@ export default function MultipleDemo() {

if (!event.query.trim().length) {
_filteredCountries = [...countries];
}
}
else {
_filteredCountries = countries.filter((country) => {
return country.name.toLowerCase().startsWith(event.query.toLowerCase());
Expand All @@ -77,10 +77,10 @@ export default function MultipleDemo() {
countryservice.getCountries().then((data) => setCountries(data));
/*
Countries is an array of objects with a name and a code;
[
[
...
{"name": "United Kingdom", "code": "UK"},
{"name": "United States", "code": "USA"},
{"name": "United Kingdom", "code": "UK"},
{"name": "United States", "code": "USA"},
...
]
*/
Expand All @@ -93,7 +93,7 @@ export default function MultipleDemo() {
`,
typescript: `
import { useEffect, useState } from 'react';
import { AutoComplete } from "primereact/autocomplete";
import { AutoComplete, AutoCompleteCompleteMethodParams } from "primereact/autocomplete";

interface Country {
name: string;
Expand All @@ -113,7 +113,7 @@ export default function MultipleDemo() {

if (!event.query.trim().length) {
_filteredCountries = [...countries];
}
}
else {
_filteredCountries = countries.filter((country) => {
return country.name.toLowerCase().startsWith(event.query.toLowerCase());
Expand All @@ -128,10 +128,10 @@ export default function MultipleDemo() {
countryservice.getCountries().then((data) => setCountries(data));
/*
Countries is an array of objects with a name and a code;
[
[
...
{"name": "United Kingdom", "code": "UK"},
{"name": "United States", "code": "USA"},
{"name": "United Kingdom", "code": "UK"},
{"name": "United States", "code": "USA"},
...
]
*/
Expand Down
28 changes: 14 additions & 14 deletions components/doc/autocomplete/objectsdoc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useEffect, useState } from 'react';
import { CountryService } from '../../../service/CountryService';
import { AutoComplete } from '../../lib/autocomplete/AutoComplete';
import { DocSectionText } from '../common/docsectiontext';
import { DocSectionCode } from '../common/docsectioncode';
import { CountryService } from '../../../service/CountryService';
import { DocSectionText } from '../common/docsectiontext';

export function ObjectsDoc(props) {
const [countries, setCountries] = useState([]);
Expand Down Expand Up @@ -32,10 +32,10 @@ export function ObjectsDoc(props) {
countryservice.getCountries().then((data) => setCountries(data));
/*
Countries is an array of objects with name, code pairs;
[
[
...
{"name": "United Kingdom", "code": "UK"},
{"name": "United States", "code": "USA"},
{"name": "United Kingdom", "code": "UK"},
{"name": "United States", "code": "USA"},
...
]
*/
Expand All @@ -62,7 +62,7 @@ export default function ObjectDemo() {

if (!event.query.trim().length) {
_filteredCountries = [...countries];
}
}
else {
_filteredCountries = countries.filter((country) => {
return country.name.toLowerCase().startsWith(event.query.toLowerCase());
Expand All @@ -77,10 +77,10 @@ export default function ObjectDemo() {
countryservice.getCountries().then((data) => setCountries(data));
/*
Countries is an array of objects with a name and a code;
[
[
...
{"name": "United Kingdom", "code": "UK"},
{"name": "United States", "code": "USA"},
{"name": "United Kingdom", "code": "UK"},
{"name": "United States", "code": "USA"},
...
]
*/
Expand All @@ -93,7 +93,7 @@ export default function ObjectDemo() {
`,
typescript: `
import { useEffect, useState } from 'react';
import { AutoComplete } from "primereact/autocomplete";
import { AutoComplete, AutoCompleteCompleteMethodParams } from "primereact/autocomplete";

interface Country {
name: string;
Expand All @@ -113,7 +113,7 @@ export default function ObjectDemo() {

if (!event.query.trim().length) {
_filteredCountries = [...countries];
}
}
else {
_filteredCountries = countries.filter((country) => {
return country.name.toLowerCase().startsWith(event.query.toLowerCase());
Expand All @@ -128,10 +128,10 @@ export default function ObjectDemo() {
countryservice.getCountries().then((data) => setCountries(data));
/*
Countries is an array of objects with a name and a code;
[
[
...
{"name": "United Kingdom", "code": "UK"},
{"name": "United States", "code": "USA"},
{"name": "United Kingdom", "code": "UK"},
{"name": "United States", "code": "USA"},
...
]
*/
Expand Down
30 changes: 15 additions & 15 deletions components/doc/autocomplete/templatedoc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useEffect, useState } from 'react';
import getConfig from 'next/config';
import { useEffect, useState } from 'react';
import { CountryService } from '../../../service/CountryService';
import { AutoComplete } from '../../lib/autocomplete/AutoComplete';
import { DocSectionText } from '../common/docsectiontext';
import { DocSectionCode } from '../common/docsectioncode';
import { CountryService } from '../../../service/CountryService';
import { DocSectionText } from '../common/docsectiontext';

export function TemplateDoc(props) {
const [countries, setCountries] = useState([]);
Expand Down Expand Up @@ -49,10 +49,10 @@ export function TemplateDoc(props) {
countryservice.getCountries().then((data) => setCountries(data));
/*
Countries is an array of objects with name, code pairs;
[
[
...
{"name": "United Kingdom", "code": "UK"},
{"name": "United States", "code": "USA"},
{"name": "United Kingdom", "code": "UK"},
{"name": "United States", "code": "USA"},
...
]
*/
Expand All @@ -79,7 +79,7 @@ export default function TemplateDemo() {

if (!event.query.trim().length) {
_filteredCountries = [...countries];
}
}
else {
_filteredCountries = countries.filter((country) => {
return country.name.toLowerCase().startsWith(event.query.toLowerCase());
Expand Down Expand Up @@ -109,10 +109,10 @@ export default function TemplateDemo() {
countryservice.getCountries().then((data) => setCountries(data));
/*
Countries is an array of objects with a name and a code;
[
[
...
{"name": "United Kingdom", "code": "UK"},
{"name": "United States", "code": "USA"},
{"name": "United Kingdom", "code": "UK"},
{"name": "United States", "code": "USA"},
...
]
*/
Expand All @@ -125,7 +125,7 @@ export default function TemplateDemo() {
`,
typescript: `
import { useEffect, useState } from 'react';
import { AutoComplete } from "primereact/autocomplete";
import { AutoComplete, AutoCompleteCompleteMethodParams } from "primereact/autocomplete";

interface Country {
name: string;
Expand All @@ -145,7 +145,7 @@ export default function TemplateDemo() {

if (!event.query.trim().length) {
_filteredCountries = [...countries];
}
}
else {
_filteredCountries = countries.filter((country) => {
return country.name.toLowerCase().startsWith(event.query.toLowerCase());
Expand Down Expand Up @@ -175,10 +175,10 @@ export default function TemplateDemo() {
countryservice.getCountries().then((data) => setCountries(data));
/*
Countries is an array of objects with a name and a code;
[
[
...
{"name": "United Kingdom", "code": "UK"},
{"name": "United States", "code": "USA"},
{"name": "United Kingdom", "code": "UK"},
{"name": "United States", "code": "USA"},
...
]
*/
Expand Down
12 changes: 6 additions & 6 deletions components/doc/autocomplete/virtualscrolldoc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useState } from 'react';
import Link from 'next/link';
import { useState } from 'react';
import { AutoComplete } from '../../lib/autocomplete/AutoComplete';
import { DocSectionText } from '../common/docsectiontext';
import { DocSectionCode } from '../common/docsectioncode';
import { DocSectionText } from '../common/docsectiontext';

export function VirtualScrollDoc(props) {
const [selectedItem, setSelectedItem] = useState(null);
Expand All @@ -27,7 +27,7 @@ export function VirtualScrollDoc(props) {

const code = {
basic: `
<AutoComplete value={selectedItem} suggestions={filteredItems} completeMethod={searchItems}
<AutoComplete value={selectedItem} suggestions={filteredItems} completeMethod={searchItems}
virtualScrollerOptions={{ itemSize: 38 }} field="label" dropdown onChange={(e) => setSelectedItem(e.value)} />
`,
javascript: `
Expand Down Expand Up @@ -55,14 +55,14 @@ export default function VirtualScrollerDemo() {
}

return (
<AutoComplete value={selectedItem} suggestions={filteredItems} completeMethod={searchItems}
<AutoComplete value={selectedItem} suggestions={filteredItems} completeMethod={searchItems}
virtualScrollerOptions={{ itemSize: 38 }} field="label" dropdown onChange={(e) => setSelectedItem(e.value)} />
)
}
`,
typescript: `
import { useState } from "react";
import { AutoComplete } from "primereact/autocomplete";
import { AutoComplete, AutoCompleteCompleteMethodParams } from "primereact/autocomplete";

interface Item {
label: string;
Expand Down Expand Up @@ -90,7 +90,7 @@ export default function VirtualScrollerDemo() {
}

return (
<AutoComplete value={selectedItem} suggestions={filteredItems} completeMethod={searchItems}
<AutoComplete value={selectedItem} suggestions={filteredItems} completeMethod={searchItems}
virtualScrollerOptions={{ itemSize: 38 }} field="label" dropdown onChange={(e: AutoCompleteChangeParams) => setSelectedItem(e.value)} />
)
}
Expand Down