You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FCT 1187 - enable filter selection in filters (#2971)
* feat(filter selects): use new appearance:filter and optionStyle:checkbox props for select input
* feat(filters): [publish_preview] insure that options and option groups are handled by the 'add filters' select input
* chore(rebase): update yarn.lock
* feat(filters): add aria-labels to fixture inputs for better ability to find them in tests, add aria-label to ul containing filter chips in TriggerButton for a11y/easier test targeting, add more complete tests for Footer, TriggerButton, and FilterMenu
* test(filters): add tests
* feat(filters): add aria-live=polite to filtersList container and selected filter values containers
* feat(filters): add aria-label to add filter select in filters, use radix dialog to find filter inputs instead of looking for combobox in filters.spec.tsx
* feat(filter selects): use new appearance:filter and optionStyle:checkbox props for select input
* fix(deps): add proptypes back in
* feat(filter selects): use new appearance:filter and optionStyle:checkbox props for select input
* feat(filters stories): clean up story code a bit
* feat(filters stories): rebase and clean up readmes/icons
* feat(filters): update visible filters if number of persisted filters changes
* feat(filters): remove todo comments from jsdoc blocks in filters
* feat(filters): update filter-menu to apply custom styling to select wrappers when parent of custom select menu to allow the select input's options menu to scroll, add max-height to filter-menu dropdowns, update usage example to be more readable and add comments, update story to open filters by default so user doesn't have to click on the filters button to see the list, add filters-with-state fixture for use in VRT, add defaultOpen prop to filters so that the filters list can mount on first render, add VRTs for various open/closed states
* feat(filters): add changeset, update readme with more helpful description
* FCT-1187 - Filter Selection tests (#2979)
* feat(filters): implement filters selection tests, add test helpers
* feat(vrt): only defaultOpen a filterMenu if it isnt persisted and there are more locally visible filters than there are visible filters from props
---------
Co-authored-by: Byron Wall <[email protected]>
* chore(filters): restore spec files
* fix(add filter button): add role of button to wrapping div that receives forwarded ref from radix trigger popover
* fix(filters divider): divider is 1px
* feat(filter selects): use new appearance:filter and optionStyle:checkbox props for select input
* fix(add filter button): remove button role, since wrapper is wrapping a button
* feat(operators): add new filter.operatorLabel type/prop to handle display of the selected operator value in the trigger menu, add test to ensure operator label displays in trigger button, make radio option text 14px
---------
Co-authored-by: Valorie <[email protected]>
Co-authored-by: Valorie <[email protected]>
Copy file name to clipboardExpand all lines: packages/components/filters/README.md
+194-9Lines changed: 194 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,11 @@
5
5
6
6
## Description
7
7
8
-
The `Filters` component displays all active filters. It also allows for adding and removing filters.
8
+
The `Filters` component pattern is a component that provides the controls to filter the items in a table or list.
9
9
10
-
This description is a stub and shold be expanded as development continues.
10
+
- Available filter controls are configured in the `filters` array. Each `filter` object includes a `filterMenuConfiguration` object, in which the inputs that allow the user to select a value for that filter are defined.
11
+
12
+
- The selected values for each filter are passed to the component in the `appliedFilters` array. Values in the `appliedFilters` array will be displayed in each filter's menu button.
11
13
12
14
## Installation
13
15
@@ -34,14 +36,197 @@ npm --save install react
34
36
```jsx
35
37
importFiltersfrom'@commercetools-uikit/filters';
36
38
37
-
/**TODO: EXPAND THIS */
38
-
constExample= () =><Filters />;
39
-
40
-
exportdefaultExample;
39
+
/** Input for a specific filter, provided by parent application */
|`appliedFilters`|`Array: TAppliedFilter[]`<br/>[See signature.](#signature-appliedFilters)| ✅ || array of applied filters, each containing a unique key and an array of values. |
119
+
|`filters`|`Array: TFilterConfiguration[]`<br/>[See signature.](#signature-filters)| ✅ || configuration for the available filters. |
120
+
|`filterGroups`|`Array: TFilterGroupConfiguration[]`<br/>[See signature.](#signature-filterGroups)||| optional configuration for filter groups. |
121
+
|`onClearAllRequest`|`Function`<br/>[See signature.](#signature-onClearAllRequest)| ✅ || controls the `clear all` (added filters) button from the menu list, meant to clear the parent application's filter state |
122
+
|`onAddFilterRequest`|`Function`<br/>[See signature.](#signature-onAddFilterRequest)||| optional callback when the add filter button is clicked |
123
+
|`renderSearchComponent`|`ReactNode`| ✅ || function to render a search input, selectable from applicable UI Kit components. |
124
+
|`defaultOpen`|`boolean`||`false`| controls whether the filters list is initially open |
125
+
126
+
## Signatures
127
+
128
+
### Signature `appliedFilters`
129
+
130
+
```ts
131
+
{
132
+
/**
133
+
* unique identifier for the filter
134
+
*/
135
+
filterKey: string;
136
+
/**
137
+
* the values applied to this filter by the user
138
+
*/
139
+
values: TAppliedFilterValue[];
140
+
}
141
+
```
142
+
143
+
### Signature `filters`
144
+
145
+
```ts
146
+
{
147
+
/**
148
+
* unique identifier for the filter
149
+
*/
150
+
key: string;
151
+
/**
152
+
* formatted message to display the filter name
153
+
*/
154
+
label: ReactNode;
155
+
/**
156
+
* formatted message to display the selected operator value
157
+
*/
158
+
operatorLabel?:ReactNode;
159
+
/**
160
+
* configuration object for the filter menu.
161
+
*/
162
+
filterMenuConfiguration: {
163
+
/**
164
+
* the input in which the user selects values for the filter
165
+
*/
166
+
renderMenuBody: () =>ReactNode;
167
+
/**
168
+
* the input in which the user can select which operator should be used for this filter
169
+
*/
170
+
renderOperatorsInput?: () =>ReactNode;
171
+
/**
172
+
* optional button that allows the user to apply selected filter values
173
+
*/
174
+
renderApplyButton?: () =>ReactNode;
175
+
/**
176
+
* controls whether `clear` button in Menu Body Footer is displayed
The `Filters` component displays all active filters. It also allows for adding and removing filters.
1
+
The `Filters` component pattern is a component that provides the controls to filter the items in a table or list.
2
2
3
-
This description is a stub and shold be expanded as development continues.
3
+
- Available filter controls are configured in the `filters` array. Each `filter` object includes a `filterMenuConfiguration` object, in which the inputs that allow the user to select a value for that filter are defined.
4
+
5
+
- The selected values for each filter are passed to the component in the `appliedFilters` array. Values in the `appliedFilters` array will be displayed in each filter's menu button.
0 commit comments