@khanacademy/perseus 48.2.0 → 49.0.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/dist/es/index.js CHANGED
@@ -44,13 +44,21 @@ import cornersOutIcon from '@phosphor-icons/core/regular/corners-out.svg';
44
44
  import Link from '@khanacademy/wonder-blocks-link';
45
45
 
46
46
  function _extends() {
47
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
48
- for (var e = 1; e < arguments.length; e++) {
49
- var t = arguments[e];
50
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
47
+ _extends = Object.assign || function (target) {
48
+ for (var i = 1; i < arguments.length; i++) {
49
+ var source = arguments[i];
50
+
51
+ for (var key in source) {
52
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
53
+ target[key] = source[key];
54
+ }
55
+ }
51
56
  }
52
- return n;
53
- }, _extends.apply(null, arguments);
57
+
58
+ return target;
59
+ };
60
+
61
+ return _extends.apply(this, arguments);
54
62
  }
55
63
 
56
64
  /**
@@ -4445,14 +4453,17 @@ const InteractiveUtil = {
4445
4453
  }
4446
4454
  };
4447
4455
 
4448
- function _classPrivateFieldBase(e, t) {
4449
- if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance");
4450
- return e;
4456
+ function _classPrivateFieldBase(receiver, privateKey) {
4457
+ if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
4458
+ throw new TypeError("attempted to use private field on non-instance");
4459
+ }
4460
+
4461
+ return receiver;
4451
4462
  }
4452
4463
 
4453
4464
  var id = 0;
4454
- function _classPrivateFieldKey(e) {
4455
- return "__private_" + id++ + "_" + e;
4465
+ function _classPrivateFieldKey(name) {
4466
+ return "__private_" + id++ + "_" + name;
4456
4467
  }
4457
4468
 
4458
4469
  /*!
@@ -21081,14 +21092,19 @@ TextInput.defaultProps = {
21081
21092
  disabled: false
21082
21093
  };
21083
21094
 
21084
- function _objectWithoutPropertiesLoose(r, e) {
21085
- if (null == r) return {};
21086
- var t = {};
21087
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
21088
- if (e.includes(n)) continue;
21089
- t[n] = r[n];
21095
+ function _objectWithoutPropertiesLoose(source, excluded) {
21096
+ if (source == null) return {};
21097
+ var target = {};
21098
+ var sourceKeys = Object.keys(source);
21099
+ var key, i;
21100
+
21101
+ for (i = 0; i < sourceKeys.length; i++) {
21102
+ key = sourceKeys[i];
21103
+ if (excluded.indexOf(key) >= 0) continue;
21104
+ target[key] = source[key];
21090
21105
  }
21091
- return t;
21106
+
21107
+ return target;
21092
21108
  }
21093
21109
 
21094
21110
  const _excluded$7 = ["position", "visibility", "left", "top"];
@@ -27369,36 +27385,41 @@ class Dropdown extends React.Component {
27369
27385
  value: String(i + 1),
27370
27386
  label: choice
27371
27387
  }))];
27372
- return /*#__PURE__*/React.createElement(UniqueIDProvider, {
27373
- scope: "dropdown-widget",
27374
- mockOnFirstRender: true
27375
- }, ids => /*#__PURE__*/React.createElement(View
27376
- // NOTE(jared): These are required to prevent weird behavior
27377
- // When there's a dropdown in a zoomable table.
27378
- , {
27379
- onClick: e => {
27380
- e.stopPropagation();
27381
- },
27382
- onTouchStart: e => {
27383
- e.stopPropagation();
27384
- }
27385
- }, this.props.visibleLabel && /*#__PURE__*/React.createElement(LabelLarge, {
27386
- tag: "label",
27387
- htmlFor: ids.get("dropdown")
27388
- }, this.props.visibleLabel), /*#__PURE__*/React.createElement(SingleSelect, {
27389
- id: ids.get("dropdown"),
27390
- placeholder: "",
27391
- onChange: value => this._handleChange(parseInt(value)),
27392
- selectedValue: String(this.props.selected),
27393
- disabled: this.props.apiOptions.readOnly,
27394
- "aria-label": this.props.ariaLabel || this.props.visibleLabel || this.context.strings.selectAnAnswer
27395
- // This is currently necessary for SRs to read the labels properly.
27396
- // However, WB is working on a change to add the "combobox" role to
27397
- // all dropdowns.
27398
- // See https://khanacademy.atlassian.net/browse/WB-1671
27399
- ,
27400
- role: "combobox"
27401
- }, children)));
27388
+ return (
27389
+ /*#__PURE__*/
27390
+ // TODO(WB-1812, somewhatabstract): Migrate to Id or useId
27391
+ // eslint-disable-next-line no-restricted-syntax
27392
+ React.createElement(UniqueIDProvider, {
27393
+ scope: "dropdown-widget",
27394
+ mockOnFirstRender: true
27395
+ }, ids => /*#__PURE__*/React.createElement(View
27396
+ // NOTE(jared): These are required to prevent weird behavior
27397
+ // When there's a dropdown in a zoomable table.
27398
+ , {
27399
+ onClick: e => {
27400
+ e.stopPropagation();
27401
+ },
27402
+ onTouchStart: e => {
27403
+ e.stopPropagation();
27404
+ }
27405
+ }, this.props.visibleLabel && /*#__PURE__*/React.createElement(LabelLarge, {
27406
+ tag: "label",
27407
+ htmlFor: ids.get("dropdown")
27408
+ }, this.props.visibleLabel), /*#__PURE__*/React.createElement(SingleSelect, {
27409
+ id: ids.get("dropdown"),
27410
+ placeholder: "",
27411
+ onChange: value => this._handleChange(parseInt(value)),
27412
+ selectedValue: String(this.props.selected),
27413
+ disabled: this.props.apiOptions.readOnly,
27414
+ "aria-label": this.props.ariaLabel || this.props.visibleLabel || this.context.strings.selectAnAnswer
27415
+ // This is currently necessary for SRs to read the labels properly.
27416
+ // However, WB is working on a change to add the "combobox" role to
27417
+ // all dropdowns.
27418
+ // See https://khanacademy.atlassian.net/browse/WB-1671
27419
+ ,
27420
+ role: "combobox"
27421
+ }, children)))
27422
+ );
27402
27423
  }
