@moda/om 17.14.2 → 18.0.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/CHANGELOG.md +12 -0
- package/dist/index.cjs.js +95 -135
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +95 -135
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/AspectRatioBox/AspectRatioBox.d.ts +1 -1
- package/dist/src/components/Badge/Badge.d.ts +2 -2
- package/dist/src/components/Breadcrumbs/Breadcrumb/Breadcrumb.d.ts +1 -1
- package/dist/src/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/src/components/Breakpoint/Breakpoint.d.ts +4 -4
- package/dist/src/components/Breakpoint/BreakpointProvider.d.ts +1 -1
- package/dist/src/components/Breakpoint/generateMediaQuery.d.ts +2 -2
- package/dist/src/components/Button/Button.d.ts +1 -1
- package/dist/src/components/Checkbox/Checkbox.d.ts +2 -2
- package/dist/src/components/Clickable/Clickable.d.ts +3 -3
- package/dist/src/components/ColorSwatch/ColorSwatch.d.ts +2 -2
- package/dist/src/components/ColorSwatch/skuColors.d.ts +1 -1
- package/dist/src/components/Constrain/Constrain.d.ts +1 -1
- package/dist/src/components/Constrain/ExceedConstrain.d.ts +1 -1
- package/dist/src/components/ControlLink/ControlLink.d.ts +1 -1
- package/dist/src/components/CreditCardNumberInput/CreditCardNumberInput.d.ts +1 -1
- package/dist/src/components/CreditCardNumberInput/CreditCardNumberInputField.d.ts +1 -1
- package/dist/src/components/DefinitionList/DefinitionList.d.ts +1 -1
- package/dist/src/components/Divider/Divider.d.ts +1 -1
- package/dist/src/components/Expandable/Expandable.d.ts +1 -1
- package/dist/src/components/Field/Field.d.ts +1 -1
- package/dist/src/components/Label/Label.d.ts +1 -1
- package/dist/src/components/Loading/Loading.d.ts +1 -1
- package/dist/src/components/Modal/Modal.d.ts +1 -1
- package/dist/src/components/ModalOverlay/ModalOverlay.d.ts +1 -1
- package/dist/src/components/Overlay/Overlay.d.ts +1 -1
- package/dist/src/components/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/src/components/Popover/Popover.d.ts +1 -1
- package/dist/src/components/PromoBanner/PromoBanner.d.ts +1 -1
- package/dist/src/components/RadioButton/RadioButton.d.ts +1 -1
- package/dist/src/components/SearchInput/SearchInput.d.ts +1 -2
- package/dist/src/components/Select/MultiSelect.d.ts +1 -1
- package/dist/src/components/Select/Select.d.ts +2 -2
- package/dist/src/components/Select/SelectLabel.d.ts +1 -1
- package/dist/src/components/Select/SelectOption.d.ts +1 -1
- package/dist/src/components/Select/SelectOptions.d.ts +1 -1
- package/dist/src/components/Select/useSelect.d.ts +1 -1
- package/dist/src/components/SelectableButton/SelectableButton.d.ts +1 -1
- package/dist/src/components/Shape/Shape.d.ts +1 -1
- package/dist/src/components/SlidingPane/SlidingPane.d.ts +1 -1
- package/dist/src/components/Stack/Stack.d.ts +1 -1
- package/dist/src/components/Tabs/Tab.d.ts +2 -2
- package/dist/src/components/Tabs/TabList.d.ts +1 -1
- package/dist/src/components/Tabs/TabPanel.d.ts +1 -1
- package/dist/src/components/Tabs/TabPanels.d.ts +1 -1
- package/dist/src/components/Tabs/Tabs.d.ts +1 -1
- package/dist/src/components/Tag/Tag.d.ts +1 -1
- package/dist/src/components/Text/Text.d.ts +4 -4
- package/dist/src/components/TextInput/TextInput.d.ts +2 -2
- package/dist/src/components/Textarea/Textarea.d.ts +1 -1
- package/dist/src/components/Toast/Toast.d.ts +1 -1
- package/dist/src/components/VerticalDivider/VerticalDivider.d.ts +1 -1
- package/dist/src/hooks/useBreakpoint.d.ts +3 -3
- package/dist/src/hooks/useKeyboardListNavigation.d.ts +3 -3
- package/dist/src/utilities/States/isRenderProps.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/SearchInput/SearchInput.stories.tsx +2 -6
- package/src/components/SearchInput/SearchInput.test.tsx +14 -0
- package/src/components/SearchInput/SearchInput.tsx +6 -13
|
@@ -14,4 +14,18 @@ describe('SearchInput', () => {
|
|
|
14
14
|
|
|
15
15
|
expect(screen.getByRole('textbox')).toHaveValue('');
|
|
16
16
|
});
|
|
17
|
+
|
|
18
|
+
it('calls onChange when typing', async () => {
|
|
19
|
+
const onChange = jest.fn();
|
|
20
|
+
|
|
21
|
+
render(<SearchInput value='' onChange={onChange} />);
|
|
22
|
+
|
|
23
|
+
await userEvent.type(screen.getByRole('textbox'), 'Greetings');
|
|
24
|
+
|
|
25
|
+
expect(onChange).toHaveBeenCalledWith('Greetings');
|
|
26
|
+
|
|
27
|
+
await userEvent.click(screen.getByRole('button'));
|
|
28
|
+
|
|
29
|
+
expect(onChange).toHaveBeenCalledWith('');
|
|
30
|
+
});
|
|
17
31
|
});
|
|
@@ -9,7 +9,6 @@ import './SearchInput.scss';
|
|
|
9
9
|
export type SearchInputProps = TextInputProps & {
|
|
10
10
|
value?: string;
|
|
11
11
|
onClear?(): void;
|
|
12
|
-
onChangeValue?(value: string): void;
|
|
13
12
|
};
|
|
14
13
|
|
|
15
14
|
const DEFAULT_INPUT_VALUE = '';
|
|
@@ -17,7 +16,6 @@ const DEFAULT_INPUT_VALUE = '';
|
|
|
17
16
|
export const SearchInput: React.FC<SearchInputProps> = ({
|
|
18
17
|
className,
|
|
19
18
|
onChange,
|
|
20
|
-
onChangeValue,
|
|
21
19
|
onClear,
|
|
22
20
|
value = DEFAULT_INPUT_VALUE,
|
|
23
21
|
...rest
|
|
@@ -26,13 +24,12 @@ export const SearchInput: React.FC<SearchInputProps> = ({
|
|
|
26
24
|
|
|
27
25
|
const [controlledValue, setValue] = useState(value);
|
|
28
26
|
|
|
29
|
-
const
|
|
27
|
+
const handleClear = useCallback(() => {
|
|
30
28
|
setValue(DEFAULT_INPUT_VALUE);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}, [onClear]);
|
|
29
|
+
onChange?.(DEFAULT_INPUT_VALUE);
|
|
30
|
+
onClear?.();
|
|
31
|
+
ref.current?.focus();
|
|
32
|
+
}, [onClear, onChange]);
|
|
36
33
|
|
|
37
34
|
const handleChange = useCallback(
|
|
38
35
|
(value: string) => {
|
|
@@ -44,10 +41,6 @@ export const SearchInput: React.FC<SearchInputProps> = ({
|
|
|
44
41
|
|
|
45
42
|
useEffect(() => setValue(value), [value]);
|
|
46
43
|
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
onChangeValue && onChangeValue(controlledValue);
|
|
49
|
-
}, [controlledValue, onChangeValue]);
|
|
50
|
-
|
|
51
44
|
return (
|
|
52
45
|
<div className={classNames('SearchInput', className)}>
|
|
53
46
|
<div className='SearchInput__icon'>
|
|
@@ -63,7 +56,7 @@ export const SearchInput: React.FC<SearchInputProps> = ({
|
|
|
63
56
|
/>
|
|
64
57
|
|
|
65
58
|
{controlledValue && (
|
|
66
|
-
<Clickable className='SearchInput__clear' onClick={
|
|
59
|
+
<Clickable className='SearchInput__clear' onClick={handleClear} type='reset'>
|
|
67
60
|
<ExitIcon />
|
|
68
61
|
</Clickable>
|
|
69
62
|
)}
|