@soul-refiner/design-system 1.7.16 → 1.7.17
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.
|
@@ -10,6 +10,7 @@ export interface FilterProps {
|
|
|
10
10
|
disabled?: boolean;
|
|
11
11
|
graphic?: React.ReactElement;
|
|
12
12
|
graphicAlignment?: 'left' | 'right';
|
|
13
|
+
resetGraphic?: boolean;
|
|
13
14
|
label?: string;
|
|
14
15
|
sx?: string;
|
|
15
16
|
triggerType: FilterTriggerTypes;
|
|
@@ -23,9 +24,9 @@ export interface FilterProps {
|
|
|
23
24
|
applyResetActions?: boolean;
|
|
24
25
|
}
|
|
25
26
|
declare const Filter: {
|
|
26
|
-
({ closeOnBlur, disabled, graphic, graphicAlignment, label, sx, triggerType, options, defaultValue, closeOnChange, optionOnChange, optionShowClose, checkbox, applyOnClick, resetOnClick, applyResetActions, }: FilterProps): React.JSX.Element;
|
|
27
|
+
({ closeOnBlur, disabled, graphic, graphicAlignment, resetGraphic, label, sx, triggerType, options, defaultValue, closeOnChange, optionOnChange, optionShowClose, checkbox, applyOnClick, resetOnClick, applyResetActions, }: FilterProps): React.JSX.Element;
|
|
27
28
|
Trigger: {
|
|
28
|
-
({ disabled, graphic, graphicAlignment, label, onClick, open, type, value, }: FilterTriggerProps): React.JSX.Element;
|
|
29
|
+
({ disabled, graphic, graphicAlignment, label, onClick, resetGraphic, open, onReset, type, value, }: FilterTriggerProps): React.JSX.Element;
|
|
29
30
|
displayName: string;
|
|
30
31
|
};
|
|
31
32
|
};
|
|
@@ -35,7 +36,9 @@ export interface FilterTriggerProps {
|
|
|
35
36
|
graphicAlignment?: 'left' | 'right';
|
|
36
37
|
label?: string;
|
|
37
38
|
onClick?: (event: React.MouseEvent) => void;
|
|
39
|
+
onReset?: (event: React.MouseEvent) => void;
|
|
38
40
|
open: boolean;
|
|
41
|
+
resetGraphic?: boolean;
|
|
39
42
|
type: FilterTriggerTypes;
|
|
40
43
|
value?: string;
|
|
41
44
|
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
4
|
import { Box, Button, P } from '../../';
|
|
5
|
-
import { ChevronDown, ChevronUp } from '../../../icons';
|
|
5
|
+
import { ChevronDown, ChevronUp, Close } from '../../../icons';
|
|
6
6
|
import { Styles } from '../../../common';
|
|
7
7
|
import { Spacer, Option } from './filter_option';
|
|
8
|
-
const Filter = ({ closeOnBlur = true, disabled, graphic, graphicAlignment = 'left', label = '', sx, triggerType, options, defaultValue = '', closeOnChange = true, optionOnChange, optionShowClose, checkbox, applyOnClick, resetOnClick, applyResetActions, }) => {
|
|
8
|
+
const Filter = ({ closeOnBlur = true, disabled, graphic, graphicAlignment = 'left', resetGraphic, label = '', sx, triggerType, options, defaultValue = '', closeOnChange = true, optionOnChange, optionShowClose, checkbox, applyOnClick, resetOnClick, applyResetActions, }) => {
|
|
9
9
|
const multiple = !!checkbox;
|
|
10
10
|
const wrapperRef = React.useRef(null);
|
|
11
11
|
const optionsRef = React.useRef(null);
|
|
@@ -98,8 +98,17 @@ const Filter = ({ closeOnBlur = true, disabled, graphic, graphicAlignment = 'lef
|
|
|
98
98
|
}),
|
|
99
99
|
triggerType === 'pill' && React.createElement(Spacer, { key: `spacer-${options.length}` }),
|
|
100
100
|
];
|
|
101
|
+
const showResetGraphic = resetGraphic &&
|
|
102
|
+
(typeof selected === 'string' ? !!selected : !!selected.length);
|
|
101
103
|
return (React.createElement(Wrapper, { "$sx": sx, tabIndex: 0, ref: wrapperRef, onBlurCapture: handleBlur },
|
|
102
|
-
React.createElement(FilterTrigger, { disabled: disabled, graphic: graphic, graphicAlignment: graphicAlignment, label: label, onClick: handleOpen,
|
|
104
|
+
React.createElement(FilterTrigger, { disabled: disabled, graphic: graphic, graphicAlignment: graphicAlignment, label: label, onClick: handleOpen, onReset: resetGraphic
|
|
105
|
+
? (event) => {
|
|
106
|
+
event.stopPropagation();
|
|
107
|
+
resetOnClick && resetOnClick(event);
|
|
108
|
+
setSelected(multiple ? [] : '');
|
|
109
|
+
setOpen(false);
|
|
110
|
+
}
|
|
111
|
+
: undefined, open: open, resetGraphic: showResetGraphic, type: triggerType, value: filterLabel }),
|
|
103
112
|
open && (React.createElement(Container, { ref: optionsRef },
|
|
104
113
|
React.createElement(React.Fragment, null,
|
|
105
114
|
dropdownOptions,
|
|
@@ -151,13 +160,14 @@ const wrapperProps = {
|
|
|
151
160
|
$dir: 'row',
|
|
152
161
|
$gap: 16,
|
|
153
162
|
};
|
|
154
|
-
const FilterTrigger = ({ disabled, graphic, graphicAlignment, label, onClick, open, type, value, }) => {
|
|
163
|
+
const FilterTrigger = ({ disabled, graphic, graphicAlignment, label, onClick, resetGraphic, open, onReset, type, value, }) => {
|
|
155
164
|
if (type === 'pill') {
|
|
156
165
|
return (React.createElement(Pill, { disabled: disabled, onClick: onClick, "$labelIsDefault": value === label, ...wrapperProps },
|
|
157
166
|
graphicAlignment === 'left' ? graphic : null,
|
|
158
167
|
React.createElement(P, { ...textProps }, value),
|
|
168
|
+
resetGraphic ? React.createElement(Close, { color: "blue-3", onClick: onReset }) : null,
|
|
159
169
|
graphicAlignment === 'right' ? graphic : null,
|
|
160
|
-
!graphic && (open ? React.createElement(ChevronUp, null) : React.createElement(ChevronDown, null))));
|
|
170
|
+
!graphic && !resetGraphic && (open ? React.createElement(ChevronUp, null) : React.createElement(ChevronDown, null))));
|
|
161
171
|
}
|
|
162
172
|
if (type === 'labeled') {
|
|
163
173
|
return (React.createElement(Labeled, { disabled: disabled, onClick: onClick, ...wrapperProps },
|