Skip to content

Commit 0221b86

Browse files
committed
feat(ui-simple-select,ui-select): add layout prop to Select and SimpleSelect
INSTUI-4482
1 parent 54118ac commit 0221b86

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

packages/ui-select/src/Select/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,7 @@ class Select extends Component<SelectProps> {
690690
onBlur,
691691
onInputChange,
692692
onRequestHideOptions,
693+
layout,
693694
...rest
694695
} = this.props
695696

@@ -745,6 +746,7 @@ class Select extends Component<SelectProps> {
745746
: interaction,
746747
isRequired,
747748
shouldNotWrap,
749+
layout,
748750
display: isInline ? 'inline-block' : 'block',
749751
renderBeforeInput: this.handleRenderBeforeInput(),
750752
// On iOS VoiceOver, if there is a custom element instead of the changing up and down arrow button

packages/ui-select/src/Select/props.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,12 @@ type PropsFromTextInput = {
256256
* when available space is exceeded.
257257
*/
258258
shouldNotWrap?: boolean
259+
260+
/**
261+
* In `stacked` mode the input is below the label, in `inline` mode the
262+
* container is to the right/left (depending on text direction)
263+
*/
264+
layout?: 'stacked' | 'inline'
259265
}
260266

261267
// These props are directly passed to Popover
@@ -328,7 +334,8 @@ const propTypes: PropValidators<PropKeys> = {
328334
renderAfterInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
329335
children: ChildrenPropTypes.oneOf([Group, Option]),
330336
shouldNotWrap: PropTypes.bool,
331-
scrollToHighlightedOption: PropTypes.bool
337+
scrollToHighlightedOption: PropTypes.bool,
338+
layout: PropTypes.oneOf(['stacked', 'inline'])
332339
}
333340

334341
const allowedProps: AllowedPropKeys = [
@@ -365,7 +372,8 @@ const allowedProps: AllowedPropKeys = [
365372
'renderAfterInput',
366373
'children',
367374
'shouldNotWrap',
368-
'scrollToHighlightedOption'
375+
'scrollToHighlightedOption',
376+
'layout'
369377
]
370378

371379
export type { SelectProps, SelectOwnProps, SelectStyle }

packages/ui-simple-select/src/SimpleSelect/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ class SimpleSelect extends Component<SimpleSelectProps, SimpleSelectState> {
458458
onShowOptions,
459459
onHideOptions,
460460
children,
461+
layout,
461462
...rest
462463
} = this.props
463464

@@ -493,6 +494,7 @@ class SimpleSelect extends Component<SimpleSelectProps, SimpleSelectState> {
493494
onRequestHighlightOption={this.handleHighlightOption}
494495
onRequestSelectOption={this.handleSelectOption}
495496
isOptionContentAppliedToInput={this.props.isOptionContentAppliedToInput}
497+
layout={layout}
496498
{...passthroughProps(rest)}
497499
>
498500
{this.renderChildren()}

packages/ui-simple-select/src/SimpleSelect/props.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ type PropsPassedToSelect = {
232232
* If the selected `SimpleSelect.Option`'s `renderAfterLabel` value is empty, default arrow icon will be rendered.
233233
*/
234234
isOptionContentAppliedToInput?: boolean
235+
236+
/**
237+
* In `stacked` mode the input is below the label, in `inline` mode the
238+
* container is to the right/left (depending on text direction)
239+
*/
240+
layout?: 'stacked' | 'inline'
235241
}
236242

237243
type PropKeys = keyof SimpleSelectOwnProps
@@ -248,6 +254,7 @@ type SimpleSelectProps = PickPropsWithExceptions<
248254
| 'onRequestSelectOption'
249255
| 'inputValue'
250256
| 'isShowingOptions'
257+
| 'layout'
251258
> &
252259
SimpleSelectOwnProps &
253260
OtherHTMLAttributes<
@@ -294,7 +301,8 @@ const propTypes: PropValidators<PropKeys> = {
294301
renderBeforeInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
295302
renderAfterInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
296303
children: ChildrenPropTypes.oneOf([Group, Option]),
297-
isOptionContentAppliedToInput: PropTypes.bool
304+
isOptionContentAppliedToInput: PropTypes.bool,
305+
layout: PropTypes.oneOf(['stacked', 'inline'])
298306
}
299307

300308
const allowedProps: AllowedPropKeys = [
@@ -326,7 +334,8 @@ const allowedProps: AllowedPropKeys = [
326334
'renderEmptyOption',
327335
'renderBeforeInput',
328336
'renderAfterInput',
329-
'children'
337+
'children',
338+
'layout'
330339
]
331340

332341
export type { SimpleSelectProps, SimpleSelectState }

0 commit comments

Comments
 (0)