@khanacademy/perseus 90.0.1 → 90.0.2

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/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { B as ButtonGroup, G as Graphie, H as HUD, I as Icon, a as InlineIcon, M as MathInput, b as MultiButtonGroup, N as NumberInput, R as RangeInput, S as SvgImage, T as TextInput, r as registerWidgets, c as basicWidgets, e as extraWidgets, d as replaceDeprecatedWidgets, P as PerseusI18nContext, A as ApiOptions, C as ClassNames, j as jsxRuntimeExports, U as UserInputManager, f as Renderer, D as DependenciesContext, g as Util, h as getDependencies, J as JiptParagraphs, i as hintPaddingInlineStart, k as hintBorderWidth, m as mediaQueries, s as sharedStyles, l as context$1, n as getWidgetTypeByWidgetId, o as getWidgetExport, p as PerseusMarkdown, t as typeToButton, q as getEquationString, u as defaultPlotProps, v as chooseType, w as DEFAULT_GRAPHER_PROPS } from './chunk-register-all-widgets-for-testing-BTFpfYiU.js';
2
- export { L as Categorizer, $ as Dependencies, E as Expression, X as GrapherWidget, z as InputNumber, O as InteractiveGraphWidget, a5 as KhanColors, a0 as Log, a1 as MathRenderingContext, Q as MatrixWidget, F as NumericInput, a3 as PerseusI18nContextProvider, W as PlotterWidget, K as Radio, V as TableWidget, x as Widgets, _ as bodyXsmallBold, a8 as containerSizeClass, ac as contentHasWidgetType, at as deriveUserInputFromSerializedState, af as getAbsoluteValueCoords, as as getAngleCoords, ag as getCircleCoords, ah as getExponentialCoords, a9 as getInteractiveBoxFromSizeClass, aj as getLineCoords, ak as getLinearSystemCoords, ai as getLogarithmCoords, al as getPointCoords, am as getPolygonCoords, ar as getQuadraticCoords, an as getSegmentCoords, ao as getSinusoidCoords, ap as getTangentCoords, aq as getVectorCoords, ad as getWidgetFromWidgetMap, ab as getWidgetSubTypeByWidgetId, ae as getWidgetsFromWidgetMap, Y as iconChevronDown, Z as iconTrash, a2 as interactiveSizes, aa as mathOnlyParser, au as parseDataFromJSONP, a6 as preprocessTex, a7 as registerAllWidgetsForTesting, a4 as usePerseusI18n, y as widgets } from './chunk-register-all-widgets-for-testing-BTFpfYiU.js';
1
+ import { B as ButtonGroup, G as Graphie, H as HUD, I as Icon, a as InlineIcon, M as MathInput, b as MultiButtonGroup, N as NumberInput, R as RangeInput, S as SvgImage, T as TextInput, r as registerWidgets, c as basicWidgets, e as extraWidgets, d as replaceDeprecatedWidgets, P as PerseusI18nContext, A as ApiOptions, C as ClassNames, j as jsxRuntimeExports, U as UserInputManager, f as Renderer, D as DependenciesContext, g as Util, h as getDependencies, J as JiptParagraphs, i as hintPaddingInlineStart, k as hintBorderWidth, m as mediaQueries, s as sharedStyles, l as context$1, n as getWidgetTypeByWidgetId, o as getWidgetExport, p as PerseusMarkdown, t as typeToButton, q as getEquationString, u as defaultPlotProps, v as chooseType, w as DEFAULT_GRAPHER_PROPS } from './chunk-register-all-widgets-for-testing-CgikCidU.js';
2
+ export { L as Categorizer, $ as Dependencies, E as Expression, X as GrapherWidget, z as InputNumber, O as InteractiveGraphWidget, a5 as KhanColors, a0 as Log, a1 as MathRenderingContext, Q as MatrixWidget, F as NumericInput, a3 as PerseusI18nContextProvider, W as PlotterWidget, K as Radio, V as TableWidget, x as Widgets, _ as bodyXsmallBold, a8 as containerSizeClass, ac as contentHasWidgetType, at as deriveUserInputFromSerializedState, af as getAbsoluteValueCoords, as as getAngleCoords, ag as getCircleCoords, ah as getExponentialCoords, a9 as getInteractiveBoxFromSizeClass, aj as getLineCoords, ak as getLinearSystemCoords, ai as getLogarithmCoords, al as getPointCoords, am as getPolygonCoords, ar as getQuadraticCoords, an as getSegmentCoords, ao as getSinusoidCoords, ap as getTangentCoords, aq as getVectorCoords, ad as getWidgetFromWidgetMap, ab as getWidgetSubTypeByWidgetId, ae as getWidgetsFromWidgetMap, Y as iconChevronDown, Z as iconTrash, a2 as interactiveSizes, aa as mathOnlyParser, au as parseDataFromJSONP, a6 as preprocessTex, a7 as registerAllWidgetsForTesting, a4 as usePerseusI18n, y as widgets } from './chunk-register-all-widgets-for-testing-CgikCidU.js';
3
3
  import { addLibraryVersionToPerseusDebug } from '@khanacademy/perseus-utils';
