@khanacademy/perseus 11.6.0 → 12.0.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/CHANGELOG.md +35 -0
  2. package/dist/components/math-input.d.ts +38 -11
  3. package/dist/components/tex-buttons.d.ts +2 -1
  4. package/dist/es/index.css +5 -6
  5. package/dist/es/index.js +1454 -1371
  6. package/dist/es/index.js.map +1 -1
  7. package/dist/index.css +5 -6
  8. package/dist/index.d.ts +2 -8
  9. package/dist/index.js +1475 -1390
  10. package/dist/index.js.map +1 -1
  11. package/dist/item-renderer.d.ts +3 -0
  12. package/dist/perseus-types.d.ts +2 -1
  13. package/dist/perseus-version.d.ts +8 -0
  14. package/dist/strings.js +3 -0
  15. package/dist/version.d.ts +1 -11
  16. package/dist/widgets/expression.d.ts +15 -14
  17. package/package.json +9 -9
  18. package/src/__tests__/mock-asset-loading-widget.tsx +1 -2
  19. package/src/components/__stories__/graphie.stories.tsx +2 -2
  20. package/src/components/__stories__/math-input.stories.tsx +17 -4
  21. package/src/components/__tests__/math-input.test.tsx +95 -8
  22. package/src/components/math-input.tsx +274 -96
  23. package/src/components/tex-buttons.tsx +2 -2
  24. package/src/index.ts +2 -5
  25. package/src/item-renderer.tsx +3 -0
  26. package/src/item-version.ts +2 -2
  27. package/src/perseus-types.ts +11 -1
  28. package/src/perseus-version.ts +9 -0
  29. package/src/styles/perseus-renderer.less +5 -6
  30. package/src/styles/widgets/expression.less +0 -6
  31. package/src/version.ts +9 -10
  32. package/src/widgets/__stories__/expression.stories.tsx +24 -13
  33. package/src/widgets/__tests__/expression.test.tsx +4 -77
  34. package/src/widgets/expression.tsx +99 -94
  35. package/tsconfig-build.json +1 -0
  36. package/tsconfig-build.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # @khanacademy/perseus
2
2
 
3
+ ## 12.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 5bcf118c: # Update MathInput
8
+
9
+ - `buttonSets` is now deprecated in favor of `keypadButtonSets`, but currently maps to the new prop for backwards compatability.
10
+ - `buttonsVisible` is now a bit misleading: "focused" is the default state with a toggle-able keypad and "always" shows the keypad by default.
11
+
12
+ ### Minor Changes
13
+
14
+ - 5bcf118c: Desktop Expression Widget now uses v2 keypad
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [5bcf118c]
19
+ - @khanacademy/math-input@14.1.0
20
+
21
+ ## 11.6.1
22
+
23
+ ### Patch Changes
24
+
25
+ - 1721c05c: Fix broken Expression Mobile test
26
+ - 55d4cd00: Print package name and version when loaded in the page
27
+ - Updated dependencies [4f8afadd]
28
+ - Updated dependencies [7d8905b6]
29
+ - Updated dependencies [55d4cd00]
30
+ - @khanacademy/math-input@14.0.1
31
+ - @khanacademy/kas@0.3.2
32
+ - @khanacademy/kmath@0.1.3
33
+ - @khanacademy/perseus-core@1.1.1
34
+ - @khanacademy/perseus-linter@0.3.5
35
+ - @khanacademy/pure-markdown@0.2.7
36
+ - @khanacademy/simple-markdown@0.10.1
37
+
3
38
  ## 11.6.0
4
39
 
5
40
  ### Minor Changes
@@ -1,25 +1,55 @@
1
+ import { CursorContext } from "@khanacademy/math-input";
1
2
  import * as React from "react";
2
- import type { ButtonSetsType } from "./tex-buttons";
3
- import type { MathFieldInterface } from "@khanacademy/math-input";
3
+ import type { LegacyButtonSets } from "../perseus-types";
4
+ import type { PerseusDependenciesV2 } from "../types";
5
+ import type { Keys, MathFieldInterface } from "@khanacademy/math-input";
4
6
  type ButtonsVisibleType = "always" | "never" | "focused";