27403
27424
  }
27404
27425
  Dropdown.contextType = PerseusI18nContext;
@@ -27501,32 +27522,37 @@ class Explanation extends React.Component {
27501
27522
  "white-space": "normal"
27502
27523
  };
27503
27524
  const contentStyling = [styles$k.content, this.state.expanded ? styles$k.contentExpanded : styles$k.contentCollapsed, allowTransition && (this.state.expanded ? styles$k.transitionExpanded : styles$k.transitionCollapsed)];
27504
- return /*#__PURE__*/React.createElement(UniqueIDProvider, {
27505
- mockOnFirstRender: true,
27506
- scope: "explanation-widget"
27507
- }, ids => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
27508
- "aria-expanded": this.state.expanded,
27509
- "aria-controls": ids.get("content"),
27510
- endIcon: caretIcon,
27511
- kind: "tertiary",
27512
- labelStyle: labelStyle,
27513
- onClick: this._onClick,
27514
- size: "small",
27515
- style: buttonStyleOverrides
27516
- }, promptText), /*#__PURE__*/React.createElement(View, {
27517
- id: ids.get("content"),
27518
- style: contentStyling,
27519
- "aria-hidden": !this.state.expanded,
27520
- testId: "content-container"
27521
- }, /*#__PURE__*/React.createElement(View, {
27522
- style: styles$k.contentWrapper
27523
- }, /*#__PURE__*/React.createElement(Renderer, {
27524
- apiOptions: this.props.apiOptions,
27525
- content: this.props.explanation,
27526
- widgets: this.props.widgets,
27527
- linterContext: this.props.linterContext,
27528
- strings: this.context.strings
27529
- })))));
27525
+ return (
27526
+ /*#__PURE__*/
27527
+ // TODO(WB-1812, somewhatabstract): Migrate to Id or useId
27528
+ // eslint-disable-next-line no-restricted-syntax
27529
+ React.createElement(UniqueIDProvider, {
27530
+ mockOnFirstRender: true,
27531
+ scope: "explanation-widget"
27532
+ }, ids => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
27533
+ "aria-expanded": this.state.expanded,
27534
+ "aria-controls": ids.get("content"),
27535
+ endIcon: caretIcon,
27536
+ kind: "tertiary",
27537
+ labelStyle: labelStyle,
27538
+ onClick: this._onClick,
27539
+ size: "small",
27540
+ style: buttonStyleOverrides
27541
+ }, promptText), /*#__PURE__*/React.createElement(View, {
27542
+ id: ids.get("content"),
27543
+ style: contentStyling,
27544
+ "aria-hidden": !this.state.expanded,
27545
+ testId: "content-container"
27546
+ }, /*#__PURE__*/React.createElement(View, {
27547
+ style: styles$k.contentWrapper
27548
+ }, /*#__PURE__*/React.createElement(Renderer, {
27549
+ apiOptions: this.props.apiOptions,
27550
+ content: this.props.explanation,
27551
+ widgets: this.props.widgets,
27552
+ linterContext: this.props.linterContext,
27553
+ strings: this.context.strings
27554
+ })))))
27555
+ );
27530
27556
  }
27531
27557
  }
27532
27558
  Explanation.contextType = PerseusI18nContext;
@@ -38888,6 +38914,8 @@ const AnswerChoices = props => {
38888
38914
  };
38889
38915
 
38890
38916
  const HideAnswersToggle = props => {
38917
+ // TODO(WB-1812, somewhatabstract): Migrate to Id or useId
38918
+ // eslint-disable-next-line no-restricted-syntax
38891
38919
  const idFactory = useUniqueIdWithMock();
38892
38920
  const switchId = idFactory.get("hide-answers-toggle");
38893
38921
  const labelId = idFactory.get("hide-answers-label");
@@ -38933,6 +38961,9 @@ const AnswerPill = props => {
38933
38961
  focused,
38934
38962
  hovered
38935
38963
  } = props;
38964
+
38965
+ // TODO(WB-1812, somewhatabstract): Migrate to Id or useId
38966
+ // eslint-disable-next-line no-restricted-syntax
38936
38967
  const idFactory = useUniqueIdWithMock();
38937
38968
  const {
38938
38969
  strings
@@ -45276,7 +45307,7 @@ const init = function init() {
45276
45307
 
45277
45308
  // This file is processed by a Rollup plugin (replace) to inject the production
45278
45309
  const libName = "@khanacademy/perseus";
45279
- const libVersion = "48.2.0";
45310
+ const libVersion = "49.0.0";
45280
45311
  addLibraryVersionToPerseusDebug(libName, libVersion);
45281
45312
 
45282
45313
  const apiVersion = {