woocommerce/plugins/woocommerce-blocks/assets/js/editor-components/search-list-control
Mike Jolley 2d506f9f57 Fix/you do not need lodash (https://github.com/woocommerce/woocommerce-blocks/pull/9161)
* Remove lodash `without` usage

* isNumber

* Remove lodash `difference`

* Replace lodash isEmpty with type guard

* Replace isObject with type guard

* remove lodash noop

* Replace lodash clamp

* replace lodash uniqueId

* Remove uniqueId import

* Add eslint rule to restrict lodash import

* Replace lodash range

* Replace lodash has() function

Replace lodash has

* replace omitby

* Replace lodash isEqual with fastDeepEqual

* Replace kebabCase with change-case package

* Replace lodash camelCase

Replace lodash mapKeys with function

Move mapkeys to utility

Create camelCaseKeys which replaces usage of mapKeys

* Replace lodash debounce with custom utiity

* replace lodash keyby

* Replace lodash pick with native function

* Replace lodash cloneDeep with klona

* Replace snake case keys package with change case

* Replace sortBy with fast sort package

* replace isEmpty with type guard

* Replace pickBy usage in validation reducer

* Replace groupBy usage in search list control

* Replace flatten, uniqBy usage in getProducts()

* Remove setWith and clone from updateState

* Replace custom useThrottle with useThrottledCallback from use-debounce package

* onSelectRate can use-debounce

* Fix missing flatten

* Update assets/js/data/cart/test/push-changes.ts

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
2023-04-28 11:29:45 +01:00
..
test Fix/you do not need lodash (https://github.com/woocommerce/woocommerce-blocks/pull/9161) 2023-04-28 11:29:45 +01:00
README.md Improve the structure of the WooCommerce Blocks Handbook (https://github.com/woocommerce/woocommerce-blocks/pull/6429) 2022-06-09 17:52:19 +02:00
index.ts Update WordPress Monorepo packages with React 17x support (https://github.com/woocommerce/woocommerce-blocks/pull/5223) 2021-12-07 15:47:50 +00:00
item.tsx Add decoding to product names (https://github.com/woocommerce/woocommerce-blocks/pull/8824) 2023-03-23 06:27:02 -07:00
search-list-control.tsx Improve Products block Attributes Filter Inspector Controls (https://github.com/woocommerce/woocommerce-blocks/pull/8583) 2023-03-08 17:22:51 +01:00
style.scss Improve Products block Attributes Filter Inspector Controls (https://github.com/woocommerce/woocommerce-blocks/pull/8583) 2023-03-08 17:22:51 +01:00
types.ts Improve Products block Attributes Filter Inspector Controls (https://github.com/woocommerce/woocommerce-blocks/pull/8583) 2023-03-08 17:22:51 +01:00
utils.tsx Fix/you do not need lodash (https://github.com/woocommerce/woocommerce-blocks/pull/9161) 2023-04-28 11:29:45 +01:00

README.md

SearchListControl

Table of contents

Component to display a searchable, selectable list of items.

Usage

<SearchListControl
	list={ list }
	isLoading={ loading }
	selected={ selected }
	onChange={ ( items ) => setState( { selected: items } ) }
/>

Props

Name Type Default Description
className String null Additional CSS classes
isHierarchical Boolean null Whether the list of items is hierarchical or not. If true, each list item is expected to have a parent property
isLoading Boolean null Whether the list of items is still loading
isSingle Boolean null Restrict selections to one item
list Array null A complete list of item objects, each with id, name properties. This is displayed as a clickable/keyboard-able list, and possibly filtered by the search term (searches name)
messages Object null Messages displayed or read to the user. Configure these to reflect your object type. See defaultMessages above for examples
onChange Function null (required) Callback fired when selected items change, whether added, cleared, or removed. Passed an array of item objects (as passed in via props.list)
onSearch Function null Callback fired when the search field is used
renderItem Function null Callback to render each item in the selection list, allows any custom object-type rendering
selected Array null (required) The list of currently selected items
search String null
setState Function null
debouncedSpeak Function null
instanceId Number null

list item structure

  • id: Number
  • name: String

messages object structure

  • clear: String - A more detailed label for the "Clear all" button, read to screen reader users.
  • list: String - Label for the list of selectable items, only read to screen reader users.
  • noItems: String - Message to display when the list is empty (implies nothing loaded from the server or parent component).
  • noResults: String - Message to display when no matching results are found. %s is the search term.
  • search: String - Label for the search input
  • selected: Function - Label for the selected items. This is actually a function, so that we can pass through the count of currently selected items.
  • updated: String - Label indicating that search results have changed, read to screen reader users.

SearchListItem

Usage

Used implicitly by SearchListControl when the renderItem prop is omitted.

Props

Name Type Default Description
className String null Additional CSS classes
countLabel ReactNode null Label to display in the count bubble. Takes preference over item.count.
depth Number 0 Depth, non-zero if the list is hierarchical
item Object null Current item to display
isSelected Boolean null Whether this item is selected
isSingle Boolean null Whether this should only display a single item (controls radio vs checkbox icon)
onSelect Function null Callback for selecting the item
search String '' Search string, used to highlight the substring in the item name

We're hiring! Come work with us!

🐞 Found a mistake, or have a suggestion? Leave feedback about this document here.