Skip to content

Commit

Permalink
feat(async creatable select): add isCondensed prop to input and field…
Browse files Browse the repository at this point in the history
… components (#2799)

* feat(async-creatable-select): add isCondensed prop to field and input

* refactor(async-creatable-select-input): move vrt

---------

Co-authored-by: Jonathan Creasman <[email protected]>
Co-authored-by: Carlos Cortizas <[email protected]>
Co-authored-by: Carlos Cortizas <[email protected]>
  • Loading branch information
4 people authored Apr 29, 2024
1 parent 0798b97 commit 52e5c72
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/afraid-toes-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@commercetools-uikit/async-creatable-select-field': minor
'@commercetools-uikit/async-creatable-select-input': minor
---

Add isCondensed prop that when set to true, condenses the input height, icon size and font size.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default Example;
| `filterOption` | `AsyncCreatableProps['filterOption']` | | | Custom method to filter whether an option should be displayed in the menu&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
| `containerId` | `AsyncCreatableProps['id']` | | | The id to set on the SelectContainer component&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
| `isClearable` | `AsyncCreatableProps['isClearable']` | | | Is the select value clearable&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
| `isCondensed` | `boolean` | | | Use this property to reduce the paddings of the component for a ui compact variant |
| `isDisabled` | `AsyncCreatableProps['isDisabled']` | | | Is the select disabled&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
| `isReadOnly` | `boolean` | | | Is the select read-only |
| `isOptionDisabled` | `AsyncCreatableProps['isOptionDisabled']` | | | Override the built-in logic to detect whether an option is disabled&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ storiesOf('Components|Fields/SelectFields', module)
hintIcon={hintIcon}
badge={text('badge', '')}
iconLeft={iconLeft ? createElement(iconLeft) : undefined}
isCondensed={boolean('isCondensed', false)}
{...addMenuPortalProps()}
/>
<NeighbouringStackingContext />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ export type TAsyncCreatableSelectFieldProps = {
* [Props from React select was used](https://react-select.com/props)
*/
isClearable?: ReactSelectAsyncCreatableProps['isClearable'];
/**
* Use this property to reduce the paddings of the component for a ui compact variant
*/
isCondensed?: boolean;
/**
* Is the select disabled
* <br>
Expand Down Expand Up @@ -519,6 +523,7 @@ export default class AsyncCreatableSelectField extends Component<
createOptionPosition={this.props.createOptionPosition}
showOptionGroupDivider={this.props.showOptionGroupDivider}
iconLeft={this.props.iconLeft}
isCondensed={this.props.isCondensed}
{...filterDataAttributes(this.props)}
/>
<FieldErrors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ const DefaultRoute = () => (
renderWarning={() => 'Custom warning'}
/>
</Spec>
<Spec label="is condensed">
<AsyncCreatableSelectField
title="State"
name="form-field-name"
value={value}
isCondensed={true}
onChange={() => {}}
loadOptions={loadOptions}
horizontalConstraint={7}
/>
</Spec>
</Suite>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default Example;
| `inputValue` | `AsyncCreatableProps['inputValue']` | | | The value of the search input&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
| `containerId` | `AsyncCreatableProps['id']` | | | The id to set on the SelectContainer component&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
| `isClearable` | `AsyncCreatableProps['isClearable']` | | | Is the select value clearable&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
| `isCondensed` | `boolean` | | | Use this property to reduce the paddings of the component for a ui compact variant |
| `isDisabled` | `AsyncCreatableProps['isDisabled']` | | | Is the select disabled&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
| `isOptionDisabled` | `AsyncCreatableProps['isOptionDisabled']` | | | Override the built-in logic to detect whether an option is disabled&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
| `isMulti` | `AsyncCreatableProps['isMulti']` | | | Support multiple selected options&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class SelectStory extends Component {
id={text('id', '')}
containerId={text('containerId', '')}
isClearable={boolean('isClearable', false)}
isCondensed={boolean('isCondensed', false)}
isDisabled={boolean('isDisabled', false)}
isReadOnly={boolean('isReadOnly', false)}
isMulti={isMulti}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ export type TAsyncCreatableSelectInputProps = {
* [Props from React select was used](https://react-select.com/props)
*/
isClearable?: ReactSelectAsyncCreatableProps['isClearable'];
/**
* Use this property to reduce the paddings of the component for a ui compact variant
*/
isCondensed?: boolean;
/**
* Is the select disabled
* <br>
Expand Down Expand Up @@ -411,6 +415,7 @@ const AsyncCreatableSelectInput = (props: TAsyncCreatableSelectInputProps) => {
hasError: props.hasError,
showOptionGroupDivider: props.showOptionGroupDivider,
menuPortalZIndex: props.menuPortalZIndex,
isCondensed: props.isCondensed,
isDisabled: props.isDisabled,
isReadOnly: props.isReadOnly,
iconLeft: props.iconLeft,
Expand Down Expand Up @@ -508,6 +513,7 @@ const AsyncCreatableSelectInput = (props: TAsyncCreatableSelectInputProps) => {
createOptionPosition={props.createOptionPosition}
// @ts-ignore
iconLeft={props.iconLeft}
isCondensed={props.isCondensed}
/>
</div>
</Constraints.Horizontal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,15 @@ export const component = () => (
iconLeft={<WorldIcon />}
/>
</Spec>
<Spec label="is condensed">
<AsyncCreatableSelectInput
value={value}
onChange={() => {}}
isCondensed={true}
defaultOptions={true}
loadOptions={loadOptions}
horizontalConstraint={7}
/>
</Spec>
</Suite>
);

0 comments on commit 52e5c72

Please sign in to comment.