@khanacademy/wonder-blocks-popover 5.1.0 → 5.2.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 CHANGED
@@ -1,5 +1,44 @@
1
1
  # @khanacademy/wonder-blocks-popover
2
2
 
3
+ ## 5.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - a42d9f3: PopoverContent: Add `iconAlt` prop so alt text can be set on the icon
8
+
9
+ ### Patch Changes
10
+
11
+ - fff5da0: Migrate to semanticColor tokens
12
+ - Updated dependencies [ed26d66]
13
+ - Updated dependencies [5655b9f]
14
+ - Updated dependencies [5655b9f]
15
+ - Updated dependencies [8f53293]
16
+ - Updated dependencies [fff5da0]
17
+ - Updated dependencies [6d37702]
18
+ - Updated dependencies [051f0f8]
19
+ - Updated dependencies [e1b78db]
20
+ - Updated dependencies [8f53293]
21
+ - Updated dependencies [051f0f8]
22
+ - @khanacademy/wonder-blocks-core@12.2.0
23
+ - @khanacademy/wonder-blocks-tokens@5.0.0
24
+ - @khanacademy/wonder-blocks-icon-button@6.1.2
25
+ - @khanacademy/wonder-blocks-modal@7.1.2
26
+ - @khanacademy/wonder-blocks-tooltip@4.1.2
27
+ - @khanacademy/wonder-blocks-typography@3.1.2
28
+
29
+ ## 5.1.1
30
+
31
+ ### Patch Changes
32
+
33
+ - ee8d95a: Rollback rollup version from v4 to v2 to prevent an issue with CJS builds in unit tests
34
+ - Updated dependencies [ee8d95a]
35
+ - @khanacademy/wonder-blocks-core@12.1.1
36
+ - @khanacademy/wonder-blocks-icon-button@6.1.1
37
+ - @khanacademy/wonder-blocks-modal@7.1.1
38
+ - @khanacademy/wonder-blocks-tokens@4.2.1
39
+ - @khanacademy/wonder-blocks-tooltip@4.1.1
40
+ - @khanacademy/wonder-blocks-typography@3.1.1
41
+
3
42
  ## 5.1.0
4
43
 
5
44
  ### Minor Changes
@@ -50,6 +50,11 @@ type Props = (CommonProps & {
50
50
  * same time with image.
51
51
  */
52
52
  icon?: string | React.ReactElement<React.ComponentProps<"img">> | React.ReactElement<React.ComponentProps<"svg">>;
53
+ /**
54
+ * Alt text for the icon. This prop is only used if the `icon` prop
55
+ * is passed a url (instead of a svg or img element).
56
+ */
57
+ iconAlt?: string;
53
58
  /**
54
59
  * Decorate the popover with a full-bleed illustration. It cannot be used at
55
60
  * the same time with icon.
@@ -64,6 +69,7 @@ type Props = (CommonProps & {
64
69
  */
65
70
  emphasized?: boolean;
66
71
  icon?: never;
72
+ iconAlt?: never;
67
73
  image?: never;
68
74
  });
69
75
  type DefaultProps = {
package/dist/es/index.js CHANGED
@@ -5,7 +5,7 @@ import { View, Id, addStyle } from '@khanacademy/wonder-blocks-core';
5
5
  import { TooltipTail, TooltipPopper } from '@khanacademy/wonder-blocks-tooltip';
6
6
  import { maybeGetPortalMountedModalHostElement } from '@khanacademy/wonder-blocks-modal';
7
7
  import { StyleSheet } from 'aphrodite';
8
- import { spacing, color } from '@khanacademy/wonder-blocks-tokens';
8
+ import { spacing, semanticColor, color } from '@khanacademy/wonder-blocks-tokens';
9
9
  import { HeadingSmall, Body } from '@khanacademy/wonder-blocks-typography';
10
10
  import xIcon from '@phosphor-icons/core/regular/x.svg';
11
11
  import IconButton from '@khanacademy/wonder-blocks-icon-button';
@@ -145,7 +145,7 @@ class PopoverEventListener extends React.Component {
145
145
  });
146
146
  return;
147
147
  }
