From 9b09cd904c58e7efb2d91049568e09269a260e8b Mon Sep 17 00:00:00 2001 From: gucal Date: Wed, 13 Mar 2024 10:38:30 +0300 Subject: [PATCH 1/2] #6139 - New invalid properties --- components/lib/autocomplete/AutoCompleteBase.js | 2 ++ components/lib/autocomplete/autocomplete.d.ts | 5 +++++ components/lib/calendar/CalendarBase.js | 2 ++ components/lib/calendar/calendar.d.ts | 5 +++++ components/lib/cascadeselect/CascadeSelectBase.js | 2 ++ components/lib/cascadeselect/cascadeselect.d.ts | 5 +++++ components/lib/checkbox/CheckboxBase.js | 2 ++ components/lib/checkbox/checkbox.d.ts | 5 +++++ components/lib/chips/ChipsBase.js | 2 ++ components/lib/chips/chips.d.ts | 5 +++++ components/lib/dropdown/DropdownBase.js | 2 ++ components/lib/dropdown/dropdown.d.ts | 5 +++++ components/lib/inputnumber/InputNumberBase.js | 4 +++- components/lib/inputnumber/inputnumber.d.ts | 5 +++++ components/lib/inputswitch/InputSwitchBase.js | 2 ++ components/lib/inputswitch/inputswitch.d.ts | 9 +++++++-- components/lib/inputtext/InputTextBase.js | 4 +++- components/lib/inputtext/inputtext.d.ts | 5 +++++ components/lib/inputtextarea/InputTextareaBase.js | 4 +++- components/lib/inputtextarea/inputtextarea.d.ts | 5 +++++ components/lib/listbox/ListBoxBase.js | 4 +++- components/lib/listbox/listbox.d.ts | 5 +++++ components/lib/multiselect/MultiSelectBase.js | 2 ++ components/lib/multiselect/multiselect.d.ts | 5 +++++ components/lib/password/PasswordBase.js | 4 +++- components/lib/password/password.d.ts | 5 +++++ components/lib/radiobutton/RadioButtonBase.js | 4 +++- components/lib/radiobutton/radiobutton.d.ts | 5 +++++ components/lib/selectbutton/SelectButtonBase.js | 3 ++- components/lib/selectbutton/selectbutton.d.ts | 5 +++++ components/lib/togglebutton/ToggleButtonBase.js | 4 +++- components/lib/togglebutton/togglebutton.d.ts | 5 +++++ components/lib/treeselect/TreeSelectBase.js | 2 ++ components/lib/treeselect/treeselect.d.ts | 5 +++++ components/lib/tristatecheckbox/TriStateCheckboxBase.js | 2 ++ components/lib/tristatecheckbox/tristatecheckbox.d.ts | 5 +++++ 36 files changed, 135 insertions(+), 10 deletions(-) diff --git a/components/lib/autocomplete/AutoCompleteBase.js b/components/lib/autocomplete/AutoCompleteBase.js index 1a47a9d608..4235241dd4 100644 --- a/components/lib/autocomplete/AutoCompleteBase.js +++ b/components/lib/autocomplete/AutoCompleteBase.js @@ -8,6 +8,7 @@ const classes = { 'p-autocomplete-dd': props.dropdown, 'p-autocomplete-multiple': props.multiple, 'p-inputwrapper-filled': props.value, + 'p-invalid': props.invalid, 'p-inputwrapper-focus': focusedState }), container: ({ props }) => @@ -165,6 +166,7 @@ export const AutoCompleteBase = ComponentBase.extend({ inputId: null, inputRef: null, inputStyle: null, + invalid: false, itemTemplate: null, loadingIcon: null, maxLength: null, diff --git a/components/lib/autocomplete/autocomplete.d.ts b/components/lib/autocomplete/autocomplete.d.ts index da565f89f4..921db8271a 100755 --- a/components/lib/autocomplete/autocomplete.d.ts +++ b/components/lib/autocomplete/autocomplete.d.ts @@ -256,6 +256,11 @@ export interface AutoCompleteProps extends Omit | undefined; + /** + * When present, it specifies that the component should have invalid state style. + * @defaultValue false + */ + invalid?: boolean | undefined; /** * When specified, disables the component. * @defaultValue false diff --git a/components/lib/cascadeselect/CascadeSelectBase.js b/components/lib/cascadeselect/CascadeSelectBase.js index c23d22c390..0a90ae7803 100644 --- a/components/lib/cascadeselect/CascadeSelectBase.js +++ b/components/lib/cascadeselect/CascadeSelectBase.js @@ -8,6 +8,7 @@ const classes = { 'p-cascadeselect p-component p-inputwrapper', { 'p-disabled': props.disabled, + 'p-invalid': props.invalid, 'p-focus': focusedState, 'p-inputwrapper-filled': props.value, 'p-inputwrapper-focus': focusedState || overlayVisibleState @@ -149,6 +150,7 @@ export const CascadeSelectBase = ComponentBase.extend({ id: null, inputId: null, inputRef: null, + invalid: false, itemTemplate: null, name: null, onBeforeHide: null, diff --git a/components/lib/cascadeselect/cascadeselect.d.ts b/components/lib/cascadeselect/cascadeselect.d.ts index 373ea08edb..87187f16e5 100644 --- a/components/lib/cascadeselect/cascadeselect.d.ts +++ b/components/lib/cascadeselect/cascadeselect.d.ts @@ -227,6 +227,11 @@ export interface CascadeSelectProps extends Omit React.ReactNode) | undefined; + /** + * When present, it specifies that the component should have invalid state style. + * @defaultValue false + */ + invalid?: boolean | undefined; /** * When present, it specifies that the component should be disabled. * @defaultValue false diff --git a/components/lib/checkbox/CheckboxBase.js b/components/lib/checkbox/CheckboxBase.js index 993a0ae489..45b5aacea5 100644 --- a/components/lib/checkbox/CheckboxBase.js +++ b/components/lib/checkbox/CheckboxBase.js @@ -7,6 +7,7 @@ const classes = { classNames('p-checkbox-box', { 'p-highlight': checked, 'p-disabled': props.disabled, + 'p-invalid': props.invalid, 'p-focus': focusedState }), root: ({ props, checked, focusedState }) => @@ -49,6 +50,7 @@ export const CheckboxBase = ComponentBase.extend({ id: null, inputId: null, inputRef: null, + invalid: false, name: null, onChange: null, onClick: null, diff --git a/components/lib/checkbox/checkbox.d.ts b/components/lib/checkbox/checkbox.d.ts index 80d64edd8d..807039146e 100644 --- a/components/lib/checkbox/checkbox.d.ts +++ b/components/lib/checkbox/checkbox.d.ts @@ -159,6 +159,11 @@ export interface CheckboxProps extends Omit classNames('p-dropdown p-component p-inputwrapper', { 'p-disabled': props.disabled, + 'p-invalid': props.invalid, 'p-focus': focusedState, 'p-dropdown-clearable': props.showClear && !props.disabled, 'p-inputwrapper-filled': ObjectUtils.isNotEmpty(props.value), @@ -176,6 +177,7 @@ export const DropdownBase = ComponentBase.extend({ id: null, inputId: null, inputRef: null, + invalid: false, itemTemplate: null, loading: false, loadingIcon: null, diff --git a/components/lib/dropdown/dropdown.d.ts b/components/lib/dropdown/dropdown.d.ts index b15b721823..d0e0ff2ab8 100644 --- a/components/lib/dropdown/dropdown.d.ts +++ b/components/lib/dropdown/dropdown.d.ts @@ -246,6 +246,11 @@ export interface DropdownProps extends Omit @@ -151,6 +152,7 @@ export const InputNumberBase = ComponentBase.extend({ inputMode: null, inputRef: null, inputStyle: null, + invalid: false, locale: undefined, localeMatcher: undefined, max: null, diff --git a/components/lib/inputnumber/inputnumber.d.ts b/components/lib/inputnumber/inputnumber.d.ts index ef19e8b7a8..32d5775cd4 100644 --- a/components/lib/inputnumber/inputnumber.d.ts +++ b/components/lib/inputnumber/inputnumber.d.ts @@ -228,6 +228,11 @@ export interface InputNumberProps extends Omit = PassThroughType; @@ -130,6 +130,11 @@ export interface InputSwitchProps extends Omit | React.HTMLAttributes>; + /** + * When present, it specifies that the component should have invalid state style. + * @defaultValue false + */ + invalid?: boolean | undefined; /** * Uses to pass attributes to the panel's DOM element. */ diff --git a/components/lib/radiobutton/RadioButtonBase.js b/components/lib/radiobutton/RadioButtonBase.js index 5704c26fc6..0e8bd3fe38 100644 --- a/components/lib/radiobutton/RadioButtonBase.js +++ b/components/lib/radiobutton/RadioButtonBase.js @@ -6,7 +6,8 @@ const classes = { classNames('p-radiobutton p-component', { 'p-radiobutton-checked': props.checked, 'p-radiobutton-disabled': props.disabled, - 'p-radiobutton-focused': focusedState + 'p-radiobutton-focused': focusedState, + 'p-invalid': props.invalid }), input: ({ props, focusedState }) => classNames('p-radiobutton-box', { @@ -57,6 +58,7 @@ export const RadioButtonBase = ComponentBase.extend({ id: null, inputId: null, inputRef: null, + invalid: false, name: null, onChange: null, onClick: null, diff --git a/components/lib/radiobutton/radiobutton.d.ts b/components/lib/radiobutton/radiobutton.d.ts index bbb0700b54..adb80a3870 100644 --- a/components/lib/radiobutton/radiobutton.d.ts +++ b/components/lib/radiobutton/radiobutton.d.ts @@ -120,6 +120,11 @@ export interface RadioButtonProps extends Omit classNames('p-selectbutton p-buttonset p-component', props.className), + root: ({ props }) => classNames('p-selectbutton p-buttonset p-component', props.className, { 'p-invalid': props.invalid }), button: ({ itemProps: props, focusedState }) => classNames('p-button p-component', { 'p-highlight': props.selected, @@ -23,6 +23,7 @@ export const SelectButtonBase = ComponentBase.extend({ optionDisabled: null, tabIndex: null, multiple: false, + invalid: false, unselectable: true, allowEmpty: true, disabled: false, diff --git a/components/lib/selectbutton/selectbutton.d.ts b/components/lib/selectbutton/selectbutton.d.ts index 31219be908..b63e1a31ad 100644 --- a/components/lib/selectbutton/selectbutton.d.ts +++ b/components/lib/selectbutton/selectbutton.d.ts @@ -117,6 +117,11 @@ export interface SelectButtonProps extends Omit Date: Wed, 13 Mar 2024 10:55:31 +0300 Subject: [PATCH 2/2] Remove invalid class from password --- components/lib/password/Password.js | 1 + components/lib/password/PasswordBase.js | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/lib/password/Password.js b/components/lib/password/Password.js index 854a26f20f..630de75b0b 100644 --- a/components/lib/password/Password.js +++ b/components/lib/password/Password.js @@ -431,6 +431,7 @@ export const Password = React.memo( onFocus: onFocus, onInput: onInput, onKeyUp: onKeyup, + invalid: props.invalid, style: props.inputStyle, tabIndex: props.tabIndex, tooltip: props.tooltip, diff --git a/components/lib/password/PasswordBase.js b/components/lib/password/PasswordBase.js index 036855868c..18734fd12d 100644 --- a/components/lib/password/PasswordBase.js +++ b/components/lib/password/PasswordBase.js @@ -9,8 +9,7 @@ const classes = { { 'p-inputwrapper-filled': isFilled, 'p-inputwrapper-focus': focusedState, - 'p-input-icon-right': props.toggleMask, - 'p-invalid': props.invalid + 'p-input-icon-right': props.toggleMask }, props.className ),