Skip to content

Commit

Permalink
Fix primefaces#5461: Passthrough TS and casing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Jan 9, 2024
1 parent 87c92d6 commit 4b5b7d0
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 25 deletions.
35 changes: 35 additions & 0 deletions components/lib/accordion/accordion.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export declare type AccordionPassThroughTransitionType = ReactCSSTransitionProps
export interface AccordionTabPassThroughMethodOptions {
props: AccordionTabProps;
parent: AccordionPassThroughMethodOptions;
context: AccordionContext;
}

/**
Expand Down Expand Up @@ -74,6 +75,40 @@ export interface AccordionTabPassThroughOptions {
transition?: AccordionPassThroughTransitionType;
}

/**
* Defines current inline context in Accordion component.
*/
export interface AccordionContext {
/**
* Opened tab index.
*/
index: number;
/**
* Total number of tabs
*/
count: number;
/**
* Is this the first tab?
* @defaultValue false
*/
first: boolean;
/**
* Is this the last tab?
* @defaultValue false
*/
last: boolean;
/**
* Is this tab currently selected.
* @defaultValue false
*/
selected: boolean;
/**
* Is this tab currently disabled.
* @defaultValue false
*/
disabled: boolean;
}

/**
* Defines valid properties in AccordionTab component.
* @group Properties
Expand Down
4 changes: 4 additions & 0 deletions components/lib/cascadeselect/cascadeselect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ export interface CascadeSelectPassThroughOptions {
* Uses to pass attributes to the item's DOM element.
*/
item?: CascadeSelectPassThroughType<React.HTMLAttributes<HTMLLIElement>>;
/**
* Uses to pass attributes to the sub-list's DOM element.
*/
sublist?: CascadeSelectPassThroughType<React.HTMLAttributes<HTMLUListElement>>;
/**
* Uses to pass attributes to the content's DOM element.
*/
Expand Down
50 changes: 25 additions & 25 deletions components/lib/passthrough/tailwind/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const Tailwind = {
},
body: 'p-5', // Padding.
title: 'text-2xl font-bold mb-2', // Font size, font weight, and margin bottom.
subtitle: {
subTitle: {
className: classNames(
'font-normal mb-2 text-gray-600', // Font weight, margin bottom, and text color.
'dark:text-white/60 ' //dark
Expand Down Expand Up @@ -516,10 +516,10 @@ const Tailwind = {
},
chooseIcon: 'mr-2 inline-block',
chooseButtonLabel: 'flex-1 font-bold',
uploadbutton: {
uploadButton: {
icon: 'mr-2'
},
cancelbutton: {
cancelButton: {
icon: 'mr-2'
},
content: {
Expand All @@ -531,7 +531,7 @@ const Tailwind = {
thumbnail: 'shrink-0',
fileName: 'mb-2',
fileSize: 'mr-2',
uploadicon: 'mr-2'
uploadIcon: 'mr-2'
},
//Messages
messages: {
Expand Down Expand Up @@ -750,8 +750,8 @@ const Tailwind = {
menu: {
className: classNames('outline-none', 'py-1 px-0 rounded-md list-none bg-white border-none shadow-lg')
},
menulist: 'm-0 p-0 border-none outline-none no-underline list-none',
menubutton: {
menuList: 'm-0 p-0 border-none outline-none no-underline list-none',
menuButton: {
root: ({ parent }) => ({
className: classNames('rounded-l-none', { 'rounded-r-full': parent.props.rounded })
}),
Expand Down Expand Up @@ -785,15 +785,15 @@ const Tailwind = {
className: classNames({ 'rounded-tr-none rounded-br-none': props.showButtons && props.buttonLayout == 'stacked' })
})
},
buttongroup: ({ props }) => ({
buttonGroup: ({ props }) => ({
className: classNames({ 'flex flex-col': props.showButtons && props.buttonLayout == 'stacked' })
}),
incrementbutton: ({ props }) => ({
incrementButton: ({ props }) => ({
className: classNames('flex !items-center !justify-center', {
'rounded-br-none rounded-bl-none rounded-bl-none !p-0 flex-1 w-[3rem]': props.showButtons && props.buttonLayout == 'stacked'
})
}),
decrementbutton: ({ props }) => ({
decrementButton: ({ props }) => ({
className: classNames('flex !items-center !justify-center', {
'rounded-tr-none rounded-tl-none rounded-tl-none !p-0 flex-1 w-[3rem]': props.showButtons && props.buttonLayout == 'stacked'
})
Expand Down Expand Up @@ -837,7 +837,7 @@ const Tailwind = {
label: {
className: classNames('block whitespace-nowrap overflow-hidden flex flex-1 w-1 text-overflow-ellipsis cursor-pointer', 'bg-transparent border-0 p-3 text-gray-700 dark:text-white/80', 'appearance-none rounded-md')
},
dropdownbutton: {
dropdownButton: {
className: classNames('flex items-center justify-center shrink-0', 'bg-transparent text-gray-600 dark:text-white/80 w-[3rem] rounded-tr-6 rounded-br-6')
},
panel: 'absolute py-3 bg-white dark:bg-gray-900 border-0 shadow-md',
Expand All @@ -855,7 +855,7 @@ const Tailwind = {
content: {
className: classNames('flex items-center overflow-hidden relative', 'py-3 px-5')
},
optiongroupicon: 'ml-auto',
optionGroupIcon: 'ml-auto',
transition: TRANSITIONS.overlay
},
inputmask: {
Expand All @@ -867,7 +867,7 @@ const Tailwind = {
'opacity-60 select-none pointer-events-none cursor-default': props.disabled
})
}),
cancelitem: ({ context }) => ({
cancelItem: ({ context }) => ({
className: classNames(
'inline-flex items-center cursor-pointer'

Expand All @@ -876,7 +876,7 @@ const Tailwind = {
// }
)
}),
cancelicon: {
cancelIcon: {
className: classNames('text-red-500', 'w-5 h-5', 'transition duration-200 ease-in')
},
item: ({ props, context }) => ({
Expand All @@ -891,10 +891,10 @@ const Tailwind = {
}
)
}),
officon: {
offIcon: {
className: classNames('text-gray-700 hover:text-blue-400', 'w-5 h-5', 'transition duration-200 ease-in')
},
onicon: {
onIcon: {
className: classNames('text-blue-500', 'w-5 h-5', 'transition duration-200 ease-in')
}
},
Expand Down Expand Up @@ -954,7 +954,7 @@ const Tailwind = {
}),
panel: 'p-5 bg-white dark:bg-gray-900 text-gray-700 dark:text-white/80 shadow-md rounded-md',
meter: 'mb-2 bg-gray-300 dark:bg-gray-700 h-3',
meterlabel: ({ state, props }) => ({
meterLabel: ({ state, props }) => ({
className: classNames(
'transition-width duration-1000 ease-in-out h-full',
{
Expand All @@ -965,10 +965,10 @@ const Tailwind = {
{ 'pr-[2.5rem] ': props.toggleMask }
)
}),
showicon: {
showIcon: {
className: classNames('absolute top-1/2 -mt-2', 'right-3 text-gray-600 dark:text-white/70')
},
hideicon: {
hideIcon: {
className: classNames('absolute top-1/2 -mt-2', 'right-3 text-gray-600 dark:text-white/70')
},
transition: TRANSITIONS.overlay
Expand Down Expand Up @@ -1099,14 +1099,14 @@ const Tailwind = {
'opacity-60 select-none pointer-events-none cursor-default': context.disabled
})
}),
itemgroup: {
itemGroup: {
className: classNames('m-0 p-3 text-gray-800 bg-white font-bold', 'dark:bg-gray-900 dark:text-white/80', 'cursor-auto')
},
header: {
className: classNames('p-3 border-b border-gray-300 text-gray-700 bg-gray-100 mt-0 rounded-tl-lg rounded-tr-lg', 'dark:bg-gray-800 dark:text-white/80 dark:border-blue-900/40')
},
filtercontainer: 'relative',
filterinput: {
filterContainer: 'relative',
filterInput: {
className: classNames(
'pr-7 -mr-7',
'w-full',
Expand All @@ -1115,8 +1115,8 @@ const Tailwind = {
'hover:border-blue-500 focus:outline-none focus:outline-offset-0 focus:shadow-[0_0_0_0.2rem_rgba(191,219,254,1)] dark:focus:shadow-[0_0_0_0.2rem_rgba(147,197,253,0.5)]'
)
},
filtericon: '-mt-2 absolute top-1/2',
clearicon: 'text-gray-500 right-12 -mt-2 absolute top-1/2',
filterIcon: '-mt-2 absolute top-1/2',
clearIcon: 'text-gray-500 right-12 -mt-2 absolute top-1/2',
transition: TRANSITIONS.overlay
},
calendar: {
Expand All @@ -1133,7 +1133,7 @@ const Tailwind = {
})
})
},
dropdownbutton: ({ props }) => ({
dropdownButton: ({ props }) => ({
root: {
className: classNames({ 'rounded-l-none': props.showIcon })
}
Expand Down Expand Up @@ -1471,7 +1471,7 @@ const Tailwind = {
token: {
className: classNames('py-1 px-2 mr-2 bg-gray-300 dark:bg-gray-700 text-gray-700 dark:text-white/80 rounded-full', 'cursor-default inline-flex items-center')
},
dropdownbutton: {
dropdownButton: {
root: 'rounded-tl-none rounded-bl-none'
},
panel: {
Expand Down
35 changes: 35 additions & 0 deletions components/lib/tabview/tabview.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,41 @@ interface TabPanelHeaderTemplateOptions {
export interface TabPanelPassThroughMethodOptions {
props: TabPanelProps;
parent: TabViewPassThroughMethodOptions;
context: TabViewContext;
}

/**
* Defines current inline context in Tabview component.
*/
export interface TabViewContext {
/**
* Opened tab index.
*/
index: number;
/**
* Total number of tabs
*/
count: number;
/**
* Is this the first tab?
* @defaultValue false
*/
first: boolean;
/**
* Is this the last tab?
* @defaultValue false
*/
last: boolean;
/**
* Is this tab currently selected.
* @defaultValue false
*/
selected: boolean;
/**
* Is this tab currently disabled.
* @defaultValue false
*/
disabled: boolean;
}

/**
Expand Down

0 comments on commit 4b5b7d0

Please sign in to comment.