@khanacademy/perseus 5.0.0 → 6.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/CHANGELOG.md +42 -0
- package/dist/components/fixed-to-responsive.d.ts +27 -1
- package/dist/components/fixed-to-responsive.js.flow +27 -1
- package/dist/components/graph.d.ts +42 -26
- package/dist/components/graph.js.flow +42 -28
- package/dist/components/graphie.d.ts +34 -22
- package/dist/components/graphie.js.flow +37 -24
- package/dist/components/hud.d.ts +8 -14
- package/dist/components/hud.js.flow +7 -14
- package/dist/components/inline-icon.d.ts +9 -19
- package/dist/components/inline-icon.js.flow +26 -13
- package/dist/components/lint.d.ts +41 -13
- package/dist/components/lint.js.flow +42 -13
- package/dist/components/math-output.d.ts +15 -11
- package/dist/components/math-output.js.flow +15 -11
- package/dist/components/sortable.d.ts +17 -9
- package/dist/components/sortable.js.flow +22 -9
- package/dist/components/svg-image.d.ts +5 -3
- package/dist/components/svg-image.js.flow +5 -3
- package/dist/components/tooltip.d.ts +45 -4
- package/dist/components/tooltip.js.flow +44 -31
- package/dist/es/index.css +0 -3
- package/dist/es/index.js +477 -648
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +0 -3
- package/dist/index.js +481 -645
- package/dist/index.js.map +1 -1
- package/dist/perseus-types.d.ts +11 -9
- package/dist/perseus-types.js.flow +11 -9
- package/dist/renderer.d.ts +2 -2
- package/dist/renderer.js.flow +1 -3
- package/dist/styles/shared.d.ts +0 -1
- package/dist/styles/shared.js.flow +0 -1
- package/dist/types.d.ts +0 -10
- package/dist/types.js.flow +0 -13
- package/dist/util/a11y.d.ts +0 -1
- package/dist/util/a11y.js.flow +0 -1
- package/dist/util/interactive.d.ts +2 -0
- package/dist/util/interactive.js.flow +2 -0
- package/dist/util.d.ts +3 -3
- package/dist/util.js.flow +4 -3
- package/dist/widgets/grapher.d.ts +1 -1
- package/dist/widgets/grapher.js.flow +12 -3
- package/dist/widgets/matcher.d.ts +7 -3
- package/dist/widgets/matcher.js.flow +7 -3
- package/dist/widgets/number-line.d.ts +1 -1
- package/dist/widgets/number-line.js.flow +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/item-renderer.test.tsx.snap +151 -159
- package/src/__tests__/__snapshots__/renderer.test.tsx.snap +358 -394
- package/src/__tests__/__snapshots__/server-item-renderer.test.tsx.snap +169 -189
- package/src/components/__stories__/lint.stories.tsx +56 -21
- package/src/components/__stories__/sortable.stories.tsx +5 -5
- package/src/components/__stories__/tooltip.stories.tsx +52 -0
- package/src/components/__tests__/__snapshots__/sortable.test.tsx.snap +114 -30
- package/src/components/__tests__/__snapshots__/sorter.test.tsx.snap +172 -204
- package/src/components/__tests__/sortable.test.tsx +54 -16
- package/src/components/__tests__/sorter.test.tsx +12 -9
- package/src/components/fixed-to-responsive.tsx +43 -38
- package/src/components/graph.tsx +95 -81
- package/src/components/graphie.tsx +62 -32
- package/src/components/hud.tsx +104 -115
- package/src/components/inline-icon.tsx +15 -32
- package/src/components/input-with-examples.tsx +4 -4
- package/src/components/lint.tsx +47 -41
- package/src/components/math-output.tsx +17 -11
- package/src/components/simple-keypad-input.tsx +2 -2
- package/src/components/sortable.tsx +134 -94
- package/src/components/svg-image.tsx +10 -11
- package/src/components/tooltip.tsx +189 -171
- package/src/interactive2/types.ts +2 -2
- package/src/multi-items/__tests__/__snapshots__/multi-renderer.test.tsx.snap +708 -764
- package/src/perseus-types.ts +13 -9
- package/src/renderer.tsx +11 -22
- package/src/types.ts +0 -18
- package/src/util/interactive.ts +18 -5
- package/src/util/tex.ts +13 -77
- package/src/util.ts +3 -4
- package/src/widgets/__tests__/__snapshots__/categorizer.test.ts.snap +717 -773
- package/src/widgets/__tests__/__snapshots__/cs-program.test.ts.snap +28 -36
- package/src/widgets/__tests__/__snapshots__/definition.test.ts.snap +52 -60
- package/src/widgets/__tests__/__snapshots__/dropdown.test.ts.snap +100 -108
- package/src/widgets/__tests__/__snapshots__/explanation.test.ts.snap +212 -260
- package/src/widgets/__tests__/__snapshots__/graded-group-set-jipt.test.ts.snap +613 -641
- package/src/widgets/__tests__/__snapshots__/graded-group-set.test.ts.snap +249 -261
- package/src/widgets/__tests__/__snapshots__/graded-group.test.ts.snap +671 -735
- package/src/widgets/__tests__/__snapshots__/grapher.test.ts.snap +2676 -2684
- package/src/widgets/__tests__/__snapshots__/group.test.tsx.snap +938 -1002
- package/src/widgets/__tests__/__snapshots__/iframe.test.ts.snap +28 -36
- package/src/widgets/__tests__/__snapshots__/image.test.ts.snap +227 -255
- package/src/widgets/__tests__/__snapshots__/input-number.test.ts.snap +353 -357
- package/src/widgets/__tests__/__snapshots__/interaction.test.ts.snap +255 -259
- package/src/widgets/__tests__/__snapshots__/interactive-graph.test.ts.snap +2401 -2433
- package/src/widgets/__tests__/__snapshots__/matcher.test.tsx.snap +600 -756
- package/src/widgets/__tests__/__snapshots__/matrix.test.ts.snap +420 -428
- package/src/widgets/__tests__/__snapshots__/number-line.test.ts.snap +762 -770
- package/src/widgets/__tests__/__snapshots__/numeric-input.test.ts.snap +373 -393
- package/src/widgets/__tests__/__snapshots__/orderer.test.ts.snap +116 -148
- package/src/widgets/__tests__/__snapshots__/passage-ref.test.ts.snap +289 -301
- package/src/widgets/__tests__/__snapshots__/passage.test.tsx.snap +1679 -1711
- package/src/widgets/__tests__/__snapshots__/radio.test.ts.snap +2692 -2960
- package/src/widgets/__tests__/__snapshots__/video.test.ts.snap +90 -98
- package/src/widgets/__tests__/matcher.test.tsx +33 -9
- package/src/widgets/expression.tsx +9 -6
- package/src/widgets/grapher.tsx +3 -3
- package/src/widgets/image.tsx +2 -2
- package/src/widgets/interactive-graph.tsx +5 -5
- package/src/widgets/matcher.tsx +43 -24
- package/src/widgets/number-line.tsx +1 -1
- package/src/widgets/simulator.tsx +4 -6
- package/{tsconfig.json → tsconfig-build.json} +6 -6
- package/tsconfig-build.tsbuildinfo +1 -0
- package/tsconfig.tsbuildinfo +0 -1
package/dist/index.js
CHANGED
|
@@ -9,11 +9,10 @@ var i18n = require('@khanacademy/wonder-blocks-i18n');
|
|
|
9
9
|
var classNames = require('classnames');
|
|
10
10
|
var React = require('react');
|
|
11
11
|
var _ = require('underscore');
|
|
12
|
-
var PropTypes = require('prop-types');
|
|
13
12
|
var $ = require('jquery');
|
|
14
13
|
var MathQuill = require('mathquill');
|
|
15
14
|
var ReactDOM = require('react-dom');
|
|
16
|
-
var
|
|
15
|
+
var PropTypes = require('prop-types');
|
|
17
16
|
var kmath = require('@khanacademy/kmath');
|
|
18
17
|
var Spacing = require('@khanacademy/wonder-blocks-spacing');
|
|
19
18
|
var aphrodite = require('aphrodite');
|
|
@@ -29,6 +28,7 @@ var wonderBlocksLayout = require('@khanacademy/wonder-blocks-layout');
|
|
|
29
28
|
var wonderBlocksPopover = require('@khanacademy/wonder-blocks-popover');
|
|
30
29
|
var wonderBlocksDropdown = require('@khanacademy/wonder-blocks-dropdown');
|
|
31
30
|
var debounce = require('lodash.debounce');
|
|
31
|
+
var createReactClass = require('create-react-class');
|
|
32
32
|
var Tooltip$1 = require('@khanacademy/wonder-blocks-tooltip');
|
|
33
33
|
var Link = require('@khanacademy/wonder-blocks-link');
|
|
34
34
|
|
|
@@ -58,18 +58,18 @@ var i18n__namespace = /*#__PURE__*/_interopNamespace(i18n);
|
|
|
58
58
|
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
59
59
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
60
60
|
var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
61
|
-
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
62
61
|
var $__default = /*#__PURE__*/_interopDefaultLegacy($);
|
|
63
62
|
var MathQuill__default = /*#__PURE__*/_interopDefaultLegacy(MathQuill);
|
|
64
63
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
65
64
|
var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
66
|
-
var
|
|
65
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
67
66
|
var Spacing__default = /*#__PURE__*/_interopDefaultLegacy(Spacing);
|
|
68
67
|
var SimpleMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(SimpleMarkdown);
|
|
69
68
|
var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
|
|
70
69
|
var Clickable__default = /*#__PURE__*/_interopDefaultLegacy(Clickable);
|
|
71
70
|
var Color__default = /*#__PURE__*/_interopDefaultLegacy(Color);
|
|
72
71
|
var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
|
|
72
|
+
var createReactClass__default = /*#__PURE__*/_interopDefaultLegacy(createReactClass);
|
|
73
73
|
var Tooltip__default = /*#__PURE__*/_interopDefaultLegacy(Tooltip$1);
|
|
74
74
|
var Link__default = /*#__PURE__*/_interopDefaultLegacy(Link);
|
|
75
75
|
|
|
@@ -127,7 +127,30 @@ function _toPropertyKey(arg) {
|
|
|
127
127
|
return typeof key === "symbol" ? key : String(key);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
/**
|
|
131
|
+
* A stripped version of Icon.jsx from webapp. Takes an SVG icon and renders it
|
|
132
|
+
* inline like Font Awesome did.
|
|
133
|
+
*
|
|
134
|
+
* If you are looking for an icon that we've used before you should look in
|
|
135
|
+
* webapp's `icon-paths.js` which is a reference file for all the SVG paths
|
|
136
|
+
* that we've used. You'll need to copy the object from that file into
|
|
137
|
+
* whichever file you're using the icon and explicitly pass it in to the
|
|
138
|
+
* <InlineIcon/> React component.
|
|
139
|
+
*
|
|
140
|
+
* We assume that the viewBox is cropped and aligned to (0, 0), but icons can
|
|
141
|
+
* be defined differently. At some point we might want to add these attributes
|
|
142
|
+
* to `icon-paths.js`, but for now this is a fairly safe assumption.
|
|
143
|
+
*
|
|
144
|
+
* Sample usage:
|
|
145
|
+
*
|
|
146
|
+
* const editIcon = {
|
|
147
|
+
* path: "M41.209 53.753l5.39 0l0 5.39l3.136 0l6.468-6.517-8.477-8.526-6.517 6.517l0 3.136zm33.173-34.937q-.882-.882-1.862.049l-19.6 19.6q-.931.98-.049 1.862t1.862-.049l19.6-19.6q.931-.98.049-1.862zm-38.563 45.668l0-16.121l37.632-37.632 16.17 16.121-37.632 37.632l-16.17 0zm43.022-12.397l0 10.633q-.049 6.713-4.753 11.417t-11.368 4.704l-46.599 0q-6.713 0-11.417-4.753t-4.704-11.368l0-46.599q0-6.664 4.753-11.417t11.368-4.704l46.599 0q3.528 0 6.566 1.372.833.392.98 1.323t-.49 1.617l-2.744 2.744q-.784.784-1.96.441t-2.352-.343l-46.599 0q-3.675 0-6.321 2.646t-2.646 6.321l0 46.599q0 3.675 2.646 6.321t6.321 2.646l46.599 0q3.675 0 6.321-2.646t2.646-6.321l0-7.056q0-.735.49-1.225l3.577-3.577q.833-.833 1.96-.392t1.127 1.617zm7.203-51.646q2.254 0 3.773 1.568l8.526 8.526q1.568 1.568 1.568 3.822t-1.568 3.773l-5.145 5.145-16.121-16.121 5.145-5.145q1.568-1.568 3.822-1.568z",
|
|
148
|
+
* width: 100,
|
|
149
|
+
* height: 78.912,
|
|
150
|
+
* };
|
|
151
|
+
* <InlineIcon {...editIcon} />
|
|
152
|
+
*
|
|
153
|
+
*/
|
|
131
154
|
const InlineIcon = _ref => {
|
|
132
155
|
let {
|
|
133
156
|
path,
|
|
@@ -151,18 +174,6 @@ const InlineIcon = _ref => {
|
|
|
151
174
|
fill: "currentColor"
|
|
152
175
|
}));
|
|
153
176
|
};
|
|
154
|
-
InlineIcon.propTypes = {
|
|
155
|
-
// An SVG path to render.
|
|
156
|
-
path: PropTypes__default["default"].string.isRequired,
|
|
157
|
-
// The path's viewBox dimensions.
|
|
158
|
-
// We set the viewport height to 1em and scale the width accordingly.
|
|
159
|
-
height: PropTypes__default["default"].number.isRequired,
|
|
160
|
-
width: PropTypes__default["default"].number.isRequired,
|
|
161
|
-
style: PropTypes__default["default"].object,
|
|
162
|
-
// A11y description for this icon. If absent, icon is marked
|
|
163
|
-
// aria-hidden=true
|
|
164
|
-
title: PropTypes__default["default"].string
|
|
165
|
-
};
|
|
166
177
|
|
|
167
178
|
let _dependencies = null;
|
|
168
179
|
const setDependencies = dependencies => {
|
|
@@ -695,145 +706,95 @@ _defineProperty(MathInput, "defaultProps", {
|
|
|
695
706
|
buttonsVisible: "focused"
|
|
696
707
|
});
|
|
697
708
|
|
|
698
|
-
/**
|
|
699
|
-
* A generic tooltip library for React.js
|
|
700
|
-
*
|
|
701
|
-
* This should eventually end up in react-components
|
|
702
|
-
*
|
|
703
|
-
* Interface: ({a, b} means one of a or b)
|
|
704
|
-
* import Tooltip from "./tooltip";
|
|
705
|
-
* <Tooltip
|
|
706
|
-
* className="class-for-tooltip-contents"
|
|
707
|
-
* horizontalPosition="left" // one of "left", "right"
|
|
708
|
-
* horizontalAlign="left" // one of "left", "right"
|
|
709
|
-
* verticalPosition="bottom" // one of "top", "bottom"
|
|
710
|
-
* arrowSize={10} // arrow size in pixels
|
|
711
|
-
* borderColor="#ccc" // color of the border for the tooltip
|
|
712
|
-
* show={true} // whether the tooltip should currently be visible
|
|
713
|
-
* targetContainerStyle={targetContainerStyle}
|
|
714
|
-
* >
|
|
715
|
-
* <TargetElementOfTheTooltip />
|
|
716
|
-
* <TooltipContents1 />
|
|
717
|
-
* <TooltipContents2 />
|
|
718
|
-
* </Tooltip>
|
|
719
|
-
*
|
|
720
|
-
* To show/hide the tooltip, the parent component should call the
|
|
721
|
-
* .show() and .hide() methods of the tooltip when appropriate.
|
|
722
|
-
* (These are usually set up as handlers of events on the target element.)
|
|
723
|
-
*
|
|
724
|
-
* Notes:
|
|
725
|
-
* className should not specify a border; that is handled by borderColor
|
|
726
|
-
* so that the arrow and tooltip match
|
|
727
|
-
*/
|
|
728
709
|
const zIndex = 10;
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
borderRight = hBorder;
|
|
750
|
-
}
|
|
751
|
-
const vBorder = "".concat(this.props.height, "px solid ").concat(this.props.color);
|
|
752
|
-
if (this.props.verticalDirection === "top") {
|
|
753
|
-
borderTop = vBorder;
|
|
754
|
-
} else {
|
|
755
|
-
borderBottom = vBorder;
|
|
756
|
-
}
|
|
757
|
-
return /*#__PURE__*/React__namespace.createElement("div", {
|
|
758
|
-
style: {
|
|
759
|
-
display: "block",
|
|
760
|
-
height: 0,
|
|
761
|
-
width: 0,
|
|
762
|
-
position: "absolute",
|
|
763
|
-
left: this.props.left,
|
|
764
|
-
top: this.props["top"],
|
|
765
|
-
borderLeft: borderLeft,
|
|
766
|
-
borderRight: borderRight,
|
|
767
|
-
borderTop: borderTop,
|
|
768
|
-
borderBottom: borderBottom
|
|
769
|
-
}
|
|
770
|
-
});
|
|
710
|
+
let HorizontalDirection = /*#__PURE__*/function (HorizontalDirection) {
|
|
711
|
+
HorizontalDirection["Left"] = "left";
|
|
712
|
+
HorizontalDirection["Right"] = "right";
|
|
713
|
+
return HorizontalDirection;
|
|
714
|
+
}({});
|
|
715
|
+
let VerticalDirection = /*#__PURE__*/function (VerticalDirection) {
|
|
716
|
+
VerticalDirection["Top"] = "top";
|
|
717
|
+
VerticalDirection["Bottom"] = "bottom";
|
|
718
|
+
return VerticalDirection;
|
|
719
|
+
}({});
|
|
720
|
+
const Triangle = props => {
|
|
721
|
+
let borderLeft;
|
|
722
|
+
let borderRight;
|
|
723
|
+
let borderTop;
|
|
724
|
+
let borderBottom;
|
|
725
|
+
const hBorder = "".concat(props.width, "px solid transparent");
|
|
726
|
+
if (props.horizontalDirection === "right") {
|
|
727
|
+
borderLeft = hBorder;
|
|
728
|
+
} else {
|
|
729
|
+
borderRight = hBorder;
|
|
771
730
|
}
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
top: 0
|
|
795
|
-
};
|
|
796
|
-
},
|
|
731
|
+
const vBorder = "".concat(props.height, "px solid ").concat(props.color);
|
|
732
|
+
if (props.verticalDirection === "top") {
|
|
733
|
+
borderTop = vBorder;
|
|
734
|
+
} else {
|
|
735
|
+
borderBottom = vBorder;
|
|
736
|
+
}
|
|
737
|
+
return /*#__PURE__*/React__namespace.createElement("div", {
|
|
738
|
+
style: {
|
|
739
|
+
display: "block",
|
|
740
|
+
height: 0,
|
|
741
|
+
width: 0,
|
|
742
|
+
position: "absolute",
|
|
743
|
+
left: props.left,
|
|
744
|
+
top: props["top"],
|
|
745
|
+
borderLeft: borderLeft,
|
|
746
|
+
borderRight: borderRight,
|
|
747
|
+
borderTop: borderTop,
|
|
748
|
+
borderBottom: borderBottom
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
};
|
|
752
|
+
const TooltipArrow = props => {
|
|
797
753
|
// TODO(aria): Think about adding a box-shadow to the triangle here
|
|
798
754
|
// See http://css-tricks.com/triangle-with-shadow/
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
755
|
+
|
|
756
|
+
//const isRight = (this.props.horizontalDirection === "right");
|
|
757
|
+
const isTop = props.verticalDirection === "top";
|
|
758
|
+
const frontTopOffset = isTop ? 0 : 1;
|
|
759
|
+
const borderTopOffset = isTop ? 0 : -1;
|
|
760
|
+
return /*#__PURE__*/React__namespace.createElement("div", {
|
|
761
|
+
style: {
|
|
762
|
+
display: "block",
|
|
763
|
+
position: props.position,
|
|
764
|
+
visibility: props.visibility,
|
|
765
|
+
left: props.left,
|
|
766
|
+
top: props["top"],
|
|
767
|
+
width: props.width + 2,
|
|
768
|
+
height: props.height + 1,
|
|
769
|
+
marginTop: -1,
|
|
770
|
+
marginBottom: -2,
|
|
771
|
+
zIndex: zIndex
|
|
772
|
+
}
|
|
773
|
+
}, /*#__PURE__*/React__namespace.createElement(Triangle, {
|
|
774
|
+
horizontalDirection: props.horizontalDirection,
|
|
775
|
+
verticalDirection: props.verticalDirection,
|
|
776
|
+
color: props.border,
|
|
777
|
+
left: 0,
|
|
778
|
+
top: borderTopOffset,
|
|
779
|
+
width: props.width + 2 // one extra for the diagonal
|
|
780
|
+
,
|
|
781
|
+
height: props.height + 2
|
|
782
|
+
}), /*#__PURE__*/React__namespace.createElement(Triangle, {
|
|
783
|
+
horizontalDirection: props.horizontalDirection,
|
|
784
|
+
verticalDirection: props.verticalDirection,
|
|
785
|
+
color: props.color,
|
|
786
|
+
left: 1,
|
|
787
|
+
top: frontTopOffset,
|
|
788
|
+
width: props.width,
|
|
789
|
+
height: props.height
|
|
790
|
+
}));
|
|
791
|
+
};
|
|
792
|
+
TooltipArrow.defaultProps = {
|
|
793
|
+
position: "relative",
|
|
794
|
+
visibility: "visible",
|
|
795
|
+
left: 0,
|
|
796
|
+
top: 0
|
|
797
|
+
};
|
|
837
798
|
const VERTICAL_CORNERS = {
|
|
838
799
|
top: {
|
|
839
800
|
top: "-100%"
|
|
@@ -860,59 +821,34 @@ const HORIZONTAL_ALIGNMNENTS = {
|
|
|
860
821
|
arrowLeft: arrowSize => -arrowSize - 2
|
|
861
822
|
}
|
|
862
823
|
};
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
propTypes: {
|
|
868
|
-
show: PropTypes__default["default"].bool.isRequired,
|
|
869
|
-
className: PropTypes__default["default"].string,
|
|
870
|
-
arrowSize: PropTypes__default["default"].number,
|
|
871
|
-
borderColor: PropTypes__default["default"].string,
|
|
872
|
-
verticalPosition: PropTypes__default["default"].oneOf(Object.keys(VERTICAL_CORNERS)),
|
|
873
|
-
horizontalPosition: PropTypes__default["default"].oneOf(Object.keys(HORIZONTAL_CORNERS)),
|
|
874
|
-
horizontalAlign: PropTypes__default["default"].oneOf(Object.keys(HORIZONTAL_ALIGNMNENTS)),
|
|
875
|
-
children: PropTypes__default["default"].arrayOf(PropTypes__default["default"].element).isRequired,
|
|
876
|
-
targetContainerStyle: PropTypes__default["default"].any // style object
|
|
877
|
-
},
|
|
878
|
-
|
|
879
|
-
getDefaultProps: function () {
|
|
880
|
-
return {
|
|
881
|
-
className: "",
|
|
882
|
-
arrowSize: 10,
|
|
883
|
-
borderColor: "#ccc",
|
|
884
|
-
verticalPosition: "bottom",
|
|
885
|
-
horizontalPosition: "left",
|
|
886
|
-
horizontalAlign: "left",
|
|
887
|
-
targetContainerStyle: {}
|
|
888
|
-
};
|
|
889
|
-
},
|
|
890
|
-
getInitialState: function () {
|
|
891
|
-
return {
|
|
824
|
+
class Tooltip extends React__namespace.Component {
|
|
825
|
+
constructor() {
|
|
826
|
+
super(...arguments);
|
|
827
|
+
_defineProperty(this, "state", {
|
|
892
828
|
height: null // used for offsetting "top" positioned tooltips
|
|
893
|
-
};
|
|
894
|
-
}
|
|
829
|
+
});
|
|
830
|
+
}
|
|
895
831
|
|
|
896
|
-
componentDidMount
|
|
832
|
+
componentDidMount() {
|
|
897
833
|
this._updateHeight();
|
|
898
|
-
}
|
|
899
|
-
UNSAFE_componentWillReceiveProps
|
|
834
|
+
}
|
|
835
|
+
UNSAFE_componentWillReceiveProps() {
|
|
900
836
|
// If the contents have changed, reset our measure of the height
|
|
901
837
|
this.setState({
|
|
902
838
|
height: null
|
|
903
839
|
});
|
|
904
|
-
}
|
|
905
|
-
componentDidUpdate
|
|
840
|
+
}
|
|
841
|
+
componentDidUpdate() {
|
|
906
842
|
this._updateHeight();
|
|
907
|
-
}
|
|
908
|
-
_renderToolTipDiv
|
|
843
|
+
}
|
|
844
|
+
_renderToolTipDiv(isTooltipAbove) {
|
|
909
845
|
const settings = Object.assign({}, HORIZONTAL_CORNERS[this.props.horizontalPosition], HORIZONTAL_ALIGNMNENTS[this.props.horizontalAlign], VERTICAL_CORNERS[this.props.verticalPosition]);
|
|
910
846
|
let arrowAbove;
|
|
911
847
|
let arrowBelow;
|
|
912
848
|
if (isTooltipAbove) {
|
|
913
849
|
// We put an absolutely positioned arrow in the correct place
|
|
914
850
|
arrowAbove = /*#__PURE__*/React__namespace.createElement(TooltipArrow, {
|
|
915
|
-
verticalDirection:
|
|
851
|
+
verticalDirection: VerticalDirection.Top,
|
|
916
852
|
horizontalDirection: this.props.horizontalAlign,
|
|
917
853
|
position: "absolute",
|
|
918
854
|
color: "white",
|
|
@@ -927,7 +863,7 @@ const Tooltip = createReactClass__default["default"]({
|
|
|
927
863
|
// And we use a visibility: hidden arrow below to shift up the
|
|
928
864
|
// content by the correct amount
|
|
929
865
|
arrowBelow = /*#__PURE__*/React__namespace.createElement(TooltipArrow, {
|
|
930
|
-
verticalDirection:
|
|
866
|
+
verticalDirection: VerticalDirection.Top,
|
|
931
867
|
horizontalDirection: this.props.horizontalAlign,
|
|
932
868
|
visibility: "hidden",
|
|
933
869
|
color: "white",
|
|
@@ -940,7 +876,7 @@ const Tooltip = createReactClass__default["default"]({
|
|
|
940
876
|
});
|
|
941
877
|
} else {
|
|
942
878
|
arrowAbove = /*#__PURE__*/React__namespace.createElement(TooltipArrow, {
|
|
943
|
-
verticalDirection:
|
|
879
|
+
verticalDirection: VerticalDirection.Bottom,
|
|
944
880
|
horizontalDirection: this.props.horizontalAlign,
|
|
945
881
|
color: "white",
|
|
946
882
|
border: this.props.borderColor,
|
|
@@ -988,8 +924,8 @@ const Tooltip = createReactClass__default["default"]({
|
|
|
988
924
|
zIndex: zIndex - 1
|
|
989
925
|
}
|
|
990
926
|
}, this.props.children.slice(1)), arrowBelow));
|
|
991
|
-
}
|
|
992
|
-
_updateHeight
|
|
927
|
+
}
|
|
928
|
+
_updateHeight() {
|
|
993
929
|
const tooltipContainer = ReactDOM__default["default"].findDOMNode(
|
|
994
930
|
// eslint-disable-next-line react/no-string-refs
|
|
995
931
|
this.refs.tooltipContainer);
|
|
@@ -999,8 +935,8 @@ const Tooltip = createReactClass__default["default"]({
|
|
|
999
935
|
height
|
|
1000
936
|
});
|
|
1001
937
|
}
|
|
1002
|
-
}
|
|
1003
|
-
render
|
|
938
|
+
}
|
|
939
|
+
render() {
|
|
1004
940
|
const isTooltipAbove = this.props.verticalPosition === "top";
|
|
1005
941
|
|
|
1006
942
|
/* We wrap the entire output in a span so that it displays inline */
|
|
@@ -1008,6 +944,17 @@ const Tooltip = createReactClass__default["default"]({
|
|
|
1008
944
|
style: this.props.targetContainerStyle
|
|
1009
945
|
}, this.props.children[0]), !isTooltipAbove && this._renderToolTipDiv());
|
|
1010
946
|
}
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
// Sorry. // Apology-Oriented-Programming
|
|
950
|
+
_defineProperty(Tooltip, "defaultProps", {
|
|
951
|
+
className: "",
|
|
952
|
+
arrowSize: 10,
|
|
953
|
+
borderColor: "#ccc",
|
|
954
|
+
verticalPosition: VerticalDirection.Bottom,
|
|
955
|
+
horizontalPosition: HorizontalDirection.Left,
|
|
956
|
+
horizontalAlign: HorizontalDirection.Left,
|
|
957
|
+
targetContainerStyle: {}
|
|
1011
958
|
});
|
|
1012
959
|
|
|
1013
960
|
/**
|
|
@@ -2909,9 +2856,9 @@ class Expression extends React__namespace.Component {
|
|
|
2909
2856
|
role: "tooltip"
|
|
2910
2857
|
}, /*#__PURE__*/React__namespace.createElement(Tooltip, {
|
|
2911
2858
|
className: "error-text-container",
|
|
2912
|
-
horizontalPosition:
|
|
2913
|
-
horizontalAlign:
|
|
2914
|
-
verticalPosition:
|
|
2859
|
+
horizontalPosition: HorizontalDirection.Right,
|
|
2860
|
+
horizontalAlign: HorizontalDirection.Left,
|
|
2861
|
+
verticalPosition: VerticalDirection.Top,
|
|
2915
2862
|
arrowSize: 10,
|
|
2916
2863
|
borderColor: "#fcc335",
|
|
2917
2864
|
show: this.state.showErrorText
|
|
@@ -2983,7 +2930,7 @@ _defineProperty(Expression, "defaultProps", {
|
|
|
2983
2930
|
const keypadConfigurationForProps = widgetOptions => {
|
|
2984
2931
|
// Always use the Expression keypad, regardless of the button sets that have
|
|
2985
2932
|
// been enabled.
|
|
2986
|
-
const keypadType = mathInput.
|
|
2933
|
+
const keypadType = mathInput.KeypadType.EXPRESSION;
|
|
2987
2934
|
|
|
2988
2935
|
// Extract any and all variables and constants from the answer forms.
|
|
2989
2936
|
const uniqueExtraVariables = {};
|
|
@@ -3445,8 +3392,6 @@ function tickStepFromNumTicks(span, numTicks) {
|
|
|
3445
3392
|
// Round start and stop values to step interval.
|
|
3446
3393
|
return step;
|
|
3447
3394
|
}
|
|
3448
|
-
// [min, max]
|
|
3449
|
-
|
|
3450
3395
|
const constrainTickStep = (step, range) => {
|
|
3451
3396
|
const span = range[1] - range[0];
|
|
3452
3397
|
const numTicks = span / step;
|
|
@@ -4483,31 +4428,25 @@ var constants$1 = /*#__PURE__*/Object.freeze({
|
|
|
4483
4428
|
articleMaxWidthTableInPx: articleMaxWidthTableInPx
|
|
4484
4429
|
});
|
|
4485
4430
|
|
|
4486
|
-
/* eslint-disable react/prop-types */
|
|
4487
4431
|
const MIN_VIEWPORT_HEIGHT = 480;
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
className: PropTypes__default["default"].string,
|
|
4494
|
-
constrainHeight: PropTypes__default["default"].bool,
|
|
4495
|
-
allowFullBleed: PropTypes__default["default"].bool
|
|
4496
|
-
},
|
|
4497
|
-
getDefaultProps: function () {
|
|
4498
|
-
return {
|
|
4499
|
-
className: "",
|
|
4500
|
-
constrainHeight: false,
|
|
4501
|
-
allowFullBleed: false
|
|
4502
|
-
};
|
|
4503
|
-
},
|
|
4504
|
-
getInitialState: function () {
|
|
4505
|
-
return {
|
|
4432
|
+
class FixedToResponsive extends React__namespace.Component {
|
|
4433
|
+
constructor() {
|
|
4434
|
+
super(...arguments);
|
|
4435
|
+
_defineProperty(this, "_isMounted", false);
|
|
4436
|
+
_defineProperty(this, "state", {
|
|
4506
4437
|
viewportHeight: null,
|
|
4507
4438
|
viewportWidth: null
|
|
4508
|
-
};
|
|
4509
|
-
|
|
4510
|
-
|
|
4439
|
+
});
|
|
4440
|
+
_defineProperty(this, "_cacheViewportSize", () => {
|
|
4441
|
+
if (this._isMounted) {
|
|
4442
|
+
this.setState({
|
|
4443
|
+
viewportHeight: Math.max(MIN_VIEWPORT_HEIGHT, window.innerHeight),
|
|
4444
|
+
viewportWidth: window.innerWidth
|
|
4445
|
+
});
|
|
4446
|
+
}
|
|
4447
|
+
});
|
|
4448
|
+
}
|
|
4449
|
+
componentDidMount() {
|
|
4511
4450
|
// TODO(scottgrant): This is a hack to remove the deprecated call to
|
|
4512
4451
|
// this.isMounted() but is still considered an anti-pattern.
|
|
4513
4452
|
this._isMounted = true;
|
|
@@ -4528,19 +4467,11 @@ const FixedToResponsive = createReactClass__default["default"]({
|
|
|
4528
4467
|
} else {
|
|
4529
4468
|
this._cacheViewportSize();
|
|
4530
4469
|
}
|
|
4531
|
-
}
|
|
4532
|
-
componentWillUnmount
|
|
4470
|
+
}
|
|
4471
|
+
componentWillUnmount() {
|
|
4533
4472
|
this._isMounted = false;
|
|
4534
|
-
}
|
|
4535
|
-
|
|
4536
|
-
if (this._isMounted) {
|
|
4537
|
-
this.setState({
|
|
4538
|
-
viewportHeight: Math.max(MIN_VIEWPORT_HEIGHT, window.innerHeight),
|
|
4539
|
-
viewportWidth: window.innerWidth
|
|
4540
|
-
});
|
|
4541
|
-
}
|
|
4542
|
-
},
|
|
4543
|
-
render: function () {
|
|
4473
|
+
}
|
|
4474
|
+
render() {
|
|
4544
4475
|
// The ideal behavior for responsified, fixed size child components is
|
|
4545
4476
|
// that they shrink when they need to (while preserving aspect ratio)
|
|
4546
4477
|
// but never grow larger than their original dimensions. We accomplish
|
|
@@ -4596,6 +4527,11 @@ const FixedToResponsive = createReactClass__default["default"]({
|
|
|
4596
4527
|
}
|
|
4597
4528
|
return container;
|
|
4598
4529
|
}
|
|
4530
|
+
}
|
|
4531
|
+
_defineProperty(FixedToResponsive, "defaultProps", {
|
|
4532
|
+
className: "",
|
|
4533
|
+
constrainHeight: false,
|
|
4534
|
+
allowFullBleed: false
|
|
4599
4535
|
});
|
|
4600
4536
|
|
|
4601
4537
|
/* eslint-disable @babel/no-invalid-this */
|
|
@@ -9125,6 +9061,26 @@ const KhanColors = {
|
|
|
9125
9061
|
DYNAMIC: "#6495ED" // BLUE
|
|
9126
9062
|
};
|
|
9127
9063
|
|
|
9064
|
+
function render(element, container, callback) {
|
|
9065
|
+
// TODO(LP-11406): Replace this, or callers, with React Portal
|
|
9066
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'void' is not assignable to type 'ElementRef<ElementType>'.
|
|
9067
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
9068
|
+
return ReactDOM__default["default"].render(
|
|
9069
|
+
/*#__PURE__*/
|
|
9070
|
+
/**
|
|
9071
|
+
* `RenderStateRoot` is responsible for tracking whether it's
|
|
9072
|
+
* the initial render or subsequent renders. It's used by
|
|
9073
|
+
* `useUniqueId` and will be used by `UniqueIDProvider` and
|
|
9074
|
+
* `WithSSRPlaceholder` in the future. We're placing it as
|
|
9075
|
+
* high up in the render tree as possible to ensure that any
|
|
9076
|
+
* components using that hook or those components will function
|
|
9077
|
+
* correctly.
|
|
9078
|
+
*/
|
|
9079
|
+
React__namespace.createElement(wonderBlocksCore.RenderStateRoot, {
|
|
9080
|
+
throwIfNested: false
|
|
9081
|
+
}, element), container, callback);
|
|
9082
|
+
}
|
|
9083
|
+
|
|
9128
9084
|
function findChildOrAdd(elem, className) {
|
|
9129
9085
|
const $child = $__default["default"](elem).find("." + className);
|
|
9130
9086
|
if ($child.length === 0) {
|
|
@@ -9199,74 +9155,18 @@ var Tex$1 = {
|
|
|
9199
9155
|
|
|
9200
9156
|
// Store the formula that we're using
|
|
9201
9157
|
$elem.attr("data-math-formula", text);
|
|
9202
|
-
const
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
|
|
9210
|
-
colorIsTextColor: true
|
|
9211
|
-
});
|
|
9212
|
-
// If that worked, and we previously formatted with
|
|
9213
|
-
// mathjax, do some mathjax cleanup
|
|
9214
|
-
if ($elem.attr("data-math-type") === "mathjax") {
|
|
9215
|
-
// Remove the old mathjax stuff
|
|
9216
|
-
if (typeof MathJax !== "undefined") {
|
|
9217
|
-
const jax = MathJax.Hub.getJaxFor(script);
|
|
9218
|
-
if (jax) {
|
|
9219
|
-
const e = jax.SourceElement();
|
|
9220
|
-
if (e.previousSibling && e.previousSibling.className) {
|
|
9221
|
-
jax.Remove();
|
|
9222
|
-
}
|
|
9223
|
-
}
|
|
9224
|
-
}
|
|
9225
|
-
}
|
|
9226
|
-
$elem.attr("data-math-type", "katex");
|
|
9227
|
-
// Call the callback
|
|
9158
|
+
const {
|
|
9159
|
+
TeX
|
|
9160
|
+
} = await getDependencies();
|
|
9161
|
+
// We use createElement instead of JSX here because we can't name this file tex.tsx;
|
|
9162
|
+
// that name is already taken.
|
|
9163
|
+
render( /*#__PURE__*/React__namespace.createElement(TeX, {
|
|
9164
|
+
children: text
|
|
9165
|
+
}), $katexHolder[0], () => {
|
|
9228
9166
|
if (callback) {
|
|
9229
9167
|
doCallback(elem, callback);
|
|
9230
9168
|
}
|
|
9231
|
-
|
|
9232
|
-
} catch (err) {
|
|
9233
|
-
getDependencies().logKaTeXError(text, err);
|
|
9234
|
-
if (err instanceof katex.ParseError) {
|
|
9235
|
-
throw err;
|
|
9236
|
-
}
|
|
9237
|
-
}
|
|
9238
|
-
|
|
9239
|
-
// Otherwise, fallback to MathJax
|
|
9240
|
-
|
|
9241
|
-
// (Note: we don't need to do any katex cleanup here, because
|
|
9242
|
-
// KaTeX is smart and cleans itself up)
|
|
9243
|
-
$elem.attr("data-math-type", "mathjax");
|
|
9244
|
-
// Update the script tag, or add one if necessary
|
|
9245
|
-
if (!script) {
|
|
9246
|
-
$mathjaxHolder.append("<script type='math/tex'>" + text.replace(/<\//g, "< /") + "</script>");
|
|
9247
|
-
} else {
|
|
9248
|
-
if ("text" in script) {
|
|
9249
|
-
// IE8, etc
|
|
9250
|
-
script.text = text;
|
|
9251
|
-
} else {
|
|
9252
|
-
script.textContent = text;
|
|
9253
|
-
}
|
|
9254
|
-
}
|
|
9255
|
-
if (typeof MathJax !== "undefined") {
|
|
9256
|
-
// Put the process, a debug log, and the callback into the
|
|
9257
|
-
// MathJax queue
|
|
9258
|
-
MathJax.Hub.Queue(["Reprocess", MathJax.Hub, $mathjaxHolder[0]]);
|
|
9259
|
-
if (callback) {
|
|
9260
|
-
MathJax.Hub.Queue(function () {
|
|
9261
|
-
const cb = MathJax.Callback(function () {});
|
|
9262
|
-
doCallback(elem, function () {
|
|
9263
|
-
callback();
|
|
9264
|
-
cb();
|
|
9265
|
-
});
|
|
9266
|
-
return cb;
|
|
9267
|
-
});
|
|
9268
|
-
}
|
|
9269
|
-
}
|
|
9169
|
+
});
|
|
9270
9170
|
}
|
|
9271
9171
|
},
|
|
9272
9172
|
// Function to restore a node to a non-math-processed state
|
|
@@ -11240,10 +11140,11 @@ ___default["default"].extend(GraphUtils.Graphie.prototype, {
|
|
|
11240
11140
|
}
|
|
11241
11141
|
isClickingCanvas = true;
|
|
11242
11142
|
if (options.onMouseMove) {
|
|
11143
|
+
const handler = options.onMouseMove;
|
|
11243
11144
|
$__default["default"](document).bind("vmousemove.mouseLayer", function (e) {
|
|
11244
11145
|
if (isClickingCanvas) {
|
|
11245
11146
|
e.preventDefault();
|
|
11246
|
-
|
|
11147
|
+
handler(graph.getMouseCoord(e));
|
|
11247
11148
|
}
|
|
11248
11149
|
});
|
|
11249
11150
|
}
|
|
@@ -11260,18 +11161,21 @@ ___default["default"].extend(GraphUtils.Graphie.prototype, {
|
|
|
11260
11161
|
}
|
|
11261
11162
|
});
|
|
11262
11163
|
if (options.onMouseOver) {
|
|
11164
|
+
const handler = options.onMouseOver;
|
|
11263
11165
|
$__default["default"](graph.mouselayer.canvas).on("vmouseover", function (e) {
|
|
11264
|
-
|
|
11166
|
+
handler(graph.getMouseCoord(e));
|
|
11265
11167
|
});
|
|
11266
11168
|
}
|
|
11267
11169
|
if (options.onMouseOut) {
|
|
11170
|
+
const handler = options.onMouseOut;
|
|
11268
11171
|
$__default["default"](graph.mouselayer.canvas).on("vmouseout", function (e) {
|
|
11269
|
-
|
|
11172
|
+
handler(graph.getMouseCoord(e));
|
|
11270
11173
|
});
|
|
11271
11174
|
}
|
|
11272
11175
|
}
|
|
11273
11176
|
if (!options.allowScratchpad) {
|
|
11274
|
-
|
|
11177
|
+
var _options$setDrawingAr, _options;
|
|
11178
|
+
(_options$setDrawingAr = (_options = options).setDrawingAreaAvailable) === null || _options$setDrawingAr === void 0 ? void 0 : _options$setDrawingAr.call(_options, false);
|
|
11275
11179
|
}
|
|
11276
11180
|
|
|
11277
11181
|
// Add mouse and visible wrapper layers for DOM-node-wrapped movables
|
|
@@ -15075,26 +14979,6 @@ ___default["default"].extend(MovableLine$4.prototype, {
|
|
|
15075
14979
|
}
|
|
15076
14980
|
});
|
|
15077
14981
|
|
|
15078
|
-
function render(element, container, callback) {
|
|
15079
|
-
// TODO(LP-11406): Replace this, or callers, with React Portal
|
|
15080
|
-
// @ts-expect-error [FEI-5003] - TS2322 - Type 'void' is not assignable to type 'ElementRef<ElementType>'.
|
|
15081
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
15082
|
-
return ReactDOM__default["default"].render(
|
|
15083
|
-
/*#__PURE__*/
|
|
15084
|
-
/**
|
|
15085
|
-
* `RenderStateRoot` is responsible for tracking whether it's
|
|
15086
|
-
* the initial render or subsequent renders. It's used by
|
|
15087
|
-
* `useUniqueId` and will be used by `UniqueIDProvider` and
|
|
15088
|
-
* `WithSSRPlaceholder` in the future. We're placing it as
|
|
15089
|
-
* high up in the render tree as possible to ensure that any
|
|
15090
|
-
* components using that hook or those components will function
|
|
15091
|
-
* correctly.
|
|
15092
|
-
*/
|
|
15093
|
-
React__namespace.createElement(wonderBlocksCore.RenderStateRoot, {
|
|
15094
|
-
throwIfNested: false
|
|
15095
|
-
}, element), container, callback);
|
|
15096
|
-
}
|
|
15097
|
-
|
|
15098
14982
|
/* eslint-disable @babel/no-invalid-this */
|
|
15099
14983
|
const add$1 = {
|
|
15100
14984
|
constrain: function () {
|
|
@@ -16576,24 +16460,27 @@ const {
|
|
|
16576
16460
|
class Graphie extends React__namespace.Component {
|
|
16577
16461
|
constructor() {
|
|
16578
16462
|
super(...arguments);
|
|
16463
|
+
_defineProperty(this, "graphieDivRef", /*#__PURE__*/React__namespace.createRef());
|
|
16579
16464
|
_defineProperty(this, "getGraphie", () => {
|
|
16580
16465
|
// @ts-expect-error [FEI-5003] - TS2339 - Property '_graphie' does not exist on type 'Graphie'.
|
|
16581
16466
|
return this._graphie;
|
|
16582
16467
|
});
|
|
16583
16468
|
_defineProperty(this, "_range", () => {
|
|
16584
|
-
|
|
16585
|
-
if (
|
|
16469
|
+
const boundsCheckRange = range => {
|
|
16470
|
+
if (range[0] >= range[1]) {
|
|
16586
16471
|
return [-10, 10];
|
|
16587
16472
|
}
|
|
16588
|
-
return
|
|
16589
|
-
}
|
|
16473
|
+
return range;
|
|
16474
|
+
};
|
|
16475
|
+
return [boundsCheckRange(this.props.range[0]), boundsCheckRange(this.props.range[1])];
|
|
16590
16476
|
});
|
|
16591
16477
|
_defineProperty(this, "_box", () => {
|
|
16592
|
-
|
|
16478
|
+
const ensureMinSize = pixelDim => {
|
|
16593
16479
|
// 340 = default size in the editor. exact value
|
|
16594
16480
|
// is arbitrary; this is just a safety check.
|
|
16595
16481
|
return pixelDim > 0 ? pixelDim : 340;
|
|
16596
|
-
}
|
|
16482
|
+
};
|
|
16483
|
+
return [ensureMinSize(this.props.box[0]), ensureMinSize(this.props.box[1])];
|
|
16597
16484
|
});
|
|
16598
16485
|
_defineProperty(this, "_scale", () => {
|
|
16599
16486
|
const box = this._box();
|
|
@@ -16605,9 +16492,7 @@ class Graphie extends React__namespace.Component {
|
|
|
16605
16492
|
});
|
|
16606
16493
|
_defineProperty(this, "_setupGraphie", () => {
|
|
16607
16494
|
this._removeMovables();
|
|
16608
|
-
|
|
16609
|
-
// eslint-disable-next-line react/no-string-refs
|
|
16610
|
-
const graphieDiv = ReactDOM__default["default"].findDOMNode(this.refs.graphieDiv);
|
|
16495
|
+
const graphieDiv = ReactDOM__default["default"].findDOMNode(this.graphieDivRef.current);
|
|
16611
16496
|
// @ts-expect-error [FEI-5003] - TS2769 - No overload matches this call. | TS2339 - Property 'empty' does not exist on type 'JQueryStatic'.
|
|
16612
16497
|
$__default["default"](graphieDiv).empty();
|
|
16613
16498
|
// @ts-expect-error [FEI-5003] - TS2339 - Property '_graphie' does not exist on type 'Graphie'.
|
|
@@ -16821,29 +16706,12 @@ class Graphie extends React__namespace.Component {
|
|
|
16821
16706
|
className: "graphie-container"
|
|
16822
16707
|
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
16823
16708
|
className: "graphie",
|
|
16824
|
-
ref:
|
|
16709
|
+
ref: this.graphieDivRef
|
|
16825
16710
|
}));
|
|
16826
16711
|
}
|
|
16827
16712
|
}
|
|
16828
16713
|
|
|
16829
16714
|
// Attach Graphie.createClass and Graphie.createSimpleClass
|
|
16830
|
-
_defineProperty(Graphie, "propTypes", {
|
|
16831
|
-
addMouseLayer: PropTypes__default["default"].bool,
|
|
16832
|
-
box: PropTypes__default["default"].arrayOf(PropTypes__default["default"].number).isRequired,
|
|
16833
|
-
children: PropTypes__default["default"].node,
|
|
16834
|
-
isMobile: PropTypes__default["default"].bool,
|
|
16835
|
-
onClick: PropTypes__default["default"].func,
|
|
16836
|
-
onMouseDown: PropTypes__default["default"].func,
|
|
16837
|
-
onMouseMove: PropTypes__default["default"].func,
|
|
16838
|
-
onMouseUp: PropTypes__default["default"].func,
|
|
16839
|
-
options: PropTypes__default["default"].shape({
|
|
16840
|
-
snapStep: PropTypes__default["default"].arrayOf(PropTypes__default["default"].number)
|
|
16841
|
-
}),
|
|
16842
|
-
range: PropTypes__default["default"].arrayOf(PropTypes__default["default"].arrayOf(PropTypes__default["default"].number)),
|
|
16843
|
-
responsive: PropTypes__default["default"].bool,
|
|
16844
|
-
setDrawingAreaAvailable: PropTypes__default["default"].func,
|
|
16845
|
-
setup: PropTypes__default["default"].func.isRequired
|
|
16846
|
-
});
|
|
16847
16715
|
_defineProperty(Graphie, "defaultProps", {
|
|
16848
16716
|
range: [[-10, 10], [-10, 10]],
|
|
16849
16717
|
options: {},
|
|
@@ -17479,13 +17347,15 @@ class SvgImage extends React__namespace.Component {
|
|
|
17479
17347
|
}
|
|
17480
17348
|
});
|
|
17481
17349
|
}
|
|
17482
|
-
|
|
17350
|
+
|
|
17351
|
+
// TODO: the "40" scale factor was introduced in D14974 but is not
|
|
17352
|
+
// documented where it came from.
|
|
17483
17353
|
graphie = /*#__PURE__*/React__namespace.createElement(Graphie
|
|
17484
17354
|
// eslint-disable-next-line react/no-string-refs
|
|
17485
17355
|
, {
|
|
17486
17356
|
ref: "graphie",
|
|
17487
17357
|
box: box,
|
|
17488
|
-
scale: scale,
|
|
17358
|
+
scale: [40 * this.props.scale, 40 * this.props.scale],
|
|
17489
17359
|
range: this.state.range,
|
|
17490
17360
|
options: ___default["default"].pick(this.state, "labels"),
|
|
17491
17361
|
responsive: responsive,
|
|
@@ -18012,6 +17882,35 @@ const exclamationIcon = {
|
|
|
18012
17882
|
height: 12,
|
|
18013
17883
|
width: 12
|
|
18014
17884
|
};
|
|
17885
|
+
var Severity = /*#__PURE__*/function (Severity) {
|
|
17886
|
+
Severity[Severity["Error"] = 1] = "Error";
|
|
17887
|
+
Severity[Severity["Warning"] = 2] = "Warning";
|
|
17888
|
+
Severity[Severity["Recommendation"] = 3] = "Recommendation";
|
|
17889
|
+
Severity[Severity["OfflineReportingOnly"] = 4] = "OfflineReportingOnly";
|
|
17890
|
+
return Severity;
|
|
17891
|
+
}(Severity || {});
|
|
17892
|
+
/**
|
|
17893
|
+
* This component renders "lint" nodes in a markdown parse tree. Lint nodes
|
|
17894
|
+
* are inserted into the tree by the Perseus linter (see
|
|
17895
|
+
* perseus-linter/src/index).
|
|
17896
|
+
*
|
|
17897
|
+
* This component serves multiple purposes
|
|
17898
|
+
*
|
|
17899
|
+
* 1) It renders a small circle in the right margin to indicate that there
|
|
17900
|
+
* is lint on (or near) that line.
|
|
17901
|
+
*
|
|
17902
|
+
* 2) The area around the circle is hoverable: when the mouse moves over it
|
|
17903
|
+
* the linty content is highlighted and a tooltip is displayed that explains
|
|
17904
|
+
* what the problem is.
|
|
17905
|
+
*
|
|
17906
|
+
* 3) The hoverable area is also an HTML <a> tag. Clicking on it opens
|
|
17907
|
+
* a new tab and links to additional details about the specific lint rule.
|
|
17908
|
+
*
|
|
17909
|
+
* The CSS required to position the circles in the right margin is tricky
|
|
17910
|
+
* and it does not always work perfectly. When lint occurs on a block element
|
|
17911
|
+
* that has a right margin (like anything blockquoted) the circle will appear
|
|
17912
|
+
* to the left of where it belongs. And if there is more
|
|
17913
|
+
**/
|
|
18015
17914
|
class Lint extends React__namespace.Component {
|
|
18016
17915
|
constructor() {
|
|
18017
17916
|
super(...arguments);
|
|
@@ -18034,11 +17933,11 @@ class Lint extends React__namespace.Component {
|
|
|
18034
17933
|
let severityStyle;
|
|
18035
17934
|
let warningText;
|
|
18036
17935
|
let warningTextStyle;
|
|
18037
|
-
if (this.props.severity ===
|
|
17936
|
+
if (this.props.severity === Severity.Error) {
|
|
18038
17937
|
severityStyle = styles$A.indicatorError;
|
|
18039
17938
|
warningText = "Error";
|
|
18040
17939
|
warningTextStyle = styles$A.publishBlockingError;
|
|
18041
|
-
} else if (this.props.severity ===
|
|
17940
|
+
} else if (this.props.severity === Severity.Warning) {
|
|
18042
17941
|
severityStyle = styles$A.indicatorWarning;
|
|
18043
17942
|
warningText = "Warning";
|
|
18044
17943
|
warningTextStyle = styles$A.warning;
|
|
@@ -18073,7 +17972,6 @@ class Lint extends React__namespace.Component {
|
|
|
18073
17972
|
componentWillUnmount() {
|
|
18074
17973
|
// TODO(somewhatabstract): Use WB timing
|
|
18075
17974
|
// eslint-disable-next-line no-restricted-syntax
|
|
18076
|
-
// @ts-expect-error [FEI-5003] - TS2769 - No overload matches this call.
|
|
18077
17975
|
window.clearTimeout(this._positionTimeout);
|
|
18078
17976
|
}
|
|
18079
17977
|
|
|
@@ -18119,24 +18017,6 @@ class Lint extends React__namespace.Component {
|
|
|
18119
18017
|
}, this.renderLink(styles$A.hoverTarget), /*#__PURE__*/React__namespace.createElement("div", null, children));
|
|
18120
18018
|
}
|
|
18121
18019
|
}
|
|
18122
|
-
_defineProperty(Lint, "propTypes", {
|
|
18123
|
-
// The children are the linty content we're highlighting
|
|
18124
|
-
children: PropTypes__default["default"].node,
|
|
18125
|
-
// Inline lint is highlighted differently than block lint.
|
|
18126
|
-
inline: PropTypes__default["default"].bool,
|
|
18127
|
-
// This is the text that appears in the tooltip
|
|
18128
|
-
message: PropTypes__default["default"].string.isRequired,
|
|
18129
|
-
// This is used as the fragment id (hash) in the URL of the link
|
|
18130
|
-
ruleName: PropTypes__default["default"].string.isRequired,
|
|
18131
|
-
// Lint warnings inside tables are handled specially
|
|
18132
|
-
insideTable: PropTypes__default["default"].bool.isRequired,
|
|
18133
|
-
// Should lint highlighting be rendered as a block to the left of
|
|
18134
|
-
// the lint instead of on the right gutter?
|
|
18135
|
-
blockHighlight: PropTypes__default["default"].bool,
|
|
18136
|
-
// How important this lint message is for the editor. Severity goes
|
|
18137
|
-
// from 1 (indicating an error) to 4 (offline reporting only)
|
|
18138
|
-
severity: PropTypes__default["default"].number
|
|
18139
|
-
});
|
|
18140
18020
|
const styles$A = aphrodite.StyleSheet.create({
|
|
18141
18021
|
// This is the class of the outermost element.
|
|
18142
18022
|
// We use relative positioning so that the lint indicator can be
|
|
@@ -19403,8 +19283,6 @@ class Renderer extends React__namespace.Component {
|
|
|
19403
19283
|
|
|
19404
19284
|
// The i18n linter.
|
|
19405
19285
|
|
|
19406
|
-
// @ts-expect-error [FEI-5003] - TS2564 - Property 'lastRenderedMarkdown' has no initializer and is not definitely assigned in the constructor.
|
|
19407
|
-
|
|
19408
19286
|
// @ts-expect-error [FEI-5003] - TS2564 - Property 'reuseMarkdown' has no initializer and is not definitely assigned in the constructor.
|
|
19409
19287
|
|
|
19410
19288
|
// @ts-expect-error [FEI-5003] - TS2564 - Property 'translationIndex' has no initializer and is not definitely assigned in the constructor.
|
|
@@ -20567,9 +20445,6 @@ class Renderer extends React__namespace.Component {
|
|
|
20567
20445
|
}
|
|
20568
20446
|
render() {
|
|
20569
20447
|
const apiOptions = this.getApiOptions();
|
|
20570
|
-
const {
|
|
20571
|
-
KatexProvider
|
|
20572
|
-
} = getDependencies();
|
|
20573
20448
|
if (this.reuseMarkdown) {
|
|
20574
20449
|
return this.lastRenderedMarkdown;
|
|
20575
20450
|
}
|
|
@@ -20610,9 +20485,9 @@ class Renderer extends React__namespace.Component {
|
|
|
20610
20485
|
// Persues.TranslationComponent registry so that when jipt
|
|
20611
20486
|
// calls its before_dom_insert we can lookup this component by
|
|
20612
20487
|
// this attribute and render the text with markdown.
|
|
20613
|
-
return /*#__PURE__*/React__namespace.createElement(
|
|
20488
|
+
return /*#__PURE__*/React__namespace.createElement(DefinitionProvider, null, /*#__PURE__*/React__namespace.createElement("div", {
|
|
20614
20489
|
"data-perseus-component-index": this.translationIndex
|
|
20615
|
-
}, content))
|
|
20490
|
+
}, content));
|
|
20616
20491
|
}
|
|
20617
20492
|
}
|
|
20618
20493
|
|
|
@@ -20661,9 +20536,9 @@ class Renderer extends React__namespace.Component {
|
|
|
20661
20536
|
[ClassNames.RESPONSIVE_RENDERER]: true,
|
|
20662
20537
|
[ClassNames.TWO_COLUMN_RENDERER]: this._isTwoColumn
|
|
20663
20538
|
});
|
|
20664
|
-
this.lastRenderedMarkdown = /*#__PURE__*/React__namespace.createElement(
|
|
20539
|
+
this.lastRenderedMarkdown = /*#__PURE__*/React__namespace.createElement(DefinitionProvider, null, /*#__PURE__*/React__namespace.createElement("div", {
|
|
20665
20540
|
className: className
|
|
20666
|
-
}, markdownContents))
|
|
20541
|
+
}, markdownContents));
|
|
20667
20542
|
return this.lastRenderedMarkdown;
|
|
20668
20543
|
}
|
|
20669
20544
|
}
|
|
@@ -20939,13 +20814,6 @@ class MathOutput extends React__namespace.Component {
|
|
|
20939
20814
|
this._unbindBlurHandler();
|
|
20940
20815
|
}
|
|
20941
20816
|
}
|
|
20942
|
-
_defineProperty(MathOutput, "propTypes", {
|
|
20943
|
-
value: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].number]),
|
|
20944
|
-
className: PropTypes__default["default"].string,
|
|
20945
|
-
labelText: PropTypes__default["default"].string,
|
|
20946
|
-
onFocus: PropTypes__default["default"].func,
|
|
20947
|
-
onBlur: PropTypes__default["default"].func
|
|
20948
|
-
});
|
|
20949
20817
|
_defineProperty(MathOutput, "defaultProps", {
|
|
20950
20818
|
value: "",
|
|
20951
20819
|
onFocus: function () {},
|
|
@@ -21186,9 +21054,9 @@ class InputWithExamples extends React__namespace.Component {
|
|
|
21186
21054
|
, {
|
|
21187
21055
|
ref: "tooltip",
|
|
21188
21056
|
className: "perseus-formats-tooltip preview-measure",
|
|
21189
|
-
horizontalPosition:
|
|
21190
|
-
horizontalAlign:
|
|
21191
|
-
verticalPosition:
|
|
21057
|
+
horizontalPosition: HorizontalDirection.Left,
|
|
21058
|
+
horizontalAlign: HorizontalDirection.Left,
|
|
21059
|
+
verticalPosition: VerticalDirection.Bottom,
|
|
21192
21060
|
arrowSize: 10,
|
|
21193
21061
|
borderColor: "#ccc",
|
|
21194
21062
|
show: showExamples
|
|
@@ -21259,7 +21127,7 @@ class SimpleKeypadInput extends React__namespace.Component {
|
|
|
21259
21127
|
onFocus: () => {
|
|
21260
21128
|
if (keypadElement) {
|
|
21261
21129
|
keypadElement.configure({
|
|
21262
|
-
keypadType: mathInput.
|
|
21130
|
+
keypadType: mathInput.KeypadType.FRACTION
|
|
21263
21131
|
}, () => {
|
|
21264
21132
|
if (_this._isMounted) {
|
|
21265
21133
|
onFocus && onFocus();
|
|
@@ -27902,6 +27770,34 @@ class Graph extends React__namespace.Component {
|
|
|
27902
27770
|
return ___default["default"].pick(this.props, "range", "step", "markings", "labels", "backgroundImage", "showProtractor", "showRuler", "rulerLabel", "rulerTicks", "gridStep", "snapStep");
|
|
27903
27771
|
});
|
|
27904
27772
|
}
|
|
27773
|
+
componentDidMount() {
|
|
27774
|
+
this._setupGraphie(true);
|
|
27775
|
+
}
|
|
27776
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
27777
|
+
const potentialChanges = ["labels", "range", "step", "markings", "showProtractor", "showRuler", "rulerLabel", "rulerTicks", "gridStep", "snapStep"];
|
|
27778
|
+
const self = this;
|
|
27779
|
+
___default["default"].each(potentialChanges, function (prop) {
|
|
27780
|
+
if (!___default["default"].isEqual(self.props[prop], nextProps[prop])) {
|
|
27781
|
+
self._shouldSetupGraphie = true;
|
|
27782
|
+
}
|
|
27783
|
+
});
|
|
27784
|
+
}
|
|
27785
|
+
componentDidUpdate() {
|
|
27786
|
+
// Only setupGraphie once per componentDidUpdate().
|
|
27787
|
+
// See explanation in setupGraphie().
|
|
27788
|
+
this._hasSetupGraphieThisUpdate = false;
|
|
27789
|
+
if (this._shouldSetupGraphie) {
|
|
27790
|
+
this._setupGraphie(false);
|
|
27791
|
+
this._shouldSetupGraphie = false;
|
|
27792
|
+
}
|
|
27793
|
+
}
|
|
27794
|
+
|
|
27795
|
+
/* Reset the graphie canvas to its initial state
|
|
27796
|
+
*
|
|
27797
|
+
* Use when re-rendering the parent component and you need a blank
|
|
27798
|
+
* graphie.
|
|
27799
|
+
*/
|
|
27800
|
+
|
|
27905
27801
|
render() {
|
|
27906
27802
|
let image;
|
|
27907
27803
|
const imageData = this.props.backgroundImage;
|
|
@@ -27940,55 +27836,7 @@ class Graph extends React__namespace.Component {
|
|
|
27940
27836
|
ref: "graphieDiv"
|
|
27941
27837
|
}));
|
|
27942
27838
|
}
|
|
27943
|
-
componentDidMount() {
|
|
27944
|
-
this._setupGraphie(true);
|
|
27945
|
-
}
|
|
27946
|
-
componentDidUpdate() {
|
|
27947
|
-
// Only setupGraphie once per componentDidUpdate().
|
|
27948
|
-
// See explanation in setupGraphie().
|
|
27949
|
-
this._hasSetupGraphieThisUpdate = false;
|
|
27950
|
-
if (this._shouldSetupGraphie) {
|
|
27951
|
-
this._setupGraphie(false);
|
|
27952
|
-
this._shouldSetupGraphie = false;
|
|
27953
|
-
}
|
|
27954
|
-
}
|
|
27955
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
27956
|
-
const potentialChanges = ["labels", "range", "step", "markings", "showProtractor", "showRuler", "rulerLabel", "rulerTicks", "gridStep", "snapStep"];
|
|
27957
|
-
const self = this;
|
|
27958
|
-
___default["default"].each(potentialChanges, function (prop) {
|
|
27959
|
-
if (!___default["default"].isEqual(self.props[prop], nextProps[prop])) {
|
|
27960
|
-
self._shouldSetupGraphie = true;
|
|
27961
|
-
}
|
|
27962
|
-
});
|
|
27963
|
-
}
|
|
27964
|
-
|
|
27965
|
-
/* Reset the graphie canvas to its initial state
|
|
27966
|
-
*
|
|
27967
|
-
* Use when re-rendering the parent component and you need a blank
|
|
27968
|
-
* graphie.
|
|
27969
|
-
*/
|
|
27970
27839
|
}
|
|
27971
|
-
_defineProperty(Graph, "propTypes", {
|
|
27972
|
-
box: PropTypes__default["default"].array.isRequired,
|
|
27973
|
-
labels: PropTypes__default["default"].arrayOf(PropTypes__default["default"].string),
|
|
27974
|
-
range: PropTypes__default["default"].arrayOf(PropTypes__default["default"].arrayOf(PropTypes__default["default"].number)),
|
|
27975
|
-
step: PropTypes__default["default"].arrayOf(PropTypes__default["default"].number),
|
|
27976
|
-
gridStep: PropTypes__default["default"].arrayOf(PropTypes__default["default"].number),
|
|
27977
|
-
snapStep: PropTypes__default["default"].arrayOf(PropTypes__default["default"].number),
|
|
27978
|
-
markings: PropTypes__default["default"].string,
|
|
27979
|
-
backgroundImage: PropTypes__default["default"].shape({
|
|
27980
|
-
url: PropTypes__default["default"].string
|
|
27981
|
-
}),
|
|
27982
|
-
showProtractor: PropTypes__default["default"].bool,
|
|
27983
|
-
showRuler: PropTypes__default["default"].bool,
|
|
27984
|
-
rulerLabel: PropTypes__default["default"].string,
|
|
27985
|
-
rulerTicks: PropTypes__default["default"].number,
|
|
27986
|
-
onGraphieUpdated: PropTypes__default["default"].func,
|
|
27987
|
-
instructions: PropTypes__default["default"].string,
|
|
27988
|
-
onClick: PropTypes__default["default"].func,
|
|
27989
|
-
setDrawingAreaAvailable: PropTypes__default["default"].func,
|
|
27990
|
-
isMobile: PropTypes__default["default"].bool
|
|
27991
|
-
});
|
|
27992
27840
|
_defineProperty(Graph, "defaultProps", {
|
|
27993
27841
|
labels: ["x", "y"],
|
|
27994
27842
|
range: [[-10, 10], [-10, 10]],
|
|
@@ -28001,10 +27849,6 @@ _defineProperty(Graph, "defaultProps", {
|
|
|
28001
27849
|
showRuler: false,
|
|
28002
27850
|
rulerLabel: "",
|
|
28003
27851
|
rulerTicks: 10,
|
|
28004
|
-
instructions: null,
|
|
28005
|
-
onGraphieUpdated: null,
|
|
28006
|
-
onClick: null,
|
|
28007
|
-
onMouseDown: null,
|
|
28008
27852
|
isMobile: false
|
|
28009
27853
|
});
|
|
28010
27854
|
|
|
@@ -29484,7 +29328,10 @@ class InteractiveGraph extends React__namespace.Component {
|
|
|
29484
29328
|
} else {
|
|
29485
29329
|
instructions = undefined;
|
|
29486
29330
|
}
|
|
29487
|
-
|
|
29331
|
+
let onMouseDown;
|
|
29332
|
+
if (this.isClickToAddPoints()) {
|
|
29333
|
+
onMouseDown = this.handleAddPointsMouseDown;
|
|
29334
|
+
}
|
|
29488
29335
|
const gridStep = this.props.gridStep || Util.getGridStep(this.props.range, this.props.step, box[0]);
|
|
29489
29336
|
const snapStep = this.props.snapStep || Util.snapStepFromGridStep(gridStep);
|
|
29490
29337
|
const isMobile = this.props.apiOptions.isMobile;
|
|
@@ -30067,7 +29914,6 @@ _defineProperty(InteractiveGraph, "defaultProps", {
|
|
|
30067
29914
|
labels: ["x", "y"],
|
|
30068
29915
|
range: [[-10, 10], [-10, 10]],
|
|
30069
29916
|
step: [1, 1],
|
|
30070
|
-
// @ts-expect-error [FEI-5003] - TS2739 - Type '{ readonly url: null; }' is missing the following properties from type 'PerseusImageBackground': width, height
|
|
30071
29917
|
backgroundImage: defaultBackgroundImage$1,
|
|
30072
29918
|
markings: "graph",
|
|
30073
29919
|
showTooltips: false,
|
|
@@ -32430,14 +32276,18 @@ var LightsPuzzle$1 = {
|
|
|
32430
32276
|
transform: transformProps
|
|
32431
32277
|
};
|
|
32432
32278
|
|
|
32433
|
-
|
|
32434
|
-
|
|
32435
|
-
|
|
32436
|
-
|
|
32437
|
-
|
|
32438
|
-
|
|
32439
|
-
|
|
32440
|
-
|
|
32279
|
+
let Layout = /*#__PURE__*/function (Layout) {
|
|
32280
|
+
Layout["HORIZONTAL"] = "horizontal";
|
|
32281
|
+
Layout["VERTICAL"] = "vertical";
|
|
32282
|
+
return Layout;
|
|
32283
|
+
}({});
|
|
32284
|
+
var ItemState = /*#__PURE__*/function (ItemState) {
|
|
32285
|
+
ItemState["STATIC"] = "static";
|
|
32286
|
+
ItemState["DRAGGING"] = "dragging";
|
|
32287
|
+
ItemState["ANIMATING"] = "animating";
|
|
32288
|
+
ItemState["DISABLED"] = "disabled";
|
|
32289
|
+
return ItemState;
|
|
32290
|
+
}(ItemState || {}); // Augment the given position with the scroll position of the offset parent.
|
|
32441
32291
|
const addOffsetParentScroll = ($el, position) => {
|
|
32442
32292
|
// NOTE(slim): $(el).offsetParent() is NOT equivalent to $el[0].offsetParent.
|
|
32443
32293
|
// Specifically, when `el` is not positioned, then the native HTMLElement.offsetParent
|
|
@@ -32451,14 +32301,13 @@ const addOffsetParentScroll = ($el, position) => {
|
|
|
32451
32301
|
left: position.left + $offsetParent.scrollLeft()
|
|
32452
32302
|
};
|
|
32453
32303
|
};
|
|
32454
|
-
|
|
32455
32304
|
// A placeholder that appears in the sortable whenever an item is dragged.
|
|
32456
32305
|
class Placeholder extends React__namespace.Component {
|
|
32457
32306
|
render() {
|
|
32458
32307
|
const {
|
|
32459
32308
|
layout
|
|
32460
32309
|
} = this.props;
|
|
32461
|
-
const className = aphrodite.css(styles$e.card, styles$e.placeholder, layout === HORIZONTAL
|
|
32310
|
+
const className = aphrodite.css(styles$e.card, styles$e.placeholder, layout === Layout.HORIZONTAL && styles$e.horizontalCard);
|
|
32462
32311
|
const style = {
|
|
32463
32312
|
width: this.props.width,
|
|
32464
32313
|
height: this.props.height
|
|
@@ -32472,11 +32321,6 @@ class Placeholder extends React__namespace.Component {
|
|
|
32472
32321
|
});
|
|
32473
32322
|
}
|
|
32474
32323
|
}
|
|
32475
|
-
_defineProperty(Placeholder, "propTypes", {
|
|
32476
|
-
layout: PropTypes__default["default"].oneOf([HORIZONTAL$2, VERTICAL$1]),
|
|
32477
|
-
width: PropTypes__default["default"].number.isRequired,
|
|
32478
|
-
height: PropTypes__default["default"].number.isRequired
|
|
32479
|
-
});
|
|
32480
32324
|
// A draggable item in the sortable. Can be in one of four states:
|
|
32481
32325
|
// Static: The item is not being interacted with.
|
|
32482
32326
|
// Dragging: The item is being dragged.
|
|
@@ -32503,7 +32347,8 @@ class Draggable extends React__namespace.Component {
|
|
|
32503
32347
|
mouse: {
|
|
32504
32348
|
left: 0,
|
|
32505
32349
|
top: 0
|
|
32506
|
-
}
|
|
32350
|
+
},
|
|
32351
|
+
dragging: false
|
|
32507
32352
|
});
|
|
32508
32353
|
_defineProperty(this, "getCurrentPosition", () => {
|
|
32509
32354
|
return {
|
|
@@ -32522,7 +32367,7 @@ class Draggable extends React__namespace.Component {
|
|
|
32522
32367
|
$__default["default"](document).off("mouseup", this.onMouseUp);
|
|
32523
32368
|
});
|
|
32524
32369
|
_defineProperty(this, "onMouseDown", event => {
|
|
32525
|
-
if (this.props.
|
|
32370
|
+
if (this.props.state !== ItemState.STATIC) {
|
|
32526
32371
|
return;
|
|
32527
32372
|
}
|
|
32528
32373
|
if (!(event.button === 0 || event.touches != null && event.touches.length === 1)) {
|
|
@@ -32564,7 +32409,7 @@ class Draggable extends React__namespace.Component {
|
|
|
32564
32409
|
});
|
|
32565
32410
|
});
|
|
32566
32411
|
_defineProperty(this, "onMouseMove", event => {
|
|
32567
|
-
const notDragging = this.props.
|
|
32412
|
+
const notDragging = this.props.state !== ItemState.DRAGGING || !this.state.dragging;
|
|
32568
32413
|
if (notDragging) {
|
|
32569
32414
|
return;
|
|
32570
32415
|
}
|
|
@@ -32582,7 +32427,7 @@ class Draggable extends React__namespace.Component {
|
|
|
32582
32427
|
}
|
|
32583
32428
|
});
|
|
32584
32429
|
_defineProperty(this, "onMouseUp", event => {
|
|
32585
|
-
const notDragging = this.props.
|
|
32430
|
+
const notDragging = this.props.state !== ItemState.DRAGGING || !this.state.dragging;
|
|
32586
32431
|
if (notDragging) {
|
|
32587
32432
|
return;
|
|
32588
32433
|
}
|
|
@@ -32636,20 +32481,20 @@ class Draggable extends React__namespace.Component {
|
|
|
32636
32481
|
const {
|
|
32637
32482
|
includePadding,
|
|
32638
32483
|
layout,
|
|
32639
|
-
type
|
|
32484
|
+
state: type
|
|
32640
32485
|
} = this.props;
|
|
32641
32486
|
|
|
32642
32487
|
// We need to keep backwards compatbility with rules specified directly
|
|
32643
32488
|
// in CSS. Hence the hacky tacking on of manual classNames.
|
|
32644
32489
|
// See sortable.less for details.
|
|
32645
|
-
let className = aphrodite.css(styles$e.card, styles$e.draggable, layout === HORIZONTAL
|
|
32490
|
+
let className = aphrodite.css(styles$e.card, styles$e.draggable, layout === Layout.HORIZONTAL && styles$e.horizontalCard, layout === Layout.VERTICAL && styles$e.verticalCard, type === ItemState.DRAGGING && styles$e.dragging, type === ItemState.DISABLED && styles$e.disabled, !includePadding && styles$e.unpaddedCard) + " " + ClassNames.INTERACTIVE + " perseus-sortable-draggable";
|
|
32646
32491
|
if (!includePadding) {
|
|
32647
32492
|
className += " perseus-sortable-draggable-unpadded";
|
|
32648
32493
|
}
|
|
32649
32494
|
const style = {
|
|
32650
32495
|
position: "static"
|
|
32651
32496
|
};
|
|
32652
|
-
if (this.props.
|
|
32497
|
+
if (this.props.state === ItemState.DRAGGING || this.props.state === ItemState.ANIMATING) {
|
|
32653
32498
|
___default["default"].extend(style, {
|
|
32654
32499
|
position: "absolute"
|
|
32655
32500
|
}, this.getCurrentPosition());
|
|
@@ -32679,10 +32524,10 @@ class Draggable extends React__namespace.Component {
|
|
|
32679
32524
|
}));
|
|
32680
32525
|
}
|
|
32681
32526
|
componentDidUpdate(prevProps) {
|
|
32682
|
-
if (this.props.
|
|
32527
|
+
if (this.props.state === prevProps.state) {
|
|
32683
32528
|
return;
|
|
32684
32529
|
}
|
|
32685
|
-
if (this.props.
|
|
32530
|
+
if (this.props.state === ItemState.ANIMATING) {
|
|
32686
32531
|
// Start animating
|
|
32687
32532
|
const current = this.getCurrentPosition();
|
|
32688
32533
|
const duration = 15 * Math.sqrt(Math.sqrt(Math.pow(this.props.endPosition.left - current.left, 2) + Math.pow(this.props.endPosition.top - current.top, 2)));
|
|
@@ -32693,29 +32538,16 @@ class Draggable extends React__namespace.Component {
|
|
|
32693
32538
|
// Animating -> Static
|
|
32694
32539
|
complete: this.props.onAnimationEnd
|
|
32695
32540
|
});
|
|
32696
|
-
} else if (this.props.
|
|
32541
|
+
} else if (this.props.state === ItemState.STATIC) {
|
|
32697
32542
|
// Ensure that any animations are done
|
|
32698
32543
|
// @ts-expect-error [FEI-5003] - TS2769 - No overload matches this call. | TS2339 - Property 'finish' does not exist on type 'JQueryStatic'.
|
|
32699
32544
|
$__default["default"](ReactDOM__default["default"].findDOMNode(this)).finish();
|
|
32700
32545
|
}
|
|
32701
32546
|
}
|
|
32702
32547
|
}
|
|
32703
|
-
_defineProperty(Draggable, "propTypes", {
|
|
32704
|
-
content: PropTypes__default["default"].string.isRequired,
|
|
32705
|
-
endPosition: PropTypes__default["default"].object.isRequired,
|
|
32706
|
-
includePadding: PropTypes__default["default"].bool,
|
|
32707
|
-
layout: PropTypes__default["default"].oneOf([HORIZONTAL$2, VERTICAL$1]),
|
|
32708
|
-
onAnimationEnd: PropTypes__default["default"].func.isRequired,
|
|
32709
|
-
onMouseDown: PropTypes__default["default"].func.isRequired,
|
|
32710
|
-
onMouseMove: PropTypes__default["default"].func.isRequired,
|
|
32711
|
-
onMouseUp: PropTypes__default["default"].func.isRequired,
|
|
32712
|
-
onRender: PropTypes__default["default"].func.isRequired,
|
|
32713
|
-
type: PropTypes__default["default"].oneOf([STATIC, DRAGGING, ANIMATING, DISABLED]),
|
|
32714
|
-
linterContext: PerseusLinter__namespace.linterContextProps
|
|
32715
|
-
});
|
|
32716
32548
|
_defineProperty(Draggable, "defaultProps", {
|
|
32717
32549
|
includePadding: true,
|
|
32718
|
-
type: STATIC,
|
|
32550
|
+
type: ItemState.STATIC,
|
|
32719
32551
|
linterContext: PerseusLinter__namespace.linterContextDefault
|
|
32720
32552
|
});
|
|
32721
32553
|
class Sortable extends React__namespace.Component {
|
|
@@ -32730,7 +32562,7 @@ class Sortable extends React__namespace.Component {
|
|
|
32730
32562
|
}, 20));
|
|
32731
32563
|
this.state = {
|
|
32732
32564
|
items: Sortable.itemsFromProps(this.props),
|
|
32733
|
-
|
|
32565
|
+
texRendererLoaded: false
|
|
32734
32566
|
};
|
|
32735
32567
|
}
|
|
32736
32568
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
@@ -32758,20 +32590,13 @@ class Sortable extends React__namespace.Component {
|
|
|
32758
32590
|
}, 0);
|
|
32759
32591
|
}
|
|
32760
32592
|
}
|
|
32761
|
-
componentDidMount() {
|
|
32762
|
-
getDependencies().getKaTeX().then(katex => {
|
|
32763
|
-
this.setState({
|
|
32764
|
-
katex
|
|
32765
|
-
});
|
|
32766
|
-
});
|
|
32767
|
-
}
|
|
32768
32593
|
static itemsFromProps(props) {
|
|
32769
|
-
const
|
|
32594
|
+
const state = props.disabled ? ItemState.DISABLED : ItemState.STATIC;
|
|
32770
32595
|
return props.options.map((option, i) => {
|
|
32771
32596
|
return {
|
|
32772
32597
|
option: option,
|
|
32773
32598
|
key: i,
|
|
32774
|
-
|
|
32599
|
+
state,
|
|
32775
32600
|
endPosition: {},
|
|
32776
32601
|
width: 0,
|
|
32777
32602
|
height: 0
|
|
@@ -32794,8 +32619,7 @@ class Sortable extends React__namespace.Component {
|
|
|
32794
32619
|
// explictly set on Draggables - this prevents them from changing size
|
|
32795
32620
|
// or shape while being dragged.
|
|
32796
32621
|
|
|
32797
|
-
|
|
32798
|
-
let items = ___default["default"].clone(this.state.items);
|
|
32622
|
+
let items = [...this.state.items];
|
|
32799
32623
|
|
|
32800
32624
|
// Fetches a jQuery list of elements for each item
|
|
32801
32625
|
const $items = ___default["default"].map(items, function (item) {
|
|
@@ -32813,7 +32637,7 @@ class Sortable extends React__namespace.Component {
|
|
|
32813
32637
|
if (constraints !== null && constraints !== void 0 && constraints.width) {
|
|
32814
32638
|
// Items must be at least as wide as the specified constraint
|
|
32815
32639
|
syncWidth = ___default["default"].max(widths.concat(constraints.width));
|
|
32816
|
-
} else if (layout === VERTICAL
|
|
32640
|
+
} else if (layout === Layout.VERTICAL) {
|
|
32817
32641
|
// Sync widths to get a clean column
|
|
32818
32642
|
syncWidth = ___default["default"].max(widths);
|
|
32819
32643
|
}
|
|
@@ -32821,21 +32645,17 @@ class Sortable extends React__namespace.Component {
|
|
|
32821
32645
|
if (constraints !== null && constraints !== void 0 && constraints.height) {
|
|
32822
32646
|
// Items must be at least as high as the specified constraint
|
|
32823
32647
|
syncHeight = ___default["default"].max(heights.concat(constraints.height));
|
|
32824
|
-
} else if (layout === HORIZONTAL
|
|
32648
|
+
} else if (layout === Layout.HORIZONTAL) {
|
|
32825
32649
|
// Sync widths to get a clean row
|
|
32826
32650
|
syncHeight = ___default["default"].max(heights);
|
|
32827
32651
|
}
|
|
32828
|
-
|
|
32829
|
-
// @ts-expect-error [FEI-5003] - TS2740 - Type 'any[]' is missing the following properties from type 'SortableItem': option, key, type, endPosition, and 2 more.
|
|
32830
32652
|
items = ___default["default"].map(items, function (item, i) {
|
|
32831
32653
|
item.width = syncWidth || widths[i];
|
|
32832
32654
|
item.height = syncHeight || heights[i];
|
|
32833
32655
|
return item;
|
|
32834
32656
|
});
|
|
32835
|
-
|
|
32836
|
-
// @ts-expect-error [FEI-5003] - TS2740 - Type 'SortableItem' is missing the following properties from type 'readonly SortableItem[]': length, concat, join, slice, and 18 more.
|
|
32837
32657
|
this.setState({
|
|
32838
|
-
items
|
|
32658
|
+
items
|
|
32839
32659
|
}, () => {
|
|
32840
32660
|
this.props.onMeasure && this.props.onMeasure({
|
|
32841
32661
|
widths: widths,
|
|
@@ -32845,14 +32665,30 @@ class Sortable extends React__namespace.Component {
|
|
|
32845
32665
|
}
|
|
32846
32666
|
render() {
|
|
32847
32667
|
var _this$props$constrain, _this$props$constrain2;
|
|
32848
|
-
//
|
|
32849
|
-
//
|
|
32850
|
-
//
|
|
32851
|
-
//
|
|
32852
|
-
//
|
|
32853
|
-
//
|
|
32854
|
-
|
|
32855
|
-
|
|
32668
|
+
// To minimize layout shift, we display a spinner until our math
|
|
32669
|
+
// renderer is ready to render the math inside the sortable. To
|
|
32670
|
+
// do this, we:
|
|
32671
|
+
// - render a dummy TeX component to force the math renderer to load
|
|
32672
|
+
// - display a spinner until the TeX component calls its onRender
|
|
32673
|
+
// callback, signifying that the math is rendered (from which we can
|
|
32674
|
+
// infer that the math renderer has loaded)
|
|
32675
|
+
//
|
|
32676
|
+
// If we didn't do this, the user might see a sortable with empty
|
|
32677
|
+
// cells on first render, and then the math would pop in a few moments
|
|
32678
|
+
// later once the rendering library loaded.
|
|
32679
|
+
if (this.props.waitForTexRendererToLoad && !this.state.texRendererLoaded) {
|
|
32680
|
+
const {
|
|
32681
|
+
TeX
|
|
32682
|
+
} = getDependencies();
|
|
32683
|
+
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(wonderBlocksProgressSpinner.CircularSpinner, null), /*#__PURE__*/React__namespace.createElement("div", {
|
|
32684
|
+
style: {
|
|
32685
|
+
display: "none"
|
|
32686
|
+
}
|
|
32687
|
+
}, /*#__PURE__*/React__namespace.createElement(TeX, {
|
|
32688
|
+
onRender: () => this.setState({
|
|
32689
|
+
texRendererLoaded: true
|
|
32690
|
+
})
|
|
32691
|
+
}, "1")));
|
|
32856
32692
|
}
|
|
32857
32693
|
const cards = [];
|
|
32858
32694
|
const {
|
|
@@ -32861,19 +32697,19 @@ class Sortable extends React__namespace.Component {
|
|
|
32861
32697
|
// We need to keep backwards compatbility with rules specified directly
|
|
32862
32698
|
// in CSS. See sortable.less for details.
|
|
32863
32699
|
const className = aphrodite.css(styles$e.sortable) + " perseus-sortable";
|
|
32864
|
-
const syncWidth = ((_this$props$constrain = this.props.constraints) === null || _this$props$constrain === void 0 ? void 0 : _this$props$constrain.width) || layout === VERTICAL
|
|
32865
|
-
const syncHeight = ((_this$props$constrain2 = this.props.constraints) === null || _this$props$constrain2 === void 0 ? void 0 : _this$props$constrain2.height) || layout === HORIZONTAL
|
|
32700
|
+
const syncWidth = ((_this$props$constrain = this.props.constraints) === null || _this$props$constrain === void 0 ? void 0 : _this$props$constrain.width) || layout === Layout.VERTICAL;
|
|
32701
|
+
const syncHeight = ((_this$props$constrain2 = this.props.constraints) === null || _this$props$constrain2 === void 0 ? void 0 : _this$props$constrain2.height) || layout === Layout.HORIZONTAL;
|
|
32866
32702
|
___default["default"].each(this.state.items, function (item, i, items) {
|
|
32867
32703
|
const isLast = i === items.length - 1;
|
|
32868
|
-
const isStatic = item.
|
|
32704
|
+
const isStatic = item.state === ItemState.STATIC || item.state === ItemState.DISABLED;
|
|
32869
32705
|
let margin;
|
|
32870
32706
|
|
|
32871
32707
|
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
32872
|
-
if (this.props.layout === HORIZONTAL
|
|
32708
|
+
if (this.props.layout === Layout.HORIZONTAL) {
|
|
32873
32709
|
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
32874
32710
|
margin = "0 " + this.props.margin + "px 0 0"; // right
|
|
32875
32711
|
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
32876
|
-
} else if (this.props.layout === VERTICAL
|
|
32712
|
+
} else if (this.props.layout === Layout.VERTICAL) {
|
|
32877
32713
|
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
32878
32714
|
margin = "0 0 " + this.props.margin + "px 0"; // bottom
|
|
32879
32715
|
}
|
|
@@ -32881,7 +32717,7 @@ class Sortable extends React__namespace.Component {
|
|
|
32881
32717
|
cards.push( /*#__PURE__*/React__namespace.createElement(Draggable, {
|
|
32882
32718
|
content: item.option,
|
|
32883
32719
|
key: item.key,
|
|
32884
|
-
|
|
32720
|
+
state: item.state
|
|
32885
32721
|
// @ts-expect-error [FEI-5003] - TS2769 - No overload matches this call.
|
|
32886
32722
|
,
|
|
32887
32723
|
ref: item.key,
|
|
@@ -32930,7 +32766,7 @@ class Sortable extends React__namespace.Component {
|
|
|
32930
32766
|
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
32931
32767
|
this, item.key)
|
|
32932
32768
|
}));
|
|
32933
|
-
if (item.
|
|
32769
|
+
if (item.state === ItemState.DRAGGING || item.state === ItemState.ANIMATING) {
|
|
32934
32770
|
cards.push( /*#__PURE__*/React__namespace.createElement(Placeholder, {
|
|
32935
32771
|
key: "placeholder_" + item.key,
|
|
32936
32772
|
ref: "placeholder_" + item.key,
|
|
@@ -32949,7 +32785,7 @@ class Sortable extends React__namespace.Component {
|
|
|
32949
32785
|
// Static -> Dragging
|
|
32950
32786
|
const items = ___default["default"].map(this.state.items, function (item) {
|
|
32951
32787
|
if (item.key === key) {
|
|
32952
|
-
item.
|
|
32788
|
+
item.state = ItemState.DRAGGING;
|
|
32953
32789
|
}
|
|
32954
32790
|
return item;
|
|
32955
32791
|
});
|
|
@@ -33009,7 +32845,7 @@ class Sortable extends React__namespace.Component {
|
|
|
33009
32845
|
|
|
33010
32846
|
// @ts-expect-error [FEI-5003] - TS2551 - Property 'splice' does not exist on type 'readonly SortableItem[]'. Did you mean 'slice'?
|
|
33011
32847
|
items.splice(currentIndex, 1);
|
|
33012
|
-
if (this.props.layout === HORIZONTAL
|
|
32848
|
+
if (this.props.layout === Layout.HORIZONTAL) {
|
|
33013
32849
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'offset' does not exist on type 'JQueryStatic'. | TS2339 - Property 'offset' does not exist on type 'JQueryStatic'.
|
|
33014
32850
|
const midWidth = $draggable.offset().left - $sortable.offset().left;
|
|
33015
32851
|
let sumWidth = 0;
|
|
@@ -33049,7 +32885,7 @@ class Sortable extends React__namespace.Component {
|
|
|
33049
32885
|
const nextAnimationFrame = requestAnimationFrame(() => {
|
|
33050
32886
|
const items = ___default["default"].map(this.state.items, function (item) {
|
|
33051
32887
|
if (item.key === key) {
|
|
33052
|
-
item.
|
|
32888
|
+
item.state = ItemState.ANIMATING;
|
|
33053
32889
|
const $placeholder = $__default["default"](
|
|
33054
32890
|
// @ts-expect-error [FEI-5003] - TS2769 - No overload matches this call.
|
|
33055
32891
|
ReactDOM__default["default"].findDOMNode(
|
|
@@ -33079,7 +32915,7 @@ class Sortable extends React__namespace.Component {
|
|
|
33079
32915
|
// Animating -> Static
|
|
33080
32916
|
const items = ___default["default"].map(this.state.items, function (item) {
|
|
33081
32917
|
if (item.key === key) {
|
|
33082
|
-
item.
|
|
32918
|
+
item.state = ItemState.STATIC;
|
|
33083
32919
|
}
|
|
33084
32920
|
return item;
|
|
33085
32921
|
});
|
|
@@ -33092,7 +32928,7 @@ class Sortable extends React__namespace.Component {
|
|
|
33092
32928
|
}
|
|
33093
32929
|
}
|
|
33094
32930
|
_defineProperty(Sortable, "defaultProps", {
|
|
33095
|
-
layout: HORIZONTAL
|
|
32931
|
+
layout: Layout.HORIZONTAL,
|
|
33096
32932
|
padding: true,
|
|
33097
32933
|
disabled: false,
|
|
33098
32934
|
constraints: {},
|
|
@@ -33100,7 +32936,7 @@ _defineProperty(Sortable, "defaultProps", {
|
|
|
33100
32936
|
margin: 5,
|
|
33101
32937
|
onChange: function () {},
|
|
33102
32938
|
linterContext: PerseusLinter__namespace.linterContextDefault,
|
|
33103
|
-
|
|
32939
|
+
waitForTexRendererToLoad: true
|
|
33104
32940
|
});
|
|
33105
32941
|
const styles$e = aphrodite.StyleSheet.create({
|
|
33106
32942
|
sortable: {
|
|
@@ -33162,7 +32998,7 @@ class Matcher extends React__namespace.Component {
|
|
|
33162
32998
|
_defineProperty(this, "state", {
|
|
33163
32999
|
leftHeight: 0,
|
|
33164
33000
|
rightHeight: 0,
|
|
33165
|
-
|
|
33001
|
+
texRendererLoaded: false
|
|
33166
33002
|
});
|
|
33167
33003
|
_defineProperty(this, "changeAndTrack", e => {
|
|
33168
33004
|
this.props.onChange(e);
|
|
@@ -33181,10 +33017,10 @@ class Matcher extends React__namespace.Component {
|
|
|
33181
33017
|
});
|
|
33182
33018
|
});
|
|
33183
33019
|
_defineProperty(this, "getUserInput", () => {
|
|
33184
|
-
// If
|
|
33185
|
-
// of the sortables on the left and right, so we just return
|
|
33186
|
-
// arrays until we render for the first time.
|
|
33187
|
-
if (!this.state.
|
|
33020
|
+
// If the math renderer hasn't loaded then we won't be able to get the
|
|
33021
|
+
// contents of the sortables on the left and right, so we just return
|
|
33022
|
+
// empty arrays until we render for the first time.
|
|
33023
|
+
if (!this.state.texRendererLoaded) {
|
|
33188
33024
|
return {
|
|
33189
33025
|
left: [],
|
|
33190
33026
|
right: []
|
|
@@ -33214,20 +33050,33 @@ class Matcher extends React__namespace.Component {
|
|
|
33214
33050
|
return Matcher.validate(this.getUserInput(), rubric);
|
|
33215
33051
|
});
|
|
33216
33052
|
}
|
|
33217
|
-
componentDidMount() {
|
|
33218
|
-
getDependencies().getKaTeX().then(katex => this.setState({
|
|
33219
|
-
katex
|
|
33220
|
-
}));
|
|
33221
|
-
}
|
|
33222
33053
|
render() {
|
|
33223
|
-
//
|
|
33224
|
-
//
|
|
33225
|
-
//
|
|
33226
|
-
//
|
|
33227
|
-
//
|
|
33228
|
-
//
|
|
33229
|
-
|
|
33230
|
-
|
|
33054
|
+
// To minimize layout shift, we display a spinner until our math
|
|
33055
|
+
// renderer is ready to render the math inside the matcher. To
|
|
33056
|
+
// do this, we:
|
|
33057
|
+
// - render a dummy TeX component to force the math renderer to load
|
|
33058
|
+
// - display a spinner until the TeX component calls its onRender
|
|
33059
|
+
// callback, signifying that the math is rendered (from which we can
|
|
33060
|
+
// infer that the math renderer has loaded)
|
|
33061
|
+
//
|
|
33062
|
+
// If we didn't do this, the user might see a matcher with empty
|
|
33063
|
+
// columns on first render, and then the math would pop in a few
|
|
33064
|
+
// moments later once the rendering library loaded.
|
|
33065
|
+
if (!this.state.texRendererLoaded) {
|
|
33066
|
+
const {
|
|
33067
|
+
TeX
|
|
33068
|
+
} = getDependencies();
|
|
33069
|
+
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(wonderBlocksProgressSpinner.CircularSpinner, null), /*#__PURE__*/React__namespace.createElement("div", {
|
|
33070
|
+
style: {
|
|
33071
|
+
display: "none"
|
|
33072
|
+
}
|
|
33073
|
+
}, /*#__PURE__*/React__namespace.createElement(TeX, {
|
|
33074
|
+
onRender: () => {
|
|
33075
|
+
this.setState({
|
|
33076
|
+
texRendererLoaded: true
|
|
33077
|
+
});
|
|
33078
|
+
}
|
|
33079
|
+
}, "1")));
|
|
33231
33080
|
}
|
|
33232
33081
|
|
|
33233
33082
|
// Use the same random() function to shuffle both columns sequentially
|
|
@@ -33265,7 +33114,7 @@ class Matcher extends React__namespace.Component {
|
|
|
33265
33114
|
className: aphrodite.css(styles$d.column)
|
|
33266
33115
|
}, /*#__PURE__*/React__namespace.createElement(Sortable, {
|
|
33267
33116
|
options: left,
|
|
33268
|
-
layout:
|
|
33117
|
+
layout: Layout.VERTICAL,
|
|
33269
33118
|
padding: this.props.padding,
|
|
33270
33119
|
disabled: !this.props.orderMatters,
|
|
33271
33120
|
constraints: constraints,
|
|
@@ -33282,7 +33131,7 @@ class Matcher extends React__namespace.Component {
|
|
|
33282
33131
|
// @ts-expect-error [FEI-5003] - TS2322 - Type 'readonly unknown[]' is not assignable to type 'readonly string[]'.
|
|
33283
33132
|
, {
|
|
33284
33133
|
options: right,
|
|
33285
|
-
layout:
|
|
33134
|
+
layout: Layout.VERTICAL,
|
|
33286
33135
|
padding: this.props.padding,
|
|
33287
33136
|
constraints: constraints,
|
|
33288
33137
|
onMeasure: this.onMeasureRight,
|
|
@@ -39935,11 +39784,7 @@ class Histogram extends React__namespace.Component {
|
|
|
39935
39784
|
box: this.props.box,
|
|
39936
39785
|
range: range,
|
|
39937
39786
|
data: data,
|
|
39938
|
-
scale: [
|
|
39939
|
-
// @ts-expect-error [FEI-5003] - TS2345 - Argument of type 'any[]' is not assignable to parameter of type 'Coordinates'.
|
|
39940
|
-
Util.scaleFromExtent(range[0], this.props.box[0]),
|
|
39941
|
-
// @ts-expect-error [FEI-5003] - TS2345 - Argument of type 'any[]' is not assignable to parameter of type 'Coordinates'.
|
|
39942
|
-
Util.scaleFromExtent(range[1], this.props.box[1])]
|
|
39787
|
+
scale: [Util.scaleFromExtent(range[0], this.props.box[0]), Util.scaleFromExtent(range[1], this.props.box[1])]
|
|
39943
39788
|
};
|
|
39944
39789
|
const axisStyle = {
|
|
39945
39790
|
stroke: "#000",
|
|
@@ -45775,99 +45620,90 @@ _defineProperty(ElementContainer, "defaultProps", {
|
|
|
45775
45620
|
title: "More"
|
|
45776
45621
|
});
|
|
45777
45622
|
|
|
45778
|
-
|
|
45779
|
-
|
|
45780
|
-
|
|
45781
|
-
|
|
45782
|
-
|
|
45783
|
-
|
|
45784
|
-
|
|
45785
|
-
|
|
45786
|
-
|
|
45787
|
-
|
|
45788
|
-
|
|
45789
|
-
|
|
45790
|
-
|
|
45791
|
-
|
|
45792
|
-
|
|
45793
|
-
|
|
45794
|
-
|
|
45795
|
-
|
|
45796
|
-
|
|
45797
|
-
|
|
45798
|
-
|
|
45799
|
-
|
|
45800
|
-
|
|
45801
|
-
|
|
45802
|
-
|
|
45803
|
-
|
|
45804
|
-
|
|
45805
|
-
|
|
45806
|
-
|
|
45807
|
-
|
|
45808
|
-
|
|
45809
|
-
|
|
45810
|
-
|
|
45811
|
-
|
|
45812
|
-
|
|
45813
|
-
|
|
45814
|
-
|
|
45815
|
-
|
|
45816
|
-
|
|
45817
|
-
|
|
45818
|
-
|
|
45819
|
-
|
|
45820
|
-
|
|
45821
|
-
|
|
45822
|
-
|
|
45823
|
-
|
|
45824
|
-
|
|
45825
|
-
|
|
45826
|
-
|
|
45827
|
-
|
|
45828
|
-
|
|
45829
|
-
|
|
45830
|
-
|
|
45831
|
-
|
|
45832
|
-
|
|
45833
|
-
|
|
45834
|
-
|
|
45835
|
-
|
|
45836
|
-
|
|
45837
|
-
|
|
45838
|
-
|
|
45839
|
-
|
|
45840
|
-
|
|
45841
|
-
|
|
45842
|
-
|
|
45623
|
+
// Displays a stylized open eye: lint warnings are visible
|
|
45624
|
+
const VisibleIcon = () => /*#__PURE__*/React__namespace.createElement("svg", {
|
|
45625
|
+
width: "24",
|
|
45626
|
+
height: "24",
|
|
45627
|
+
viewBox: "0 0 24 24",
|
|
45628
|
+
className: aphrodite.css(styles$2.icon)
|
|
45629
|
+
}, /*#__PURE__*/React__namespace.createElement("defs", null, /*#__PURE__*/React__namespace.createElement("path", {
|
|
45630
|
+
id: "a",
|
|
45631
|
+
d: "M7.401 10.035c-1.424.748-2.599 1.905-3.544 " + "3.48a1 1 0 0 1-1.714-1.03C4.325 8.849 7.652 7 " + "12 7c4.348 0 7.675 1.848 9.857 5.486a1 1 0 0 " + "1-1.714 1.028c-.945-1.574-2.12-2.73-3.544-" + "3.48a5 5 0 1 1-9.198 0zM12 15a3 3 0 1 0 0-6 3 3 " + "0 0 0 0 6z"
|
|
45632
|
+
})), /*#__PURE__*/React__namespace.createElement("g", {
|
|
45633
|
+
fill: "none",
|
|
45634
|
+
fillRule: "evenodd"
|
|
45635
|
+
}, /*#__PURE__*/React__namespace.createElement("path", {
|
|
45636
|
+
fill: "none",
|
|
45637
|
+
d: "M0 0h24v24H0z"
|
|
45638
|
+
}), /*#__PURE__*/React__namespace.createElement("mask", {
|
|
45639
|
+
id: "b",
|
|
45640
|
+
fill: "#fff"
|
|
45641
|
+
}, /*#__PURE__*/React__namespace.createElement("use", {
|
|
45642
|
+
href: "#a"
|
|
45643
|
+
})), /*#__PURE__*/React__namespace.createElement("use", {
|
|
45644
|
+
fill: "#fff",
|
|
45645
|
+
fillRule: "nonzero",
|
|
45646
|
+
href: "#a"
|
|
45647
|
+
}), /*#__PURE__*/React__namespace.createElement("g", {
|
|
45648
|
+
fill: "#fff",
|
|
45649
|
+
mask: "url(#b)"
|
|
45650
|
+
}, /*#__PURE__*/React__namespace.createElement("path", {
|
|
45651
|
+
d: "M0 0h24v24H0z"
|
|
45652
|
+
}))));
|
|
45653
|
+
|
|
45654
|
+
// Displays a stylized eye with a line through it: I don't want to see lint
|
|
45655
|
+
const HiddenIcon = () => /*#__PURE__*/React__namespace.createElement("svg", {
|
|
45656
|
+
width: "24",
|
|
45657
|
+
height: "24",
|
|
45658
|
+
viewBox: "0 0 24 24",
|
|
45659
|
+
className: aphrodite.css(styles$2.icon)
|
|
45660
|
+
}, /*#__PURE__*/React__namespace.createElement("defs", null, /*#__PURE__*/React__namespace.createElement("path", {
|
|
45661
|
+
id: "a",
|
|
45662
|
+
d: "M8.794 7.38C9.791 7.127 10.86 7 12 7c4.348 0 " + "7.675 1.848 9.857 5.486a1 1 0 0 1-1.714 " + "1.028c-.945-1.574-2.12-2.73-3.544-3.48.258." + "604.401 1.268.401 1.966 0 1.02-.305 " + "1.967-.828 2.757l2.535 2.536a1 1 0 0 " + "1-1.414 1.414l-12-12a1 1 0 0 1 " + "1.414-1.414L8.794 7.38zm5.914 5.913a3 3 0 0 " + "0-4.001-4.001l4 4.001zM6.072 8.486l2.976 " + "2.976a3 3 0 0 0 3.49 3.49l1.579 1.58A5 5 0 " + "0 1 7.4 10.035c-1.424.747-2.599 1.904-3.544 " + "3.478a1 1 0 0 1-1.714-1.028c1.049-1.75 " + "2.363-3.085 3.929-4z"
|
|
45663
|
+
})), /*#__PURE__*/React__namespace.createElement("g", {
|
|
45664
|
+
fill: "none",
|
|
45665
|
+
fillRule: "evenodd"
|
|
45666
|
+
}, /*#__PURE__*/React__namespace.createElement("path", {
|
|
45667
|
+
fill: "none",
|
|
45668
|
+
d: "M0 0h24v24H0z"
|
|
45669
|
+
}), /*#__PURE__*/React__namespace.createElement("mask", {
|
|
45670
|
+
id: "b",
|
|
45671
|
+
fill: "#fff"
|
|
45672
|
+
}, /*#__PURE__*/React__namespace.createElement("use", {
|
|
45673
|
+
href: "#a"
|
|
45674
|
+
})), /*#__PURE__*/React__namespace.createElement("use", {
|
|
45675
|
+
fill: "#fff",
|
|
45676
|
+
fillRule: "nonzero",
|
|
45677
|
+
href: "#a"
|
|
45678
|
+
}), /*#__PURE__*/React__namespace.createElement("g", {
|
|
45679
|
+
fill: "#fff",
|
|
45680
|
+
mask: "url(#b)"
|
|
45681
|
+
}, /*#__PURE__*/React__namespace.createElement("path", {
|
|
45682
|
+
d: "M0 0h24v24H0z"
|
|
45683
|
+
}))));
|
|
45684
|
+
const HUD = _ref => {
|
|
45685
|
+
let {
|
|
45686
|
+
message,
|
|
45687
|
+
enabled,
|
|
45688
|
+
onClick,
|
|
45689
|
+
fixedPosition = true
|
|
45690
|
+
} = _ref;
|
|
45691
|
+
let state;
|
|
45692
|
+
let icon;
|
|
45693
|
+
if (enabled) {
|
|
45694
|
+
state = styles$2.enabled;
|
|
45695
|
+
icon = /*#__PURE__*/React__namespace.createElement(VisibleIcon, null);
|
|
45696
|
+
} else {
|
|
45697
|
+
state = styles$2.disabled;
|
|
45698
|
+
icon = /*#__PURE__*/React__namespace.createElement(HiddenIcon, null);
|
|
45843
45699
|
}
|
|
45844
|
-
|
|
45845
|
-
|
|
45846
|
-
|
|
45847
|
-
|
|
45848
|
-
state = styles$2.enabled;
|
|
45849
|
-
icon = this.renderVisibleIcon();
|
|
45850
|
-
} else {
|
|
45851
|
-
state = styles$2.disabled;
|
|
45852
|
-
icon = this.renderHiddenIcon();
|
|
45700
|
+
return /*#__PURE__*/React__namespace.createElement("button", {
|
|
45701
|
+
className: aphrodite.css(styles$2.hud, fixedPosition && styles$2.hudFixedPosition, state),
|
|
45702
|
+
onClick: e => {
|
|
45703
|
+
onClick();
|
|
45853
45704
|
}
|
|
45854
|
-
|
|
45855
|
-
|
|
45856
|
-
onClick: e => {
|
|
45857
|
-
this.props.onClick();
|
|
45858
|
-
}
|
|
45859
|
-
}, icon, this.props.message);
|
|
45860
|
-
}
|
|
45861
|
-
}
|
|
45862
|
-
_defineProperty(HUD, "propTypes", {
|
|
45863
|
-
message: PropTypes__default["default"].string.isRequired,
|
|
45864
|
-
enabled: PropTypes__default["default"].bool.isRequired,
|
|
45865
|
-
onClick: PropTypes__default["default"].func.isRequired,
|
|
45866
|
-
fixedPosition: PropTypes__default["default"].bool
|
|
45867
|
-
});
|
|
45868
|
-
_defineProperty(HUD, "defaultProps", {
|
|
45869
|
-
fixedPosition: true
|
|
45870
|
-
});
|
|
45705
|
+
}, icon, message);
|
|
45706
|
+
};
|
|
45871
45707
|
const styles$2 = aphrodite.StyleSheet.create({
|
|
45872
45708
|
hud: {
|
|
45873
45709
|
boxSizing: "border-box",
|