7
+ type KeypadButtonSets = {
8
+ advancedRelations?: boolean;
9
+ basicRelations?: boolean;
10
+ divisionKey?: boolean;
11
+ logarithms?: boolean;
12
+ preAlgebra?: boolean;
13
+ trigonometry?: boolean;
14
+ };
5
15
  type Props = {
6
16
  className?: string;
7
17
  value: string;
8
18
  onChange: any;
9
19
  convertDotToTimes: boolean;
10
- buttonsVisible: ButtonsVisibleType;
11
- buttonSets: ButtonSetsType;
20
+ /**
21
+ * @deprecated Use `keypadButtonSets` instead. Maps to `keypadButtonSets`.
22
+ * @see keypadButtonSets
23
+ */
24
+ buttonSets?: LegacyButtonSets;
25
+ /**
26
+ * Overrides deprecated `buttonSets` prop.
27
+ */
28
+ keypadButtonSets?: KeypadButtonSets;
12
29
  labelText?: string;
13
30
  onFocus?: () => void;
14
31
  onBlur?: () => void;
32
+ hasError?: boolean;
33
+ extraKeys?: ReadonlyArray<Keys>;
34
+ /**
35
+ * Whether to show the keypad buttons.
36
+ * The strings now misleading, but we keep them for backwards compatibility.
37
+ * - `focused` means that the keypad **appears on toggle, *off* by default**.
38
+ * - `always` means that the keypad **appears on toggle, *on* by default.**
39
+ * - `never` means that the keypad is **never shown**.
40
+ */
41
+ buttonsVisible?: ButtonsVisibleType;
42
+ analytics: PerseusDependenciesV2["analytics"];
15
43
  };
16
44
  type DefaultProps = {
17
45
  value: Props["value"];
18
46
  convertDotToTimes: Props["convertDotToTimes"];
19
- buttonsVisible: Props["buttonsVisible"];
20
47
  };
21
48
  type State = {
22
49
  focused: boolean;
50
+ keypadOpen: boolean;
51
+ cursorContext: typeof CursorContext[keyof typeof CursorContext];
52
+ openedWithEventType?: string;
23
53
  };
24
54
  declare class MathInput extends React.Component<Props, State> {
25
55
  mouseDown: boolean;
@@ -28,16 +58,13 @@ declare class MathInput extends React.Component<Props, State> {
28
58
  static defaultProps: DefaultProps;
29
59
  state: State;
30
60
  componentDidMount(): void;
31
- componentWillUnmount(): void;
32
- handleFocus: () => void;
33
- handleMouseDown: (arg1: MouseEvent) => void;
34
- handleMouseUp: (arg1: MouseEvent) => void;
35
- handleBlur: (arg1: React.FocusEvent) => void;
36
- _shouldShowButtons: () => boolean;
61
+ openKeypad(): void;
62
+ closeKeypad(): void;
37
63
  insert: (value: any) => void;
38
64
  mathField: () => MathFieldInterface | null;
39
65
  focus: () => void;
40
66
  blur: () => void;
67
+ handleKeypadPress: (key: Keys, e: any) => void;
41
68
  render(): React.ReactNode;
42
69
  }
43
70
  export default MathInput;
@@ -1,4 +1,5 @@
1
1
  import * as React from "react";
2
+ import type { LegacyButtonSets } from "../perseus-types";
2
3
  import type { Keys } from "@khanacademy/math-input";
3
4
  type ButtonSet = (props: any) => [
4
5
  React.ReactNode,
@@ -6,7 +7,7 @@ type ButtonSet = (props: any) => [
6
7
  string
7
8
  ];
8
9
  type ButtonSets = {
9
- readonly [key: string]: ReadonlyArray<ButtonSet>;
10
+ readonly [key in LegacyButtonSets[number]]: ReadonlyArray<ButtonSet>;
10
11
  };
11
12
  declare const buttonSets: ButtonSets;
12
13
  export type ButtonSetsType = ReadonlyArray<keyof typeof buttonSets>;
package/dist/es/index.css CHANGED
@@ -2666,9 +2666,6 @@ body.mobile .categorizer-container td.category input[type="radio"] + span:active
2666
2666
  padding: 5px;
2667
2667
  width: 210px;
2668
2668
  }
2669
- .perseus-widget-expression.show-error-tooltip .perseus-math-input.mq-editable-field.mq-math-mode > .mq-root-block {
2670
- padding-right: 25px;
2671
- }
2672
2669
  .perseus-widget-expression .perseus-formats-tooltip {
2673
2670
  width: 190px;
2674
2671
  }
@@ -3562,11 +3559,13 @@ body.mobile .framework-perseus table.perseus-widget-table-of-values.non-markdown
3562
3559
  list-style-type: none;
3563
3560
  }
3564
3561
  .perseus-math-input.mq-editable-field.mq-math-mode {
3565
- background: #fff;
3562
+ background-color: transparent;
3566
3563
  font-size: 18px;
3567
3564
  min-width: 100px;
3568
- border-color: #a4a4a4;
3569
- border-radius: 5px;
3565
+ border: unset;
3566
+ }
3567
+ .perseus-math-input.mq-editable-field.mq-math-mode.mq-focused {
3568
+ box-shadow: unset;
3570
3569
  }
3571
3570
  .perseus-math-input.mq-editable-field.mq-math-mode > .mq-root-block {
3572
3571
  padding: 4px;