@khanacademy/perseus 16.0.0 → 17.1.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 (57) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/dist/article-renderer.d.ts +1 -2
  3. package/dist/components.d.ts +0 -1
  4. package/dist/dependencies.d.ts +1 -0
  5. package/dist/es/index.css +20 -90
  6. package/dist/es/index.js +457 -1028
  7. package/dist/es/index.js.map +1 -1
  8. package/dist/index.css +20 -90
  9. package/dist/index.d.ts +0 -1
  10. package/dist/index.js +456 -1031
  11. package/dist/index.js.map +1 -1
  12. package/dist/perseus-types.d.ts +1 -0
  13. package/dist/server-item-renderer.d.ts +42 -15
  14. package/dist/strings.js +1 -23
  15. package/dist/widgets/label-image/answer-pill.d.ts +10 -0
  16. package/dist/widgets/label-image/hide-answers-toggle.d.ts +6 -0
  17. package/dist/widgets/label-image/marker.d.ts +6 -9
  18. package/dist/widgets/label-image/types.d.ts +1 -0
  19. package/dist/widgets/label-image.d.ts +101 -12
  20. package/package.json +30 -22
  21. package/src/__stories__/server-item-renderer.stories.tsx +20 -1
  22. package/src/__testdata__/server-item-renderer.testdata.ts +173 -0
  23. package/src/__tests__/__snapshots__/renderer.test.tsx.snap +3 -3
  24. package/src/__tests__/server-item-renderer.test.tsx +38 -1
  25. package/src/article-renderer.tsx +13 -15
  26. package/src/components.ts +0 -1
  27. package/src/dependencies.ts +4 -0
  28. package/src/index.ts +0 -1
  29. package/src/perseus-types.ts +2 -0
  30. package/src/server-item-renderer.tsx +26 -14
  31. package/src/styles/khan-exercise.css +0 -24
  32. package/src/styles/widgets/label-image.less +32 -0
  33. package/src/widgets/__stories__/label-image.stories.tsx +73 -3
  34. package/src/widgets/__testdata__/label-image.testdata.ts +118 -1
  35. package/src/widgets/__tests__/__snapshots__/dropdown.test.ts.snap +2 -2
  36. package/src/widgets/label-image/__stories__/answer-pill.stories.tsx +62 -0
  37. package/src/widgets/label-image/__tests__/answer-pill.test.tsx +83 -0
  38. package/src/widgets/label-image/__tests__/hide-answers-toggle.test.tsx +39 -0
  39. package/src/widgets/label-image/answer-choices.tsx +7 -1
  40. package/src/widgets/label-image/answer-pill.tsx +89 -0
  41. package/src/widgets/label-image/hide-answers-toggle.tsx +40 -0
  42. package/src/widgets/label-image/marker.tsx +116 -174
  43. package/src/widgets/label-image/types.ts +1 -0
  44. package/src/widgets/label-image.test.ts +142 -52
  45. package/src/widgets/label-image.tsx +212 -135
  46. package/tsconfig-build.tsbuildinfo +1 -1
  47. package/dist/components/tex-buttons.d.ts +0 -25
  48. package/dist/item-renderer.d.ts +0 -125
  49. package/dist/mixins/provide-keypad.d.ts +0 -39
  50. package/src/__stories__/item-renderer.stories.tsx +0 -30
  51. package/src/__testdata__/item-renderer.testdata.ts +0 -299
  52. package/src/__tests__/__snapshots__/item-renderer.test.tsx.snap +0 -224
  53. package/src/__tests__/item-renderer.test.tsx +0 -930
  54. package/src/components/__stories__/text-buttons.stories.tsx +0 -54
  55. package/src/components/tex-buttons.tsx +0 -334
  56. package/src/item-renderer.tsx +0 -529
  57. package/src/mixins/provide-keypad.tsx +0 -137
package/CHANGELOG.md CHANGED
@@ -1,5 +1,79 @@
1
1
  # @khanacademy/perseus
2
2
 
