Skip to content

Commit 94f0a6f

Browse files
committed
feat(ui-simple-select,ui-select): add layout prop to Select and SimpleSelect
INSTUI-4482
1 parent 6650445 commit 94f0a6f

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ class Select extends Component<SelectProps> {
694694
onBlur,
695695
onInputChange,
696696
onRequestHideOptions,
697+
layout,
697698
...rest
698699
} = this.props
699700

@@ -749,6 +750,7 @@ class Select extends Component<SelectProps> {
749750
: interaction,
750751
isRequired,
751752
shouldNotWrap,
753+
layout,
752754
display: isInline ? 'inline-block' : 'block',
753755
renderBeforeInput: this.handleRenderBeforeInput(),
754756
// 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: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,14 @@ type PropsFromTextInput = {
256256
* when available space is exceeded.
257257
*/
258258
shouldNotWrap?: boolean
259+
260+
/**
261+
* In `stacked` mode the input is below the label.
262+
*
263+
* In `inline` mode the input is to the right/left (depending on text direction) of the label,
264+
* and the layout will look like `stacked` for small screens.
265+
*/
266+
layout?: 'stacked' | 'inline'
259267
}
260268

261269
// These props are directly passed to Popover
@@ -328,7 +336,8 @@ const propTypes: PropValidators<PropKeys> = {
328336
renderAfterInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
329337
children: ChildrenPropTypes.oneOf([Group, Option]),
330338
shouldNotWrap: PropTypes.bool,
331-
scrollToHighlightedOption: PropTypes.bool
339+
scrollToHighlightedOption: PropTypes.bool,
340+
layout: PropTypes.oneOf(['stacked', 'inline'])
332341
}
333342

334343
const allowedProps: AllowedPropKeys = [
@@ -365,7 +374,8 @@ const allowedProps: AllowedPropKeys = [
365374
'renderAfterInput',
366375
'children',
367376
'shouldNotWrap',
368-
'scrollToHighlightedOption'
377+
'scrollToHighlightedOption',
378+
'layout'
369379
]
370380

371381
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
@@ -503,6 +503,7 @@ class SimpleSelect extends Component<SimpleSelectProps, SimpleSelectState> {
503503
onShowOptions,
504504
onHideOptions,
505505
children,
506+
layout,
506507
...rest
507508
} = this.props
508509

@@ -538,6 +539,7 @@ class SimpleSelect extends Component<SimpleSelectProps, SimpleSelectState> {
538539
onRequestHighlightOption={this.handleHighlightOption}
539540
onRequestSelectOption={this.handleSelectOption}
540541
isOptionContentAppliedToInput={this.props.isOptionContentAppliedToInput}
542+
layout={layout}
541543
{...passthroughProps(rest)}
542544
>
543545
{this.renderChildren()}

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,14 @@ 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.
238+
*
239+
* In `inline` mode the input is to the right/left (depending on text direction) of the label,
240+
* and the layout will look like `stacked` for small screens.
241+
*/
242+
layout?: 'stacked' | 'inline'
235243
}
236244

237245
type PropKeys = keyof SimpleSelectOwnProps
@@ -248,6 +256,7 @@ type SimpleSelectProps = PickPropsWithExceptions<
248256
| 'onRequestSelectOption'
249257
| 'inputValue'
250258
| 'isShowingOptions'
259+
| 'layout'
251260
> &
252261
SimpleSelectOwnProps &
253262
OtherHTMLAttributes<
@@ -294,7 +303,8 @@ const propTypes: PropValidators<PropKeys> = {
294303
renderBeforeInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
295304
renderAfterInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
296305
children: ChildrenPropTypes.oneOf([Group, Option]),
297-
isOptionContentAppliedToInput: PropTypes.bool
306+
isOptionContentAppliedToInput: PropTypes.bool,
307+
layout: PropTypes.oneOf(['stacked', 'inline'])
298308
}
299309

300310
const allowedProps: AllowedPropKeys = [
@@ -326,7 +336,8 @@ const allowedProps: AllowedPropKeys = [
326336
'renderEmptyOption',
327337
'renderBeforeInput',
328338
'renderAfterInput',
329-
'children'
339+
'children',
340+
'layout'
330341
]
331342

332343
export type { SimpleSelectProps, SimpleSelectState }

0 commit comments

Comments
 (0)