diff --git a/CHANGELOG.md b/CHANGELOG.md index 78e778f2d..cd062f5f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## react-components 5.34.10 (2024-06-24) + +- [Select] Pass through additional props to select inner component (by [@sean-mckenna](https://github.com/sean-mckenna)) +- [Button] Remove button loading background colour (by [@sean-mckenna](https://github.com/sean-mckenna)) + ## react-components 5.34.9 (2024-04-29) - [Logo] Adjust Security Compliance Management logo viewBox to match Continuous Delivery (by [@Lukeaber](https://github.com/Lukeaber)) diff --git a/packages/react-components/package.json b/packages/react-components/package.json index adf3814d8..41e94e8cd 100644 --- a/packages/react-components/package.json +++ b/packages/react-components/package.json @@ -1,6 +1,6 @@ { "name": "@puppet/react-components", - "version": "5.34.9", + "version": "5.34.10", "author": "Puppet, Inc.", "license": "Apache-2.0", "main": "build/library.js", @@ -91,4 +91,4 @@ "regenerator-runtime": "^0.13.7", "scroll-into-view-if-needed": "^2.2.25" } -} \ No newline at end of file +} diff --git a/packages/react-components/source/react/library/select/Select.js b/packages/react-components/source/react/library/select/Select.js index 31199ff99..308067377 100644 --- a/packages/react-components/source/react/library/select/Select.js +++ b/packages/react-components/source/react/library/select/Select.js @@ -380,6 +380,11 @@ class Select extends Component { style, type, value, + actionLabel, + onChange, + onFilter, + onBlur: onBlurProp, + ...restProps } = this.props; let input; @@ -411,6 +416,7 @@ class Select extends Component { }} onChange={onValueChange} autoComplete="off" + {...restProps} /> ); break; @@ -431,6 +437,7 @@ class Select extends Component { ref={button => { this.button = button; }} + {...restProps} /> setValue(newValue)} -/> +/>; ``` ### Nonexistent value @@ -61,17 +61,23 @@ const isValueInOptions = options.map(option => option.value).includes(value); value={value} onChange={newValue => setValue(newValue)} /> - {!isValueInOptions && "{value}" is not an option} - + {!isValueInOptions && ( + + "{value}" is not an option + + )} +; ``` ## Variations ### Autocomplete -With `type` set to `autocomplete`, the `Select` input will accept text and provide filtered menu options accordingly. Full keyboard navigation of the menu options is retained. +With `type` set to `autocomplete`, the `Select` input will accept text and the menu options can be filtered accordingly. Full keyboard navigation of the menu options is retained. ```jsx +const [fieldValue, setFieldValue] = React.useState(''); + const options = [ { value: 'apple', label: 'apple' }, { value: 'orange', label: 'orange' }, @@ -86,16 +92,30 @@ const options = [ const style = { margin: 10 }; +const noResults = [ + { + value: [], + label: 'No results found', + }, +]; + +let filteredOptions = [...options]; +if (state.fieldValue !== undefined && state.fieldValue !== '') { + filteredOptions = options.filter(options => + options.label.includes(state.fieldValue), + ); +} +
{ - setState({value}); + setState({ value }); }} />; ``` @@ -228,6 +253,7 @@ const style = { margin: 10 }; ``` ## Option properties + ### Disabled options Use the `disabled` object property to disable a row in a dropdown. diff --git a/packages/react-components/source/scss/library/components/_button.scss b/packages/react-components/source/scss/library/components/_button.scss index 9ac073e02..766f58ccb 100644 --- a/packages/react-components/source/scss/library/components/_button.scss +++ b/packages/react-components/source/scss/library/components/_button.scss @@ -152,8 +152,7 @@ $puppet-button-padding-vertical: 5px; @include button-type-properties(map-get($typedef, hover)); } - &:active, - &.rc-button-loading { + &:active { @include button-type-properties(map-get($typedef, active)); } diff --git a/packages/react-components/source/scss/library/components/forms/_input.scss b/packages/react-components/source/scss/library/components/forms/_input.scss index d0b9c28c3..1debb3b70 100644 --- a/packages/react-components/source/scss/library/components/forms/_input.scss +++ b/packages/react-components/source/scss/library/components/forms/_input.scss @@ -98,7 +98,7 @@ padding-left: 31px; } - .rc-input-icon.trailing ~ .rc-input { + .rc-input:has(+ .rc-input-icon.trailing) { padding-right: 31px; } @@ -125,7 +125,7 @@ right: $puppet-common-spacing-base * 4 - 1; } - .rc-input-icon.trailing ~ .rc-input { + .rc-input:has(+ .rc-input-icon.trailing) { padding-right: $puppet-common-spacing-base * 10 - 1; } }