@khanacademy/perseus-editor 6.2.2 → 6.3.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/components/line-swatch.d.ts +8 -0
- package/dist/components/util.d.ts +0 -1
- package/dist/es/index.js +229 -202
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +230 -203
- package/dist/index.js.map +1 -1
- package/package.json +34 -34
package/dist/es/index.js
CHANGED
|
@@ -29,7 +29,7 @@ import Switch from '@khanacademy/wonder-blocks-switch';
|
|
|
29
29
|
|
|
30
30
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
31
31
|
const libName = "@khanacademy/perseus-editor";
|
|
32
|
-
const libVersion = "6.
|
|
32
|
+
const libVersion = "6.3.0";
|
|
33
33
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
34
34
|
|
|
35
35
|
function _extends() {
|
|
@@ -219,7 +219,7 @@ class SectionControlButton extends React.Component {
|
|
|
219
219
|
role: "button",
|
|
220
220
|
hideDefaultFocusRing: true,
|
|
221
221
|
"aria-label": title,
|
|
222
|
-
style: styles$
|
|
222
|
+
style: styles$v.button
|
|
223
223
|
}, ({
|
|
224
224
|
hovered,
|
|
225
225
|
focused,
|
|
@@ -227,7 +227,7 @@ class SectionControlButton extends React.Component {
|
|
|
227
227
|
}) => /*#__PURE__*/React.createElement(InlineIcon$b, icon));
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
|
-
const styles$
|
|
230
|
+
const styles$v = StyleSheet.create({
|
|
231
231
|
button: {
|
|
232
232
|
backgroundColor: color.gold,
|
|
233
233
|
margin: 2,
|
|
@@ -20749,19 +20749,19 @@ class TexErrorView extends React.Component {
|
|
|
20749
20749
|
const {
|
|
20750
20750
|
showErrors
|
|
20751
20751
|
} = this.state;
|
|
20752
|
-
const iconStyle = showErrors ? styles$
|
|
20752
|
+
const iconStyle = showErrors ? styles$u.iconExpanded : styles$u.iconCollapsed;
|
|
20753
20753
|
return /*#__PURE__*/React.createElement(View, {
|
|
20754
|
-
style: styles$
|
|
20754
|
+
style: styles$u.errorContainer
|
|
20755
20755
|
}, /*#__PURE__*/React.createElement(View, {
|
|
20756
|
-
style: styles$
|
|
20756
|
+
style: styles$u.title,
|
|
20757
20757
|
onClick: this.handleToggleTexErrors
|
|
20758
20758
|
}, /*#__PURE__*/React.createElement(PhosphorIcon, {
|
|
20759
20759
|
icon: caretRight,
|
|
20760
20760
|
style: iconStyle
|
|
20761
20761
|
}), "\xA0 TeX Errors (", errorList.length, ")"), showErrors && /*#__PURE__*/React.createElement(View, {
|
|
20762
|
-
style: styles$
|
|
20762
|
+
style: styles$u.errorExplanation
|
|
20763
20763
|
}, "If your math doesn't display correctly, these errors might help you troubleshoot. Message #content-kitchen for help."), showErrors && errorList.map((e, index) => /*#__PURE__*/React.createElement(View, {
|
|
20764
|
-
style: styles$
|
|
20764
|
+
style: styles$u.error,
|
|
20765
20765
|
key: index
|
|
20766
20766
|
}, /*#__PURE__*/React.createElement(View, {
|
|
20767
20767
|
style: {
|
|
@@ -20770,7 +20770,7 @@ class TexErrorView extends React.Component {
|
|
|
20770
20770
|
}, e.math), /*#__PURE__*/React.createElement(View, null, e.message))));
|
|
20771
20771
|
}
|
|
20772
20772
|
}
|
|
20773
|
-
const styles$
|
|
20773
|
+
const styles$u = StyleSheet.create({
|
|
20774
20774
|
title: {
|
|
20775
20775
|
backgroundColor: "#eee",
|
|
20776
20776
|
fontSize: "1.25em",
|
|
@@ -24571,7 +24571,7 @@ class SimpleButton extends React.Component {
|
|
|
24571
24571
|
} = _this$props,
|
|
24572
24572
|
otherProps = _objectWithoutPropertiesLoose(_this$props, _excluded$3);
|
|
24573
24573
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
24574
|
-
className: css(styles$
|
|
24574
|
+
className: css(styles$t.baseButton, color === "green" && styles$t.green, color === "orange" && styles$t.orange),
|
|
24575
24575
|
onClick: onClick
|
|
24576
24576
|
}, otherProps), children);
|
|
24577
24577
|
}
|
|
@@ -24586,7 +24586,7 @@ SimpleButton.defaultProps = {
|
|
|
24586
24586
|
color: "green",
|
|
24587
24587
|
onClick: () => {}
|
|
24588
24588
|
};
|
|
24589
|
-
const styles$
|
|
24589
|
+
const styles$t = StyleSheet.create({
|
|
24590
24590
|
baseButton: {
|
|
24591
24591
|
top: "0",
|
|
24592
24592
|
fontSize: "11px",
|
|
@@ -24806,23 +24806,23 @@ const LeafContainer = ({
|
|
|
24806
24806
|
}) => {
|
|
24807
24807
|
const hasPreviewHeading = shape.type === "content" || shape.type === "hint";
|
|
24808
24808
|
const previewHeading = hasPreviewHeading && /*#__PURE__*/React.createElement("div", {
|
|
24809
|
-
className: css(styles$
|
|
24809
|
+
className: css(styles$s.containerHeader)
|
|
24810
24810
|
}, /*#__PURE__*/React.createElement(Header, {
|
|
24811
24811
|
depth: path.length,
|
|
24812
|
-
className: css(styles$
|
|
24812
|
+
className: css(styles$s.containerTitle)
|
|
24813
24813
|
}, capitalize(name)));
|
|
24814
24814
|
return /*#__PURE__*/React.createElement("div", {
|
|
24815
|
-
className: css(styles$
|
|
24815
|
+
className: css(styles$s.container)
|
|
24816
24816
|
}, /*#__PURE__*/React.createElement("span", {
|
|
24817
|
-
className: css(styles$
|
|
24817
|
+
className: css(styles$s.row, styles$s.rowHeading)
|
|
24818
24818
|
}, /*#__PURE__*/React.createElement("div", {
|
|
24819
|
-
className: css(styles$
|
|
24819
|
+
className: css(styles$s.columnLeft)
|
|
24820
24820
|
}, /*#__PURE__*/React.createElement("div", {
|
|
24821
|
-
className: "pod-title " + css(styles$
|
|
24821
|
+
className: "pod-title " + css(styles$s.containerHeader)
|
|
24822
24822
|
}, /*#__PURE__*/React.createElement("div", {
|
|
24823
|
-
className: css(styles$
|
|
24823
|
+
className: css(styles$s.containerTitle)
|
|
24824
24824
|
}, capitalize(name)), controls)), /*#__PURE__*/React.createElement("div", {
|
|
24825
|
-
className: css(styles$
|
|
24825
|
+
className: css(styles$s.columnRight)
|
|
24826
24826
|
}, previewHeading)), children);
|
|
24827
24827
|
};
|
|
24828
24828
|
const ArrayContainer = props => {
|
|
@@ -24835,11 +24835,11 @@ const ArrayContainer = props => {
|
|
|
24835
24835
|
actions
|
|
24836
24836
|
} = props;
|
|
24837
24837
|
return /*#__PURE__*/React.createElement("div", {
|
|
24838
|
-
className: css(styles$
|
|
24838
|
+
className: css(styles$s.container)
|
|
24839
24839
|
}, controls && /*#__PURE__*/React.createElement("div", {
|
|
24840
|
-
className: css(styles$
|
|
24840
|
+
className: css(styles$s.columnLeft, styles$s.containerHeader)
|
|
24841
24841
|
}, controls), /*#__PURE__*/React.createElement("div", null, children), /*#__PURE__*/React.createElement("div", {
|
|
24842
|
-
className: css(styles$
|
|
24842
|
+
className: css(styles$s.columnLeft)
|
|
24843
24843
|
}, /*#__PURE__*/React.createElement("a", {
|
|
24844
24844
|
href: "javascript:void 0",
|
|
24845
24845
|
onClick: () => actions.addArrayElement(path, shape.elementShape)
|
|
@@ -24852,28 +24852,28 @@ const ObjectContainer = ({
|
|
|
24852
24852
|
path
|
|
24853
24853
|
}) => {
|
|
24854
24854
|
const headingEditor = /*#__PURE__*/React.createElement("div", {
|
|
24855
|
-
className: css(styles$
|
|
24855
|
+
className: css(styles$s.containerHeader)
|
|
24856
24856
|
}, /*#__PURE__*/React.createElement(Header, {
|
|
24857
24857
|
depth: path.length,
|
|
24858
|
-
className: css(styles$
|
|
24858
|
+
className: css(styles$s.containerTitle)
|
|
24859
24859
|
}, capitalize(name)), controls);
|
|
24860
24860
|
const headingPreview = (name || controls) && /*#__PURE__*/React.createElement("div", {
|
|
24861
|
-
className: css(styles$
|
|
24861
|
+
className: css(styles$s.containerHeader, styles$s.previewCollectionHeader)
|
|
24862
24862
|
}, /*#__PURE__*/React.createElement(Header, {
|
|
24863
24863
|
depth: path.length,
|
|
24864
|
-
className: css(styles$
|
|
24864
|
+
className: css(styles$s.containerTitle)
|
|
24865
24865
|
}, capitalize(name)));
|
|
24866
24866
|
const hasBothHeadings = headingEditor && headingPreview;
|
|
24867
24867
|
return /*#__PURE__*/React.createElement("div", {
|
|
24868
|
-
className: css(styles$
|
|
24868
|
+
className: css(styles$s.container)
|
|
24869
24869
|
}, hasBothHeadings && /*#__PURE__*/React.createElement("span", {
|
|
24870
|
-
className: css(styles$
|
|
24870
|
+
className: css(styles$s.row)
|
|
24871
24871
|
}, /*#__PURE__*/React.createElement("div", {
|
|
24872
|
-
className: css(styles$
|
|
24872
|
+
className: css(styles$s.columnLeft)
|
|
24873
24873
|
}, headingEditor), /*#__PURE__*/React.createElement("div", {
|
|
24874
|
-
className: css(styles$
|
|
24874
|
+
className: css(styles$s.columnRight)
|
|
24875
24875
|
}, headingPreview)), /*#__PURE__*/React.createElement("div", {
|
|
24876
|
-
className: css(path.length > 0 && styles$
|
|
24876
|
+
className: css(path.length > 0 && styles$s.contentIndent)
|
|
24877
24877
|
}, children));
|
|
24878
24878
|
};
|
|
24879
24879
|
|
|
@@ -24996,11 +24996,11 @@ const ItemNodeContent = withStickiness(props => {
|
|
|
24996
24996
|
className: "framework-perseus"
|
|
24997
24997
|
}, lens(renderers).get(path));
|
|
24998
24998
|
return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("div", {
|
|
24999
|
-
className: css(styles$
|
|
24999
|
+
className: css(styles$s.row)
|
|
25000
25000
|
}, /*#__PURE__*/React.createElement("div", {
|
|
25001
|
-
className: css(styles$
|
|
25001
|
+
className: css(styles$s.columnLeft)
|
|
25002
25002
|
}, /*#__PURE__*/React.createElement("div", {
|
|
25003
|
-
className: css(sticky && styles$
|
|
25003
|
+
className: css(sticky && styles$s.sticky)
|
|
25004
25004
|
},
|
|
25005
25005
|
/*#__PURE__*/
|
|
25006
25006
|
// @ts-expect-error - TS2769 - No overload matches this call.
|
|
@@ -25008,9 +25008,9 @@ const ItemNodeContent = withStickiness(props => {
|
|
|
25008
25008
|
onChange: newVal => actions.mergeValueAtPath(path, newVal),
|
|
25009
25009
|
apiOptions: apiOptions
|
|
25010
25010
|
})))), /*#__PURE__*/React.createElement("div", {
|
|
25011
|
-
className: css(styles$
|
|
25011
|
+
className: css(styles$s.columnRight)
|
|
25012
25012
|
}, /*#__PURE__*/React.createElement("div", {
|
|
25013
|
-
className: css(sticky && styles$
|
|
25013
|
+
className: css(sticky && styles$s.sticky)
|
|
25014
25014
|
}, preview))));
|
|
25015
25015
|
});
|
|
25016
25016
|
const HintNodeContent = withStickiness(props => {
|
|
@@ -25026,13 +25026,13 @@ const HintNodeContent = withStickiness(props => {
|
|
|
25026
25026
|
className: "framework-perseus"
|
|
25027
25027
|
}, lens(renderers).get(path));
|
|
25028
25028
|
return /*#__PURE__*/React.createElement("div", {
|
|
25029
|
-
className: css(styles$
|
|
25029
|
+
className: css(styles$s.row)
|
|
25030
25030
|
}, /*#__PURE__*/React.createElement("div", {
|
|
25031
|
-
className: css(styles$
|
|
25031
|
+
className: css(styles$s.columnLeft)
|
|
25032
25032
|
}, /*#__PURE__*/React.createElement("div", {
|
|
25033
|
-
className: css(sticky && styles$
|
|
25033
|
+
className: css(sticky && styles$s.sticky)
|
|
25034
25034
|
}, /*#__PURE__*/React.createElement(HintEditor, _extends({}, data, {
|
|
25035
|
-
className: css(styles$
|
|
25035
|
+
className: css(styles$s.hintEditor),
|
|
25036
25036
|
onChange: newVal => actions.mergeValueAtPath(path, newVal),
|
|
25037
25037
|
apiOptions: apiOptions,
|
|
25038
25038
|
showTitle: false,
|
|
@@ -25047,9 +25047,9 @@ const HintNodeContent = withStickiness(props => {
|
|
|
25047
25047
|
isFirst: true,
|
|
25048
25048
|
isLast: true
|
|
25049
25049
|
})))), /*#__PURE__*/React.createElement("div", {
|
|
25050
|
-
className: css(styles$
|
|
25050
|
+
className: css(styles$s.columnRight)
|
|
25051
25051
|
}, /*#__PURE__*/React.createElement("div", {
|
|
25052
|
-
className: css(sticky && styles$
|
|
25052
|
+
className: css(sticky && styles$s.sticky)
|
|
25053
25053
|
}, preview)));
|
|
25054
25054
|
});
|
|
25055
25055
|
const TagsNodeContent = props => {
|
|
@@ -25066,9 +25066,9 @@ const TagsNodeContent = props => {
|
|
|
25066
25066
|
return null;
|
|
25067
25067
|
}
|
|
25068
25068
|
return /*#__PURE__*/React.createElement("div", {
|
|
25069
|
-
className: css(styles$
|
|
25069
|
+
className: css(styles$s.columnLeft)
|
|
25070
25070
|
}, /*#__PURE__*/React.createElement("div", {
|
|
25071
|
-
className: css(styles$
|
|
25071
|
+
className: css(styles$s.tagsEditor)
|
|
25072
25072
|
}, /*#__PURE__*/React.createElement(GroupMetadataEditor, {
|
|
25073
25073
|
value: data,
|
|
25074
25074
|
onChange: newVal => actions.setValueAtPath(path, newVal),
|
|
@@ -25099,23 +25099,23 @@ const ArrayNodeContent = props => {
|
|
|
25099
25099
|
const subpath = path.concat(i);
|
|
25100
25100
|
const controls = [i > 0 && /*#__PURE__*/React.createElement("div", {
|
|
25101
25101
|
key: "moveArrayElementUp",
|
|
25102
|
-
className: css(styles$
|
|
25102
|
+
className: css(styles$s.control)
|
|
25103
25103
|
}, /*#__PURE__*/React.createElement(SimpleButton, {
|
|
25104
25104
|
color: "orange",
|
|
25105
25105
|
title: "Move up",
|
|
25106
25106
|
onClick: () => actions.moveArrayElementUp(subpath)
|
|
25107
25107
|
}, /*#__PURE__*/React.createElement("div", {
|
|
25108
|
-
className: css(styles$
|
|
25108
|
+
className: css(styles$s.verticalFlip)
|
|
25109
25109
|
}, /*#__PURE__*/React.createElement(InlineIcon$6, iconChevronDown)))), i < data.length - 1 && /*#__PURE__*/React.createElement("div", {
|
|
25110
25110
|
key: "moveArrayElementDown",
|
|
25111
|
-
className: css(styles$
|
|
25111
|
+
className: css(styles$s.control)
|
|
25112
25112
|
}, /*#__PURE__*/React.createElement(SimpleButton, {
|
|
25113
25113
|
color: "orange",
|
|
25114
25114
|
title: "Move down",
|
|
25115
25115
|
onClick: () => actions.moveArrayElementDown(subpath)
|
|
25116
25116
|
}, /*#__PURE__*/React.createElement(InlineIcon$6, iconChevronDown))), /*#__PURE__*/React.createElement("div", {
|
|
25117
25117
|
key: "removeArrayElement",
|
|
25118
|
-
className: css(styles$
|
|
25118
|
+
className: css(styles$s.control)
|
|
25119
25119
|
}, /*#__PURE__*/React.createElement(SimpleButton, {
|
|
25120
25120
|
color: "orange",
|
|
25121
25121
|
title: "Delete",
|
|
@@ -25123,7 +25123,7 @@ const ArrayNodeContent = props => {
|
|
|
25123
25123
|
}, /*#__PURE__*/React.createElement(InlineIcon$6, iconTrash$4)))];
|
|
25124
25124
|
return /*#__PURE__*/React.createElement("div", {
|
|
25125
25125
|
key: i,
|
|
25126
|
-
className: css(styles$
|
|
25126
|
+
className: css(styles$s.arrayElement, !elementIsLeaf && styles$s.arrayElementAndNotLeaf)
|
|
25127
25127
|
}, /*#__PURE__*/React.createElement(NodeContainer, _extends({}, otherProps, {
|
|
25128
25128
|
key: i,
|
|
25129
25129
|
shape: shape.elementShape,
|
|
@@ -25149,7 +25149,7 @@ const ObjectNodeContent = props => {
|
|
|
25149
25149
|
// made sense to the shape's author is the order in which we'll iterate :)
|
|
25150
25150
|
const children = Object.keys(shape.shape).map(subkey => /*#__PURE__*/React.createElement("div", {
|
|
25151
25151
|
key: subkey,
|
|
25152
|
-
className: css(styles$
|
|
25152
|
+
className: css(styles$s.objectElement)
|
|
25153
25153
|
}, /*#__PURE__*/React.createElement(NodeContainer, _extends({}, otherProps, {
|
|
25154
25154
|
shape: shape.shape[subkey],
|
|
25155
25155
|
data: data[subkey],
|
|
@@ -25316,7 +25316,7 @@ class MultiRendererEditor extends React.Component {
|
|
|
25316
25316
|
}, this._renderContent());
|
|
25317
25317
|
}
|
|
25318
25318
|
}
|
|
25319
|
-
const styles$
|
|
25319
|
+
const styles$s = StyleSheet.create({
|
|
25320
25320
|
// This is used in a number of places throughout this file.
|
|
25321
25321
|
container: {},
|
|
25322
25322
|
// eslint-disable-next-line react-native/no-unused-styles
|
|
@@ -25468,47 +25468,47 @@ const StatefulArticleEditor = createReactClass({
|
|
|
25468
25468
|
screen
|
|
25469
25469
|
} = this.state;
|
|
25470
25470
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
25471
|
-
style: styles$
|
|
25471
|
+
style: styles$r.controlBar
|
|
25472
25472
|
}, /*#__PURE__*/React.createElement("span", {
|
|
25473
|
-
style: styles$
|
|
25473
|
+
style: styles$r.controls
|
|
25474
25474
|
}, "Mode:", " ", /*#__PURE__*/React.createElement("span", {
|
|
25475
25475
|
onClick: () => this.setState({
|
|
25476
25476
|
mode: "edit"
|
|
25477
25477
|
}),
|
|
25478
|
-
style: mode === "edit" ? styles$
|
|
25478
|
+
style: mode === "edit" ? styles$r.controlSelected : styles$r.control
|
|
25479
25479
|
}, "EDIT"), " | ", /*#__PURE__*/React.createElement("span", {
|
|
25480
25480
|
onClick: () => this.setState({
|
|
25481
25481
|
mode: "preview"
|
|
25482
25482
|
}),
|
|
25483
|
-
style: mode === "preview" ? styles$
|
|
25483
|
+
style: mode === "preview" ? styles$r.controlSelected : styles$r.control
|
|
25484
25484
|
}, "PREVIEW"), " | ", /*#__PURE__*/React.createElement("span", {
|
|
25485
25485
|
onClick: () => this.setState({
|
|
25486
25486
|
mode: "json"
|
|
25487
25487
|
}),
|
|
25488
|
-
style: mode === "json" ? styles$
|
|
25488
|
+
style: mode === "json" ? styles$r.controlSelected : styles$r.control
|
|
25489
25489
|
}, "JSON")), /*#__PURE__*/React.createElement("span", {
|
|
25490
|
-
style: styles$
|
|
25490
|
+
style: styles$r.controls
|
|
25491
25491
|
}, "Screen:", " ", /*#__PURE__*/React.createElement("span", {
|
|
25492
25492
|
onClick: () => this.setState({
|
|
25493
25493
|
screen: "phone"
|
|
25494
25494
|
}),
|
|
25495
|
-
style: screen === "phone" ? styles$
|
|
25495
|
+
style: screen === "phone" ? styles$r.controlSelected : styles$r.control
|
|
25496
25496
|
}, "PHONE"), " | ", /*#__PURE__*/React.createElement("span", {
|
|
25497
25497
|
onClick: () => this.setState({
|
|
25498
25498
|
screen: "tablet"
|
|
25499
25499
|
}),
|
|
25500
|
-
style: screen === "tablet" ? styles$
|
|
25500
|
+
style: screen === "tablet" ? styles$r.controlSelected : styles$r.control
|
|
25501
25501
|
}, "TABLET"), " | ", /*#__PURE__*/React.createElement("span", {
|
|
25502
25502
|
onClick: () => this.setState({
|
|
25503
25503
|
screen: "desktop"
|
|
25504
25504
|
}),
|
|
25505
|
-
style: screen === "desktop" ? styles$
|
|
25505
|
+
style: screen === "desktop" ? styles$r.controlSelected : styles$r.control
|
|
25506
25506
|
}, "DESKTOP"))), /*#__PURE__*/React.createElement("div", {
|
|
25507
|
-
style: styles$
|
|
25507
|
+
style: styles$r.editor
|
|
25508
25508
|
}, /*#__PURE__*/React.createElement(ArticleEditor, this.state)));
|
|
25509
25509
|
}
|
|
25510
25510
|
});
|
|
25511
|
-
const styles$
|
|
25511
|
+
const styles$r = {
|
|
25512
25512
|
controlBar: {
|
|
25513
25513
|
marginBottom: 25,
|
|
25514
25514
|
marginTop: 5
|
|
@@ -26998,10 +26998,10 @@ class GradedGroupEditor extends React.Component {
|
|
|
26998
26998
|
}, /*#__PURE__*/React.createElement("div", {
|
|
26999
26999
|
className: "perseus-widget-row"
|
|
27000
27000
|
}, /*#__PURE__*/React.createElement("label", {
|
|
27001
|
-
className: css(styles$
|
|
27001
|
+
className: css(styles$q.title)
|
|
27002
27002
|
}, "Title:", " ", /*#__PURE__*/React.createElement(TextInput$6, {
|
|
27003
27003
|
value: this.props.title,
|
|
27004
|
-
className: css(styles$
|
|
27004
|
+
className: css(styles$q.input)
|
|
27005
27005
|
// @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
|
|
27006
27006
|
,
|
|
27007
27007
|
onChange: this.change("title")
|
|
@@ -27026,7 +27026,7 @@ class GradedGroupEditor extends React.Component {
|
|
|
27026
27026
|
}, /*#__PURE__*/React.createElement(InlineIcon$4, iconPlus$1), " Add a hint"), this.props.hint && /*#__PURE__*/React.createElement("div", {
|
|
27027
27027
|
className: "perseus-hint-editor"
|
|
27028
27028
|
}, /*#__PURE__*/React.createElement("div", {
|
|
27029
|
-
className: css(styles$
|
|
27029
|
+
className: css(styles$q.hintsTitle)
|
|
27030
27030
|
}, "Hint"), /*#__PURE__*/React.createElement(Editor, {
|
|
27031
27031
|
ref: this.hintEditor,
|
|
27032
27032
|
content: this.props.hint ? this.props.hint.content : "",
|
|
@@ -27063,7 +27063,7 @@ GradedGroupEditor.defaultProps = {
|
|
|
27063
27063
|
images: {},
|
|
27064
27064
|
hint: null
|
|
27065
27065
|
};
|
|
27066
|
-
const styles$
|
|
27066
|
+
const styles$q = StyleSheet.create({
|
|
27067
27067
|
title: {
|
|
27068
27068
|
fontSize: 18,
|
|
27069
27069
|
fontWeight: "bold"
|
|
@@ -28402,13 +28402,13 @@ function MathquillInput(props) {
|
|
|
28402
28402
|
}
|
|
28403
28403
|
});
|
|
28404
28404
|
return /*#__PURE__*/React.createElement(View, {
|
|
28405
|
-
style: styles$
|
|
28405
|
+
style: styles$p.outerWrapper
|
|
28406
28406
|
}, /*#__PURE__*/React.createElement("span", {
|
|
28407
28407
|
ref: mathFieldWrapperRef,
|
|
28408
28408
|
className: "perseus-math-input mq-editable-field mq-math-mode"
|
|
28409
28409
|
}));
|
|
28410
28410
|
}
|
|
28411
|
-
const styles$
|
|
28411
|
+
const styles$p = StyleSheet.create({
|
|
28412
28412
|
outerWrapper: {
|
|
28413
28413
|
display: "inline-block",
|
|
28414
28414
|
borderStyle: "solid",
|
|
@@ -29469,7 +29469,7 @@ const GraphPointsCountSelector = ({
|
|
|
29469
29469
|
// Never uses placeholder, always has value
|
|
29470
29470
|
,
|
|
29471
29471
|
placeholder: "",
|
|
29472
|
-
style: styles$
|
|
29472
|
+
style: styles$o.singleSelectShort
|
|
29473
29473
|
}, [...[...Array(7).keys()].map(n => /*#__PURE__*/React.createElement(OptionItem, {
|
|
29474
29474
|
key: n,
|
|
29475
29475
|
value: `${n}`,
|
|
@@ -29480,7 +29480,7 @@ const GraphPointsCountSelector = ({
|
|
|
29480
29480
|
label: "unlimited"
|
|
29481
29481
|
})]);
|
|
29482
29482
|
};
|
|
29483
|
-
const styles$
|
|
29483
|
+
const styles$o = StyleSheet.create({
|
|
29484
29484
|
singleSelectShort: {
|
|
29485
29485
|
// Non-standard spacing, but it's the smallest we can go
|
|
29486
29486
|
// without running into styling issues with the dropdown.
|
|
@@ -29493,7 +29493,7 @@ const GraphTypeSelector = props => {
|
|
|
29493
29493
|
selectedValue: props.graphType,
|
|
29494
29494
|
onChange: props.onChange,
|
|
29495
29495
|
placeholder: "Select a graph type",
|
|
29496
|
-
style: styles$
|
|
29496
|
+
style: styles$n.singleSelectShort
|
|
29497
29497
|
}, /*#__PURE__*/React.createElement(OptionItem, {
|
|
29498
29498
|
value: "linear",
|
|
29499
29499
|
label: "Linear function"
|
|
@@ -29526,7 +29526,7 @@ const GraphTypeSelector = props => {
|
|
|
29526
29526
|
label: "Angle"
|
|
29527
29527
|
}));
|
|
29528
29528
|
};
|
|
29529
|
-
const styles$
|
|
29529
|
+
const styles$n = StyleSheet.create({
|
|
29530
29530
|
singleSelectShort: {
|
|
29531
29531
|
// Non-standard spacing, but it's the smallest we can go
|
|
29532
29532
|
// without running into styling issues with the dropdown.
|
|
@@ -29543,16 +29543,16 @@ const LabeledRow = props => {
|
|
|
29543
29543
|
style
|
|
29544
29544
|
} = props;
|
|
29545
29545
|
return /*#__PURE__*/React.createElement("label", {
|
|
29546
|
-
className: css(styles$
|
|
29546
|
+
className: css(styles$m.label)
|
|
29547
29547
|
}, /*#__PURE__*/React.createElement(View, {
|
|
29548
|
-
style: [styles$
|
|
29548
|
+
style: [styles$m.row, style]
|
|
29549
29549
|
}, labelSide === "start" || /*#__PURE__*/React.createElement(LabelSmall, {
|
|
29550
|
-
style: styles$
|
|
29550
|
+
style: styles$m.spaceEnd
|
|
29551
29551
|
}, label), children, labelSide === "end" && /*#__PURE__*/React.createElement(LabelSmall, {
|
|
29552
|
-
style: styles$
|
|
29552
|
+
style: styles$m.spaceStart
|
|
29553
29553
|
}, label)));
|
|
29554
29554
|
};
|
|
29555
|
-
const styles$
|
|
29555
|
+
const styles$m = StyleSheet.create({
|
|
29556
29556
|
label: {
|
|
29557
29557
|
width: "fit-content"
|
|
29558
29558
|
},
|
|
@@ -29946,10 +29946,10 @@ class InteractiveGraphSettings extends React.Component {
|
|
|
29946
29946
|
onChange: this.change
|
|
29947
29947
|
}))), /*#__PURE__*/React.createElement(LabeledRow, {
|
|
29948
29948
|
label: "Background image URL:",
|
|
29949
|
-
style: styles$
|
|
29949
|
+
style: styles$l.resetSpaceTop
|
|
29950
29950
|
}, /*#__PURE__*/React.createElement("input", {
|
|
29951
29951
|
type: "text",
|
|
29952
|
-
className: css(styles$
|
|
29952
|
+
className: css(styles$l.backgroundUrlInput),
|
|
29953
29953
|
ref: this.bgUrlRef,
|
|
29954
29954
|
value: this.state.backgroundImage.url || "",
|
|
29955
29955
|
onChange: e => {
|
|
@@ -29963,28 +29963,28 @@ class InteractiveGraphSettings extends React.Component {
|
|
|
29963
29963
|
onKeyPress: this.changeBackgroundUrl,
|
|
29964
29964
|
onBlur: this.changeBackgroundUrl
|
|
29965
29965
|
}), /*#__PURE__*/React.createElement(InfoTip$c, null, /*#__PURE__*/React.createElement("p", null, "Create an image in graphie, or use the \"Add image\" function to create a background."))), /*#__PURE__*/React.createElement(View, {
|
|
29966
|
-
style: styles$
|
|
29966
|
+
style: styles$l.rulerSection
|
|
29967
29967
|
}, /*#__PURE__*/React.createElement(View, {
|
|
29968
|
-
style: styles$
|
|
29968
|
+
style: styles$l.checkboxRow
|
|
29969
29969
|
}, /*#__PURE__*/React.createElement(PropCheckBox$7, {
|
|
29970
29970
|
label: "Show ruler",
|
|
29971
29971
|
showRuler: this.props.showRuler,
|
|
29972
29972
|
onChange: this.change,
|
|
29973
|
-
style: styles$
|
|
29973
|
+
style: styles$l.resetSpaceTop
|
|
29974
29974
|
}), /*#__PURE__*/React.createElement(PropCheckBox$7, {
|
|
29975
29975
|
label: "Show protractor",
|
|
29976
29976
|
showProtractor: this.props.showProtractor,
|
|
29977
29977
|
onChange: this.change,
|
|
29978
|
-
style: styles$
|
|
29978
|
+
style: styles$l.resetSpaceTop
|
|
29979
29979
|
})), (this.props.showRuler || this.props.showProtractor) && /*#__PURE__*/React.createElement(Banner, {
|
|
29980
29980
|
layout: "floating",
|
|
29981
29981
|
text: "The ruler and protractor are not accessible. Please consider an alternate approach.",
|
|
29982
29982
|
kind: "warning"
|
|
29983
29983
|
}), this.props.showRuler && /*#__PURE__*/React.createElement(View, {
|
|
29984
|
-
style: styles$
|
|
29984
|
+
style: styles$l.spaceTop
|
|
29985
29985
|
}, /*#__PURE__*/React.createElement(LabeledRow, {
|
|
29986
29986
|
label: "Ruler label:",
|
|
29987
|
-
style: styles$
|
|
29987
|
+
style: styles$l.resetSpaceTop
|
|
29988
29988
|
}, /*#__PURE__*/React.createElement(SingleSelect, {
|
|
29989
29989
|
id: "ruler-label-select",
|
|
29990
29990
|
selectedValue: this.props.rulerLabel,
|
|
@@ -29994,7 +29994,7 @@ class InteractiveGraphSettings extends React.Component {
|
|
|
29994
29994
|
});
|
|
29995
29995
|
},
|
|
29996
29996
|
placeholder: "None",
|
|
29997
|
-
style: styles$
|
|
29997
|
+
style: styles$l.singleSelectShort
|
|
29998
29998
|
}, /*#__PURE__*/React.createElement(OptionItem, {
|
|
29999
29999
|
value: "",
|
|
30000
30000
|
label: "None",
|
|
@@ -30035,7 +30035,7 @@ class InteractiveGraphSettings extends React.Component {
|
|
|
30035
30035
|
});
|
|
30036
30036
|
},
|
|
30037
30037
|
placeholder: "10",
|
|
30038
|
-
style: styles$
|
|
30038
|
+
style: styles$l.singleSelectShort
|
|
30039
30039
|
}, [1, 2, 4, 8, 10, 16].map(value => /*#__PURE__*/React.createElement(OptionItem, {
|
|
30040
30040
|
key: value,
|
|
30041
30041
|
value: `${value}`,
|
|
@@ -30059,7 +30059,7 @@ InteractiveGraphSettings.defaultProps = {
|
|
|
30059
30059
|
rulerLabel: "",
|
|
30060
30060
|
rulerTicks: 10
|
|
30061
30061
|
};
|
|
30062
|
-
const styles$
|
|
30062
|
+
const styles$l = StyleSheet.create({
|
|
30063
30063
|
resetSpaceTop: {
|
|
30064
30064
|
marginTop: 0
|
|
30065
30065
|
},
|
|
@@ -30104,10 +30104,10 @@ const LockedFigureSelect = props => {
|
|
|
30104
30104
|
onChange
|
|
30105
30105
|
} = props;
|
|
30106
30106
|
return /*#__PURE__*/React.createElement(View, {
|
|
30107
|
-
style: styles$
|
|
30107
|
+
style: styles$k.container
|
|
30108
30108
|
}, /*#__PURE__*/React.createElement(ActionMenu, {
|
|
30109
30109
|
menuText: "Add locked figure",
|
|
30110
|
-
style: styles$
|
|
30110
|
+
style: styles$k.addElementSelect
|
|
30111
30111
|
}, [/*#__PURE__*/React.createElement(ActionItem, {
|
|
30112
30112
|
key: `${id}-point`,
|
|
30113
30113
|
label: "Point",
|
|
@@ -30118,7 +30118,7 @@ const LockedFigureSelect = props => {
|
|
|
30118
30118
|
onClick: () => onChange("line")
|
|
30119
30119
|
}, "Line")]));
|
|
30120
30120
|
};
|
|
30121
|
-
const styles$
|
|
30121
|
+
const styles$k = StyleSheet.create({
|
|
30122
30122
|
container: {
|
|
30123
30123
|
marginTop: spacing.xSmall_8
|
|
30124
30124
|
},
|
|
@@ -30218,13 +30218,13 @@ const ColorSwatch = props => {
|
|
|
30218
30218
|
"aria-label":
|
|
30219
30219
|
// Don't include an aria label for decorative circles.
|
|
30220
30220
|
!decorative ? `Color: ${color$1}, ${filled ? "filled" : "open"}` : undefined,
|
|
30221
|
-
style: [styles$
|
|
30221
|
+
style: [styles$j.colorSwatch, {
|
|
30222
30222
|
border: `4px solid ${lockedFigureColors[color$1]}`,
|
|
30223
30223
|
backgroundColor: filled ? lockedFigureColors[color$1] : color.white
|
|
30224
30224
|
}]
|
|
30225
30225
|
});
|
|
30226
30226
|
};
|
|
30227
|
-
const styles$
|
|
30227
|
+
const styles$j = StyleSheet.create({
|
|
30228
30228
|
colorSwatch: {
|
|
30229
30229
|
// Add a white outline so that the color swatch is visible when
|
|
30230
30230
|
// the dropdown option is highlighted with its blue background.
|
|
@@ -30244,10 +30244,10 @@ const ColorSelect = props => {
|
|
|
30244
30244
|
onChange
|
|
30245
30245
|
} = props;
|
|
30246
30246
|
return /*#__PURE__*/React.createElement(View, {
|
|
30247
|
-
style: [styles$
|
|
30247
|
+
style: [styles$i.row, style]
|
|
30248
30248
|
}, /*#__PURE__*/React.createElement(LabelMedium, {
|
|
30249
30249
|
htmlFor: id,
|
|
30250
|
-
style: styles$
|
|
30250
|
+
style: styles$i.label,
|
|
30251
30251
|
tag: "label"
|
|
30252
30252
|
}, "color"), /*#__PURE__*/React.createElement(SingleSelect, {
|
|
30253
30253
|
id: id,
|
|
@@ -30266,7 +30266,7 @@ const ColorSelect = props => {
|
|
|
30266
30266
|
})
|
|
30267
30267
|
}, colorName))));
|
|
30268
30268
|
};
|
|
30269
|
-
const styles$
|
|
30269
|
+
const styles$i = StyleSheet.create({
|
|
30270
30270
|
row: {
|
|
30271
30271
|
flexDirection: "row",
|
|
30272
30272
|
alignItems: "center"
|
|
@@ -30276,6 +30276,34 @@ const styles$h = StyleSheet.create({
|
|
|
30276
30276
|
}
|
|
30277
30277
|
});
|
|
30278
30278
|
|
|
30279
|
+
const LineSwatch = props => {
|
|
30280
|
+
const {
|
|
30281
|
+
color,
|
|
30282
|
+
lineStyle
|
|
30283
|
+
} = props;
|
|
30284
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
30285
|
+
style: styles$h.container
|
|
30286
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
30287
|
+
"aria-label": `${color}, ${lineStyle}`,
|
|
30288
|
+
style: [styles$h.lineSwatch, {
|
|
30289
|
+
border: `5px ${lineStyle} ${lockedFigureColors[color]}`
|
|
30290
|
+
}]
|
|
30291
|
+
}));
|
|
30292
|
+
};
|
|
30293
|
+
const styles$h = StyleSheet.create({
|
|
30294
|
+
container: {
|
|
30295
|
+
backgroundColor: color.white,
|
|
30296
|
+
justifyContent: "center",
|
|
30297
|
+
padding: spacing.xSmall_8,
|
|
30298
|
+
borderRadius: spacing.xxxSmall_4
|
|
30299
|
+
},
|
|
30300
|
+
lineSwatch: {
|
|
30301
|
+
// Add a white outline so that the color swatch is visible when
|
|
30302
|
+
// the dropdown option is highlighted with its blue background.
|
|
30303
|
+
width: 40
|
|
30304
|
+
}
|
|
30305
|
+
});
|
|
30306
|
+
|
|
30279
30307
|
const LockedFigureSettingsAccordion = props => {
|
|
30280
30308
|
const {
|
|
30281
30309
|
children,
|
|
@@ -30380,78 +30408,6 @@ const styles$e = StyleSheet.create({
|
|
|
30380
30408
|
}
|
|
30381
30409
|
});
|
|
30382
30410
|
|
|
30383
|
-
function focusWithChromeStickyFocusBugWorkaround(element) {
|
|
30384
|
-
// NOTE(marksandstrom) Chrome sticky focus bug.
|
|
30385
|
-
//
|
|
30386
|
-
// There is a bug in Chrome related to sticky positioning and
|
|
30387
|
-
// focus: When a child of an element with sticky positioning is
|
|
30388
|
-
// focused with the focus() method, the scrollable area
|
|
30389
|
-
// containing that element will scroll to the top (even though
|
|
30390
|
-
// the element is already visble on the page). For a dropdown
|
|
30391
|
-
// this means that the area will be scrolled to the top when
|
|
30392
|
-
// the user interacts with the dropdown (since we actively
|
|
30393
|
-
// manage dropdown header and option focus for keyboard users).
|
|
30394
|
-
//
|
|
30395
|
-
// To work around this bug the `preventScroll` focus option is
|
|
30396
|
-
// used.
|
|
30397
|
-
//
|
|
30398
|
-
// Using `focusOptions` is an experimental browser feature
|
|
30399
|
-
// "that should not be used in production code". However, since
|
|
30400
|
-
// Chrome is the only browser we support that exhibits this
|
|
30401
|
-
// buggy behavior and using `focusOptions` works around the
|
|
30402
|
-
// bug, it is perfectly reasonable to use the feature in this
|
|
30403
|
-
// case. We are not relying on the effect of the
|
|
30404
|
-
// `preventScroll` option otherwise.
|
|
30405
|
-
//
|
|
30406
|
-
// focusOptions documentation:
|
|
30407
|
-
//
|
|
30408
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
|
|
30409
|
-
//
|
|
30410
|
-
// Note that there could be cases where we want default focus() behavior.
|
|
30411
|
-
// One that comes to mind is a dropdown with a long list of options that
|
|
30412
|
-
// might be rendered off screen when opened. With this workaround the
|
|
30413
|
-
// selected option would not be scrolled into view if the option is near
|
|
30414
|
-
// the end of the list. We're not aware of any uses of the dropdown where
|
|
30415
|
-
// this is an issue, however, so there isn't currently a way to out of the
|
|
30416
|
-
// `preventScroll` behavior.
|
|
30417
|
-
|
|
30418
|
-
// @ts-expect-error - TS2339 - Property 'focus' does not exist on type 'Element'.
|
|
30419
|
-
element.focus({
|
|
30420
|
-
preventScroll: true
|
|
30421
|
-
});
|
|
30422
|
-
}
|
|
30423
|
-
function getValidNumberFromString(value) {
|
|
30424
|
-
const parsed = parseFloat(value);
|
|
30425
|
-
// If the value is not a number, return 0.
|
|
30426
|
-
return isNaN(parsed) ? 0 : parsed;
|
|
30427
|
-
}
|
|
30428
|
-
const DEFAULT_COLOR = "grayH";
|
|
30429
|
-
function getDefaultFigureForType(type) {
|
|
30430
|
-
switch (type) {
|
|
30431
|
-
case "point":
|
|
30432
|
-
return {
|
|
30433
|
-
type: "point",
|
|
30434
|
-
coord: [0, 0],
|
|
30435
|
-
color: DEFAULT_COLOR,
|
|
30436
|
-
filled: true
|
|
30437
|
-
};
|
|
30438
|
-
case "line":
|
|
30439
|
-
return {
|
|
30440
|
-
type: "line",
|
|
30441
|
-
kind: "line",
|
|
30442
|
-
points: [getDefaultFigureForType("point"), _extends({}, getDefaultFigureForType("point"), {
|
|
30443
|
-
coord: [2, 2]
|
|
30444
|
-
})],
|
|
30445
|
-
color: DEFAULT_COLOR,
|
|
30446
|
-
lineStyle: "solid",
|
|
30447
|
-
showStartPoint: false,
|
|
30448
|
-
showEndPoint: false
|
|
30449
|
-
};
|
|
30450
|
-
default:
|
|
30451
|
-
throw new UnreachableCaseError(type);
|
|
30452
|
-
}
|
|
30453
|
-
}
|
|
30454
|
-
|
|
30455
30411
|
/**
|
|
30456
30412
|
* LockedPointSettings is a component that allows the user to edit the
|
|
30457
30413
|
* settings of specifically a locked point on the graph.
|
|
@@ -30472,7 +30428,7 @@ const LockedPointSettings = props => {
|
|
|
30472
30428
|
} = props;
|
|
30473
30429
|
|
|
30474
30430
|
// Keep track of the coordinates via state as the user is editing them,
|
|
30475
|
-
// before they are updated in the props
|
|
30431
|
+
// before they are updated in the props as a valid number.
|
|
30476
30432
|
const [coordState, setCoordState] = React.useState([
|
|
30477
30433
|
// Using strings to make it easier to work with the text fields.
|
|
30478
30434
|
coord[0].toString(), coord[1].toString()]);
|
|
@@ -30483,21 +30439,25 @@ const LockedPointSettings = props => {
|
|
|
30483
30439
|
const xCoordId = ids.get("x-coord");
|
|
30484
30440
|
const yCoordId = ids.get("y-coord");
|
|
30485
30441
|
const colorSelectId = ids.get("point-color-select");
|
|
30486
|
-
function
|
|
30487
|
-
|
|
30442
|
+
function handleCoordChange(newValue, coordIndex) {
|
|
30443
|
+
// Update the local state (update the input field value).
|
|
30444
|
+
const newCoordState = [...coordState];
|
|
30445
|
+
newCoordState[coordIndex] = newValue;
|
|
30446
|
+
setCoordState(newCoordState);
|
|
30447
|
+
|
|
30448
|
+
// If the new value is not a number, don't update the props.
|
|
30449
|
+
// If it's empty, keep the props the same value instead of setting to 0.
|
|
30450
|
+
if (isNaN(+newValue) || newValue === "") {
|
|
30451
|
+
return;
|
|
30452
|
+
}
|
|
30488
30453
|
|
|
30489
|
-
//
|
|
30490
|
-
|
|
30491
|
-
|
|
30454
|
+
// Update the props (update the graph).
|
|
30455
|
+
const newCoords = [...coord];
|
|
30456
|
+
newCoords[coordIndex] = +newValue;
|
|
30492
30457
|
onChangeProps({
|
|
30493
|
-
coord:
|
|
30458
|
+
coord: newCoords
|
|
30494
30459
|
});
|
|
30495
30460
|
}
|
|
30496
|
-
function handleCoordChange(newValue, coordIndex) {
|
|
30497
|
-
const newCoord = [...coordState];
|
|
30498
|
-
newCoord[coordIndex] = newValue;
|
|
30499
|
-
setCoordState(newCoord);
|
|
30500
|
-
}
|
|
30501
30461
|
function handleColorChange(newValue) {
|
|
30502
30462
|
onChangeProps({
|
|
30503
30463
|
color: newValue
|
|
@@ -30528,7 +30488,6 @@ const LockedPointSettings = props => {
|
|
|
30528
30488
|
type: "number",
|
|
30529
30489
|
value: coordState[0],
|
|
30530
30490
|
onChange: newValue => handleCoordChange(newValue, 0),
|
|
30531
|
-
onBlur: handleBlur,
|
|
30532
30491
|
style: styles$d.textField
|
|
30533
30492
|
}), /*#__PURE__*/React.createElement(Strut, {
|
|
30534
30493
|
size: spacing.medium_16
|
|
@@ -30541,7 +30500,6 @@ const LockedPointSettings = props => {
|
|
|
30541
30500
|
type: "number",
|
|
30542
30501
|
value: coordState[1],
|
|
30543
30502
|
onChange: newValue => handleCoordChange(newValue, 1),
|
|
30544
|
-
onBlur: handleBlur,
|
|
30545
30503
|
style: styles$d.textField
|
|
30546
30504
|
})), onToggle && /*#__PURE__*/React.createElement(LabeledSwitch, {
|
|
30547
30505
|
label: "show point on graph",
|
|
@@ -30563,7 +30521,7 @@ const LockedPointSettings = props => {
|
|
|
30563
30521
|
}
|
|
30564
30522
|
})), onRemove && /*#__PURE__*/React.createElement(LockedFigureSettingsActions, {
|
|
30565
30523
|
onRemove: onRemove,
|
|
30566
|
-
figureAriaLabel: `locked point at ${
|
|
30524
|
+
figureAriaLabel: `locked point at ${coord[0]}, ${coord[1]}`
|
|
30567
30525
|
}));
|
|
30568
30526
|
};
|
|
30569
30527
|
const styles$d = StyleSheet.create({
|
|
@@ -30592,12 +30550,12 @@ const LockedLineSettings = props => {
|
|
|
30592
30550
|
points,
|
|
30593
30551
|
color: lineColor,
|
|
30594
30552
|
lineStyle = "solid",
|
|
30595
|
-
|
|
30596
|
-
|
|
30553
|
+
showPoint1,
|
|
30554
|
+
showPoint2,
|
|
30597
30555
|
onChangeProps,
|
|
30598
30556
|
onRemove
|
|
30599
30557
|
} = props;
|
|
30600
|
-
const [
|
|
30558
|
+
const [point1, point2] = points;
|
|
30601
30559
|
|
|
30602
30560
|
// Generate unique IDs so that the programmatic labels can be associated
|
|
30603
30561
|
// with their respective text fields.
|
|
@@ -30605,8 +30563,9 @@ const LockedLineSettings = props => {
|
|
|
30605
30563
|
const kindSelectId = ids.get("line-kind-select");
|
|
30606
30564
|
const colorSelectId = ids.get("line-color-select");
|
|
30607
30565
|
const styleSelectId = ids.get("line-style-select");
|
|
30608
|
-
const
|
|
30609
|
-
|
|
30566
|
+
const capitalizeKind = kind.charAt(0).toUpperCase() + kind.slice(1);
|
|
30567
|
+
const lineLabel = `${capitalizeKind} (${point1.coord[0]},
|
|
30568
|
+
${point1.coord[1]}), (${point2.coord[0]}, ${point2.coord[1]})`;
|
|
30610
30569
|
function handleChangePoint(newPointProps, index) {
|
|
30611
30570
|
const newPoints = [...points];
|
|
30612
30571
|
newPoints[index] = _extends({}, points[index], newPointProps);
|
|
@@ -30618,9 +30577,9 @@ const LockedLineSettings = props => {
|
|
|
30618
30577
|
onChangeProps({
|
|
30619
30578
|
color: newColor,
|
|
30620
30579
|
// Keep the line's points' colors in sync with the line color.
|
|
30621
|
-
points: [_extends({},
|
|
30580
|
+
points: [_extends({}, point1, {
|
|
30622
30581
|
color: newColor
|
|
30623
|
-
}), _extends({},
|
|
30582
|
+
}), _extends({}, point2, {
|
|
30624
30583
|
color: newColor
|
|
30625
30584
|
})]
|
|
30626
30585
|
});
|
|
@@ -30630,8 +30589,9 @@ const LockedLineSettings = props => {
|
|
|
30630
30589
|
style: styles$c.row
|
|
30631
30590
|
}, /*#__PURE__*/React.createElement(LabelLarge, null, lineLabel), /*#__PURE__*/React.createElement(Strut, {
|
|
30632
30591
|
size: spacing.xSmall_8
|
|
30633
|
-
}), /*#__PURE__*/React.createElement(
|
|
30634
|
-
color: lineColor
|
|
30592
|
+
}), /*#__PURE__*/React.createElement(LineSwatch, {
|
|
30593
|
+
color: lineColor,
|
|
30594
|
+
lineStyle: lineStyle
|
|
30635
30595
|
}))
|
|
30636
30596
|
}, /*#__PURE__*/React.createElement(View, {
|
|
30637
30597
|
style: [styles$c.row, styles$c.spaceUnder]
|
|
@@ -30688,28 +30648,28 @@ const LockedLineSettings = props => {
|
|
|
30688
30648
|
value: "dashed",
|
|
30689
30649
|
label: "dashed"
|
|
30690
30650
|
})))), /*#__PURE__*/React.createElement(LockedPointSettings, _extends({
|
|
30691
|
-
label: "
|
|
30692
|
-
toggled:
|
|
30693
|
-
},
|
|
30651
|
+
label: "Point 1",
|
|
30652
|
+
toggled: showPoint1
|
|
30653
|
+
}, point1, {
|
|
30694
30654
|
onToggle: newValue => onChangeProps({
|
|
30695
|
-
|
|
30655
|
+
showPoint1: newValue
|
|
30696
30656
|
}),
|
|
30697
30657
|
onChangeProps: newProps => handleChangePoint(newProps, 0),
|
|
30698
30658
|
style: styles$c.lockedPointSettingsContainer
|
|
30699
30659
|
})), /*#__PURE__*/React.createElement(LockedPointSettings, _extends({
|
|
30700
|
-
label: "
|
|
30701
|
-
toggled:
|
|
30702
|
-
},
|
|
30660
|
+
label: "Point 2",
|
|
30661
|
+
toggled: showPoint2
|
|
30662
|
+
}, point2, {
|
|
30703
30663
|
onToggle: newValue => onChangeProps({
|
|
30704
|
-
|
|
30664
|
+
showPoint2: newValue
|
|
30705
30665
|
}),
|
|
30706
30666
|
onChangeProps: newProps => handleChangePoint(newProps, 1),
|
|
30707
30667
|
style: styles$c.lockedPointSettingsContainer
|
|
30708
30668
|
})), /*#__PURE__*/React.createElement(LockedFigureSettingsActions, {
|
|
30709
30669
|
onRemove: onRemove,
|
|
30710
30670
|
figureAriaLabel: `locked line defined by
|
|
30711
|
-
${
|
|
30712
|
-
${
|
|
30671
|
+
${point1.coord[0]}, ${point1.coord[1]} and
|
|
30672
|
+
${point2.coord[0]}, ${point2.coord[1]}.`
|
|
30713
30673
|
}));
|
|
30714
30674
|
};
|
|
30715
30675
|
const styles$c = StyleSheet.create({
|
|
@@ -30755,6 +30715,73 @@ const LockedFigureSettings = props => {
|
|
|
30755
30715
|
return null;
|
|
30756
30716
|
};
|
|
30757
30717
|
|
|
30718
|
+
function focusWithChromeStickyFocusBugWorkaround(element) {
|
|
30719
|
+
// NOTE(marksandstrom) Chrome sticky focus bug.
|
|
30720
|
+
//
|
|
30721
|
+
// There is a bug in Chrome related to sticky positioning and
|
|
30722
|
+
// focus: When a child of an element with sticky positioning is
|
|
30723
|
+
// focused with the focus() method, the scrollable area
|
|
30724
|
+
// containing that element will scroll to the top (even though
|
|
30725
|
+
// the element is already visble on the page). For a dropdown
|
|
30726
|
+
// this means that the area will be scrolled to the top when
|
|
30727
|
+
// the user interacts with the dropdown (since we actively
|
|
30728
|
+
// manage dropdown header and option focus for keyboard users).
|
|
30729
|
+
//
|
|
30730
|
+
// To work around this bug the `preventScroll` focus option is
|
|
30731
|
+
// used.
|
|
30732
|
+
//
|
|
30733
|
+
// Using `focusOptions` is an experimental browser feature
|
|
30734
|
+
// "that should not be used in production code". However, since
|
|
30735
|
+
// Chrome is the only browser we support that exhibits this
|
|
30736
|
+
// buggy behavior and using `focusOptions` works around the
|
|
30737
|
+
// bug, it is perfectly reasonable to use the feature in this
|
|
30738
|
+
// case. We are not relying on the effect of the
|
|
30739
|
+
// `preventScroll` option otherwise.
|
|
30740
|
+
//
|
|
30741
|
+
// focusOptions documentation:
|
|
30742
|
+
//
|
|
30743
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
|
|
30744
|
+
//
|
|
30745
|
+
// Note that there could be cases where we want default focus() behavior.
|
|
30746
|
+
// One that comes to mind is a dropdown with a long list of options that
|
|
30747
|
+
// might be rendered off screen when opened. With this workaround the
|
|
30748
|
+
// selected option would not be scrolled into view if the option is near
|
|
30749
|
+
// the end of the list. We're not aware of any uses of the dropdown where
|
|
30750
|
+
// this is an issue, however, so there isn't currently a way to out of the
|
|
30751
|
+
// `preventScroll` behavior.
|
|
30752
|
+
|
|
30753
|
+
// @ts-expect-error - TS2339 - Property 'focus' does not exist on type 'Element'.
|
|
30754
|
+
element.focus({
|
|
30755
|
+
preventScroll: true
|
|
30756
|
+
});
|
|
30757
|
+
}
|
|
30758
|
+
const DEFAULT_COLOR = "grayH";
|
|
30759
|
+
function getDefaultFigureForType(type) {
|
|
30760
|
+
switch (type) {
|
|
30761
|
+
case "point":
|
|
30762
|
+
return {
|
|
30763
|
+
type: "point",
|
|
30764
|
+
coord: [0, 0],
|
|
30765
|
+
color: DEFAULT_COLOR,
|
|
30766
|
+
filled: true
|
|
30767
|
+
};
|
|
30768
|
+
case "line":
|
|
30769
|
+
return {
|
|
30770
|
+
type: "line",
|
|
30771
|
+
kind: "line",
|
|
30772
|
+
points: [getDefaultFigureForType("point"), _extends({}, getDefaultFigureForType("point"), {
|
|
30773
|
+
coord: [2, 2]
|
|
30774
|
+
})],
|
|
30775
|
+
color: DEFAULT_COLOR,
|
|
30776
|
+
lineStyle: "solid",
|
|
30777
|
+
showPoint1: false,
|
|
30778
|
+
showPoint2: false
|
|
30779
|
+
};
|
|
30780
|
+
default:
|
|
30781
|
+
throw new UnreachableCaseError(type);
|
|
30782
|
+
}
|
|
30783
|
+
}
|
|
30784
|
+
|
|
30758
30785
|
const LockedFiguresSection = props => {
|
|
30759
30786
|
const uniqueId = useUniqueIdWithMock().get("locked-figures-section");
|
|
30760
30787
|
const {
|