3
+ ## 17.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#804](https://github.com/Khan/perseus/pull/804) [`2c295e2c`](https://github.com/Khan/perseus/commit/2c295e2c26ff2bf15e1e8e82bcc34e04e4b9bab0) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Add pill that contains answer after selection in Label Image Widget
8
+
9
+ * [#804](https://github.com/Khan/perseus/pull/804) [`6f530d58`](https://github.com/Khan/perseus/commit/6f530d58b4368fb3c38d62d4dcf1f63cecf67d90) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Use WB Pill + `react-popper` to get hovering answer pill in Label Image Widget
10
+
11
+ - [#804](https://github.com/Khan/perseus/pull/804) [`cccf1897`](https://github.com/Khan/perseus/commit/cccf1897da294e4b1fec804f2639c1c56bd68201) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Adds "hide answers" toggle to hide answer pills on label image widget
12
+
13
+ ### Patch Changes
14
+
15
+ - [#804](https://github.com/Khan/perseus/pull/804) [`ce343147`](https://github.com/Khan/perseus/commit/ce343147f558c2f2a1dcbabae20bdba22c0de86d) Thanks [@nixterrimus](https://github.com/nixterrimus)! - For wide image, label image popovers only go above or below marker
16
+
17
+ * [#804](https://github.com/Khan/perseus/pull/804) [`1c8f2753`](https://github.com/Khan/perseus/commit/1c8f275391b02bef8e14d1daccef8fadea9066cd) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Implement hover on label image pills
18
+
19
+ - [#856](https://github.com/Khan/perseus/pull/856) [`6c323dc3`](https://github.com/Khan/perseus/commit/6c323dc37e7cc972fe5a1ab7cbf90a23bf4dd3a0) Thanks [@nedredmond](https://github.com/nedredmond)! - Upgrade WB
20
+
21
+ * [#858](https://github.com/Khan/perseus/pull/858) [`7433c91b`](https://github.com/Khan/perseus/commit/7433c91bb05ad0441475f40bcd05a3076e7e19f1) Thanks [@nedredmond](https://github.com/nedredmond)! - Remove custom event listeners from label image widget and use WB's built-in functionality to achieve the same thing. Fixes a bug where answer choices were not dismissing as expected.
22
+
23
+ - [#804](https://github.com/Khan/perseus/pull/804) [`dd41dd0e`](https://github.com/Khan/perseus/commit/dd41dd0e8bc76a414bb5906bba4648f57547f188) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Reverts Perseus global mobile styles for answer pill in label image widget
24
+
25
+ * [#804](https://github.com/Khan/perseus/pull/804) [`53612027`](https://github.com/Khan/perseus/commit/536120272b8cae3b01cdbe09a59488cc4704329d) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Label image dot styles
26
+
27
+ - [#861](https://github.com/Khan/perseus/pull/861) [`bb9cd667`](https://github.com/Khan/perseus/commit/bb9cd667dbb4a38724ae174063021fdf18040f9b) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Bug fix: dont hide chevron in label image on focus
28
+
29
+ * [#862](https://github.com/Khan/perseus/pull/862) [`4553af79`](https://github.com/Khan/perseus/commit/4553af79a26fc0e635d7dc03be74f39cb00a05f6) Thanks [@nedredmond](https://github.com/nedredmond)! - Darken green to match accessible pill color
30
+
31
+ - [#804](https://github.com/Khan/perseus/pull/804) [`07537aae`](https://github.com/Khan/perseus/commit/07537aae870866f4418055b5956e9387f85f72c4) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Add periodicTableWithKey to `perseus-types`
32
+
33
+ * [#804](https://github.com/Khan/perseus/pull/804) [`bb81559e`](https://github.com/Khan/perseus/commit/bb81559e02359092ba4d48107010c476b5ae09d5) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Give label image widget switch an accessible label.
34
+
35
+ - [#804](https://github.com/Khan/perseus/pull/804) [`fd09014c`](https://github.com/Khan/perseus/commit/fd09014c26e33d2c83a1e6ae3672027ac9583d41) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Minor CSS change to label image
36
+
37
+ * [#860](https://github.com/Khan/perseus/pull/860) [`1f4e17ba`](https://github.com/Khan/perseus/commit/1f4e17ba77e1491523813655af18a70285a25989) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Add hover states in label-image widget
38
+
39
+ - [#804](https://github.com/Khan/perseus/pull/804) [`f6be48a9`](https://github.com/Khan/perseus/commit/f6be48a96795858e009bea18cc1092d150f98b71) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Change marker styles in label image widget
40
+
41
+ * [#804](https://github.com/Khan/perseus/pull/804) [`34f7696b`](https://github.com/Khan/perseus/commit/34f7696b537d28c4b2054a3995f567a9a6834f73) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Allows a manually set direction to be used for label image, if and only if there's space
42
+
43
+ - [#848](https://github.com/Khan/perseus/pull/848) [`8857950b`](https://github.com/Khan/perseus/commit/8857950bdeeb6e13bc3766b1c6545289b21cbe2a) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Add analytics for label image
44
+
45
+ * [#804](https://github.com/Khan/perseus/pull/804) [`ded7af48`](https://github.com/Khan/perseus/commit/ded7af488d57e6309f7244ca4b897ac680754d74) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Update dot styling in label image widget
46
+
47
+ - [#804](https://github.com/Khan/perseus/pull/804) [`1906ec5a`](https://github.com/Khan/perseus/commit/1906ec5afb7fd7332a6cabc6afc79ee1f779f8ec) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Match marker color after checking answers
48
+
49
+ * [#851](https://github.com/Khan/perseus/pull/851) [`5e4c21bd`](https://github.com/Khan/perseus/commit/5e4c21bda5717fb793386a810be3144d7b9a9011) Thanks [@nedredmond](https://github.com/nedredmond)! - Fix label image answer pill padding when correct answer registered
50
+
51
+ - [#804](https://github.com/Khan/perseus/pull/804) [`30ce593a`](https://github.com/Khan/perseus/commit/30ce593a2f1d552338ce0818cf754c13c22af281) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Reduce motion on dot animation when option is enabled
52
+
53
+ - Updated dependencies [[`6c323dc3`](https://github.com/Khan/perseus/commit/6c323dc37e7cc972fe5a1ab7cbf90a23bf4dd3a0), [`2c295e2c`](https://github.com/Khan/perseus/commit/2c295e2c26ff2bf15e1e8e82bcc34e04e4b9bab0), [`1f4e17ba`](https://github.com/Khan/perseus/commit/1f4e17ba77e1491523813655af18a70285a25989), [`8857950b`](https://github.com/Khan/perseus/commit/8857950bdeeb6e13bc3766b1c6545289b21cbe2a)]:
54
+ - @khanacademy/math-input@16.1.2
55
+ - @khanacademy/perseus-core@1.4.1
56
+ - @khanacademy/kas@0.3.7
57
+ - @khanacademy/kmath@0.1.8
58
+ - @khanacademy/perseus-linter@0.3.10
59
+ - @khanacademy/pure-markdown@0.2.13
60
+ - @khanacademy/simple-markdown@0.11.2
61
+
62
+ ## 17.0.0
63
+
64
+ ### Major Changes
65
+
66
+ - [#852](https://github.com/Khan/perseus/pull/852) [`204788f8`](https://github.com/Khan/perseus/commit/204788f8f583bda5ff94d74fd70ec542fedd3d6e) Thanks [@handeyeco](https://github.com/handeyeco)! - Remove ItemRenderer again
67
+
68
+ * [#838](https://github.com/Khan/perseus/pull/838) [`233fc9fc`](https://github.com/Khan/perseus/commit/233fc9fcd4c65d2ff0c8f1ebd1cb1b17b76cbe0c) Thanks [@handeyeco](https://github.com/handeyeco)! - Remove TexButtons and update ExpressionEditor
69
+
70
+ ### Patch Changes
71
+
72
+ - [#854](https://github.com/Khan/perseus/pull/854) [`2e2f2cc1`](https://github.com/Khan/perseus/commit/2e2f2cc1afe99613eb688ab1e4e1fccad0c8df57) Thanks [@handeyeco](https://github.com/handeyeco)! - Remove unused CSS images for next/prev steps
73
+
74
+ - Updated dependencies [[`41d3cd93`](https://github.com/Khan/perseus/commit/41d3cd93f78d4649c8a57b6fa4964c0c9f2c45b0), [`27f691aa`](https://github.com/Khan/perseus/commit/27f691aa11f061b54db487b5b35222431776260f), [`3803452b`](https://github.com/Khan/perseus/commit/3803452b0593649faf4043bf6e1d7681a14078e4), [`ef32b88f`](https://github.com/Khan/perseus/commit/ef32b88f5027154784fb496506d7c96ee3765eac), [`820febc5`](https://github.com/Khan/perseus/commit/820febc5814a5a10d7c1743be8aa9d220f2d9bd8), [`67a09051`](https://github.com/Khan/perseus/commit/67a09051c61df98b697349ad75760193e4228bfe)]:
75
+ - @khanacademy/math-input@16.1.1
76
+
3
77
  ## 16.0.0
4
78
 
5
79
  ### Major Changes
@@ -5,13 +5,12 @@
5
5
  import * as React from "react";
6
6
  import { DependenciesContext } from "./dependencies";
7
7
  import Renderer from "./renderer";
8
- import type { KeypadProps } from "./mixins/provide-keypad";
9
8
  import type { PerseusRenderer } from "./perseus-types";
10
9
  import type { APIOptions, PerseusDependenciesV2 } from "./types";
11
10
  import type { KeypadAPI } from "@khanacademy/math-input";
12
11
  import type { KeypadContextRendererInterface } from "@khanacademy/perseus-core";
13
12
  import type { LinterContextProps } from "@khanacademy/perseus-linter";
14
- type Props = Partial<React.ContextType<typeof DependenciesContext>> & KeypadProps & {
13
+ type Props = Partial<React.ContextType<typeof DependenciesContext>> & {
15
14
  apiOptions: APIOptions;
16
15
  json: PerseusRenderer | ReadonlyArray<PerseusRenderer>;
17
16
  /**
@@ -12,5 +12,4 @@ export { default as PropCheckBox } from "./components/prop-check-box";
12
12
  export { default as RangeInput } from "./components/range-input";
13
13
  export { default as SvgImage } from "./components/svg-image";
14
14
  export { default as TextInput } from "./components/text-input";
15
- export { default as TexButtons } from "./components/tex-buttons";
16
15
  export { default as TextListEditor } from "./components/text-list-editor";
@@ -2,6 +2,7 @@ import * as React from "react";
2
2
  import type { PerseusDependencies, PerseusDependenciesV2 } from "./types";
3
3
  export declare const setDependencies: (dependencies: PerseusDependencies) => void;
4
4
  export declare const getDependencies: () => PerseusDependencies;
5
+ export type DependencyProps = Partial<React.ContextType<typeof DependenciesContext>>;
5
6
  export declare const DependenciesContext: React.Context<PerseusDependenciesV2>;
6
7
  /**
7
8
  * useDependencies provides easy access to the current Perseus dependencies.
package/dist/es/index.css CHANGED
@@ -675,30 +675,6 @@ div.timeline-total {
675
675
  width: 100px;
676
676
  }
677
677
 
678
- #previous-step {
679
- margin: 5px;
680
- cursor: pointer;
681
- float: left;
682
- width: 100px;
683
- }
684
-
685
- #next-step {
686
- margin: 5px;
687
- cursor: pointer;
688
- float: right;
689
- width: 80px;
690
- }
691
-
692
- #previous-step span {
693
- background: url(/images/previous-step.png) no-repeat 0 50% transparent;
694
- padding: 4px 0 4px 25px;
695
- }
696
-
697
- #next-step span {
698
- background: url(/images/next-step.png) no-repeat 100% 50% transparent;
699
- padding: 4px 25px 4px 0;
700
- }
701
-
702
678
  #next-problem {
703
679
  margin: 5px;
704
680
  cursor: pointer;
@@ -2819,6 +2795,26 @@ body.mobile .categorizer-container td.category input[type="radio"] + span:active
2819
2795
  .framework-perseus .perseus-label-image-widget-instructions div.paragraph {
2820
2796
  margin: 0;
2821
2797
  }
2798
+ .framework-perseus button[id*="perseus-label-image-widget-answer-pill"] div.paragraph,
2799
+ .framework-perseus div[id*="perseus-label-image-widget-answer-pill"] div.paragraph {
2800
+ all: revert;
2801
+ }
2802
+ .framework-perseus button[id*="perseus-label-image-widget-answer-pill"] div.perseus-block-math-inner,
2803
+ .framework-perseus div[id*="perseus-label-image-widget-answer-pill"] div.perseus-block-math-inner {
2804
+ margin: -5px 0 !important;
2805
+ }
2806
+ @media (max-width: 767px) {
2807
+ [id*="perseus-label-image-widget-answer-pill"] div.paragraph {
2808
+ all: revert;
2809
+ }
2810
+ [id*="perseus-label-image-widget-answer-pill"] > div.perseus-renderer-responsive {
2811
+ all: revert;
2812
+ }
2813
+ .framework-perseus.perseus-mobile [id*="perseus-label-image-widget-answer-pill"] .perseus-renderer > .paragraph,
2814
+ .framework-perseus.perseus-mobile [id*="perseus-label-image-widget-answer-pill"] .perseus-renderer > .paragraph .paragraph {
2815
+ all: revert;
2816
+ }
2817
+ }
2822
2818
  .framework-perseus:not(.perseus-article).perseus-mobile .perseus-label-image-widget-instructions {
2823
2819
  color: initial;
2824
2820
  }
@@ -3584,48 +3580,6 @@ body.mobile .framework-perseus table.perseus-widget-table-of-values.non-markdown
3584
3580
  font-size: 18px;
3585
3581
  }
3586
3582
  }
3587
- /**
3588
- * Styles for managing the popover animations.
3589
- *
3590
- * Ideally, we'd be generating these styles with Aphrodite (along with
3591
- * CSSTransitionGroup's support for custom classnames), but the generated
3592
- * styles have issues on mobile Safari.
3593
- * See: https://github.com/Khan/aphrodite/issues/68.
3594
- *
3595
- * If the animation durations change, the corresponding values in
3596
- * echo-manager.js must change as well.
3597
- */
3598
- .echo-slide-and-fade-enter {
3599
- opacity: 1 !important;
3600
- transform: translate3d(0, 0, 0) !important;
3601
- }
3602
- .echo-slide-and-fade-enter.echo-slide-and-fade-enter-active {
3603
- opacity: 0 !important;
3604
- transform: translate3d(0, -33%, 0) !important;
3605
- /**
3606
- * TODO(charlie): These times are intentionally different, which means
3607
- * that the animation really "ends" after 400ms
3608
- * cubic-bezier(1, 0, 0.9, 1) (since the opacity goes to 0), even though
3609
- * the transform doesn't complete. There's probably a way to achieve the
3610
- * same effect by manipulating the transform's Bezier curve and total
3611
- * displacement.
3612
- */
3613
- transition: transform 800ms cubic-bezier(0, 1, 0.25, 1), opacity 400ms cubic-bezier(1, 0, 0.9, 1) !important;
3614
- }
3615
- .echo-fade-only-enter {
3616
- opacity: 1 !important;
3617
- }
3618
- .echo-fade-only-enter.echo-fade-only-enter-active {
3619
- opacity: 0 !important;
3620
- transition: opacity 300ms cubic-bezier(0.25, 0, 0.75, 1) !important;
3621
- }
3622
- .echo-long-fade-only-enter {
3623
- opacity: 1 !important;
3624
- }
3625
- .echo-long-fade-only-enter.echo-long-fade-only-enter-active {
3626
- opacity: 0 !important;
3627
- transition: opacity 400ms cubic-bezier(0.75, 0, 0.75, 1) !important;
3628
- }
3629
3583
  .keypad-input {
3630
3584
  outline: none !important;
3631
3585
  }
@@ -3706,24 +3660,6 @@ body.mobile .framework-perseus table.perseus-widget-table-of-values.non-markdown
3706
3660
  color: white !important;
3707
3661
  display: inline-block !important;
3708
3662
  }
3709
- /**
3710
- * Styles for managing the popover animations.
3711
- *
3712
- * Ideally, we'd be generating these styles with Aphrodite (along with
3713
- * CSSTransitionGroup's support for custom classnames), but the generated
3714
- * styles have issues on mobile Safari.
3715
- * See: https://github.com/Khan/aphrodite/issues/68.
3716
- *
3717
- * If the animation durations change, the corresponding values in
3718
- * popover-manager.js must change as well.
3719
- */
3720
- .popover-enter {
3721
- opacity: 0 !important;
3722
- }
3723
- .popover-enter.popover-enter-active {
3724
- opacity: 1 !important;
3725
- transition: opacity 200ms ease-out !important;
3726
- }
3727
3663
  /*
3728
3664
  * MathQuill v0.10.1 http://mathquill.com
3729
3665
  * by Han, Jeanine, and Mary maintainers@mathquill.com
@@ -4160,9 +4096,3 @@ body.mobile .framework-perseus table.perseus-widget-table-of-values.non-markdown
4160
4096
  margin-top: -0.1em;
4161
4097
  }
4162
4098
 
4163
- .tabbar_item {
4164
- background-color: red;
4165
- }
4166
- .tabbar_item:focus {
4167
- background-color: green;
4168
- }