4
4
  import * as React from 'react';
5
5
  import { createElement } from 'react';
@@ -83,11 +83,11 @@ var components = /*#__PURE__*/Object.freeze({
83
83
 
84
84
  const init=function(){registerWidgets(basicWidgets);registerWidgets(extraWidgets);replaceDeprecatedWidgets();};
85
85
 
86
- const libName="@khanacademy/perseus";const libVersion="90.0.1";addLibraryVersionToPerseusDebug(libName,libVersion);
86
+ const libName="@khanacademy/perseus";const libVersion="90.0.2";addLibraryVersionToPerseusDebug(libName,libVersion);
87
87
 
88
88
  const apiVersion={major:12,minor:0};
89
89
 
90
- class ArticleRenderer extends React.Component{componentDidMount(){this._currentFocus=null;}render(){const apiOptions={...ApiOptions.defaults,...this.props.apiOptions,isArticle:true};const classes=classNames({"framework-perseus":true,"perseus-article":true,[ClassNames.MOBILE]:apiOptions.isMobile});const sections=this._sections().map((section,sectionIndex)=>{const sectionSeed=this.props.seed+sectionIndex;return jsxRuntimeExports.jsx("div",{className:"clearfix",children:jsxRuntimeExports.jsx(UserInputManager,{widgets:section.widgets,problemNum:sectionSeed,children:({userInput,handleUserInput,initializeUserInput})=>createElement(Renderer,{...section,problemNum:sectionSeed,userInput:userInput,handleUserInput:handleUserInput,initializeUserInput:initializeUserInput,ref:elem=>{if(elem){this.sectionRenderers[sectionIndex]=elem;}},key:sectionIndex,keypadElement:this.props.keypadElement,apiOptions:{...apiOptions,onFocusChange:(newFocusPath,oldFocusPath)=>{this._handleFocusChange(newFocusPath&&[sectionIndex].concat(newFocusPath),oldFocusPath&&[sectionIndex].concat(oldFocusPath));}},linterContext:PerseusLinter.pushContextStack(this.props.linterContext,"article"),legacyPerseusLint:this.props.legacyPerseusLint,strings:this.context.strings})})},sectionIndex)});return jsxRuntimeExports.jsx("div",{className:classes,children:jsxRuntimeExports.jsx(DependenciesContext.Provider,{value:this.props.dependencies,children:sections})})}constructor(props){super(props),this.sectionRenderers=[],this._handleFocusChange=(newFocusPath,oldFocusPath)=>{if(newFocusPath){this._setCurrentFocus(newFocusPath);}else {this._onRendererBlur(oldFocusPath);}},this._setCurrentFocus=newFocusPath=>{const{keypadElement,apiOptions}=this.props;const{isMobile}=apiOptions;const prevFocusPath=this._currentFocus;this._currentFocus=newFocusPath;let didFocusInput=false;let focusedInput;if(this._currentFocus){const[sectionIndex,...focusPath]=this._currentFocus;const inputPaths=this.sectionRenderers[sectionIndex].getInputPaths();didFocusInput=inputPaths.some(inputPath=>{return Util.inputPathsEqual(inputPath,focusPath)});focusedInput=this.sectionRenderers[sectionIndex].getDOMNodeForPath(focusPath);}const{onFocusChange}=this.props.apiOptions;if(onFocusChange){setTimeout(()=>{const keypadDomNode=keypadElement?.getDOMNode();const keypadHeight=keypadDomNode&&didFocusInput?keypadDomNode.getBoundingClientRect().height:0;onFocusChange(this._currentFocus,prevFocusPath,keypadHeight,didFocusInput?focusedInput:null);},0);}if(keypadElement&&isMobile){if(didFocusInput){keypadElement.activate();}else {keypadElement.dismiss();}}},this._onRendererBlur=blurPath=>{const blurringFocusPath=this._currentFocus;if(!Util.inputPathsEqual(blurPath,blurringFocusPath)){return}setTimeout(()=>{if(Util.inputPathsEqual(this._currentFocus,blurringFocusPath)){this._setCurrentFocus(null);}});},this.blur=()=>{if(this._currentFocus){const[sectionIndex,...inputPath]=this._currentFocus;this.sectionRenderers[sectionIndex].blurPath(inputPath);}},this._sections=()=>{const sections=Array.isArray(this.props.json)?this.props.json:[this.props.json];if(getDependencies().JIPT.useJIPT){const paragraphs=[];for(const section of sections){JiptParagraphs.parseToArray(section.content).forEach(paragraph=>{paragraphs.push({...section,content:paragraph});});}return paragraphs}return sections};}}ArticleRenderer.contextType=PerseusI18nContext;ArticleRenderer.defaultProps={apiOptions:ApiOptions.defaults,linterContext:PerseusLinter.linterContextDefault};
90
+ class ArticleRenderer extends React.Component{componentDidMount(){this._currentFocus=null;}render(){const apiOptions={...ApiOptions.defaults,...this.props.apiOptions,isArticle:true};const classes=classNames({"framework-perseus":true,"perseus-article":true,[ClassNames.MOBILE]:apiOptions.isMobile});const sections=this._sections().map((section,sectionIndex)=>{const sectionSeed=this.props.seed+sectionIndex;return jsxRuntimeExports.jsx(UserInputManager,{widgets:section.widgets,problemNum:sectionSeed,children:({userInput,handleUserInput,initializeUserInput})=>createElement(Renderer,{...section,problemNum:sectionSeed,userInput:userInput,handleUserInput:handleUserInput,initializeUserInput:initializeUserInput,ref:elem=>{if(elem){this.sectionRenderers[sectionIndex]=elem;}},key:sectionIndex,keypadElement:this.props.keypadElement,apiOptions:{...apiOptions,onFocusChange:(newFocusPath,oldFocusPath)=>{this._handleFocusChange(newFocusPath&&[sectionIndex].concat(newFocusPath),oldFocusPath&&[sectionIndex].concat(oldFocusPath));}},linterContext:PerseusLinter.pushContextStack(this.props.linterContext,"article"),legacyPerseusLint:this.props.legacyPerseusLint,strings:this.context.strings})},sectionIndex)});return jsxRuntimeExports.jsx("div",{className:classes,children:jsxRuntimeExports.jsx(DependenciesContext.Provider,{value:this.props.dependencies,children:sections})})}constructor(props){super(props),this.sectionRenderers=[],this._handleFocusChange=(newFocusPath,oldFocusPath)=>{if(newFocusPath){this._setCurrentFocus(newFocusPath);}else {this._onRendererBlur(oldFocusPath);}},this._setCurrentFocus=newFocusPath=>{const{keypadElement,apiOptions}=this.props;const{isMobile}=apiOptions;const prevFocusPath=this._currentFocus;this._currentFocus=newFocusPath;let didFocusInput=false;let focusedInput;if(this._currentFocus){const[sectionIndex,...focusPath]=this._currentFocus;const inputPaths=this.sectionRenderers[sectionIndex].getInputPaths();didFocusInput=inputPaths.some(inputPath=>{return Util.inputPathsEqual(inputPath,focusPath)});focusedInput=this.sectionRenderers[sectionIndex].getDOMNodeForPath(focusPath);}const{onFocusChange}=this.props.apiOptions;if(onFocusChange){setTimeout(()=>{const keypadDomNode=keypadElement?.getDOMNode();const keypadHeight=keypadDomNode&&didFocusInput?keypadDomNode.getBoundingClientRect().height:0;onFocusChange(this._currentFocus,prevFocusPath,keypadHeight,didFocusInput?focusedInput:null);},0);}if(keypadElement&&isMobile){if(didFocusInput){keypadElement.activate();}else {keypadElement.dismiss();}}},this._onRendererBlur=blurPath=>{const blurringFocusPath=this._currentFocus;if(!Util.inputPathsEqual(blurPath,blurringFocusPath)){return}setTimeout(()=>{if(Util.inputPathsEqual(this._currentFocus,blurringFocusPath)){this._setCurrentFocus(null);}});},this.blur=()=>{if(this._currentFocus){const[sectionIndex,...inputPath]=this._currentFocus;this.sectionRenderers[sectionIndex].blurPath(inputPath);}},this._sections=()=>{const sections=Array.isArray(this.props.json)?this.props.json:[this.props.json];if(getDependencies().JIPT.useJIPT){const paragraphs=[];for(const section of sections){JiptParagraphs.parseToArray(section.content).forEach(paragraph=>{paragraphs.push({...section,content:paragraph});});}return paragraphs}return sections};}}ArticleRenderer.contextType=PerseusI18nContext;ArticleRenderer.defaultProps={apiOptions:ApiOptions.defaults,linterContext:PerseusLinter.linterContextDefault};
91
91
 
92
92
  class HintRenderer extends React.Component{render(){if(this.props.hint.placeholder){return jsxRuntimeExports.jsx("span",{})}const{apiOptions,className,hint,lastHint,lastRendered,pos,totalHints}=this.props;const{isMobile}=apiOptions;const classNames$1=classNames("hint",!isMobile&&"perseus-hint-renderer",isMobile&&css(styles$2.newHint),isMobile&&lastRendered&&css(styles$2.lastRenderedNewHint),lastHint&&"last-hint",lastRendered&&"last-rendered",className);const rendererApiOptions={...apiOptions,customKeypad:false};return jsxRuntimeExports.jsx(DependenciesContext.Provider,{value:this.props.dependencies,children:jsxRuntimeExports.jsxs("div",{className:classNames$1,tabIndex:"-1",children:[!apiOptions.isMobile&&jsxRuntimeExports.jsx("span",{className:"perseus-sr-only",children:this.context.strings.hintPos({pos:pos+1})}),!apiOptions.isMobile&&totalHints!=null&&pos!=null&&jsxRuntimeExports.jsx("span",{className:"perseus-hint-label",style:{display:"block",color:apiOptions.hintProgressColor},children:`${pos+1} / ${totalHints}`}),jsxRuntimeExports.jsx(UserInputManager,{widgets:hint.widgets,problemNum:0,children:({userInput,handleUserInput,initializeUserInput})=>jsxRuntimeExports.jsx(Renderer,{ref:this.rendererRef,userInput:userInput,handleUserInput:handleUserInput,initializeUserInput:initializeUserInput,widgets:hint.widgets,content:hint.content||"",images:hint.images,apiOptions:rendererApiOptions,findExternalWidgets:this.props.findExternalWidgets,linterContext:PerseusLinter.pushContextStack(this.props.linterContext,"hint"),strings:this.context.strings})})]})})}constructor(...args){super(...args),this.rendererRef=React.createRef(),this.getSerializedState=()=>{return this.rendererRef.current?.getSerializedState()};}}HintRenderer.contextType=PerseusI18nContext;HintRenderer.defaultProps={linterContext:PerseusLinter.linterContextDefault};const styles$2=StyleSheet.create({newHint:{marginBlockEnd:sizing.size_240,borderInlineStartColor:semanticColor.core.border.neutral.subtle,borderInlineStartStyle:"solid",borderInlineStartWidth:hintBorderWidth,[mediaQueries.lgOrSmaller]:{paddingInlineStart:hintPaddingInlineStart},[mediaQueries.smOrSmaller]:{paddingInlineStart:0},":focus":{outline:"none"}},lastRenderedNewHint:{marginBlockEnd:0,borderInlineStartColor:semanticColor.core.border.instructive.default}});
93
93