@khanacademy/wonder-blocks-search-field 1.0.2 → 1.0.3

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @khanacademy/wonder-blocks-search-field
2
2
 
3
+ ## 1.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - @khanacademy/wonder-blocks-core@4.3.1
8
+ - @khanacademy/wonder-blocks-icon@1.2.27
9
+ - @khanacademy/wonder-blocks-icon-button@3.4.6
10
+ - @khanacademy/wonder-blocks-typography@1.1.31
11
+
3
12
  ## 1.0.2
4
13
 
5
14
  ### Patch Changes
package/dist/es/index.js CHANGED
@@ -10,35 +10,12 @@ import Icon, { icons } from '@khanacademy/wonder-blocks-icon';
10
10
  import Color from '@khanacademy/wonder-blocks-color';
11
11
  import Spacing from '@khanacademy/wonder-blocks-spacing';
12
12
 
13
- // The default labels that will be used by different components
14
13
  const defaultLabels = {
15
14
  clearSearch: "Clear search"
16
15
  };
17
16
 
18
17
  const _excluded = ["clearAriaLabel", "disabled", "light", "id", "value", "placeholder", "style", "testId", "onClick", "onChange", "onFocus", "onBlur"];
19
-
20
- /**
21
- * Search Field. A TextField with a search icon on its left side
22
- * and an X icon on its right side.
23
- *
24
- * ### Usage
25
- * ```jsx
26
- * import {SearchField} from "@khanacademy/wonder-blocks-search-field";
27
- *
28
- * const [value, setValue] = React.useState("");
29
- *
30
- * const handleChange = (newValue: string) => {
31
- * setValue(newValue);
32
- * };
33
- *
34
- * <SearchField
35
- * id="some-id"
36
- * value={value}
37
- * onChange={handleChange}
38
- * />
39
- * ```
40
- */
41
- const SearchField = /*#__PURE__*/React.forwardRef((props, ref) => {
18
+ const SearchField = React.forwardRef((props, ref) => {
42
19
  const {
43
20
  clearAriaLabel = defaultLabels.clearSearch,
44
21
  disabled = false,
@@ -53,20 +30,14 @@ const SearchField = /*#__PURE__*/React.forwardRef((props, ref) => {
53
30
  onFocus,
54
31
  onBlur
55
32
  } = props,
56
- otherProps = _objectWithoutPropertiesLoose(props, _excluded); // We can't just use ref.current to clear the input because ref isn't
57
- // always being passed in, so we use an innerRef to allow the
58
- // handleClear() function to focus on the input element ref.
59
-
33
+ otherProps = _objectWithoutPropertiesLoose(props, _excluded);
60
34
 
61
35
  const innerRef = React.useRef(null);
62
36
 
63
37
  const handleClear = () => {
64
38
  var _innerRef$current;
65
39
 
66
- // Empty the search text.
67
- onChange(""); // Focus back on the text field since the clear button disappears after
68
- // the field is cleared.
69
-
40
+ onChange("");
70
41
  innerRef == null ? void 0 : (_innerRef$current = innerRef.current) == null ? void 0 : _innerRef$current.focus();
71
42
  };
72
43
 
@@ -75,7 +46,7 @@ const SearchField = /*#__PURE__*/React.forwardRef((props, ref) => {
75
46
  return null;
76
47
  }
77
48
 
78
- return /*#__PURE__*/React.createElement(IconButton, {
49
+ return React.createElement(IconButton, {
79
50
  icon: icons.dismiss,
80
51
  kind: "tertiary",
81
52
  onClick: handleClear,
@@ -84,19 +55,19 @@ const SearchField = /*#__PURE__*/React.forwardRef((props, ref) => {
84
55
  });
85
56
  };
86
57
 
87
- return /*#__PURE__*/React.createElement(IDProvider, {
58
+ return React.createElement(IDProvider, {
88
59
  id: id,
89
60
  scope: "search-field"
90
- }, uniqueId => /*#__PURE__*/React.createElement(View, {
61
+ }, uniqueId => React.createElement(View, {
91
62
  onClick: onClick,
92
63
  style: [styles.inputContainer, style]
93
- }, /*#__PURE__*/React.createElement(Icon, {
64
+ }, React.createElement(Icon, {
94
65
  icon: icons.search,
95
66
  size: "medium",
96
67
  color: Color.offBlack64,
97
68
  style: styles.searchIcon,
98
69
  "aria-hidden": "true"
99
- }), /*#__PURE__*/React.createElement(TextField, _extends({
70
+ }), React.createElement(TextField, _extends({
100
71
  id: `${uniqueId}-field`,
101
72
  type: "text",
102
73
  disabled: disabled,
@@ -106,10 +77,7 @@ const SearchField = /*#__PURE__*/React.forwardRef((props, ref) => {
106
77
  onBlur: onBlur,
107
78
  placeholder: placeholder,
108
79
  ref: node => {
109
- // We have to set the value of both refs to
110
- // the HTMLInputElement from TextField.
111
80
  if (ref) {
112
- // $FlowIgnore[prop-missing]
113
81
  ref.current = node;
114
82
  }
115
83
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-search-field",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "design": "v1",
5
5
  "description": "Search Field components for Wonder Blocks.",
6
6
  "main": "dist/index.js",
@@ -17,17 +17,17 @@
17
17
  "dependencies": {
18
18
  "@babel/runtime": "^7.16.3",
19
19
  "@khanacademy/wonder-blocks-color": "^1.1.20",
20
- "@khanacademy/wonder-blocks-core": "^4.3.0",
21
- "@khanacademy/wonder-blocks-icon": "^1.2.26",
22
- "@khanacademy/wonder-blocks-icon-button": "^3.4.5",
20
+ "@khanacademy/wonder-blocks-core": "^4.3.1",
21
+ "@khanacademy/wonder-blocks-icon": "^1.2.27",
22
+ "@khanacademy/wonder-blocks-icon-button": "^3.4.6",
23
23
  "@khanacademy/wonder-blocks-spacing": "^3.0.5",
24
- "@khanacademy/wonder-blocks-typography": "^1.1.30"
24
+ "@khanacademy/wonder-blocks-typography": "^1.1.31"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "aphrodite": "^1.2.5",
28
28
  "react": "16.14.0"
29
29
  },
30
30
  "devDependencies": {
31
- "wb-dev-build-settings": "^0.3.0"
31
+ "wb-dev-build-settings": "^0.4.0"
32
32
  }
33
33
  }