148
- const node = ReactDOM.findDOMNode((_this$props$contentRe = this.props.contentRef) == null ? undefined : _this$props$contentRe.current);
148
+ const node = ReactDOM.findDOMNode((_this$props$contentRe = this.props.contentRef) == null ? void 0 : _this$props$contentRe.current);
149
149
  if (node && !node.contains(e.target)) {
150
150
  e.preventDefault();
151
151
  e.stopPropagation();
@@ -211,8 +211,8 @@ class InitialFocus extends React.Component {
211
211
  class FocusManager extends React.Component {
212
212
  constructor(...args) {
213
213
  super(...args);
214
- this.nextElementAfterPopover = undefined;
215
- this.rootNode = undefined;
214
+ this.nextElementAfterPopover = void 0;
215
+ this.rootNode = void 0;
216
216
  this.elementsThatCanBeFocusableInsidePopover = [];
217
217
  this.firstFocusableElementInPopover = null;
218
218
  this.lastFocusableElementInPopover = null;
@@ -355,20 +355,21 @@ class FocusManager extends React.Component {
355
355
  const {
356
356
  children
357
357
  } = this.props;
358
- return React.createElement("div", {
359
- ref: this.getComponentRootNode,
360
- onClick: () => {
361
- this.changeFocusabilityInsidePopover(true);
362
- },
363
- onFocus: () => {
364
- this.changeFocusabilityInsidePopover(true);
365
- },
366
- onBlur: () => {
367
- this.changeFocusabilityInsidePopover(false);
368
- }
369
- }, React.createElement(InitialFocus, {
370
- initialFocusId: this.props.initialFocusId
371
- }, children));
358
+ return (React.createElement("div", {
359
+ ref: this.getComponentRootNode,
360
+ onClick: () => {
361
+ this.changeFocusabilityInsidePopover(true);
362
+ },
363
+ onFocus: () => {
364
+ this.changeFocusabilityInsidePopover(true);
365
+ },
366
+ onBlur: () => {
367
+ this.changeFocusabilityInsidePopover(false);
368
+ }
369
+ }, React.createElement(InitialFocus, {
370
+ initialFocusId: this.props.initialFocusId
371
+ }, children))
372
+ );
372
373
  }
373
374
  }
374
375
 
@@ -596,8 +597,8 @@ PopoverContentCore.defaultProps = {
596
597
  const styles$1 = StyleSheet.create({
597
598
  content: {
598
599
  borderRadius: spacing.xxxSmall_4,
599
- border: `solid 1px ${color.offBlack16}`,
600
- backgroundColor: color.white,
600
+ border: `solid 1px ${semanticColor.border.primary}`,
601
+ backgroundColor: semanticColor.surface.primary,
601
602
  boxShadow: `0 ${spacing.xSmall_8}px ${spacing.xSmall_8}px 0 ${color.offBlack8}`,
602
603
  margin: 0,
603
604
  maxWidth: spacing.medium_16 * 18,
@@ -606,12 +607,12 @@ const styles$1 = StyleSheet.create({
606
607
  justifyContent: "center"
607
608
  },
608
609
  blue: {
609
- backgroundColor: color.blue,
610
- color: color.white
610
+ backgroundColor: semanticColor.surface.emphasis,
611
+ color: semanticColor.text.inverse
611
612
  },
612
613
  darkBlue: {
613
- backgroundColor: color.darkBlue,
614
- color: color.white
614
+ backgroundColor: semanticColor.surface.inverse,
615
+ color: semanticColor.text.inverse
615
616
  },
616
617
  closeButton: {
617
618
  margin: 0,
@@ -641,7 +642,8 @@ class PopoverContent extends React.Component {
641
642
  };
642
643
  this.maybeRenderIcon = () => {
643
644
  const {
644
- icon
645
+ icon,
646
+ iconAlt
645
647
  } = this.props;
646
648
  if (!icon) {
647
649
  return null;
@@ -650,7 +652,8 @@ class PopoverContent extends React.Component {
650
652
  style: styles.iconContainer
651
653
  }, typeof icon !== "string" ? icon : React.createElement(StyledImg, {
652
654
  src: icon,
653
- style: styles.icon
655
+ style: styles.icon,
656
+ alt: iconAlt || ""
654
657
  }));
655
658
  };
656
659
  this.maybeRenderActions = close => {
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var _extends = require('@babel/runtime/helpers/extends');
4
6
  var React = require('react');
5
7
  var ReactDOM = require('react-dom');
@@ -12,7 +14,10 @@ var wonderBlocksTypography = require('@khanacademy/wonder-blocks-typography');
12
14
  var xIcon = require('@phosphor-icons/core/regular/x.svg');
13
15
  var IconButton = require('@khanacademy/wonder-blocks-icon-button');
14
16
 
15
- function _interopNamespaceDefault(e) {
17
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
+
19
+ function _interopNamespace(e) {
20
+ if (e && e.__esModule) return e;
16
21
  var n = Object.create(null);
17
22
  if (e) {
18
23
  Object.keys(e).forEach(function (k) {
@@ -25,12 +30,15 @@ function _interopNamespaceDefault(e) {
25
30
  }
26
31
  });
27
32
  }
28
- n.default = e;
33
+ n["default"] = e;
29
34
  return Object.freeze(n);
30
35
  }
31
36
 
32
- var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
33
- var ReactDOM__namespace = /*#__PURE__*/_interopNamespaceDefault(ReactDOM);
37
+ var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
38
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
39
+ var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
40
+ var xIcon__default = /*#__PURE__*/_interopDefaultLegacy(xIcon);
41
+ var IconButton__default = /*#__PURE__*/_interopDefaultLegacy(IconButton);
34
42
 
35
43
  const defaultContext = {
36
44
  close: undefined,
@@ -65,7 +73,7 @@ class PopoverAnchor extends React__namespace.Component {
65
73
  });
66
74
  return React__namespace.cloneElement(renderedChildren, sharedProps);
67
75
  } else {
68
- return React__namespace.cloneElement(children, _extends({}, children.props, sharedProps, {
76
+ return React__namespace.cloneElement(children, _extends__default["default"]({}, children.props, sharedProps, {
69
77
  onClick: children.props.onClick ? e => {
70
78
  e.stopPropagation();
71
79
  children.props.onClick();
@@ -167,7 +175,7 @@ class PopoverEventListener extends React__namespace.Component {
167
175
  });
168
176
  return;
169
177
  }
170
- const node = ReactDOM__namespace.findDOMNode((_this$props$contentRe = this.props.contentRef) == null ? undefined : _this$props$contentRe.current);
178
+ const node = ReactDOM__namespace.findDOMNode((_this$props$contentRe = this.props.contentRef) == null ? void 0 : _this$props$contentRe.current);
171
179
  if (node && !node.contains(e.target)) {
172
180
  e.preventDefault();
173
181
  e.stopPropagation();
@@ -233,8 +241,8 @@ class InitialFocus extends React__namespace.Component {
233
241
  class FocusManager extends React__namespace.Component {
234
242
  constructor(...args) {
235
243
  super(...args);
236
- this.nextElementAfterPopover = undefined;
237
- this.rootNode = undefined;
244
+ this.nextElementAfterPopover = void 0;
245
+ this.rootNode = void 0;
238
246
  this.elementsThatCanBeFocusableInsidePopover = [];
239
247
  this.firstFocusableElementInPopover = null;
240
248
  this.lastFocusableElementInPopover = null;
@@ -377,20 +385,21 @@ class FocusManager extends React__namespace.Component {
377
385
  const {
378
386
  children
379
387
  } = this.props;
380
- return React__namespace.createElement("div", {
381
- ref: this.getComponentRootNode,
382
- onClick: () => {
383
- this.changeFocusabilityInsidePopover(true);
384
- },
385
- onFocus: () => {
386
- this.changeFocusabilityInsidePopover(true);
387
- },
388
- onBlur: () => {
389
- this.changeFocusabilityInsidePopover(false);
390
- }
391
- }, React__namespace.createElement(InitialFocus, {
392
- initialFocusId: this.props.initialFocusId
393
- }, children));
388
+ return (React__namespace.createElement("div", {
389
+ ref: this.getComponentRootNode,
390
+ onClick: () => {
391
+ this.changeFocusabilityInsidePopover(true);
392
+ },
393
+ onFocus: () => {
394
+ this.changeFocusabilityInsidePopover(true);
395
+ },
396
+ onBlur: () => {
397
+ this.changeFocusabilityInsidePopover(false);
398
+ }
399
+ }, React__namespace.createElement(InitialFocus, {
400
+ initialFocusId: this.props.initialFocusId
401
+ }, children))
402
+ );
394
403
  }
395
404
  }
396
405
 
@@ -484,7 +493,7 @@ class Popover extends React__namespace.Component {
484
493
  placement: placement,
485
494
  rootBoundary: rootBoundary,
486
495
  viewportPadding: viewportPadding
487
- }, props => React__namespace.createElement(PopoverDialog, _extends({}, props, {
496
+ }, props => React__namespace.createElement(PopoverDialog, _extends__default["default"]({}, props, {
488
497
  "aria-label": ariaLabel,
489
498
  "aria-describedby": describedBy,
490
499
  "aria-labelledby": ariaLabelledBy,
@@ -569,8 +578,8 @@ class CloseButton extends React__namespace.Component {
569
578
  return React__namespace.createElement(PopoverContext.Consumer, null, ({
570
579
  close
571
580
  }) => {
572
- return React__namespace.createElement(IconButton, {
573
- icon: xIcon,
581
+ return React__namespace.createElement(IconButton__default["default"], {
582
+ icon: xIcon__default["default"],
574
583
  "aria-label": ariaLabel,
575
584
  onClick: close,
576
585
  kind: light ? "primary" : "tertiary",
@@ -618,8 +627,8 @@ PopoverContentCore.defaultProps = {
618
627
  const styles$1 = aphrodite.StyleSheet.create({
619
628
  content: {
620
629
  borderRadius: wonderBlocksTokens.spacing.xxxSmall_4,
621
- border: `solid 1px ${wonderBlocksTokens.color.offBlack16}`,
622
- backgroundColor: wonderBlocksTokens.color.white,
630
+ border: `solid 1px ${wonderBlocksTokens.semanticColor.border.primary}`,
631
+ backgroundColor: wonderBlocksTokens.semanticColor.surface.primary,
623
632
  boxShadow: `0 ${wonderBlocksTokens.spacing.xSmall_8}px ${wonderBlocksTokens.spacing.xSmall_8}px 0 ${wonderBlocksTokens.color.offBlack8}`,
624
633
  margin: 0,
625
634
  maxWidth: wonderBlocksTokens.spacing.medium_16 * 18,
@@ -628,12 +637,12 @@ const styles$1 = aphrodite.StyleSheet.create({
628
637
  justifyContent: "center"
629
638
  },
630
639
  blue: {
631
- backgroundColor: wonderBlocksTokens.color.blue,
632
- color: wonderBlocksTokens.color.white
640
+ backgroundColor: wonderBlocksTokens.semanticColor.surface.emphasis,
641
+ color: wonderBlocksTokens.semanticColor.text.inverse
633
642
  },
634
643
  darkBlue: {
635
- backgroundColor: wonderBlocksTokens.color.darkBlue,
636
- color: wonderBlocksTokens.color.white
644
+ backgroundColor: wonderBlocksTokens.semanticColor.surface.inverse,
645
+ color: wonderBlocksTokens.semanticColor.text.inverse
637
646
  },
638
647
  closeButton: {
639
648
  margin: 0,
@@ -663,7 +672,8 @@ class PopoverContent extends React__namespace.Component {
663
672
  };
664
673
  this.maybeRenderIcon = () => {
665
674
  const {
666
- icon
675
+ icon,
676
+ iconAlt
667
677
  } = this.props;
668
678
  if (!icon) {
669
679
  return null;
@@ -672,7 +682,8 @@ class PopoverContent extends React__namespace.Component {
672
682
  style: styles.iconContainer
673
683
  }, typeof icon !== "string" ? icon : React__namespace.createElement(StyledImg, {
674
684
  src: icon,
675
- style: styles.icon
685
+ style: styles.icon,
686
+ alt: iconAlt || ""
676
687
  }));
677
688
  };
678
689
  this.maybeRenderActions = close => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-popover",
3
- "version": "5.1.0",
3
+ "version": "5.2.0",
4
4
  "design": "v1",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -13,12 +13,12 @@
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
15
  "@babel/runtime": "^7.24.5",
16
- "@khanacademy/wonder-blocks-core": "12.1.0",
17
- "@khanacademy/wonder-blocks-icon-button": "6.1.0",
18
- "@khanacademy/wonder-blocks-modal": "7.1.0",
19
- "@khanacademy/wonder-blocks-tokens": "4.2.0",
20
- "@khanacademy/wonder-blocks-tooltip": "4.1.0",
21
- "@khanacademy/wonder-blocks-typography": "3.1.0"
16
+ "@khanacademy/wonder-blocks-core": "12.2.0",
17
+ "@khanacademy/wonder-blocks-icon-button": "6.1.2",
18
+ "@khanacademy/wonder-blocks-modal": "7.1.2",
19
+ "@khanacademy/wonder-blocks-tokens": "5.0.0",
20
+ "@khanacademy/wonder-blocks-tooltip": "4.1.2",
21
+ "@khanacademy/wonder-blocks-typography": "3.1.2"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "@phosphor-icons/core": "^2.0.2",
@@ -29,7 +29,7 @@
29
29
  "react-popper": "^2.0.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@khanacademy/wb-dev-build-settings": "2.1.0"
32
+ "@khanacademy/wb-dev-build-settings": "2.1.1"
33
33
  },
34
34
  "scripts": {
35
35
  "test": "echo \"Error: no test specified\" && exit 1"