@box/blueprint-web 6.9.3 → 6.10.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/lib-esm/search-input/index.d.ts +2 -15
- package/lib-esm/search-input/index.js +3 -1
- package/lib-esm/search-input/search-input-controlled/index.d.ts +2 -0
- package/lib-esm/search-input/search-input-controlled/search-input-controlled.d.ts +3 -0
- package/lib-esm/search-input/search-input-controlled/search-input-controlled.js +79 -0
- package/lib-esm/search-input/search-input-controlled/types.d.ts +17 -0
- package/lib-esm/search-input/search-input.d.ts +4 -15
- package/lib-esm/search-input/search-input.js +4 -1
- package/lib-esm/search-input/types.d.ts +2 -3
- package/package.json +2 -2
|
@@ -1,22 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const SearchInput: import("react").ForwardRefExoticComponent<Omit<
|
|
3
|
-
ref?: ((instance: HTMLInputElement | null) => void) | import("react").RefObject<HTMLInputElement> | null | undefined;
|
|
4
|
-
}, "disabled" | "type" | "onChange" | "defaultValue" | "className" | "onSubmit" | "onKeyDown" | "searchIconAriaLabel" | "searchInputAriaLabel" | "searchInputClearAriaLabel" | "variant"> & {
|
|
5
|
-
className?: string | undefined;
|
|
6
|
-
defaultValue?: string | undefined;
|
|
7
|
-
disabled?: boolean | undefined;
|
|
8
|
-
onChange?: ((searchInputValue: string) => void) | undefined;
|
|
9
|
-
onKeyDown?: ((e: import("react").KeyboardEvent<HTMLInputElement>) => void) | undefined;
|
|
10
|
-
onSubmit?: ((searchInputValue: string) => void) | undefined;
|
|
11
|
-
searchIconAriaLabel: string;
|
|
12
|
-
searchInputAriaLabel: string;
|
|
13
|
-
searchInputClearAriaLabel: string;
|
|
14
|
-
type?: "search" | undefined;
|
|
15
|
-
variant?: "in-context" | "global" | undefined;
|
|
16
|
-
}, "ref"> & import("react").RefAttributes<HTMLInputElement>> & {
|
|
2
|
+
export declare const SearchInput: import("react").ForwardRefExoticComponent<Omit<import("./types").SearchInputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>> & {
|
|
17
3
|
/**
|
|
18
4
|
* Styled wrapper over an icon button.
|
|
19
5
|
*/
|
|
20
6
|
ActionButton: import("react").ForwardRefExoticComponent<Omit<import("../..").IconButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
7
|
+
Controlled: import("react").ForwardRefExoticComponent<Omit<import("./search-input-controlled").SearchInputControlledProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
21
8
|
};
|
|
22
9
|
export type { SearchInputActionButtonProps, SearchInputProps } from './types';
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { SearchInput as SearchInput$1 } from './search-input.js';
|
|
2
2
|
import { SearchInputActionButton } from './search-input-action-button.js';
|
|
3
|
+
import { SearchInputControlled } from './search-input-controlled/search-input-controlled.js';
|
|
3
4
|
|
|
4
5
|
const SearchInput = Object.assign(SearchInput$1, {
|
|
5
6
|
/**
|
|
6
7
|
* Styled wrapper over an icon button.
|
|
7
8
|
*/
|
|
8
|
-
ActionButton: SearchInputActionButton
|
|
9
|
+
ActionButton: SearchInputActionButton,
|
|
10
|
+
Controlled: SearchInputControlled
|
|
9
11
|
});
|
|
10
12
|
|
|
11
13
|
export { SearchInput };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Search } from '@box/blueprint-web-assets/icons/Fill';
|
|
3
|
+
import { IconIconOnLightSecondary, IconCtaIcon } from '@box/blueprint-web-assets/tokens/tokens';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { forwardRef, Children } from 'react';
|
|
6
|
+
import { IconButton } from '../../primitives/icon-button/icon-button.js';
|
|
7
|
+
import { switchCase } from '../../utils/switchCase.js';
|
|
8
|
+
import { AccessibleXMarkGlobal, AccessibleXMark } from '../search-input.js';
|
|
9
|
+
import styles from '../search.module.js';
|
|
10
|
+
|
|
11
|
+
const SearchInputControlled = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
12
|
+
const {
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
15
|
+
disabled = false,
|
|
16
|
+
onChange,
|
|
17
|
+
onClearInput,
|
|
18
|
+
onKeyDown,
|
|
19
|
+
onSubmit,
|
|
20
|
+
placeholder = '',
|
|
21
|
+
searchIconAriaLabel,
|
|
22
|
+
searchInputAriaLabel,
|
|
23
|
+
searchInputClearAriaLabel,
|
|
24
|
+
value,
|
|
25
|
+
variant,
|
|
26
|
+
...rest
|
|
27
|
+
} = props;
|
|
28
|
+
const onSearchInputKeyDown = e => {
|
|
29
|
+
if (disabled) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
switchCase({
|
|
33
|
+
Enter: () => {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
onSubmit?.(value);
|
|
36
|
+
},
|
|
37
|
+
Escape: () => {
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
onClearInput();
|
|
40
|
+
}
|
|
41
|
+
})(e.key)?.();
|
|
42
|
+
onKeyDown?.(e);
|
|
43
|
+
};
|
|
44
|
+
const isGlobal = variant === 'global';
|
|
45
|
+
const showActionButton = Children.count(children) > 0;
|
|
46
|
+
return jsxs("div", {
|
|
47
|
+
className: clsx(styles.search, className),
|
|
48
|
+
children: [jsx(Search, {
|
|
49
|
+
"aria-label": searchIconAriaLabel,
|
|
50
|
+
className: clsx(styles.searchIcon, isGlobal && styles.global),
|
|
51
|
+
color: IconIconOnLightSecondary
|
|
52
|
+
}), jsx("input", {
|
|
53
|
+
...rest,
|
|
54
|
+
ref: forwardedRef,
|
|
55
|
+
"aria-label": searchInputAriaLabel,
|
|
56
|
+
className: clsx(styles.searchInput, isGlobal && styles.global, {
|
|
57
|
+
[styles.withoutActionButton]: isGlobal && !showActionButton
|
|
58
|
+
}),
|
|
59
|
+
disabled: disabled,
|
|
60
|
+
onChange: onChange,
|
|
61
|
+
onKeyDown: onSearchInputKeyDown,
|
|
62
|
+
onSubmit: e => {
|
|
63
|
+
onSubmit?.(value);
|
|
64
|
+
},
|
|
65
|
+
placeholder: placeholder,
|
|
66
|
+
type: "search",
|
|
67
|
+
value: value
|
|
68
|
+
}), !!value && jsx(IconButton, {
|
|
69
|
+
"aria-label": searchInputClearAriaLabel,
|
|
70
|
+
className: clsx(styles.clearSearchIcon, isGlobal && styles.global, isGlobal && !showActionButton && styles.withoutActionButton),
|
|
71
|
+
color: IconCtaIcon,
|
|
72
|
+
icon: isGlobal ? AccessibleXMarkGlobal : AccessibleXMark,
|
|
73
|
+
onClick: onClearInput,
|
|
74
|
+
size: "x-small"
|
|
75
|
+
}), isGlobal && showActionButton && children]
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export { SearchInputControlled };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ChangeEvent } from 'react';
|
|
2
|
+
import { type SearchInputProps } from '../types';
|
|
3
|
+
export interface SearchInputControlledProps extends Omit<SearchInputProps, 'defaultValue' | 'onChange'> {
|
|
4
|
+
/**
|
|
5
|
+
* Handler that is called when the search value is changed.
|
|
6
|
+
*/
|
|
7
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Handler that is called when clear button is clicked or escape key is pressed when input is focused
|
|
10
|
+
*/
|
|
11
|
+
onClearInput: () => void;
|
|
12
|
+
/**
|
|
13
|
+
* Value for controlled search input.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
value: string;
|
|
17
|
+
}
|
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
defaultValue?: string | undefined;
|
|
7
|
-
disabled?: boolean | undefined;
|
|
8
|
-
onChange?: ((searchInputValue: string) => void) | undefined;
|
|
9
|
-
onKeyDown?: ((e: import("react").KeyboardEvent<HTMLInputElement>) => void) | undefined;
|
|
10
|
-
onSubmit?: ((searchInputValue: string) => void) | undefined;
|
|
11
|
-
searchIconAriaLabel: string;
|
|
12
|
-
searchInputAriaLabel: string;
|
|
13
|
-
searchInputClearAriaLabel: string;
|
|
14
|
-
type?: "search" | undefined;
|
|
15
|
-
variant?: "in-context" | "global" | undefined;
|
|
16
|
-
}, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
2
|
+
import { type SearchInputProps } from './types';
|
|
3
|
+
export declare const AccessibleXMark: () => JSX.Element;
|
|
4
|
+
export declare const AccessibleXMarkGlobal: () => JSX.Element;
|
|
5
|
+
export declare const SearchInput: import("react").ForwardRefExoticComponent<Omit<SearchInputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -15,6 +15,9 @@ const AccessibleXMarkGlobal = () => jsx(XMark, {
|
|
|
15
15
|
role: "presentation",
|
|
16
16
|
width: "1.25rem"
|
|
17
17
|
});
|
|
18
|
+
// WARNING: this uncontrolled version of SearchInput is deprecated
|
|
19
|
+
// The logic of SearchInput will be replaced with the logic that is currently in SearchInput.Controlled.
|
|
20
|
+
// This is planned by EO Q1. For more information, please contact the Home Web Team.
|
|
18
21
|
const SearchInput = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
19
22
|
const {
|
|
20
23
|
children,
|
|
@@ -92,4 +95,4 @@ const SearchInput = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
92
95
|
});
|
|
93
96
|
});
|
|
94
97
|
|
|
95
|
-
export { SearchInput };
|
|
98
|
+
export { AccessibleXMark, AccessibleXMarkGlobal, SearchInput };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import { type IconButtonProps } from '../primitives/icon-button';
|
|
3
|
-
|
|
4
|
-
export type SearchInputProps = Modify<React.ComponentPropsWithRef<'input'>, {
|
|
3
|
+
export interface SearchInputProps extends Omit<React.ComponentPropsWithRef<'input'>, 'onChange' | 'onSubmit'> {
|
|
5
4
|
className?: string;
|
|
6
5
|
/**
|
|
7
6
|
* Default value for search input.
|
|
@@ -49,5 +48,5 @@ export type SearchInputProps = Modify<React.ComponentPropsWithRef<'input'>, {
|
|
|
49
48
|
* @default "in-context"
|
|
50
49
|
*/
|
|
51
50
|
variant?: 'in-context' | 'global';
|
|
52
|
-
}
|
|
51
|
+
}
|
|
53
52
|
export type SearchInputActionButtonProps = IconButtonProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/blueprint-web",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@box/storybook-utils": "^0.0.3"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "6dd474f7b770509844935c8eedd80bc2e61750bd",
|
|
60
60
|
"module": "lib-esm/index.js",
|
|
61
61
|
"main": "lib-esm/index.js",
|
|
62
62
|
"exports": {
|