Skip to content

Commit

Permalink
Related #4431, #4602 - For Form components
Browse files Browse the repository at this point in the history
  • Loading branch information
ulasturann committed Aug 19, 2023
1 parent 48723c1 commit 5a3beca
Show file tree
Hide file tree
Showing 39 changed files with 258 additions and 190 deletions.
7 changes: 4 additions & 3 deletions components/doc/cascadeselect/basicdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function BasicDoc(props) {
basic: `
<CascadeSelect value={selectedCity} onChange={(e) => setSelectedCity(e.value)} options={countries}
optionLabel="cname" optionGroupLabel="name" optionGroupChildren={['states', 'cities']}
className="w-full md:w-14rem" breakpoint="767px" placeholder="Select a City" />
className="w-full md:w-14rem" breakpoint="767px" placeholder="Select a City" style={{ minWidth: '14rem' }} />
`,
javascript: `
import React, { useState } from "react";
Expand Down Expand Up @@ -173,7 +173,7 @@ export default function BasicDemo() {
<div className="card flex justify-content-center">
<CascadeSelect value={selectedCity} onChange={(e) => setSelectedCity(e.value)} options={countries}
optionLabel="cname" optionGroupLabel="name" optionGroupChildren={['states', 'cities']}
className="w-full md:w-14rem" breakpoint="767px" placeholder="Select a City" />
className="w-full md:w-14rem" breakpoint="767px" placeholder="Select a City" style={{ minWidth: '14rem' }} />
</div>
)
}
Expand Down Expand Up @@ -281,7 +281,7 @@ export default function BasicDemo() {
<div className="card flex justify-content-center">
<CascadeSelect value={selectedCity} onChange={(e: CascadeSelectChangeEvent) => setSelectedCity(e.value)} options={countries}
optionLabel="cname" optionGroupLabel="name" optionGroupChildren={['states', 'cities']}
className="w-full md:w-14rem" breakpoint="767px" placeholder="Select a City" />
className="w-full md:w-14rem" breakpoint="767px" placeholder="Select a City" style={{ minWidth: '14rem' }} />
</div>
)
}
Expand All @@ -307,6 +307,7 @@ export default function BasicDemo() {
className="w-full md:w-14rem"
breakpoint="767px"
placeholder="Select a City"
style={{ minWidth: '14rem' }}
/>
</div>
<DocSectionCode code={code} />
Expand Down
7 changes: 4 additions & 3 deletions components/doc/cascadeselect/floatlabeldoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function FloatLabelDoc(props) {
<span className="p-float-label">
<CascadeSelect inputId="cs-city" value={selectedCity} onChange={(e) => setSelectedCity(e.value)} options={countries}
optionLabel="cname" optionGroupLabel="name" optionGroupChildren={['states', 'cities']}
className="w-full md:w-14rem" breakpoint="767px" />
className="w-full md:w-14rem" breakpoint="767px" style={{ minWidth: '14rem' }} />
<label htmlFor="cs-city">City</label>
</span>
`,
Expand Down Expand Up @@ -177,7 +177,7 @@ export default function FloatLabelDemo() {
<span className="p-float-label">
<CascadeSelect inputId="cs-city" value={selectedCity} onChange={(e) => setSelectedCity(e.value)} options={countries}
optionLabel="cname" optionGroupLabel="name" optionGroupChildren={['states', 'cities']}
className="w-full md:w-14rem" breakpoint="767px" />
className="w-full md:w-14rem" breakpoint="767px" style={{ minWidth: '14rem' }} />
<label htmlFor="cs-city">City</label>
</span>
</div>
Expand Down Expand Up @@ -288,7 +288,7 @@ export default function FloatLabelDemo() {
<span className="p-float-label">
<CascadeSelect inputId="cs-city" value={selectedCity} onChange={(e: CascadeSelectChangeEvent) => setSelectedCity(e.value)} options={countries}
optionLabel="cname" optionGroupLabel="name" optionGroupChildren={['states', 'cities']}
className="w-full md:w-14rem" breakpoint="767px" />
className="w-full md:w-14rem" breakpoint="767px" style={{ minWidth: '14rem' }} />
<label htmlFor="cs-city">City</label>
</span>
</div>
Expand All @@ -314,6 +314,7 @@ export default function FloatLabelDemo() {
optionGroupChildren={['states', 'cities']}
className="w-full md:w-14rem"
breakpoint="767px"
style={{ minWidth: '14rem' }}
/>
<label htmlFor="cs-city">City</label>
</span>
Expand Down
7 changes: 4 additions & 3 deletions components/doc/cascadeselect/invaliddoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function InvalidDoc(props) {
basic: `
<CascadeSelect value={selectedCity} onChange={(e) => setSelectedCity(e.value)} options={countries}
optionLabel="cname" optionGroupLabel="name" optionGroupChildren={['states', 'cities']}
className="p-invalid w-full md:w-14rem" breakpoint="767px" placeholder="Select a City" />
className="p-invalid w-full md:w-14rem" breakpoint="767px" placeholder="Select a City" style={{ minWidth: '14rem' }} />
`,
javascript: `
import React, { useState } from "react";
Expand Down Expand Up @@ -173,7 +173,7 @@ export default function InvalidDemo() {
<div className="card flex justify-content-center">
<CascadeSelect value={selectedCity} onChange={(e) => setSelectedCity(e.value)} options={countries}
optionLabel="cname" optionGroupLabel="name" optionGroupChildren={['states', 'cities']}
className="p-invalid w-full md:w-14rem" breakpoint="767px" placeholder="Select a City" />
className="p-invalid w-full md:w-14rem" breakpoint="767px" placeholder="Select a City" style={{ minWidth: '14rem' }} />
</div>
)
}
Expand Down Expand Up @@ -281,7 +281,7 @@ export default function InvalidDemo() {
<div className="card flex justify-content-center">
<CascadeSelect value={selectedCity} onChange={(e: CascadeSelectChangeEvent) => setSelectedCity(e.value)} options={countries}
optionLabel="cname" optionGroupLabel="name" optionGroupChildren={['states', 'cities']}
className="p-invalid w-full md:w-14rem" breakpoint="767px" placeholder="Select a City" />
className="p-invalid w-full md:w-14rem" breakpoint="767px" placeholder="Select a City" style={{ minWidth: '14rem' }} />
</div>
)
}
Expand All @@ -306,6 +306,7 @@ export default function InvalidDemo() {
className="p-invalid w-full md:w-14rem"
breakpoint="767px"
placeholder="Select a City"
style={{ minWidth: '14rem' }}
/>
</div>
<DocSectionCode code={code} />
Expand Down
7 changes: 4 additions & 3 deletions components/doc/cascadeselect/templatedoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function TemplateDoc(props) {
basic: `
<CascadeSelect value={selectedCity} onChange={e => setSelectedCity(e.value)} options={countries}
optionLabel="cname" optionGroupLabel="name" optionGroupChildren={['states', 'cities']}
className="w-full md:w-14rem" breakpoint="767px" placeholder="Select a City" itemTemplate={countryOptionTemplate} />
className="w-full md:w-14rem" breakpoint="767px" placeholder="Select a City" itemTemplate={countryOptionTemplate} style={{ minWidth: '14rem' }} />
`,
javascript: `
import React, { useState } from "react";
Expand Down Expand Up @@ -196,7 +196,7 @@ export default function TemplateDemo() {
<div className="card flex justify-content-center">
<CascadeSelect value={selectedCity} onChange={e => setSelectedCity(e.value)} options={countries}
optionLabel="cname" optionGroupLabel="name" optionGroupChildren={['states', 'cities']}
className="w-full md:w-14rem" breakpoint="767px" placeholder="Select a City" itemTemplate={countryOptionTemplate} />
className="w-full md:w-14rem" breakpoint="767px" placeholder="Select a City" itemTemplate={countryOptionTemplate} style={{ minWidth: '14rem' }} />
</div>
)
}
Expand Down Expand Up @@ -315,7 +315,7 @@ export default function TemplateDemo() {
<div className="card flex justify-content-center">
<CascadeSelect value={selectedCity} onChange={(e: CascadeSelectChangeEvent) => setSelectedCity(event.value)} options={countries}
optionLabel="cname" optionGroupLabel="name" optionGroupChildren={['states', 'cities']}
className="w-full md:w-14rem" breakpoint="767px" placeholder="Select a City" itemTemplate={countryOptionTemplate} />
className="w-full md:w-14rem" breakpoint="767px" placeholder="Select a City" itemTemplate={countryOptionTemplate} style={{ minWidth: '14rem' }} />
</div>
)
}
Expand All @@ -341,6 +341,7 @@ export default function TemplateDemo() {
breakpoint="767px"
placeholder="Select a City"
itemTemplate={countryOptionTemplate}
style={{ minWidth: '14rem' }}
/>
</div>
<DocSectionCode code={code} />
Expand Down
6 changes: 3 additions & 3 deletions components/doc/inputgroup/basicdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ import { DocSectionText } from '../common/docsectiontext';
export function BasicDoc(props) {
const code = {
basic: `
<div className="p-inputgroup">
<div className="p-inputgroup flex-1">
<span className="p-inputgroup-addon">
<i className="pi pi-user"></i>
</span>
<InputText placeholder="Username" />
</div>
<div className="p-inputgroup">
<div className="p-inputgroup flex-1">
<span className="p-inputgroup-addon">$</span>
<InputNumber placeholder="Price" />
<span className="p-inputgroup-addon">.00</span>
</div>
<div className="p-inputgroup">
<div className="p-inputgroup flex-1">
<span className="p-inputgroup-addon">www</span>
<InputText placeholder="Website" />
</div>
Expand Down
6 changes: 3 additions & 3 deletions components/doc/inputgroup/buttondoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import { DocSectionText } from '../common/docsectiontext';
export function ButtonDoc(props) {
const code = {
basic: `
<div className="p-inputgroup">
<div className="p-inputgroup flex-1">
<Button label="Search" />
<InputText placeholder="Keyword" />
</div>
<div className="p-inputgroup">
<div className="p-inputgroup flex-1">
<InputText placeholder="Keyword" />
<Button icon="pi pi-search" className="p-button-warning" />
</div>
<div className="p-inputgroup">
<div className="p-inputgroup flex-1">
<Button icon="pi pi-check" className="p-button-success" />
<InputText placeholder="Vote" />
<Button icon="pi pi-times" className="p-button-danger" />
Expand Down
6 changes: 3 additions & 3 deletions components/doc/inputgroup/checkboxdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ export function CheckboxDoc(props) {

const code = {
basic: `
<div className="p-inputgroup">
<div className="p-inputgroup flex-1">
<InputText placeholder="Price" />
<span className="p-inputgroup-addon">
<RadioButton name="rb1" value="rb1" checked={radioValue === 'rb1'} onChange={(e) => setRadioValue(e.value)} />
</span>
</div>
<div className="p-inputgroup">
<div className="p-inputgroup flex-1">
<span className="p-inputgroup-addon">
<Checkbox checked={checked1} onChange={(e) => setChecked1(!checked1)} />
</span>
<InputText placeholder="Username" />
</div>
<div className="p-inputgroup">
<div className="p-inputgroup flex-1">
<span className="p-inputgroup-addon">
<Checkbox checked={checked2} onChange={(e) => setChecked2(!checked2)} />
</span>
Expand Down
2 changes: 1 addition & 1 deletion components/doc/inputgroup/multipledoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DocSectionText } from '../common/docsectiontext';
export function MultipleDoc(props) {
const code = {
basic: `
<div className="p-inputgroup">
<div className="p-inputgroup w-full md:w-30rem">
<span className="p-inputgroup-addon">
<i className="pi pi-clock"></i>
</span>
Expand Down
2 changes: 1 addition & 1 deletion components/doc/treetable/templatedoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Column } from '../../lib/column/Column';
import { TreeTable } from '../../lib/treetable/TreeTable';
import { DocSectionCode } from '../common/docsectioncode';
import { DocSectionText } from '../common/docsectiontext';
import { classNames } from '../../lib/utils/ClassNames';
import { classNames } from '../../lib/utils/Utils';

export function TemplateDoc(props) {
const [nodes, setNodes] = useState([]);
Expand Down
2 changes: 1 addition & 1 deletion components/layout/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Button } from '../lib/button/Button';
import { InputSwitch } from '../lib/inputswitch/InputSwitch';
import { RadioButton } from '../lib/radiobutton/RadioButton';
import { Sidebar } from '../lib/sidebar/Sidebar';
import { classNames } from '../lib/utils/ClassNames';
import { classNames } from '../lib/utils/Utils';

export default function Config(props) {
const [scale, setScale] = useState(14);
Expand Down
2 changes: 1 addition & 1 deletion components/layout/layout.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Head from 'next/head';
import { useRouter } from 'next/router';
import { useContext, useEffect, useState } from 'react';
import { classNames } from '../lib/utils/ClassNames';
import { classNames } from '../lib/utils/Utils';
import NewsSection from '../news/newssection';
import AppContentContext from './appcontentcontext';
import Config from './config';
Expand Down
2 changes: 1 addition & 1 deletion components/layout/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Link from 'next/link';
import { useRouter } from 'next/router';
import React, { memo, useEffect } from 'react';
import { StyleClass } from '../lib/styleclass/StyleClass';
import { classNames } from '../lib/utils/ClassNames';
import { classNames } from '../lib/utils/Utils';
import MenuData from './menu.json';

const Menu = memo((props) => {
Expand Down
2 changes: 1 addition & 1 deletion components/lib/button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const Button = React.memo(
return <span {...labelProps}>{props.label}</span>;
}

return !props.children && !props.label && <span className="p-button-label p-c" dangerouslySetInnerHTML={{ __html: '&nbsp;' }}></span>;
return !props.children && !props.label && <span className={cx('label')} dangerouslySetInnerHTML={{ __html: '&nbsp;' }}></span>;
};

const createBadge = () => {
Expand Down
10 changes: 5 additions & 5 deletions components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,13 @@ export const Calendar = React.memo(
if (navigation.current.button) {
initFocusableCell();

if (navigation.current.backward) DomHandler.findSingle(overlayRef.current, '.p-datepicker-prev').focus();
else DomHandler.findSingle(overlayRef.current, '.p-datepicker-next').focus();
if (navigation.current.backward) previousButton.current.focus();
else nextButton.current.focus();
} else {
let cell;

if (navigation.current.backward) {
let cells = DomHandler.find(overlayRef.current, '.p-datepicker-calendar td span:not(.p-disabled)');
let cells = DomHandler.find(overlayRef.current, '.p-datepicker-calendar td span:not(.p-disabled)'); /* @todo */

cell = cells[cells.length - 1];
} else {
Expand Down Expand Up @@ -2663,7 +2663,7 @@ export const Calendar = React.memo(
);

return (
<button {...previousButtonProps}>
<button ref={previousButton} {...previousButtonProps}>
{backwardNavigatorIcon}
<Ripple />
</button>
Expand All @@ -2690,7 +2690,7 @@ export const Calendar = React.memo(
);

return (
<button {...nextButtonProps}>
<button ref={nextButton} {...nextButtonProps}>
{forwardNavigatorIcon}
<Ripple />
</button>
Expand Down
1 change: 0 additions & 1 deletion components/lib/cascadeselect/CascadeSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@ export const CascadeSelect = React.memo(
<CascadeSelectSub
options={props.options}
selectionPath={selectionPath.current}
className={'p-cascadeselect-items'}
optionGroupIcon={props.optionGroupIcon}
optionLabel={props.optionLabel}
optionValue={props.optionValue}
Expand Down
17 changes: 7 additions & 10 deletions components/lib/cascadeselect/CascadeSelectBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,17 @@ const classes = {
'p-placeholder': label === props.placeholder,
'p-cascadeselect-label-empty': !props.value && label === 'p-emptylabel'
}),
list: ({ subProps, context }) =>
classNames('p-cascadeselect-panel p-cascadeselect-items', subProps, {
list: ({ context }) =>
classNames('p-cascadeselect-panel p-cascadeselect-items', {
'p-input-filled': (context && context.inputStyle === 'filled') || PrimeReact.inputStyle === 'filled',
'p-ripple-disabled': (context && context.ripple === false) || PrimeReact.ripple === false
}),
sublist: 'p-cascadeselect-panel p-cascadeselect-items p-cascadeselect-sublist',
item: ({ option, isOptionGroup, activeOptionState }) =>
classNames(
'p-cascadeselect-item',
{
'p-cascadeselect-item-group': isOptionGroup(option),
'p-cascadeselect-item-active p-highlight': activeOptionState === option
},
option.className
),
classNames('p-cascadeselect-item', {
'p-cascadeselect-item-group': isOptionGroup(option),
'p-cascadeselect-item-active p-highlight': activeOptionState === option
}),
dropdownIcon: 'p-cascadeselect-trigger-icon',
dropdownButton: 'p-cascadeselect-trigger',
wrapper: 'p-cascadeselect-items-wrapper',
Expand Down
8 changes: 4 additions & 4 deletions components/lib/cascadeselect/CascadeSelectSub.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export const CascadeSelectSub = React.memo((props) => {
return (
<CascadeSelectSub
options={options}
className="p-cascadeselect-sublist"
className={cx('sublist')}
selectionPath={props.selectionPath}
optionLabel={props.optionLabel}
optionValue={props.optionValue}
Expand Down Expand Up @@ -231,7 +231,7 @@ export const CascadeSelectSub = React.memo((props) => {

const itemProps = mergeProps(
{
className: cx('item', { option, isOptionGroup, activeOptionState }),
className: classNames(option.className, cx('item', { option, isOptionGroup, activeOptionState })),
style: option.style,
role: 'none'
},
Expand All @@ -258,11 +258,11 @@ export const CascadeSelectSub = React.memo((props) => {
const listProps = mergeProps(
{
ref: elementRef,
className: cx('list', { subProps: props.className, context }),
className: cx(props.level === 0 ? 'list' : 'sublist', { context }),
role: 'listbox',
'aria-orientation': 'horizontal'
},
ptm('list')
props.level === 0 ? ptm('list') : ptm('sublist')
);

return <ul {...listProps}>{submenu}</ul>;
Expand Down
Loading

0 comments on commit 5a3beca

Please sign in to comment.