@khanacademy/perseus-core 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/index.js +379 -33
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +399 -30
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/widgets/core-widget-registry.d.ts +28 -0
- package/dist/widgets/cs-program/cs-program-util.d.ts +2 -0
- package/dist/widgets/dropdown/dropdown-util.d.ts +20 -0
- package/dist/widgets/graded-group/index.d.ts +2 -2
- package/dist/widgets/graded-group-set/index.d.ts +2 -2
- package/dist/widgets/grapher/index.d.ts +5 -0
- package/dist/widgets/group/index.d.ts +2 -2
- package/dist/widgets/label-image/label-image-util.d.ts +19 -0
- package/dist/widgets/logic-export.types.d.ts +3 -0
- package/dist/widgets/number-line/number-line-util.d.ts +4 -0
- package/dist/widgets/numeric-input/numeric-input-util.d.ts +19 -0
- package/dist/widgets/phet-simulation/index.d.ts +2 -2
- package/dist/widgets/sorter/sorter-util.d.ts +16 -0
- package/dist/widgets/upgrade.d.ts +3 -0
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -29,4 +29,5 @@ export type InteractiveMarkerType = MarkerType & {
|
|
|
29
29
|
focused?: boolean;
|
|
30
30
|
};
|
|
31
31
|
export type Relationship = "lt" | "gt" | "le" | "ge";
|
|
32
|
+
export type Alignment = "default" | "block" | "inline-block" | "inline" | "float-left" | "float-right" | "full-width";
|
|
32
33
|
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Alignment } from "../types";
|
|
2
|
+
export declare function isWidgetRegistered(type: string): boolean;
|
|
3
|
+
export declare function getCurrentVersion(type: string): any;
|
|
4
|
+
export declare function getWidgetOptionsUpgrades(type: string): any;
|
|
5
|
+
export declare function getDefaultWidgetOptions(type: string): any;
|
|
6
|
+
/**
|
|
7
|
+
* Handling for the optional alignments for widgets
|
|
8
|
+
* See widget-container.jsx for details on how alignments are implemented.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Returns the list of supported alignments for the given (string) widget
|
|
12
|
+
* type. This is used primarily at editing time to display the choices
|
|
13
|
+
* for the user.
|
|
14
|
+
*
|
|
15
|
+
* Supported alignments are given as an array of strings in the exports of
|
|
16
|
+
* a widget's module.
|
|
17
|
+
*/
|
|
18
|
+
export declare const getSupportedAlignments: (type: string) => ReadonlyArray<Alignment>;
|
|
19
|
+
/**
|
|
20
|
+
* For the given (string) widget type, determine the default alignment for
|
|
21
|
+
* the widget. This is used at rendering time to go from "default" alignment
|
|
22
|
+
* to the actual alignment displayed on the screen.
|
|
23
|
+
*
|
|
24
|
+
* The default alignment is given either as a string (called
|
|
25
|
+
* `defaultAlignment`) or a function (called `getDefaultAlignment`) on
|
|
26
|
+
* the exports of a widget's module.
|
|
27
|
+
*/
|
|
28
|
+
export declare const getDefaultAlignment: (type: string) => Alignment;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PerseusDropdownWidgetOptions } from "@khanacademy/perseus-core";
|
|
2
|
+
/**
|
|
3
|
+
* For details on the individual options, see the
|
|
4
|
+
* PerseusDropdownWidgetOptions type
|
|
5
|
+
*/
|
|
6
|
+
type DropdownPublicWidgetOptions = {
|
|
7
|
+
choices: ReadonlyArray<{
|
|
8
|
+
content: string;
|
|
9
|
+
}>;
|
|
10
|
+
placeholder: PerseusDropdownWidgetOptions["placeholder"];
|
|
11
|
+
static: PerseusDropdownWidgetOptions["static"];
|
|
12
|
+
visibleLabel?: PerseusDropdownWidgetOptions["visibleLabel"];
|
|
13
|
+
ariaLabel?: PerseusDropdownWidgetOptions["ariaLabel"];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Given a PerseusDropdownWidgetOptions object, return a new object with only
|
|
17
|
+
* the public options that should be exposed to the client.
|
|
18
|
+
*/
|
|
19
|
+
declare function getDropdownPublicWidgetOptions(options: PerseusDropdownWidgetOptions): DropdownPublicWidgetOptions;
|
|
20
|
+
export default getDropdownPublicWidgetOptions;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PerseusGradedGroupWidgetOptions } from "../../data-schema";
|
|
2
2
|
import type { WidgetLogic } from "../logic-export.types";
|
|
3
3
|
export type GradedGroupDefaultWidgetOptions = Pick<PerseusGradedGroupWidgetOptions, "title" | "content" | "widgets" | "images" | "hint">;
|
|
4
|
-
declare const
|
|
5
|
-
export default
|
|
4
|
+
declare const gradedGroupWidgetLogic: WidgetLogic;
|
|
5
|
+
export default gradedGroupWidgetLogic;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PerseusGradedGroupSetWidgetOptions } from "../../data-schema";
|
|
2
2
|
import type { WidgetLogic } from "../logic-export.types";
|
|
3
3
|
export type GradedGroupSetDefaultWidgetOptions = Pick<PerseusGradedGroupSetWidgetOptions, "gradedGroups">;
|
|
4
|
-
declare const
|
|
5
|
-
export default
|
|
4
|
+
declare const gradedGroupSetWidgetLogic: WidgetLogic;
|
|
5
|
+
export default gradedGroupSetWidgetLogic;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PerseusGrapherWidgetOptions } from "../../data-schema";
|
|
2
|
+
import type { WidgetLogic } from "../logic-export.types";
|
|
3
|
+
export type GrapherDefaultWidgetOptions = Pick<PerseusGrapherWidgetOptions, "graph" | "correct" | "availableTypes">;
|
|
4
|
+
declare const grapherWidgetLogic: WidgetLogic;
|
|
5
|
+
export default grapherWidgetLogic;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PerseusGroupWidgetOptions } from "../../data-schema";
|
|
2
2
|
import type { WidgetLogic } from "../logic-export.types";
|
|
3
3
|
export type GroupDefaultWidgetOptions = Pick<PerseusGroupWidgetOptions, "content" | "widgets" | "images" | "metadata">;
|
|
4
|
-
declare const
|
|
5
|
-
export default
|
|
4
|
+
declare const groupWidgetLogic: WidgetLogic;
|
|
5
|
+
export default groupWidgetLogic;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PerseusLabelImageMarker, PerseusLabelImageWidgetOptions } from "@khanacademy/perseus-core";
|
|
2
|
+
/**
|
|
3
|
+
* For details on the individual options, see the
|
|
4
|
+
* PerseusLabelImageWidgetOptions type
|
|
5
|
+
*/
|
|
6
|
+
type LabelImagePublicWidgetOptions = {
|
|
7
|
+
choices: PerseusLabelImageWidgetOptions["choices"];
|
|
8
|
+
imageUrl: PerseusLabelImageWidgetOptions["imageUrl"];
|
|
9
|
+
imageAlt: PerseusLabelImageWidgetOptions["imageAlt"];
|
|
10
|
+
imageHeight: PerseusLabelImageWidgetOptions["imageHeight"];
|
|
11
|
+
imageWidth: PerseusLabelImageWidgetOptions["imageWidth"];
|
|
12
|
+
markers: ReadonlyArray<LabelImageMarkerPublicData>;
|
|
13
|
+
hideChoicesFromInstructions: PerseusLabelImageWidgetOptions["hideChoicesFromInstructions"];
|
|
14
|
+
multipleAnswers: PerseusLabelImageWidgetOptions["multipleAnswers"];
|
|
15
|
+
static: PerseusLabelImageWidgetOptions["static"];
|
|
16
|
+
};
|
|
17
|
+
type LabelImageMarkerPublicData = Pick<PerseusLabelImageMarker, "x" | "y" | "label">;
|
|
18
|
+
export default function getLabelImagePublicWidgetOptions(options: PerseusLabelImageWidgetOptions): LabelImagePublicWidgetOptions;
|
|
19
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Version } from "../data-schema";
|
|
2
|
+
import type { Alignment } from "../types";
|
|
2
3
|
export type WidgetOptionsUpgradeMap = {
|
|
3
4
|
[targetMajorVersion: string]: (arg1: any) => any;
|
|
4
5
|
};
|
|
@@ -7,4 +8,6 @@ export type WidgetLogic = {
|
|
|
7
8
|
version?: Version;
|
|
8
9
|
widgetOptionsUpgrades?: WidgetOptionsUpgradeMap;
|
|
9
10
|
defaultWidgetOptions?: any;
|
|
11
|
+
supportedAlignments?: ReadonlyArray<Alignment>;
|
|
12
|
+
defaultAlignment?: Alignment;
|
|
10
13
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PerseusNumberLineWidgetOptions } from "../../data-schema";
|
|
2
|
+
type NumberLinePublicWidgetOptions = Pick<PerseusNumberLineWidgetOptions, "range" | "labelRange" | "labelStyle" | "labelTicks" | "isTickCtrl" | "divisionRange" | "numDivisions" | "snapDivisions" | "tickStep" | "initialX" | "showTooltips" | "static">;
|
|
3
|
+
export default function getNumberLinePublicWidgetOptions(options: PerseusNumberLineWidgetOptions): NumberLinePublicWidgetOptions;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PerseusNumericInputWidgetOptions } from "@khanacademy/perseus-core";
|
|
2
|
+
/**
|
|
3
|
+
* For details on the individual options, see the
|
|
4
|
+
* PerseusNumericInputWidgetOptions type
|
|
5
|
+
*/
|
|
6
|
+
type NumericInputPublicWidgetOptions = {
|
|
7
|
+
labelText?: PerseusNumericInputWidgetOptions["labelText"];
|
|
8
|
+
size: PerseusNumericInputWidgetOptions["size"];
|
|
9
|
+
coefficient: PerseusNumericInputWidgetOptions["coefficient"];
|
|
10
|
+
rightAlign?: PerseusNumericInputWidgetOptions["rightAlign"];
|
|
11
|
+
static: PerseusNumericInputWidgetOptions["static"];
|
|
12
|
+
answerForms?: PerseusNumericInputWidgetOptions["answerForms"];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Given a PerseusNumericInputWidgetOptions object, return a new object with only
|
|
16
|
+
* the public options that should be exposed to the client.
|
|
17
|
+
*/
|
|
18
|
+
declare function getNumericInputPublicWidgetOptions(options: PerseusNumericInputWidgetOptions): NumericInputPublicWidgetOptions;
|
|
19
|
+
export default getNumericInputPublicWidgetOptions;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PerseusPhetSimulationWidgetOptions } from "../../data-schema";
|
|
2
2
|
import type { WidgetLogic } from "../logic-export.types";
|
|
3
3
|
export type PhetSimulationDefaultWidgetOptions = Pick<PerseusPhetSimulationWidgetOptions, "url" | "description">;
|
|
4
|
-
declare const
|
|
5
|
-
export default
|
|
4
|
+
declare const phetSimulationWidgetLogic: WidgetLogic;
|
|
5
|
+
export default phetSimulationWidgetLogic;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PerseusSorterWidgetOptions } from "@khanacademy/perseus-core";
|
|
2
|
+
/**
|
|
3
|
+
* For details on the individual options, see the
|
|
4
|
+
* PerseusSorterWidgetOptions type
|
|
5
|
+
*/
|
|
6
|
+
type SorterPublicWidgetOptions = {
|
|
7
|
+
correct: PerseusSorterWidgetOptions["correct"];
|
|
8
|
+
padding: PerseusSorterWidgetOptions["padding"];
|
|
9
|
+
layout: PerseusSorterWidgetOptions["layout"];
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Given a PerseusSorterWidgetOptions object, return a new object with only
|
|
13
|
+
* the public options that should be exposed to the client.
|
|
14
|
+
*/
|
|
15
|
+
declare function getSorterPublicWidgetOptions(options: PerseusSorterWidgetOptions): SorterPublicWidgetOptions;
|
|
16
|
+
export default getSorterPublicWidgetOptions;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PerseusWidget, PerseusWidgetsMap } from "../data-schema";
|
|
2
|
+
export declare const upgradeWidgetInfoToLatestVersion: (oldWidgetInfo: PerseusWidget) => PerseusWidget;
|
|
3
|
+
export declare function getUpgradedWidgetOptions(oldWidgetOptions: PerseusWidgetsMap): PerseusWidgetsMap;
|