@box/blueprint-web 12.94.0 → 12.95.1

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.
@@ -1,5 +1,6 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { Search } from '@box/blueprint-web-assets/icons/Fill';
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { Search as Search$1 } from '@box/blueprint-web-assets/icons/Fill';
3
+ import { Search } from '@box/blueprint-web-assets/icons/Medium';
3
4
  import { IconCtaIcon, IconIconOnLightSecondary } from '@box/blueprint-web-assets/tokens/tokens';
4
5
  import clsx from 'clsx';
5
6
  import { forwardRef, Children, useMemo, cloneElement } from 'react';
@@ -69,17 +70,22 @@ const SearchInputControlled = /*#__PURE__*/forwardRef((props, forwardedRef) => {
69
70
  'aria-label': searchInputClearAriaLabel,
70
71
  className: clsx(styles.clearSearchIcon, isGlobal && styles.global, isGlobal && !showActionButton && styles.withoutActionButton),
71
72
  color: IconCtaIcon,
72
- icon: isGlobal ? AccessibleXMarkGlobal : AccessibleXMark,
73
+ icon: isGlobal ? () => jsx(AccessibleXMarkGlobal, {
74
+ enableModernizedComponents: enableModernizedComponents
75
+ }) : () => jsx(AccessibleXMark, {
76
+ enableModernizedComponents: enableModernizedComponents
77
+ }),
73
78
  onClick: onClearInput,
74
79
  size: 'x-small'
75
- }), [isGlobal, onClearInput, searchInputClearAriaLabel, showActionButton]);
80
+ }), [isGlobal, onClearInput, searchInputClearAriaLabel, showActionButton, enableModernizedComponents]);
76
81
  const CustomStartIconComponent = useMemo(() => startIcon && /*#__PURE__*/cloneElement(startIcon, {
77
82
  className: clsx(startIcon.props?.className, styles.searchIcon, isGlobal && styles.global)
78
83
  }), [startIcon, isGlobal]);
