@khanacademy/perseus 75.1.0 → 75.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.
Files changed (36) hide show
  1. package/dist/es/index.css +3 -3
  2. package/dist/es/index.css.map +1 -1
  3. package/dist/es/index.js +20 -12
  4. package/dist/es/index.js.map +1 -1
  5. package/dist/es/strings.js +1 -1
  6. package/dist/es/strings.js.map +1 -1
  7. package/dist/index.css +3 -3
  8. package/dist/index.css.map +1 -1
  9. package/dist/index.js +22 -12
  10. package/dist/index.js.map +1 -1
  11. package/dist/server-item-renderer.d.ts +1 -1
  12. package/dist/strings.d.ts +8 -0
  13. package/dist/strings.js +1 -1
  14. package/dist/strings.js.map +1 -1
  15. package/dist/testing/feature-flags-util.d.ts +2 -2
  16. package/dist/testing/item-renderer-hooks.d.ts +2 -2
  17. package/dist/testing/item-renderer-reducer.d.ts +1 -2
  18. package/dist/testing/server-item-renderer-with-debug-ui.d.ts +1 -2
  19. package/dist/widgets/dropdown/dropdown.d.ts +1 -1
  20. package/dist/widgets/expression/expression.d.ts +2 -2
  21. package/dist/widgets/image/components/explore-image-modal-content.d.ts +2 -2
  22. package/dist/widgets/image/components/explore-image-modal.d.ts +2 -2
  23. package/dist/widgets/image/components/gif-controls-button.d.ts +5 -0
  24. package/dist/widgets/image/components/gif-controls-icon.d.ts +5 -0
  25. package/dist/widgets/image/components/{image-description-and-caption.d.ts → image-info-area.d.ts} +10 -3
  26. package/dist/widgets/image/utils.d.ts +7 -0
  27. package/dist/widgets/interactive-graphs/interactive-graph.d.ts +1 -1
  28. package/dist/widgets/interactive-graphs/utils.d.ts +18 -0
  29. package/dist/widgets/label-image/label-image.d.ts +1 -1
  30. package/dist/widgets/mock-widgets/mock-widget.d.ts +1 -1
  31. package/dist/widgets/numeric-input/numeric-input.class.d.ts +1 -1
  32. package/dist/widgets/numeric-input/numeric-input.d.ts +2 -2
  33. package/dist/widgets/radio/multiple-choice-widget.d.ts +1 -1
  34. package/dist/widgets/radio/radio.ff.d.ts +1 -1
  35. package/dist/widgets/table/table.d.ts +1 -1
  36. package/package.json +7 -7
@@ -1,8 +1,8 @@
1
+ import { type Interval, type PerseusImageBackground, type PerseusImageLabel, type Size } from "@khanacademy/perseus-core";
1
2
  import * as React from "react";
2
3
  import type { APIOptions } from "../../../types";
3
- import type { Interval, PerseusImageBackground, PerseusImageLabel, Size } from "@khanacademy/perseus-core";
4
4
  import type { LinterContextProps } from "@khanacademy/perseus-linter";
