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

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,11 @@
1
1
  # @khanacademy/wonder-blocks-search-field
2
2
 
3
+ ## 1.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - b3960766: Made SearchField not anonymous
8
+
3
9
  ## 1.0.3
4
10
 
5
11
  ### Patch Changes
package/dist/es/index.js CHANGED
@@ -15,7 +15,7 @@ const defaultLabels = {
15
15
  };
16
16
 
17
17
  const _excluded = ["clearAriaLabel", "disabled", "light", "id", "value", "placeholder", "style", "testId", "onClick", "onChange", "onFocus", "onBlur"];
18
- const SearchField = React.forwardRef((props, ref) => {
18
+ const SearchField = React.forwardRef(function SearchField(props, ref) {
19
19
  const {
20
20
  clearAriaLabel = defaultLabels.clearSearch,
21
21
  disabled = false,
package/dist/index.js CHANGED
@@ -2331,7 +2331,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
2331
2331
  * />
2332
2332
  * ```
2333
2333
  */
2334
- const SearchField = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["forwardRef"]((props, ref) => {
2334
+ const SearchField = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["forwardRef"](function SearchField(props, ref) {
2335
2335
  const {
2336
2336
  clearAriaLabel = _util_constants_js__WEBPACK_IMPORTED_MODULE_9__[/* defaultLabels */ "a"].clearSearch,
2337
2337
  disabled = false,
@@ -6443,18 +6443,19 @@ function (module, __webpack_exports__, __webpack_require__) {
6443
6443
  * 3. Keyup (spacebar/enter) -> focus state
6444
6444
  *
6445
6445
  * Warning: The event handlers returned (onClick, onMouseEnter, onMouseLeave,
6446
- * onMouseDown, onMouseUp, onDragStart, onTouchStart, onTouchEnd, onTouchCancel, onKeyDown,
6447
- * onKeyUp, onFocus, onBlur, tabIndex) should be passed on to the component
6448
- * that has the ClickableBehavior. You cannot override these handlers without
6449
- * potentially breaking the functionality of ClickableBehavior.
6446
+ * onMouseDown, onMouseUp, onDragStart, onTouchStart, onTouchEnd, onTouchCancel,
6447
+ * onKeyDown, onKeyUp, onFocus, onBlur, tabIndex) should be passed on to the
6448
+ * component that has the ClickableBehavior. You cannot override these handlers
6449
+ * without potentially breaking the functionality of ClickableBehavior.
6450
6450
  *
6451
- * There are internal props triggerOnEnter and triggerOnSpace that can be set
6452
- * to false if one of those keys shouldn't count as a click on this component.
6453
- * Be careful about setting those to false -- make certain that the component
6451
+ * There are internal props triggerOnEnter and triggerOnSpace that can be set to
6452
+ * false if one of those keys shouldn't count as a click on this component. Be
6453
+ * careful about setting those to false -- make certain that the component
6454
6454
  * shouldn't process that key.
6455
6455
  *
6456
- * See [this document](https://docs.google.com/document/d/1DG5Rg2f0cawIL5R8UqnPQpd7pbdObk8OyjO5ryYQmBM/edit#)
6457
- * for a more thorough explanation of expected behaviors and potential cavaets.
6456
+ * See [this
6457
+ document](https://docs.google.com/document/d/1DG5Rg2f0cawIL5R8UqnPQpd7pbdObk8OyjO5ryYQmBM/edit#)
6458
+ for a more thorough explanation of expected behaviors and potential cavaets.
6458
6459
  *
6459
6460
  * `ClickableBehavior` accepts a function as `children` which is passed state
6460
6461
  * and an object containing event handlers and some other props. The `children`
@@ -6462,32 +6463,30 @@ function (module, __webpack_exports__, __webpack_require__) {
6462
6463
  *
6463
6464
  * Example:
6464
6465
  *
6465
- * ```js
6466
- * class MyClickableComponent extends React.Component<Props> {
6467
- * render(): React.Node {
6468
- * const ClickableBehavior = getClickableBehavior();
6469
- * return <ClickableBehavior
6470
- * disabled={this.props.disabled}
6471
- * onClick={this.props.onClick}
6472
- * >
6473
- * {({hovered}, childrenProps) =>
6474
- * <RoundRect
6475
- * textcolor='white'
6476
- * backgroundColor={hovered ? 'red' : 'blue'}}
6477
- * {...childrenProps}
6478
- * >
6479
- * {this.props.children}
6480
- * </RoundRect>
6481
- * }
6482
- * </ClickableBehavior>
6483
- * }
6466
+ * ```jsx
6467
+ * function MyClickableComponent(props: Props) {
6468
+ * const ClickableBehavior = getClickableBehavior();
6469
+ *
6470
+ * return (
6471
+ * <ClickableBehavior disabled={props.disabled} onClick={props.onClick}>
6472
+ * {({hovered}, childrenProps) => (
6473
+ * <RoundRect
6474
+ * textcolor="white"
6475
+ * backgroundColor={hovered ? "red" : "blue"}
6476
+ * {...childrenProps}
6477
+ * >
6478
+ * {props.children}
6479
+ * </RoundRect>
6480
+ * )}
6481
+ * </ClickableBehavior>
6482
+ * );
6484
6483
  * }
6485
6484
  * ```
6486
6485
  *
6487
- * This follows a pattern called [Function as Child Components]
6488
- * (https://medium.com/merrickchristensen/function-as-child-components-5f3920a9ace9).
6486
+ * This follows a pattern called [Function as Child
6487
+ * Components](https://medium.com/merrickchristensen/function-as-child-components-5f3920a9ace9).
6489
6488
  *
6490
- * WARNING: Do not use this component directly, use getClickableBehavior
6489
+ * **WARNING:** Do not use this component directly, use getClickableBehavior
6491
6490
  * instead. getClickableBehavior takes three arguments (href, directtNav, and
6492
6491
  * router) and returns either the default ClickableBehavior or a react-router
6493
6492
  * aware version.
@@ -6495,9 +6494,9 @@ function (module, __webpack_exports__, __webpack_require__) {
6495
6494
  * The react-router aware version is returned if `router` is a react-router-dom
6496
6495
  * router, `skipClientNav` is not `true`, and `href` is an internal URL.
6497
6496
  *
6498
- * The `router` can be accessed via __RouterContext (imported from 'react-router')
6499
- * from a component rendered as a descendant of a BrowserRouter.
6500
- * See https://reacttraining.com/react-router/web/guides/basic-components.
6497
+ * The `router` can be accessed via __RouterContext (imported from
6498
+ 'react-router') from a component rendered as a descendant of a BrowserRouter.
6499
+ See https://reacttraining.com/react-router/web/guides/basic-components.
6501
6500
  */
6502
6501
 
6503
6502
  class ClickableBehavior extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
@@ -6864,100 +6863,6 @@ function (module, __webpack_exports__, __webpack_require__) {
6864
6863
  },
6865
6864
  /* 3 */
6866
6865
 
6867
- /***/
6868
- function (module, __webpack_exports__, __webpack_require__) {
6869
- "use strict";
6870
- /* harmony export (binding) */
6871
-
6872
- __webpack_require__.d(__webpack_exports__, "a", function () {
6873
- return getClickableBehavior;
6874
- });
6875
- /* harmony import */
6876
-
6877
-
6878
- var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
6879
- /* harmony import */
6880
-
6881
-
6882
- var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
6883
- /* harmony import */
6884
-
6885
-
6886
- var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
6887
- /* harmony import */
6888
-
6889
-
6890
- var react_router_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_1__);
6891
- /* harmony import */
6892
-
6893
-
6894
- var _components_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
6895
- /* harmony import */
6896
-
6897
-
6898
- var _is_client_side_url_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1);
6899
- /**
6900
- * Returns either the default ClickableBehavior or a react-router aware version.
6901
- *
6902
- * The react-router aware version is returned if `router` is a react-router-dom
6903
- * router, `skipClientNav` is not `true`, and `href` is an internal URL.
6904
- *
6905
- * The `router` can be accessed via __RouterContext (imported from 'react-router')
6906
- * from a component rendered as a descendant of a BrowserRouter.
6907
- * See https://reacttraining.com/react-router/web/guides/basic-components.
6908
- */
6909
-
6910
-
6911
- const ClickableBehaviorWithRouter = Object(react_router_dom__WEBPACK_IMPORTED_MODULE_1__["withRouter"])(_components_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_2__[
6912
- /* default */
6913
- "a"]);
6914
-
6915
- function getClickableBehavior(
6916
- /**
6917
- * The URL to navigate to.
6918
- */
6919
- href,
6920
- /**
6921
- * Should we skip using the react router and go to the page directly.
6922
- */
6923
- skipClientNav,
6924
- /**
6925
- * router object added to the React context object by react-router-dom.
6926
- */
6927
- router) {
6928
- if (router && skipClientNav !== true && href && Object(_is_client_side_url_js__WEBPACK_IMPORTED_MODULE_3__[
6929
- /* isClientSideUrl */
6930
- "a"])(href)) {
6931
- // We cast to `any` here since the type of ClickableBehaviorWithRouter
6932
- // is slightly different from the return type of this function.
6933
- // TODO(WB-1037): Always return the wrapped version once all routes have
6934
- // been ported to the app-shell in webapp.
6935
- return ClickableBehaviorWithRouter;
6936
- }
6937
-
6938
- return _components_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_2__[
6939
- /* default */
6940
- "a"];
6941
- }
6942
- /***/
6943
-
6944
- },
6945
- /* 4 */
6946
-
6947
- /***/
6948
- function (module, exports) {
6949
- module.exports = __webpack_require__(27);
6950
- /***/
6951
- },
6952
- /* 5 */
6953
-
6954
- /***/
6955
- function (module, exports) {
6956
- module.exports = __webpack_require__(8);
6957
- /***/
6958
- },
6959
- /* 6 */
6960
-
6961
6866
  /***/
6962
6867
  function (module, exports) {
6963
6868
  module.exports =
@@ -7413,6 +7318,100 @@ function (module, exports) {
7413
7318
  /***/
7414
7319
 
7415
7320
  },
7321
+ /* 4 */
7322
+
7323
+ /***/
7324
+ function (module, __webpack_exports__, __webpack_require__) {
7325
+ "use strict";
7326
+ /* harmony export (binding) */
7327
+
7328
+ __webpack_require__.d(__webpack_exports__, "a", function () {
7329
+ return getClickableBehavior;
7330
+ });
7331
+ /* harmony import */
7332
+
7333
+
7334
+ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
7335
+ /* harmony import */
7336
+
7337
+
7338
+ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
7339
+ /* harmony import */
7340
+
7341
+
7342
+ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
7343
+ /* harmony import */
7344
+
7345
+
7346
+ var react_router_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_1__);
7347
+ /* harmony import */
7348
+
7349
+
7350
+ var _components_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
7351
+ /* harmony import */
7352
+
7353
+
7354
+ var _is_client_side_url_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1);
7355
+ /**
7356
+ * Returns either the default ClickableBehavior or a react-router aware version.
7357
+ *
7358
+ * The react-router aware version is returned if `router` is a react-router-dom
7359
+ * router, `skipClientNav` is not `true`, and `href` is an internal URL.
7360
+ *
7361
+ * The `router` can be accessed via __RouterContext (imported from 'react-router')
7362
+ * from a component rendered as a descendant of a BrowserRouter.
7363
+ * See https://reacttraining.com/react-router/web/guides/basic-components.
7364
+ */
7365
+
7366
+
7367
+ const ClickableBehaviorWithRouter = Object(react_router_dom__WEBPACK_IMPORTED_MODULE_1__["withRouter"])(_components_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_2__[
7368
+ /* default */
7369
+ "a"]);
7370
+
7371
+ function getClickableBehavior(
7372
+ /**
7373
+ * The URL to navigate to.
7374
+ */
7375
+ href,
7376
+ /**
7377
+ * Should we skip using the react router and go to the page directly.
7378
+ */
7379
+ skipClientNav,
7380
+ /**
7381
+ * router object added to the React context object by react-router-dom.
7382
+ */
7383
+ router) {
7384
+ if (router && skipClientNav !== true && href && Object(_is_client_side_url_js__WEBPACK_IMPORTED_MODULE_3__[
7385
+ /* isClientSideUrl */
7386
+ "a"])(href)) {
7387
+ // We cast to `any` here since the type of ClickableBehaviorWithRouter
7388
+ // is slightly different from the return type of this function.
7389
+ // TODO(WB-1037): Always return the wrapped version once all routes have
7390
+ // been ported to the app-shell in webapp.
7391
+ return ClickableBehaviorWithRouter;
7392
+ }
7393
+
7394
+ return _components_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_2__[
7395
+ /* default */
7396
+ "a"];
7397
+ }
7398
+ /***/
7399
+
7400
+ },
7401
+ /* 5 */
7402
+
7403
+ /***/
7404
+ function (module, exports) {
7405
+ module.exports = __webpack_require__(27);
7406
+ /***/
7407
+ },
7408
+ /* 6 */
7409
+
7410
+ /***/
7411
+ function (module, exports) {
7412
+ module.exports = __webpack_require__(8);
7413
+ /***/
7414
+ },
7416
7415
  /* 7 */
7417
7416
 
7418
7417
  /***/
@@ -7442,7 +7441,7 @@ function (module, __webpack_exports__, __webpack_require__) {
7442
7441
  /* harmony import */
7443
7442
 
7444
7443
 
7445
- var react_router_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
7444
+ var react_router_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5);
7446
7445
  /* harmony import */
7447
7446
 
7448
7447
 
@@ -7458,7 +7457,7 @@ function (module, __webpack_exports__, __webpack_require__) {
7458
7457
  /* harmony import */
7459
7458
 
7460
7459
 
7461
- var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5);
7460
+ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6);
7462
7461
  /* harmony import */
7463
7462
 
7464
7463
 
@@ -7466,7 +7465,7 @@ function (module, __webpack_exports__, __webpack_require__) {
7466
7465
  /* harmony import */
7467
7466
 
7468
7467
 
7469
- var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6);
7468
+ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(3);
7470
7469
  /* harmony import */
7471
7470
 
7472
7471
 
@@ -7474,7 +7473,7 @@ function (module, __webpack_exports__, __webpack_require__) {
7474
7473
  /* harmony import */
7475
7474
 
7476
7475
 
7477
- var _util_get_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(3);
7476
+ var _util_get_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(4);
7478
7477
  /* harmony import */
7479
7478
 
7480
7479
 
@@ -7504,11 +7503,20 @@ function (module, __webpack_exports__, __webpack_require__) {
7504
7503
  /**
7505
7504
  * A component to turn any custom component into a clickable one.
7506
7505
  *
7507
- * Works by wrapping ClickableBehavior around the child element and styling the
7508
- * child appropriately and encapsulates routing logic which can be customized.
7509
- * Expects a function which returns an element as it's child.
7506
+ * Works by wrapping `ClickableBehavior` around the child element and styling
7507
+ * the child appropriately and encapsulates routing logic which can be
7508
+ * customized. Expects a function which returns an element as its child.
7509
+ *
7510
+ * Clickable allows your components to:
7511
+ *
7512
+ * - Handle mouse / touch / keyboard events
7513
+ * - Match the standard behavior of the given role
7514
+ * - Apply custom styles based on pressed / focused / hovered state
7515
+ * - Perform Client Side Navigation when href is passed and the component is a
7516
+ * descendent of a react-router Router.
7517
+ *
7518
+ * ### Usage
7510
7519
  *
7511
- * Example usage:
7512
7520
  * ```jsx
7513
7521
  * <Clickable onClick={() => alert("You clicked me!")}>
7514
7522
  * {({hovered, focused, pressed}) =>
@@ -7581,7 +7589,7 @@ function (module, __webpack_exports__, __webpack_require__) {
7581
7589
  /* default */
7582
7590
  "a"])(href, skipClientNav, router);
7583
7591
 
7584
- const getStyle = state => [styles.reset, styles.link, !hideDefaultFocusRing && state.focused && (light ? styles.focusedLight : styles.focused), style];
7592
+ const getStyle = state => [styles.reset, styles.link, !hideDefaultFocusRing && state.focused && (light ? styles.focusedLight : styles.focused), disabled && styles.disabled, style];
7585
7593
 
7586
7594
  if (beforeNav) {
7587
7595
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](ClickableBehavior, {
@@ -7659,10 +7667,22 @@ function (module, __webpack_exports__, __webpack_require__) {
7659
7667
  cursor: "pointer"
7660
7668
  },
7661
7669
  focused: {
7662
- outline: `solid 2px ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5___default.a.blue}`
7670
+ ":focus": {
7671
+ outline: `solid 2px ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5___default.a.blue}`
7672
+ }
7663
7673
  },
7664
7674
  focusedLight: {
7665
7675
  outline: `solid 2px ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5___default.a.white}`
7676
+ },
7677
+ disabled: {
7678
+ color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5___default.a.offBlack32,
7679
+ cursor: "not-allowed",
7680
+ ":focus": {
7681
+ outline: "none"
7682
+ },
7683
+ ":focus-visible": {
7684
+ outline: `solid 2px ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5___default.a.blue}`
7685
+ }
7666
7686
  }
7667
7687
  });
7668
7688
  /***/
@@ -7711,7 +7731,7 @@ function (module, __webpack_exports__, __webpack_require__) {
7711
7731
  /* harmony import */
7712
7732
 
7713
7733
 
7714
- var _util_get_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
7734
+ var _util_get_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
7715
7735
  /* harmony reexport (safe) */
7716
7736
 
7717
7737
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-search-field",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "design": "v1",
5
5
  "description": "Search Field components for Wonder Blocks.",
6
6
  "main": "dist/index.js",
@@ -108,7 +108,10 @@ type Props = {|
108
108
  * ```
109
109
  */
110
110
  const SearchField: React.AbstractComponent<Props, HTMLInputElement> =
111
- React.forwardRef<Props, HTMLInputElement>((props: Props, ref) => {
111
+ React.forwardRef<Props, HTMLInputElement>(function SearchField(
112
+ props: Props,
113
+ ref,
114
+ ) {
112
115
  const {
113
116
  clearAriaLabel = defaultLabels.clearSearch,
114
117
  disabled = false,