Skip to content

Commit

Permalink
Merge pull request #6219 from nitrogenous/icon-field
Browse files Browse the repository at this point in the history
New components IconField & InputIcon
  • Loading branch information
nitrogenous authored Mar 26, 2024
2 parents db3d6cb + 846c164 commit 709d5c4
Show file tree
Hide file tree
Showing 70 changed files with 4,373 additions and 1,266 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//Remove '*' during the development.
*
226 changes: 226 additions & 0 deletions components/doc/common/apidoc/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -27229,6 +27229,133 @@
}
}
},
"iconfield": {
"description": "IconField wraps an input and an icon.\n\n[Live Demo](https://www.primereact.org/iconfield/)",
"components": {
"IconField": {
"methods": {
"description": "Defines methods that can be accessed by the component's reference.",
"values": []
},
"props": {
"description": "Defines valid properties in IconField component. In addition to these, all properties of HTMLInputElement can be used in this component.",
"values": [
{
"name": "children",
"optional": true,
"readonly": true,
"type": "ReactNode",
"default": "",
"description": "Used to get the child elements of the component."
},
{
"name": "iconPosition",
"optional": true,
"readonly": false,
"type": "\"left\" | \"right\"",
"default": "right",
"description": "Position of the icon"
},
{
"name": "pt",
"optional": true,
"readonly": false,
"type": "IconFieldPassThroughOptions",
"default": "",
"description": "Uses to pass attributes to DOM elements inside the component."
},
{
"name": "ptOptions",
"optional": true,
"readonly": false,
"type": "PassThroughOptions",
"default": "",
"description": "Used to configure passthrough(pt) options of the component."
},
{
"name": "unstyled",
"optional": true,
"readonly": false,
"type": "boolean",
"default": "false",
"description": "When enabled, it removes component related styles in the core."
}
]
},
"callbacks": {
"description": "Defines callbacks that determine the behavior of the component based on a given condition or report the actions that the component takes.",
"values": []
}
}
},
"interfaces": {
"description": "Defines the custom interfaces used by the module.",
"values": {
"IconFieldPassThroughMethodOptions": {
"description": "Custom passthrough(pt) option method.",
"relatedProp": "",
"props": [
{
"name": "props",
"optional": false,
"readonly": false,
"type": "IconFieldProps"
},
{
"name": "context",
"optional": false,
"readonly": false,
"type": "IconFieldContext"
}
],
"callbacks": []
},
"IconFieldPassThroughOptions": {
"description": "Custom passthrough(pt) options.",
"relatedProp": "pt",
"props": [
{
"name": "root",
"optional": true,
"readonly": false,
"type": "IconFieldPassThroughType<HTMLAttributes<HTMLInputElement>>",
"description": "Uses to pass attributes to the root's DOM element."
},
{
"name": "hooks",
"optional": true,
"readonly": false,
"type": "ComponentHooks",
"description": "Used to manage all lifecycle hooks"
}
],
"callbacks": []
},
"IconFieldContext": {
"description": "Defines current options in IconField component.",
"relatedProp": "",
"props": [
{
"name": "iconPosition",
"optional": true,
"readonly": false,
"type": "\"left\" | \"right\"",
"description": "Position of the icon"
}
],
"callbacks": []
}
}
},
"types": {
"description": "Defines the custom types used by the module.",
"values": {
"IconFieldPassThroughType": {
"values": "PassThroughType<T, IconFieldPassThroughMethodOptions>"
}
}
}
},
"icons/angledoubledown": {
"components": {
"AngleDoubleDownIcon": {
Expand Down Expand Up @@ -29956,6 +30083,105 @@
}
}
},
"inputicon": {
"description": "InputIcon displays an icon.\n\n[Live Demo](https://www.primereact.org/iconfield/)",
"components": {
"InputIcon": {
"methods": {
"description": "Defines methods that can be accessed by the component's reference.",
"values": []
},
"props": {
"description": "Defines valid properties in InputIcon component. In addition to these, all properties of HTMLInputElement can be used in this component.",
"values": [
{
"name": "children",
"optional": true,
"readonly": true,
"type": "ReactNode",
"default": "",
"description": "Used to get the child elements of the component."
},
{
"name": "pt",
"optional": true,
"readonly": false,
"type": "InputIconPassThroughOptions",
"default": "",
"description": "Uses to pass attributes to DOM elements inside the component."
},
{
"name": "ptOptions",
"optional": true,
"readonly": false,
"type": "PassThroughOptions",
"default": "",
"description": "Used to configure passthrough(pt) options of the component."
},
{
"name": "unstyled",
"optional": true,
"readonly": false,
"type": "boolean",
"default": "false",
"description": "When enabled, it removes component related styles in the core."
}
]
},
"callbacks": {
"description": "Defines callbacks that determine the behavior of the component based on a given condition or report the actions that the component takes.",
"values": []
}
}
},
"interfaces": {
"description": "Defines the custom interfaces used by the module.",
"values": {
"InputIconPassThroughMethodOptions": {
"description": "Custom passthrough(pt) option method.",
"relatedProp": "",
"props": [
{
"name": "props",
"optional": false,
"readonly": false,
"type": "InputIconProps"
}
],
"callbacks": []
},
"InputIconPassThroughOptions": {
"description": "Custom passthrough(pt) options.",
"relatedProp": "pt",
"props": [
{
"name": "root",
"optional": true,
"readonly": false,
"type": "InputIconPassThroughType<HTMLAttributes<HTMLInputElement>>",
"description": "Uses to pass attributes to the root's DOM element."
},
{
"name": "hooks",
"optional": true,
"readonly": false,
"type": "ComponentHooks",
"description": "Used to manage all lifecycle hooks"
}
],
"callbacks": []
}
}
},
"types": {
"description": "Defines the custom types used by the module.",
"values": {
"InputIconPassThroughType": {
"values": "PassThroughType<T, InputIconPassThroughMethodOptions>"
}
}
}
},
"inputmask": {
"description": "InputMask component is used to enter input in a certain format such as numeric, date, currency, email and phone.\n\n[Live Demo](https://www.primereact.org/inputmask/)",
"components": {
Expand Down
14 changes: 14 additions & 0 deletions components/doc/iconfield/accessibilitydoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import { DocSectionText } from '@/components/doc/common/docsectiontext';

export function AccessibilityDoc() {
return (
<DocSectionText id="accessibility" label="Accessibility">
<h3>Screen Reader</h3>
<p>IconField and InputIcon does not require any roles and attributes.</p>

<h3>Keyboard Support</h3>
<p>Components does not include any interactive elements.</p>
</DocSectionText>
);
}
84 changes: 84 additions & 0 deletions components/doc/iconfield/basicdoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import React, { useState } from 'react';
import { DocSectionCode } from '@/components/doc/common/docsectioncode';
import { DocSectionText } from '@/components/doc/common/docsectiontext';
import { IconField } from '@/components/lib/iconfield/IconField';
import { InputIcon } from '@/components/lib/inputicon/InputIcon';
import { InputText } from '@/components/lib/inputtext/InputText';

export function BasicDoc(props) {
const code = {
basic: `
<IconField iconPosition="left">
<InputIcon className="pi pi-search"> </InputIcon>
<InputText v-model="value1" placeholder="Search" />
</IconField>
<IconField>
<InputIcon className="pi pi-spin pi-spinner"> </InputIcon>
<InputText v-model="value2" />
</IconField>
`,
javascript: `
import React from "react";
import { IconField } from "primereact/iconfield";
import { InputIcon } from "primereact/inputicon";
import { InputText } from "primereact/inputtext";
export default function BasicDemo() {
return (
<IconField iconPosition="left">
<InputIcon className="pi pi-search"> </InputIcon>
<InputText v-model="value1" placeholder="Search" />
</IconField>
<IconField>
<InputIcon className="pi pi-spin pi-spinner"> </InputIcon>
<InputText v-model="value2" />
</IconField>
)
}
`,
typescript: `
import React from "react";
import { IconField } from "primereact/iconfield";
import { InputIcon } from "primereact/inputicon";
import { InputText } from "primereact/inputtext";
export default function BasicDemo() {
return (
<IconField iconPosition="left">
<InputIcon className="pi pi-search"> </InputIcon>
<InputText v-model="value1" placeholder="Search" />
</IconField>
<IconField>
<InputIcon className="pi pi-spin pi-spinner"> </InputIcon>
<InputText v-model="value2" />
</IconField>
)
}
`
};

return (
<>
<DocSectionText {...props}>
<p>
IconField is used as a controlled input with <i>value</i> and <i>onChange</i> properties.
</p>
</DocSectionText>
<div className="card flex flex-wrap justify-content-center gap-3">
<IconField iconPosition="left">
<InputIcon className="pi pi-search" />
<InputText v-model="value1" placeholder="Search" />
</IconField>

<IconField>
<InputIcon className="pi pi-spin pi-spinner" />
<InputText v-model="value2" />
</IconField>
</div>
<DocSectionCode code={code} />
</>
);
}
18 changes: 18 additions & 0 deletions components/doc/iconfield/importdoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { DocSectionCode } from '@/components/doc/common/docsectioncode';
import { DocSectionText } from '@/components/doc/common/docsectiontext';

export function ImportDoc(props) {
const code = {
basic: `
import { IconField } from 'primereact/iconfield';
import { InputIcon } from 'primereact/inputicon';
`
};

return (
<>
<DocSectionText {...props}></DocSectionText>
<DocSectionCode code={code} hideToggleCode import hideStackBlitz />
</>
);
}
26 changes: 26 additions & 0 deletions components/doc/iconfield/pt/ptdoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import { DocSectionCode } from '@/components/doc/common/docsectioncode';
import { DocSectionText } from '@/components/doc/common/docsectiontext';
import { InputText } from '@/components/lib/inputtext/InputText';

export function PTDoc(props) {
return (
<>
<DocSectionText {...props}>
<p>
InputText is used as a controlled input with <i>value</i> and <i>onChange</i> properties.
</p>
</DocSectionText>
<div className="card flex justify-content-center">
<InputText
value={value}
onChange={(e) => setValue(e.target.value)}
pt={{
root: { className: 'border-primary-400' }
}}
/>
</div>
<DocSectionCode code={code} />
</>
);
}
Loading

0 comments on commit 709d5c4

Please sign in to comment.