5
- export interface ImageDescriptionAndCaptionProps {
5
+ export interface ImageInfoAreaProps {
6
6
  backgroundImage: PerseusImageBackground;
7
7
  title: string;
8
8
  caption: string;
@@ -22,5 +22,12 @@ export interface ImageDescriptionAndCaptionProps {
22
22
  * determine if the image is large enough to allow zooming.
23
23
  */
24
24
  zoomSize: Size;
25
+ isGifPlaying: boolean;
26
+ setIsGifPlaying: (isPaused: boolean) => void;
25
27
  }
26
- export declare const ImageDescriptionAndCaption: (props: ImageDescriptionAndCaptionProps) => React.JSX.Element;
28
+ /**
29
+ * The ImageInfoArea component includes the GIF controls, description modal
30
+ * launcher, and caption for the image. This is displayed underneath the image
31
+ * in the Image widget.
32
+ */
33
+ export declare const ImageInfoArea: (props: ImageInfoAreaProps) => React.JSX.Element | null;
@@ -1,3 +1,4 @@
1
+ export declare function isGif(url: string): boolean;
1
2
  export declare const earthMoonImage: {
2
3
  url: string;
3
4
  width: number;
@@ -29,3 +30,9 @@ export declare const graphieImage: {
29
30
  height: number;
30
31
  };
31
32
  export declare const graphieImageAlt = "An array of isosceles triangles. A triangle has height A. Two smaller triangle, one with height B and one with height C, have approximately the same combined height as A.";
33
+ export declare const gifImage: {
34
+ url: string;
35
+ width: number;
36
+ height: number;
37
+ };
38
+ export declare const gifImageAlt = "A person on a skateboard moves back and forth across a concrete structure that forms the shape of a U.";
@@ -191,7 +191,7 @@ declare class InteractiveGraph extends React.Component<Props, State> {
191
191
  hintProgressColor?: string;
192
192
  canScrollPage?: boolean;
193
193
  editorChangeDelay?: number;
194
- flags?: Record<"new-radio-widget" | "image-widget-upgrade" | "image-widget-upgrade-alignment", boolean>;
194
+ flags?: Record<"new-radio-widget" | "image-widget-upgrade-alignment" | "image-widget-upgrade-gif-controls", boolean>;
195
195
  }> & {
196
196
  baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
197
197
  canScrollPage: NonNullable<import("../..").APIOptions["canScrollPage"]>;
@@ -42,3 +42,21 @@ export declare const calculateNestedSVGCoords: (range: vec.Vector2[], width: num
42
42
  viewboxX: number;
43
43
  viewboxY: number;
44
44
  };
45
+ /**
46
+ * Gets the effective CSS zoom factor applied to an element or any of its ancestors.
47
+ * This is used to compensate for the mobile font scaling zoom applied to the body
48
+ * or exercise content via the fontScale query parameter.
49
+ *
50
+ * On mobile, the parent application may apply CSS zoom to accommodate device font
51
+ * size settings. This zoom affects coordinate calculations for click/touch events,
52
+ * as both clientX/clientY and getBoundingClientRect() return zoomed values, but
53
+ * the SVG coordinate system expects unzoomed pixel values.
54
+ *
55
+ * Note: We calculate the cumulative zoom by traversing the DOM tree rather than
56
+ * targeting specific elements to avoid coupling Perseus to parent application
57
+ * implementation details (e.g., specific class names or DOM hierarchy).
58
+ *
59
+ * @param element - The DOM element to check for CSS zoom
60
+ * @returns The cumulative zoom factor (e.g., 1.5 for 150% zoom, 1.0 for no zoom)
61
+ */
62
+ export declare function getCSSZoomFactor(element: Element): number;
@@ -150,7 +150,7 @@ declare const _default: {
150
150
  hintProgressColor?: string;
151
151
  canScrollPage?: boolean;
152
152
  editorChangeDelay?: number;
153
- flags?: Record<"new-radio-widget" | "image-widget-upgrade" | "image-widget-upgrade-alignment", boolean>;
153
+ flags?: Record<"new-radio-widget" | "image-widget-upgrade-alignment" | "image-widget-upgrade-gif-controls", boolean>;
154
154
  }> & {
155
155
  baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
156
156
  canScrollPage: NonNullable<import("../..").APIOptions["canScrollPage"]>;
@@ -74,7 +74,7 @@ declare class MockWidgetComponent extends React.Component<Props> implements Widg
74
74
  hintProgressColor?: string;
75
75
  canScrollPage?: boolean;
76
76
  editorChangeDelay?: number;
77
- flags?: Record<"new-radio-widget" | "image-widget-upgrade" | "image-widget-upgrade-alignment", boolean>;
77
+ flags?: Record<"new-radio-widget" | "image-widget-upgrade-alignment" | "image-widget-upgrade-gif-controls", boolean>;
78
78
  }> & {
79
79
  baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
80
80
  canScrollPage: NonNullable<import("../..").APIOptions["canScrollPage"]>;
@@ -81,7 +81,7 @@ export declare class NumericInput extends React.Component<NumericInputProps> imp
81
81
  hintProgressColor?: string;
82
82
  canScrollPage?: boolean;
83
83
  editorChangeDelay?: number;
84
- flags?: Record<"new-radio-widget" | "image-widget-upgrade" | "image-widget-upgrade-alignment", boolean>;
84
+ flags?: Record<"new-radio-widget" | "image-widget-upgrade-alignment" | "image-widget-upgrade-gif-controls", boolean>;
85
85
  }> & {
86
86
  baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
87
87
  canScrollPage: NonNullable<import("../..").APIOptions["canScrollPage"]>;
@@ -44,7 +44,7 @@ export declare const NumericInputComponent: React.ForwardRefExoticComponent<impo
44
44
  hintProgressColor?: string;
45
45
  canScrollPage?: boolean;
46
46
  editorChangeDelay?: number;
47
- flags?: Record<"new-radio-widget" | "image-widget-upgrade" | "image-widget-upgrade-alignment", boolean>;
47
+ flags?: Record<"new-radio-widget" | "image-widget-upgrade-alignment" | "image-widget-upgrade-gif-controls", boolean>;
48
48
  }> & {
49
49
  baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
50
50
  canScrollPage: NonNullable<import("../..").APIOptions["canScrollPage"]>;
@@ -104,7 +104,7 @@ export declare const NumericInputComponent: React.ForwardRefExoticComponent<impo
104
104
  hintProgressColor?: string;
105
105
  canScrollPage?: boolean;
106
106
  editorChangeDelay?: number;
107
- flags?: Record<"new-radio-widget" | "image-widget-upgrade" | "image-widget-upgrade-alignment", boolean>;
107
+ flags?: Record<"new-radio-widget" | "image-widget-upgrade-alignment" | "image-widget-upgrade-gif-controls", boolean>;
108
108
  }> & {
109
109
  baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
110
110
  canScrollPage: NonNullable<import("../..").APIOptions["canScrollPage"]>;
@@ -81,7 +81,7 @@ declare const Radio: React.ForwardRefExoticComponent<RadioProps & {
81
81
  hintProgressColor?: string;
82
82
  canScrollPage?: boolean;
83
83
  editorChangeDelay?: number;
84
- flags?: Record<"new-radio-widget" | "image-widget-upgrade" | "image-widget-upgrade-alignment", boolean>;
84
+ flags?: Record<"new-radio-widget" | "image-widget-upgrade-alignment" | "image-widget-upgrade-gif-controls", boolean>;
85
85
  }> & {
86
86
  baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
87
87
  canScrollPage: NonNullable<import("../..").APIOptions["canScrollPage"]>;
@@ -78,7 +78,7 @@ declare class Radio extends React.Component<Props> implements Widget {
78
78
  hintProgressColor?: string;
79
79
  canScrollPage?: boolean;
80
80
  editorChangeDelay?: number;
81
- flags?: Record<"new-radio-widget" | "image-widget-upgrade" | "image-widget-upgrade-alignment", boolean>;
81
+ flags?: Record<"new-radio-widget" | "image-widget-upgrade-alignment" | "image-widget-upgrade-gif-controls", boolean>;
82
82
  }> & {
83
83
  baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
84
84
  canScrollPage: NonNullable<import("../..").APIOptions["canScrollPage"]>;
@@ -82,7 +82,7 @@ declare class Table extends React.Component<Props> implements Widget {
82
82
  hintProgressColor?: string;
83
83
  canScrollPage?: boolean;
84
84
  editorChangeDelay?: number;
85
- flags?: Record<"new-radio-widget" | "image-widget-upgrade" | "image-widget-upgrade-alignment", boolean>;
85
+ flags?: Record<"new-radio-widget" | "image-widget-upgrade-alignment" | "image-widget-upgrade-gif-controls", boolean>;
86
86
  }> & {
87
87
  baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
88
88
  canScrollPage: NonNullable<import("../..").APIOptions["canScrollPage"]>;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Core Perseus API (includes renderers and widgets)",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "75.1.0",
6
+ "version": "75.3.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -42,12 +42,12 @@
42
42
  "tiny-invariant": "1.3.1",
43
43
  "uuid": "^10.0.0",
44
44
  "@khanacademy/kas": "2.1.7",
45
- "@khanacademy/keypad-context": "3.2.32",
46
- "@khanacademy/kmath": "2.2.32",
47
- "@khanacademy/math-input": "26.4.0",
48
- "@khanacademy/perseus-core": "23.0.2",
49
- "@khanacademy/perseus-linter": "4.8.0",
50
- "@khanacademy/perseus-score": "8.2.9",
45
+ "@khanacademy/keypad-context": "3.2.33",
46
+ "@khanacademy/kmath": "2.2.33",
47
+ "@khanacademy/math-input": "26.4.1",
48
+ "@khanacademy/perseus-core": "23.1.0",
49
+ "@khanacademy/perseus-linter": "4.8.1",
50
+ "@khanacademy/perseus-score": "8.2.10",
51
51
  "@khanacademy/perseus-utils": "2.1.4",
52
52
  "@khanacademy/pure-markdown": "2.2.6",
53
53
  "@khanacademy/simple-markdown": "2.2.1"