84
+ const Search$2 = useMemo(() => enableModernizedComponents ? Search : Search$1, [enableModernizedComponents]);
79
85
  return jsxs("div", {
80
86
  className: clsx(styles.search, disabled && styles.disabled, className),
81
87
  "data-modern": enableModernizedComponents ? 'true' : 'false',
82
- children: [startIcon ? CustomStartIconComponent : jsx(Search, {
88
+ children: [startIcon ? CustomStartIconComponent : jsx(Search$2, {
83
89
  "aria-hidden": "true",
84
90
  className: clsx(styles.searchIcon, isGlobal && styles.global),
85
91
  color: IconIconOnLightSecondary
@@ -1,6 +1,10 @@
1
1
  import { type SearchInputProps } from './types';
2
- export declare const AccessibleXMark: () => import("react/jsx-runtime").JSX.Element;
3
- export declare const AccessibleXMarkGlobal: () => import("react/jsx-runtime").JSX.Element;
2
+ export declare const AccessibleXMark: ({ enableModernizedComponents }: {
3
+ enableModernizedComponents: boolean;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const AccessibleXMarkGlobal: ({ enableModernizedComponents }: {
6
+ enableModernizedComponents: boolean;
7
+ }) => import("react/jsx-runtime").JSX.Element;
4
8
  /**
5
9
  * @deprecated This uncontrolled version of SearchInput is deprecated.
6
10
  * Currently, we have two SearchInput components: SearchInput and SearchInput.Controlled. In the future, both will be deprecated and replaced
@@ -1,5 +1,6 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { Search, XMark } from '@box/blueprint-web-assets/icons/Fill';
2
+ import { Search as Search$1, XMark as XMark$1 } from '@box/blueprint-web-assets/icons/Fill';
3
+ import { Search, XMark } from '@box/blueprint-web-assets/icons/Medium';
3
4
  import { IconIconOnLightSecondary, IconCtaIcon } from '@box/blueprint-web-assets/tokens/tokens';
4
5
  import clsx from 'clsx';
5
6
  import { forwardRef, useState, useCallback, Children } from 'react';
@@ -8,14 +9,54 @@ import { IconButton } from '../primitives/icon-button/icon-button.js';
8
9
  import { switchCase } from '../utils/switchCase.js';
9
10
  import styles from './search.module.js';
10
11
 
11
- const AccessibleXMark = () => jsx(XMark, {
12
- role: "presentation"
13
- });
14
- const AccessibleXMarkGlobal = () => jsx(XMark, {
15
- height: "1.25rem",
16
- role: "presentation",
17
- width: "1.25rem"
18
- });
12
+ const AccessibleXMark = ({
13
+ enableModernizedComponents
14
+ }) => {
15
+ const XMark$2 = enableModernizedComponents ? XMark : XMark$1;
16
+ return jsx(XMark$2, {
17
+ role: "presentation"
18
+ });
19
+ };
20
+ const AccessibleXMarkGlobal = ({
21
+ enableModernizedComponents
22
+ }) => {
23
+ const XMark$2 = enableModernizedComponents ? XMark : XMark$1;
24
+ return jsx(XMark$2, {
25
+ height: "1.25rem",
26
+ role: "presentation",
27
+ width: "1.25rem"
28
+ });
29
+ };
30
+ const getClearIcon = (isGlobal, enableModernizedComponents) => {
31
+ if (isGlobal) {
32
+ return () => jsx(AccessibleXMarkGlobal, {
33
+ enableModernizedComponents: enableModernizedComponents
34
+ });
35
+ }
36
+ return () => jsx(AccessibleXMark, {
37
+ enableModernizedComponents: enableModernizedComponents
38
+ });
39
+ };
40
+ const handleEnterKey = (event, searchValue, onSubmit) => {
41
+ event.preventDefault();
42
+ if (event.nativeEvent.isComposing) {
43
+ return;
44
+ }
45
+ onSubmit?.(searchValue);
46
+ };
47
+ const handleEscapeKey = (event, clearValue) => {
48
+ event.preventDefault();
49
+ clearValue();
50
+ };
51
+ const getInputClassNames = (isGlobal, showActionButton) => {
52
+ return clsx(styles.searchInput, isGlobal && styles.global, {
53
+ [styles.withoutActionButton]: isGlobal && !showActionButton,
54
+ [styles.withActionButton]: isGlobal && showActionButton
55
+ });
56
+ };
57
+ const getClearButtonClassNames = (isGlobal, showActionButton) => {
58
+ return clsx(styles.clearSearchIcon, isGlobal && styles.global, isGlobal && !showActionButton && styles.withoutActionButton);
59
+ };
19
60
  /**
20
61
  * @deprecated This uncontrolled version of SearchInput is deprecated.
21
62
  * Currently, we have two SearchInput components: SearchInput and SearchInput.Controlled. In the future, both will be deprecated and replaced
@@ -56,26 +97,19 @@ const SearchInput = /*#__PURE__*/forwardRef((props, forwardedRef) => {
56
97
  return;
57
98
  }
58
99
  switchCase({
59
- Enter: () => {
60
- e.preventDefault();
61
- if (e.nativeEvent.isComposing) {
62
- return;
63
- } // prevents submitting when using Japanese IME
64
- onSubmit?.(searchInputValue);
65
- },
66
- Escape: () => {
67
- e.preventDefault();
68
- updateSearchValue('');
69
- }
100
+ Enter: () => handleEnterKey(e, searchInputValue, onSubmit),
101
+ Escape: () => handleEscapeKey(e, () => updateSearchValue(''))
70
102
  })(e.key)?.();
71
103
  onKeyDown?.(e);
72
104
  };
73
105
  const isGlobal = variant === 'global';
74
106
  const showActionButton = Children.count(children) > 0;
107
+ const Search$2 = enableModernizedComponents ? Search : Search$1;
108
+ const ClearIcon = useCallback(() => getClearIcon(isGlobal, enableModernizedComponents)(), [isGlobal, enableModernizedComponents]);
75
109
  return jsxs("div", {
76
110
  className: clsx(styles.search, disabled && styles.disabled, className),
77
111
  "data-modern": enableModernizedComponents ? 'true' : 'false',
78
- children: [jsx(Search, {
112
+ children: [jsx(Search$2, {
79
113
  "aria-hidden": "true",
80
114
  className: clsx(styles.searchIcon, isGlobal && styles.global),
81
115
  color: IconIconOnLightSecondary
@@ -83,10 +117,7 @@ const SearchInput = /*#__PURE__*/forwardRef((props, forwardedRef) => {
83
117
  ...rest,
84
118
  ref: forwardedRef,
85
119
  "aria-label": searchInputAriaLabel,
86
- className: clsx(styles.searchInput, isGlobal && styles.global, {
87
- [styles.withoutActionButton]: isGlobal && !showActionButton,
88
- [styles.withActionButton]: isGlobal && showActionButton
89
- }),
120
+ className: getInputClassNames(isGlobal, showActionButton),
90
121
  disabled: disabled,
91
122
  onChange: onSearchInputChanged,
92
123
  onKeyDown: onSearchInputKeyDown,
@@ -96,9 +127,9 @@ const SearchInput = /*#__PURE__*/forwardRef((props, forwardedRef) => {
96
127
  value: searchInputValue
97
128
  }), !!searchInputValue && jsx(IconButton, {
98
129
  "aria-label": searchInputClearAriaLabel,
99
- className: clsx(styles.clearSearchIcon, isGlobal && styles.global, isGlobal && !showActionButton && styles.withoutActionButton),
130
+ className: getClearButtonClassNames(isGlobal, showActionButton),
100
131
  color: IconCtaIcon,
101
- icon: isGlobal ? AccessibleXMarkGlobal : AccessibleXMark,
132
+ icon: ClearIcon,
102
133
  onClick: onClearInputButtonClicked,
103
134
  size: "x-small"
104
135
  }), isGlobal && showActionButton && children]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/blueprint-web",
3
- "version": "12.94.0",
3
+ "version": "12.95.1",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "publishConfig": {
@@ -47,7 +47,7 @@
47
47
  "dependencies": {
48
48
  "@ariakit/react": "0.4.15",
49
49
  "@ariakit/react-core": "0.4.15",
50
- "@box/blueprint-web-assets": "^4.79.0",
50
+ "@box/blueprint-web-assets": "^4.80.0",
51
51
  "@internationalized/date": "^3.7.0",
52
52
  "@radix-ui/react-accordion": "1.1.2",
53
53
  "@radix-ui/react-checkbox": "1.0.4",
@@ -77,7 +77,7 @@
77
77
  "type-fest": "^3.2.0"
78
78
  },
79
79
  "devDependencies": {
80
- "@box/storybook-utils": "^0.14.16",
80
+ "@box/storybook-utils": "^0.14.17",
81
81
  "@types/react": "^18.0.0",
82
82
  "@types/react-dom": "^18.0.0",
83
83
  "react": "^18.3.0",