@commercetools-uikit/search-select-input 19.16.0 → 19.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -60,51 +60,54 @@ export default Example;
60
60
 
61
61
  ## Properties
62
62
 
63
- | Props | Type | Required | Default | Description |
64
- | -------------------------- | ----------------------------------------------------------------------------------------------------- | :------: | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
65
- | `horizontalConstraint` | `union`<br/>Possible values:<br/>`, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'` | | | Horizontal size limit of the input fields. |
66
- | `aria-label` | `AsyncProps['aria-label']` | | | Aria label (for assistive tech)&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
67
- | `aria-labelledby` | `AsyncProps['aria-labelledby']` | | | HTML ID of an element that should be used as the label (for assistive tech)&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
68
- | `aria-invalid` | `AsyncProps['aria-invalid']` | | | Indicate if the value entered in the input is invalid.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
69
- | `aria-errormessage` | `AsyncProps['aria-errormessage']` | | | HTML ID of an element containing an error message related to the input.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
70
- | `id` | `AsyncProps['inputId']` | | | The id of the search input. This forwarded as react-select's "inputId"&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
71
- | `containerId` | `AsyncProps['id']` | | | The id to set on the SelectContainer component. This is forwarded as react-select's "id"&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
72
- | `name` | `AsyncProps['name']` | | | Name of the HTML Input (optional - without this, no input will be rendered)&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
73
- | `placeholder` | `AsyncProps['placeholder']` | | | Placeholder text for the select value&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
74
- | `components` | `AsyncProps['components']` | | | Map of components to overwrite the default ones, see [what components you can override](https://react-select.com/components)&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
75
- | `controlShouldRenderValue` | `AsyncProps['controlShouldRenderValue']` | | `true` | Control whether the selected values should be rendered in the control&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
76
- | `tabIndex` | `AsyncProps['tabIndex']` | | | Sets the tabIndex attribute on the input&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
77
- | `value` | `AsyncProps['value']` | | `null` | The value of the select; reflected by the selected option&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
78
- | `backspaceRemovesValue` | `AsyncProps['backspaceRemovesValue']` | | | Remove the currently focused option when the user presses backspace&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
79
- | `hasError` | `boolean` | | | Indicates the input field has an error |
80
- | `hasWarning` | `boolean` | | | Indicates the input field has a warning |
81
- | `isReadOnly` | `boolean` | | | Is the select read-only |
82
- | `isDisabled` | `boolean` | | | Is the select disabled |
83
- | `isClearable` | `boolean` | | | Is the select value clearable |
84
- | `isCondensed` | `boolean` | | | Whether the input and options are rendered with condensed paddings |
85
- | `isOptionDisabled` | `AsyncProps['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) |
86
- | `isMulti` | `AsyncProps['isMulti']` | | | Support multiple selected options&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
87
- | `isAutofocussed` | `boolean` | | | Focus the control when it is mounted. Renamed autoFocus of react-select |
88
- | `noOptionsMessage` | `AsyncProps['noOptionsMessage']` | | | Can be used to render a custom value when there are no options (either because of no search results, or all options have been used, or there were none in the first place). Gets called with `{ inputValue: String }`. `inputValue` will be an empty string when no search text is present.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
89
- | `menuIsOpen` | `AsyncProps['menuIsOpen']` | | | Can be used to enforce the select input to be opened&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
90
- | `maxMenuHeight` | `AsyncProps['maxMenuHeight']` | | `220` | Maximum height of the menu before scrolling&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
91
- | `menuPortalTarget` | `AsyncProps['menuPortalTarget']` | | | Dom element to portal the select menu to&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
92
- | `menuPortalZIndex` | `number` | | `1` | z-index value for the menu portal&#xA;<br>&#xA;Use in conjunction with `menuPortalTarget` |
93
- | `menuShouldBlockScroll` | `AsyncProps['menuShouldBlockScroll']` | | | whether the menu should block scroll while open&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
94
- | `closeMenuOnSelect` | `AsyncProps['closeMenuOnSelect']` | | | Whether the menu should close after a value is selected. Defaults to `true`.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
95
- | `showOptionGroupDivider` | `boolean` | | | Determines if option groups will be separated by a divider |
96
- | `defaultOptions` | `AsyncProps['defaultOptions']` | | | The default set of options to show before the user starts searching. When set to `true`, the results for `loadOptions('')` will be autoloaded.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
97
- | `onBlur` | `Function`<br/>[See signature.](#signature-onBlur) | | | Handle blur events on the control |
98
- | `onChange` | `Function`<br/>[See signature.](#signature-onChange) | | | Called with a fake event when value changes.&#xA;<br />&#xA;The event's `target.name` will be the `name` supplied in props. The event's `target.value` will hold the value. The value will be the selected option, or an array of options in case `isMulti` is `true`. |
99
- | `onFocus` | `AsyncProps['onFocus']` | | | Handle focus events on the control&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
100
- | `onInputChange` | `AsyncProps['onInputChange']` | | | Handle change events on the input&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
101
- | `tabSelectsValue` | `AsyncProps['tabSelectsValue']` | | | Select the currently focused option when the user presses tab&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
102
- | `loadOptions` | `AsyncProps['loadOptions']` | ✅ | | Function that returns a promise, which is the set of options to be used once the promise resolves.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
103
- | `loadingMessage` | `union`<br/>Possible values:<br/>`string , (() => string)` | | | The text shown while the options are being loaded |
104
- | `cacheOptions` | `AsyncProps['cacheOptions']` | | | If cacheOptions is truthy, then the loaded data will be cached. The cache will remain until cacheOptions changes value.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
105
- | `filterOption` | `AsyncProps['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) |
106
- | `optionType` | `union`<br/>Possible values:<br/>`'single-property' , 'double-property' , 'multiple-properties'` | | | The style of the an option in the dropdown menu. It could be single lined option or an option with more and custom info |
107
- | `iconLeft` | `ReactNode` | | | Icon to display on the left of the placeholder text and selected value. Has no effect when `isMulti` is enabled. |
63
+ | Props | Type | Required | Default | Description |
64
+ | -------------------------- | ----------------------------------------------------------------------------------------------------- | :------: | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
65
+ | `horizontalConstraint` | `union`<br/>Possible values:<br/>`, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'` | | | Horizontal size limit of the input fields. |
66
+ | `aria-label` | `AsyncProps['aria-label']` | | | Aria label (for assistive tech)&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
67
+ | `aria-labelledby` | `AsyncProps['aria-labelledby']` | | | HTML ID of an element that should be used as the label (for assistive tech)&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
68
+ | `aria-invalid` | `AsyncProps['aria-invalid']` | | | Indicate if the value entered in the input is invalid.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
69
+ | `aria-errormessage` | `AsyncProps['aria-errormessage']` | | | HTML ID of an element containing an error message related to the input.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
70
+ | `id` | `AsyncProps['inputId']` | | | The id of the search input. This forwarded as react-select's "inputId"&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
71
+ | `containerId` | `AsyncProps['id']` | | | The id to set on the SelectContainer component. This is forwarded as react-select's "id"&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
72
+ | `name` | `AsyncProps['name']` | | | Name of the HTML Input (optional - without this, no input will be rendered)&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
73
+ | `placeholder` | `AsyncProps['placeholder']` | | | Placeholder text for the select value&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
74
+ | `components` | `AsyncProps['components']` | | | Map of components to overwrite the default ones, see [what components you can override](https://react-select.com/components)&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
75
+ | `controlShouldRenderValue` | `AsyncProps['controlShouldRenderValue']` | | `true` | Control whether the selected values should be rendered in the control&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
76
+ | `tabIndex` | `AsyncProps['tabIndex']` | | | Sets the tabIndex attribute on the input&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
77
+ | `value` | `AsyncProps['value']` | | `null` | The value of the select; reflected by the selected option&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
78
+ | `backspaceRemovesValue` | `AsyncProps['backspaceRemovesValue']` | | | Remove the currently focused option when the user presses backspace&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
79
+ | `hasError` | `boolean` | | | Indicates the input field has an error |
80
+ | `hasWarning` | `boolean` | | | Indicates the input field has a warning |
81
+ | `isReadOnly` | `boolean` | | | Is the select read-only |
82
+ | `isDisabled` | `boolean` | | | Is the select disabled |
83
+ | `isClearable` | `boolean` | | | Is the select value clearable |
84
+ | `isCondensed` | `boolean` | | | Whether the input and options are rendered with condensed paddings |
85
+ | `isOptionDisabled` | `AsyncProps['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) |
86
+ | `isMulti` | `AsyncProps['isMulti']` | | | Support multiple selected options&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
87
+ | `isAutofocussed` | `boolean` | | | Focus the control when it is mounted. Renamed autoFocus of react-select |
88
+ | `noOptionsMessage` | `AsyncProps['noOptionsMessage']` | | | Can be used to render a custom value when there are no options (either because of no search results, or all options have been used, or there were none in the first place). Gets called with `{ inputValue: String }`. `inputValue` will be an empty string when no search text is present.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
89
+ | `menuIsOpen` | `AsyncProps['menuIsOpen']` | | | Can be used to enforce the select input to be opened&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
90
+ | `maxMenuHeight` | `AsyncProps['maxMenuHeight']` | | `220` | Maximum height of the menu before scrolling&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
91
+ | `menuPortalTarget` | `AsyncProps['menuPortalTarget']` | | | Dom element to portal the select menu to&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
92
+ | `menuPortalZIndex` | `number` | | `1` | z-index value for the menu portal&#xA;<br>&#xA;Use in conjunction with `menuPortalTarget` |
93
+ | `menuShouldBlockScroll` | `AsyncProps['menuShouldBlockScroll']` | | | whether the menu should block scroll while open&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
94
+ | `closeMenuOnSelect` | `AsyncProps['closeMenuOnSelect']` | | | Whether the menu should close after a value is selected. Defaults to `true`.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
95
+ | `showOptionGroupDivider` | `boolean` | | | Determines if option groups will be separated by a divider |
96
+ | `defaultOptions` | `AsyncProps['defaultOptions']` | | | The default set of options to show before the user starts searching. When set to `true`, the results for `loadOptions('')` will be autoloaded.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
97
+ | `onBlur` | `Function`<br/>[See signature.](#signature-onBlur) | | | Handle blur events on the control |
98
+ | `onChange` | `Function`<br/>[See signature.](#signature-onChange) | | | Called with a fake event when value changes.&#xA;<br />&#xA;The event's `target.name` will be the `name` supplied in props. The event's `target.value` will hold the value. The value will be the selected option, or an array of options in case `isMulti` is `true`. |
99
+ | `onFocus` | `AsyncProps['onFocus']` | | | Handle focus events on the control&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
100
+ | `onInputChange` | `AsyncProps['onInputChange']` | | | Handle change events on the input&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
101
+ | `tabSelectsValue` | `AsyncProps['tabSelectsValue']` | | | Select the currently focused option when the user presses tab&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
102
+ | `loadOptions` | `AsyncProps['loadOptions']` | ✅ | | Function that returns a promise, which is the set of options to be used once the promise resolves.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
103
+ | `loadingMessage` | `union`<br/>Possible values:<br/>`string , (() => string)` | | | The text shown while the options are being loaded |
104
+ | `cacheOptions` | `AsyncProps['cacheOptions']` | | | If cacheOptions is truthy, then the loaded data will be cached. The cache will remain until cacheOptions changes value.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
105
+ | `filterOption` | `AsyncProps['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) |
106
+ | `optionType` | `union`<br/>Possible values:<br/>`'single-property' , 'double-property' , 'multiple-properties'` | | | The style of the an option in the dropdown menu. It could be single lined option or an option with more and custom info |
107
+ | `iconLeft` | `ReactNode` | | | Icon to display on the left of the placeholder text and selected value. Has no effect when `isMulti` is enabled. |
108
+ | `optionStyle` | `union`<br/>Possible values:<br/>`'list' , 'checkbox'` | | `'list'` | defines how options are rendered |
109
+ | `appearance` | `union`<br/>Possible values:<br/>`'default' , 'filter'` | | `'default'` | Indicates the appearance of the input.&#xA;Filter appearance is meant to be used when the async-select is used as a filter. |
110
+ | `count` | `number` | | | An additional value displayed on the select options menu. This value is only available in the checkbox option style when appearance is set to filter. |
108
111
 
109
112
  ## Signatures
110
113
 
@@ -50,6 +50,11 @@ var messages = reactIntl.defineMessages({
50
50
  id: 'UIKit.SearchSelectInput.placeholderMessage',
51
51
  description: 'Placeholder text for the input',
52
52
  defaultMessage: 'Search by…'
53
+ },
54
+ searchSelectInputAsFilterPlaceholder: {
55
+ id: 'UIKit.SearchSelectInput.searchSelectInputAsFilterPlaceholder',
56
+ description: 'Placeholder text for the input',
57
+ defaultMessage: 'Search'
53
58
  }
54
59
  });
55
60
 
@@ -79,7 +84,9 @@ const defaultProps = {
79
84
  value: null,
80
85
  menuPortalZIndex: 1,
81
86
  maxMenuHeight: 220,
82
- controlShouldRenderValue: true
87
+ controlShouldRenderValue: true,
88
+ appearance: 'default',
89
+ optionStyle: 'list'
83
90
  };
84
91
  const SearchSelectInput = props => {
85
92
  const intl = reactIntl.useIntl();
@@ -93,28 +100,32 @@ const SearchSelectInput = props => {
93
100
  });
94
101
  const noOptionsMessage = props.noOptionsMessage || (() => intl.formatMessage(messages.noOptionsMessage));
95
102
  const loadingMessage = props.loadingMessage || intl.formatMessage(messages.loadingOptionsMessage);
96
- const placeholder = props.placeholder || intl.formatMessage(messages.placeholderMessage);
103
+ const placeholder = props.appearance === 'filter' && !props.placeholder ? intl.formatMessage(messages.searchSelectInputAsFilterPlaceholder) : props.placeholder || intl.formatMessage(messages.placeholderMessage);
97
104
  const optionType = props.optionType;
98
- const components = react.useMemo(() => _objectSpread(_objectSpread({
105
+ const components = react.useMemo(() => _objectSpread(_objectSpread(_objectSpread({
99
106
  Option: optionInnerProps => jsxRuntime.jsx(selectUtils.CustomSelectInputOption, _objectSpread(_objectSpread({}, optionInnerProps), {}, {
100
107
  optionType: optionType,
101
108
  optionInnerProps: optionInnerProps
102
109
  }))
103
- }, props.components), {}, {
110
+ }, props.optionStyle === 'checkbox' ? selectUtils.optionStyleCheckboxComponents(props.appearance) : {}), props.components), {}, {
104
111
  DropdownIndicator: selectUtils.SearchIconDropdownIndicator
105
- }), [props.components, optionType]);
112
+ }), [props.optionStyle, props.appearance, props.components, optionType]);
106
113
  return jsxRuntime.jsx(SearchSelectInputWrapper, {
107
114
  isDisabled: props.isDisabled,
108
115
  isReadOnly: props.isReadOnly,
109
- isCondensed: props.isCondensed,
110
- children: jsxRuntime.jsx(AsyncSelectInput__default["default"], _objectSpread(_objectSpread({}, props), {}, {
116
+ isCondensed: props.appearance === 'filter' ? true : props.isCondensed,
117
+ children: jsxRuntime.jsx(AsyncSelectInput__default["default"], _objectSpread(_objectSpread(_objectSpread({}, props), {}, {
111
118
  components: components,
112
119
  placeholder: placeholder,
113
120
  iconLeft: props.iconLeft,
114
121
  loadingMessage: loadingMessage,
115
122
  noOptionsMessage: noOptionsMessage,
116
- isSearchable: true,
123
+ isSearchable: true
124
+ // @ts-expect-error
125
+ ,
117
126
  closeMenuOnSelect: props.closeMenuOnSelect
127
+ }, props.optionStyle === 'checkbox' ? selectUtils.optionsStyleCheckboxSelectProps() : {}), {}, {
128
+ controlShouldRenderValue: props.appearance === 'filter' ? false : props.controlShouldRenderValue
118
129
  }))
119
130
  });
120
131
  };
@@ -133,14 +144,17 @@ SearchSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
133
144
  onChange: _pt__default["default"].func,
134
145
  loadingMessage: _pt__default["default"].oneOfType([_pt__default["default"].string, _pt__default["default"].func]),
135
146
  optionType: _pt__default["default"].oneOf(['single-property', 'double-property', 'multiple-properties']),
136
- iconLeft: _pt__default["default"].node
147
+ iconLeft: _pt__default["default"].node,
148
+ optionStyle: _pt__default["default"].oneOf(['list', 'checkbox']).isRequired,
149
+ appearance: _pt__default["default"].oneOf(['default', 'filter']),
150
+ count: _pt__default["default"].number
137
151
  } : {};
138
152
  SearchSelectInput.defaultProps = defaultProps;
139
153
  SearchSelectInput.displayName = 'SearchSelectInput';
140
154
  var SearchSelectInput$1 = SearchSelectInput;
141
155
 
142
156
  // NOTE: This string will be replaced on build time with the package version.
143
- var version = "19.16.0";
157
+ var version = "19.17.0";
144
158
 
145
159
  exports["default"] = SearchSelectInput$1;
146
160
  exports.version = version;
@@ -49,6 +49,11 @@ var messages = reactIntl.defineMessages({
49
49
  id: 'UIKit.SearchSelectInput.placeholderMessage',
50
50
  description: 'Placeholder text for the input',
51
51
  defaultMessage: 'Search by…'
52
+ },
53
+ searchSelectInputAsFilterPlaceholder: {
54
+ id: 'UIKit.SearchSelectInput.searchSelectInputAsFilterPlaceholder',
55
+ description: 'Placeholder text for the input',
56
+ defaultMessage: 'Search'
52
57
  }
53
58
  });
54
59
 
@@ -75,7 +80,9 @@ const defaultProps = {
75
80
  value: null,
76
81
  menuPortalZIndex: 1,
77
82
  maxMenuHeight: 220,
78
- controlShouldRenderValue: true
83
+ controlShouldRenderValue: true,
84
+ appearance: 'default',
85
+ optionStyle: 'list'
79
86
  };
80
87
  const SearchSelectInput = props => {
81
88
  const intl = reactIntl.useIntl();
@@ -87,28 +94,32 @@ const SearchSelectInput = props => {
87
94
  });
88
95
  const noOptionsMessage = props.noOptionsMessage || (() => intl.formatMessage(messages.noOptionsMessage));
89
96
  const loadingMessage = props.loadingMessage || intl.formatMessage(messages.loadingOptionsMessage);
90
- const placeholder = props.placeholder || intl.formatMessage(messages.placeholderMessage);
97
+ const placeholder = props.appearance === 'filter' && !props.placeholder ? intl.formatMessage(messages.searchSelectInputAsFilterPlaceholder) : props.placeholder || intl.formatMessage(messages.placeholderMessage);
91
98
  const optionType = props.optionType;
92
- const components = react.useMemo(() => _objectSpread(_objectSpread({
99
+ const components = react.useMemo(() => _objectSpread(_objectSpread(_objectSpread({
93
100
  Option: optionInnerProps => jsxRuntime.jsx(selectUtils.CustomSelectInputOption, _objectSpread(_objectSpread({}, optionInnerProps), {}, {
94
101
  optionType: optionType,
95
102
  optionInnerProps: optionInnerProps
96
103
  }))
97
- }, props.components), {}, {
104
+ }, props.optionStyle === 'checkbox' ? selectUtils.optionStyleCheckboxComponents(props.appearance) : {}), props.components), {}, {
98
105
  DropdownIndicator: selectUtils.SearchIconDropdownIndicator
99
- }), [props.components, optionType]);
106
+ }), [props.optionStyle, props.appearance, props.components, optionType]);
100
107
  return jsxRuntime.jsx(SearchSelectInputWrapper, {
101
108
  isDisabled: props.isDisabled,
102
109
  isReadOnly: props.isReadOnly,
103
- isCondensed: props.isCondensed,
104
- children: jsxRuntime.jsx(AsyncSelectInput__default["default"], _objectSpread(_objectSpread({}, props), {}, {
110
+ isCondensed: props.appearance === 'filter' ? true : props.isCondensed,
111
+ children: jsxRuntime.jsx(AsyncSelectInput__default["default"], _objectSpread(_objectSpread(_objectSpread({}, props), {}, {
105
112
  components: components,
106
113
  placeholder: placeholder,
107
114
  iconLeft: props.iconLeft,
108
115
  loadingMessage: loadingMessage,
109
116
  noOptionsMessage: noOptionsMessage,
110
- isSearchable: true,
117
+ isSearchable: true
118
+ // @ts-expect-error
119
+ ,
111
120
  closeMenuOnSelect: props.closeMenuOnSelect
121
+ }, props.optionStyle === 'checkbox' ? selectUtils.optionsStyleCheckboxSelectProps() : {}), {}, {
122
+ controlShouldRenderValue: props.appearance === 'filter' ? false : props.controlShouldRenderValue
112
123
  }))
113
124
  });
114
125
  };
@@ -118,7 +129,7 @@ SearchSelectInput.displayName = 'SearchSelectInput';
118
129
  var SearchSelectInput$1 = SearchSelectInput;
119
130
 
120
131
  // NOTE: This string will be replaced on build time with the package version.
121
- var version = "19.16.0";
132
+ var version = "19.17.0";
122
133
 
123
134
  exports["default"] = SearchSelectInput$1;
124
135
  exports.version = version;
@@ -12,7 +12,7 @@ import { useMemo } from 'react';
12
12
  import { defineMessages, useIntl } from 'react-intl';
13
13
  import AsyncSelectInput from '@commercetools-uikit/async-select-input';
14
14
  import { warning } from '@commercetools-uikit/utils';
15
- import { warnIfMenuPortalPropsAreMissing, CustomSelectInputOption, SearchIconDropdownIndicator } from '@commercetools-uikit/select-utils';
15
+ import { warnIfMenuPortalPropsAreMissing, CustomSelectInputOption, optionStyleCheckboxComponents, optionsStyleCheckboxSelectProps, SearchIconDropdownIndicator } from '@commercetools-uikit/select-utils';
16
16
  import _styled from '@emotion/styled/base';
17
17
  import { designTokens } from '@commercetools-uikit/design-system';
18
18
  import { jsx } from '@emotion/react/jsx-runtime';
@@ -32,6 +32,11 @@ var messages = defineMessages({
32
32
  id: 'UIKit.SearchSelectInput.placeholderMessage',
33
33
  description: 'Placeholder text for the input',
34
34
  defaultMessage: 'Search by…'
35
+ },
36
+ searchSelectInputAsFilterPlaceholder: {
37
+ id: 'UIKit.SearchSelectInput.searchSelectInputAsFilterPlaceholder',
38
+ description: 'Placeholder text for the input',
39
+ defaultMessage: 'Search'
35
40
  }
36
41
  });
37
42
 
@@ -61,7 +66,9 @@ const defaultProps = {
61
66
  value: null,
62
67
  menuPortalZIndex: 1,
63
68
  maxMenuHeight: 220,
64
- controlShouldRenderValue: true
69
+ controlShouldRenderValue: true,
70
+ appearance: 'default',
71
+ optionStyle: 'list'
65
72
  };
66
73
  const SearchSelectInput = props => {
67
74
  const intl = useIntl();
@@ -75,28 +82,32 @@ const SearchSelectInput = props => {
75
82
  });
76
83
  const noOptionsMessage = props.noOptionsMessage || (() => intl.formatMessage(messages.noOptionsMessage));
77
84
  const loadingMessage = props.loadingMessage || intl.formatMessage(messages.loadingOptionsMessage);
78
- const placeholder = props.placeholder || intl.formatMessage(messages.placeholderMessage);
85
+ const placeholder = props.appearance === 'filter' && !props.placeholder ? intl.formatMessage(messages.searchSelectInputAsFilterPlaceholder) : props.placeholder || intl.formatMessage(messages.placeholderMessage);
79
86
  const optionType = props.optionType;
80
- const components = useMemo(() => _objectSpread(_objectSpread({
87
+ const components = useMemo(() => _objectSpread(_objectSpread(_objectSpread({
81
88
  Option: optionInnerProps => jsx(CustomSelectInputOption, _objectSpread(_objectSpread({}, optionInnerProps), {}, {
82
89
  optionType: optionType,
83
90
  optionInnerProps: optionInnerProps
84
91
  }))
85
- }, props.components), {}, {
92
+ }, props.optionStyle === 'checkbox' ? optionStyleCheckboxComponents(props.appearance) : {}), props.components), {}, {
86
93
  DropdownIndicator: SearchIconDropdownIndicator
87
- }), [props.components, optionType]);
94
+ }), [props.optionStyle, props.appearance, props.components, optionType]);
88
95
  return jsx(SearchSelectInputWrapper, {
89
96
  isDisabled: props.isDisabled,
90
97
  isReadOnly: props.isReadOnly,
91
- isCondensed: props.isCondensed,
92
- children: jsx(AsyncSelectInput, _objectSpread(_objectSpread({}, props), {}, {
98
+ isCondensed: props.appearance === 'filter' ? true : props.isCondensed,
99
+ children: jsx(AsyncSelectInput, _objectSpread(_objectSpread(_objectSpread({}, props), {}, {
93
100
  components: components,
94
101
  placeholder: placeholder,
95
102
  iconLeft: props.iconLeft,
96
103
  loadingMessage: loadingMessage,
97
104
  noOptionsMessage: noOptionsMessage,
98
- isSearchable: true,
105
+ isSearchable: true
106
+ // @ts-expect-error
107
+ ,
99
108
  closeMenuOnSelect: props.closeMenuOnSelect
109
+ }, props.optionStyle === 'checkbox' ? optionsStyleCheckboxSelectProps() : {}), {}, {
110
+ controlShouldRenderValue: props.appearance === 'filter' ? false : props.controlShouldRenderValue
100
111
  }))
101
112
  });
102
113
  };
@@ -115,13 +126,16 @@ SearchSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
115
126
  onChange: _pt.func,
116
127
  loadingMessage: _pt.oneOfType([_pt.string, _pt.func]),
117
128
  optionType: _pt.oneOf(['single-property', 'double-property', 'multiple-properties']),
118
- iconLeft: _pt.node
129
+ iconLeft: _pt.node,
130
+ optionStyle: _pt.oneOf(['list', 'checkbox']).isRequired,
131
+ appearance: _pt.oneOf(['default', 'filter']),
132
+ count: _pt.number
119
133
  } : {};
120
134
  SearchSelectInput.defaultProps = defaultProps;
121
135
  SearchSelectInput.displayName = 'SearchSelectInput';
122
136
  var SearchSelectInput$1 = SearchSelectInput;
123
137
 
124
138
  // NOTE: This string will be replaced on build time with the package version.
125
- var version = "19.16.0";
139
+ var version = "19.17.0";
126
140
 
127
141
  export { SearchSelectInput$1 as default, version };
@@ -243,10 +243,21 @@ export type TSearchSelectInputProps = {
243
243
  * Icon to display on the left of the placeholder text and selected value. Has no effect when `isMulti` is enabled.
244
244
  */
245
245
  iconLeft?: ReactNode;
246
+ /** defines how options are rendered */
247
+ optionStyle: 'list' | 'checkbox';
248
+ /**
249
+ * Indicates the appearance of the input.
250
+ * Filter appearance is meant to be used when the async-select is used as a filter.
251
+ */
252
+ appearance?: 'default' | 'filter';
253
+ /**
254
+ * An additional value displayed on the select options menu. This value is only available in the checkbox option style when appearance is set to filter.
255
+ */
256
+ count?: number;
246
257
  };
247
258
  declare const SearchSelectInput: {
248
259
  (props: TSearchSelectInputProps): import("@emotion/react/jsx-runtime").JSX.Element;
249
- defaultProps: Pick<TSearchSelectInputProps, "value" | "controlShouldRenderValue" | "maxMenuHeight" | "menuPortalZIndex">;
260
+ defaultProps: Pick<TSearchSelectInputProps, "value" | "appearance" | "controlShouldRenderValue" | "maxMenuHeight" | "menuPortalZIndex" | "optionStyle">;
250
261
  displayName: string;
251
262
  };
252
263
  export default SearchSelectInput;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/search-select-input",
3
3
  "description": "A search select input component built on top of `@commercetools-uikit/async-select-input` to asynchronously load results (options) using the keyword that the user has entered.",
4
- "version": "19.16.0",
4
+ "version": "19.17.0",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,12 +21,12 @@
21
21
  "dependencies": {
22
22
  "@babel/runtime": "^7.20.13",
23
23
  "@babel/runtime-corejs3": "^7.20.13",
24
- "@commercetools-uikit/async-select-input": "19.16.0",
25
- "@commercetools-uikit/design-system": "19.16.0",
26
- "@commercetools-uikit/select-utils": "19.16.0",
27
- "@commercetools-uikit/spacings": "19.16.0",
28
- "@commercetools-uikit/text": "19.16.0",
29
- "@commercetools-uikit/utils": "19.16.0",
24
+ "@commercetools-uikit/async-select-input": "19.17.0",
25
+ "@commercetools-uikit/design-system": "19.17.0",
26
+ "@commercetools-uikit/select-utils": "19.17.0",
27
+ "@commercetools-uikit/spacings": "19.17.0",
28
+ "@commercetools-uikit/text": "19.17.0",
29
+ "@commercetools-uikit/utils": "19.17.0",
30
30
  "@emotion/react": "^11.10.5",
31
31
  "@emotion/styled": "^11.10.5",
32
32
  "prop-types": "15.8.1"