@khanacademy/math-input 8.1.0 → 8.1.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/components/keypad-legacy/compute-layout-parameters.d.ts +6 -17
  3. package/dist/components/keypad-legacy/compute-layout-parameters.js.flow +13 -22
  4. package/dist/components/keypad-legacy/keypad-container.d.ts +2 -1
  5. package/dist/components/keypad-legacy/keypad-container.js.flow +7 -1
  6. package/dist/components/keypad-legacy/store/actions.d.ts +5 -3
  7. package/dist/components/keypad-legacy/store/actions.js.flow +8 -4
  8. package/dist/components/keypad-legacy/store/types.d.ts +14 -14
  9. package/dist/components/keypad-legacy/store/types.js.flow +14 -14
  10. package/dist/es/index.css +1 -1
  11. package/dist/es/index.js +132 -132
  12. package/dist/es/index.js.map +1 -1
  13. package/dist/fake-react-native-web/view.d.ts +1 -0
  14. package/dist/fake-react-native-web/view.js.flow +1 -0
  15. package/dist/index.css +1 -1
  16. package/dist/index.js +130 -134
  17. package/dist/index.js.map +1 -1
  18. package/index.html +17 -16
  19. package/less/echo.less +1 -1
  20. package/less/overrides.less +1 -1
  21. package/package.json +2 -2
  22. package/src/components/input/math-input.tsx +1 -0
  23. package/src/components/keypad/keypad-button.tsx +5 -3
  24. package/src/components/keypad/mobile-keypad.tsx +4 -0
  25. package/src/components/keypad-legacy/compute-layout-parameters.ts +127 -78
  26. package/src/components/keypad-legacy/keypad-button.tsx +2 -2
  27. package/src/components/keypad-legacy/keypad-container.tsx +30 -4
  28. package/src/components/keypad-legacy/store/actions.ts +12 -6
  29. package/src/components/keypad-legacy/store/layout-reducer.test.ts +171 -0
  30. package/src/components/keypad-legacy/store/layout-reducer.ts +46 -51
  31. package/src/components/keypad-legacy/store/types.ts +16 -14
  32. package/src/fake-react-native-web/view.tsx +2 -0
  33. package/src/full-math-input.stories.tsx +1 -1
  34. package/tsconfig-build.tsbuildinfo +1 -1
@@ -14,6 +14,7 @@ type Props = {
14
14
  onTouchStart?: (arg1: React.TouchEvent<HTMLDivElement>) => void;
15
15
  role?: string;
16
16
  style?: StyleType;
17
+ forwardRef?: React.RefObject<HTMLDivElement>;
17
18
  };
18
19
  declare class View extends React.Component<Props> {
19
20
  static styles: any;
@@ -20,6 +20,7 @@ declare type Props = {|
20
20
  onTouchStart?: (arg1: SyntheticTouchEvent<HTMLDivElement>) => void,
21
21
  role?: string,
22
22
  style?: StyleType,
23
+ forwardRef?: React.RefObject<HTMLDivElement>,
23
24
  |};
24
25
  declare class View extends React.Component<Props> {
25
26
  static styles: any;
package/dist/index.css CHANGED
@@ -102,7 +102,7 @@
102
102
  border-color: white;
103
103
  }
104
104
  .keypad-input .mq-hasCursor:empty:not(.mq-root-block):after {
105
- content: 'c';
105
+ content: "c";
106
106
  }
107
107
  .keypad-input .mq-math-mode .mq-selection .mq-non-leaf,
108
108
  .keypad-input .mq-editable-field .mq-selection .mq-non-leaf {
package/dist/index.js CHANGED
@@ -137,7 +137,8 @@ class View extends React__namespace.Component {
137
137
  onTouchMove: this.props.onTouchMove,
138
138
  onTouchStart: this.props.onTouchStart,
139
139
  "aria-label": this.props.ariaLabel,
140
- role: this.props.role
140
+ role: this.props.role,
141
+ ref: this.props.forwardRef
141
142
  }, this.props.children);
142
143
  }
143
144
  }
@@ -200,10 +201,6 @@ const innerBorderColor = offBlack16;
200
201
  const innerBorderStyle = "solid";
201
202
  const innerBorderWidthPx = 1;
202
203
 
203
- // The width at which a device is classified as a "tablet" for the purposes
204
- // of the keypad layout.
205
- const tabletCutoffPx = 600;
206
-
207
204
  // The dimensions that define various components in the tree, which may be
208
205
  // needed outside of those components in order to determine various layout
209
206
  // parameters.
@@ -921,11 +918,6 @@ let DeviceOrientation = /*#__PURE__*/function (DeviceOrientation) {
921
918
  DeviceOrientation["PORTRAIT"] = "PORTRAIT";
922
919
  return DeviceOrientation;
923
920
  }({});
924
- let DeviceType = /*#__PURE__*/function (DeviceType) {
925
- DeviceType["PHONE"] = "PHONE";
926
- DeviceType["TABLET"] = "TABLET";
927
- return DeviceType;
928
- }({});
929
921
  let LayoutMode = /*#__PURE__*/function (LayoutMode) {
930
922
  LayoutMode["FULLSCREEN"] = "FULLSCREEN";
931
923
  LayoutMode["COMPACT"] = "COMPACT";
@@ -4128,19 +4120,21 @@ const styles$e = aphrodite.StyleSheet.create({
4128
4120
  boxSizing: "border-box",
4129
4121
  background: Color__default["default"].white,
4130
4122
  borderRadius: 4,
4131
- border: "1px solid transparent",
4123
+ borderWidth: 2,
4124
+ borderStyle: "solid",
4125
+ borderColor: "transparent",
4132
4126
  flex: 1,
4133
4127
  minHeight: 42,
4134
4128
  minWidth: 42,
4135
4129
  padding: 1
4136
4130
  },
4137
4131
  hovered: {
4138
- border: "2px solid ".concat(Color__default["default"].blue),
4132
+ borderColor: Color__default["default"].blue,
4139
4133
  padding: 1,
4140
4134
  boxShadow: "none"
4141
4135
  },
4142
4136
  focused: {
4143
- border: "2px solid ".concat(Color__default["default"].blue),
4137
+ borderColor: Color__default["default"].blue,
4144
4138
  padding: 0,
4145
4139
  boxShadow: "none"
4146
4140
  },
@@ -4594,12 +4588,19 @@ class MobileKeypad extends React__namespace.Component {
4594
4588
  });
4595
4589
  }
4596
4590
  render() {
4591
+ const {
4592
+ style
4593
+ } = this.props;
4597
4594
  const {
4598
4595
  active,
4599
4596
  cursor,
4600
4597
  keypadConfig
4601
4598
  } = this.state;
4602
- const containerStyle = [styles$c.keypadContainer, active ? styles$c.activeKeypadContainer : null];
4599
+ const containerStyle = [
4600
+ // internal styles
4601
+ styles$c.keypadContainer, active ? styles$c.activeKeypadContainer : null,
4602
+ // styles passed as props
4603
+ ...(Array.isArray(style) ? style : [style])];
4603
4604
  const isExpression = (keypadConfig === null || keypadConfig === void 0 ? void 0 : keypadConfig.keypadType) === "EXPRESSION";
4604
4605
  return /*#__PURE__*/React__namespace.createElement(View, {
4605
4606
  style: containerStyle,
@@ -6374,8 +6375,8 @@ const styleForButtonDimensions = (heightPx, widthPx) => {
6374
6375
  };
6375
6376
  const mapStateToProps$7 = state => {
6376
6377
  return {
6377
- heightPx: state.layout.buttonDimensions.heightPx,
6378
- widthPx: state.layout.buttonDimensions.widthPx
6378
+ heightPx: state.layout.buttonDimensions.height,
6379
+ widthPx: state.layout.buttonDimensions.width
6379
6380
  };
6380
6381
  };
6381
6382
  var KeypadButton$1 = reactRedux.connect(mapStateToProps$7, null, null, {
@@ -6785,11 +6786,13 @@ const configureKeypad = configuration => {
6785
6786
  configuration
6786
6787
  };
6787
6788
  };
6788
- const setPageSize = (pageWidthPx, pageHeightPx) => {
6789
+ const setPageSize = (pageWidth, pageHeight, containerWidth, containerHeight) => {
6789
6790
  return {
6790
6791
  type: "SetPageSize",
6791
- pageWidthPx,
6792
- pageHeightPx
6792
+ pageWidth,
6793
+ pageHeight,
6794
+ containerWidth,
6795
+ containerHeight
6793
6796
  };
6794
6797
  };
6795
6798
  const removeEcho = animationId => {
@@ -7514,6 +7517,7 @@ const {
7514
7517
  class KeypadContainer extends React__namespace.Component {
7515
7518
  constructor() {
7516
7519
  super(...arguments);
7520
+ _defineProperty(this, "_containerRef", /*#__PURE__*/React__namespace.createRef());
7517
7521
  _defineProperty(this, "_resizeTimeout", void 0);
7518
7522
  _defineProperty(this, "hasMounted", void 0);
7519
7523
  _defineProperty(this, "state", {
@@ -7531,13 +7535,15 @@ class KeypadContainer extends React__namespace.Component {
7531
7535
  }
7532
7536
  });
7533
7537
  _defineProperty(this, "_onResize", () => {
7534
- var _this$props$onPageSiz, _this$props;
7538
+ var _this$_containerRef$c, _this$_containerRef$c2, _this$props$onPageSiz, _this$props;
7535
7539
  // Whenever the page resizes, we need to force an update, as the button
7536
7540
  // heights and keypad width are computed based on horizontal space.
7537
7541
  this.setState({
7538
7542
  viewportWidth: window.innerWidth
7539
7543
  });
7540
- (_this$props$onPageSiz = (_this$props = this.props).onPageSizeChange) === null || _this$props$onPageSiz === void 0 ? void 0 : _this$props$onPageSiz.call(_this$props, window.innerWidth, window.innerHeight);
7544
+ const containerWidth = ((_this$_containerRef$c = this._containerRef.current) === null || _this$_containerRef$c === void 0 ? void 0 : _this$_containerRef$c.clientWidth) || 0;
7545
+ const containerHeight = ((_this$_containerRef$c2 = this._containerRef.current) === null || _this$_containerRef$c2 === void 0 ? void 0 : _this$_containerRef$c2.clientHeight) || 0;
7546
+ (_this$props$onPageSiz = (_this$props = this.props).onPageSizeChange) === null || _this$props$onPageSiz === void 0 ? void 0 : _this$props$onPageSiz.call(_this$props, window.innerWidth, window.innerHeight, containerWidth, containerHeight);
7541
7547
  });
7542
7548
  _defineProperty(this, "renderKeypad", () => {
7543
7549
  const {
@@ -7637,7 +7643,8 @@ class KeypadContainer extends React__namespace.Component {
7637
7643
  return /*#__PURE__*/React__namespace.createElement(View, {
7638
7644
  style: keypadContainerStyle,
7639
7645
  dynamicStyle: dynamicStyle,
7640
- extraClassName: "keypad-container"
7646
+ extraClassName: "keypad-container",
7647
+ forwardRef: this._containerRef
7641
7648
  }, /*#__PURE__*/React__namespace.createElement(View, {
7642
7649
  style: keypadStyle,
7643
7650
  ref: element => {
@@ -7723,8 +7730,8 @@ const mapStateToProps = state => {
7723
7730
  };
7724
7731
  const mapDispatchToProps = dispatch => {
7725
7732
  return {
7726
- onPageSizeChange: (pageWidthPx, pageHeightPx) => {
7727
- dispatch(setPageSize(pageWidthPx, pageHeightPx));
7733
+ onPageSizeChange: (pageWidth, pageHeight, containerWidth, containerHeight) => {
7734
+ dispatch(setPageSize(pageWidth, pageHeight, containerWidth, containerHeight));
7728
7735
  }
7729
7736
  };
7730
7737
  };
@@ -8676,93 +8683,91 @@ const maxPortraitBrowserChrome = safariToolbar + (safariNavBarWhenExpanded - saf
8676
8683
  // (We don't need to account for the expanded navbar, since we include the
8677
8684
  // difference when reserving space above the keypad.)
8678
8685
  const worstCaseAspectRatio = 320 / (480 - safariNavBarWhenShrunk);
8679
- const computeLayoutParameters = (_ref, _ref2, _ref3, _ref4) => {
8680
- let {
8686
+ function getButtonWidth(gridDimensions, containerDimensions, navigationPadEnabled, paginationEnabled, isLandscape) {
8687
+ const {
8681
8688
  numColumns,
8682
- numMaxVisibleRows,
8683
8689
  numPages
8684
- } = _ref;
8685
- let {
8686
- pageWidthPx,
8687
- pageHeightPx
8688
- } = _ref2;
8689
- let {
8690
- deviceOrientation,
8691
- deviceType
8692
- } = _ref3;
8693
- let {
8694
- navigationPadEnabled,
8695
- paginationEnabled,
8696
- toolbarEnabled
8697
- } = _ref4;
8690
+ } = gridDimensions;
8691
+
8692
+ // We can use the container width as the effective width.
8693
+ let effectiveWidth = containerDimensions.width;
8694
+ if (navigationPadEnabled) {
8695
+ effectiveWidth -= navigationPadWidthPx;
8696
+ }
8697
+ let buttonWidthPx;
8698
+ if (numPages > 1) {
8699
+ const effectiveNumColumns = paginationEnabled ? numColumns : numColumns * numPages;
8700
+ buttonWidthPx = effectiveWidth / effectiveNumColumns;
8701
+ } else {
8702
+ buttonWidthPx = isLandscape ? maxButtonSize : effectiveWidth / numColumns;
8703
+ }
8704
+ return buttonWidthPx;
8705
+ }
8706
+ function getButtonHeight(gridDimensions, pageDimensions, containerDimensions, paginationEnabled, toolbarEnabled, isLandscape) {
8707
+ const {
8708
+ numMaxVisibleRows
8709
+ } = gridDimensions;
8710
+
8711
+ // In many cases, the browser chrome will already have been factored
8712
+ // into `pageHeight`. But we have no way of knowing if that's
8713
+ // the case or not. As such, we take a conservative approach and
8714
+ // assume that the chrome is _never_ included in `pageHeight`.
8715
+ const browserChromeHeight = isLandscape ? maxLandscapeBrowserChrome : maxPortraitBrowserChrome;
8716
+
8717
+ // Count up all the space that we need to reserve on the page.
8718
+ // Namely, we need to account for:
8719
+ // 1. Space between the keypad and the top of the page.
8720
+ // 2. The presence of the exercise toolbar.
8721
+ // 3. The presence of the view pager indicator.
8722
+ // 4. Any browser chrome that may appear later.
8723
+ const reservedSpace = minSpaceAboveKeypad + browserChromeHeight + (toolbarEnabled ? toolbarHeightPx : 0) + (paginationEnabled ? pageIndicatorHeightPx : 0);
8724
+
8725
+ // For the height, we take
8726
+ // another conservative measure when in portrait by assuming that
8727
+ // the device has the worst possible aspect ratio. In other words,
8728
+ // we ignore the device height in portrait and assume the worst.
8729
+ // This prevents the keypad from changing size when browser chrome
8730
+ // appears and disappears.
8731
+ const effectiveHeight = isLandscape ? pageDimensions.height : containerDimensions.width / worstCaseAspectRatio;
8732
+
8733
+ // In computing the
8734
+ // height, accommodate for the maximum number of rows that will ever be
8735
+ // visible (since the toggling of popovers can increase the number of
8736
+ // visible rows).
8737
+ const maxKeypadHeight = effectiveHeight - reservedSpace;
8738
+ const buttonHeightPx = Math.max(Math.min(maxKeypadHeight / numMaxVisibleRows, maxButtonSize), minButtonHeight);
8739
+ return buttonHeightPx;
8740
+ }
8741
+ const computeLayoutParameters = (gridDimensions, pageDimensions, containerDimensions, deviceOrientation, navigationPadEnabled, paginationEnabled, toolbarEnabled) => {
8742
+ const {
8743
+ numColumns,
8744
+ numPages
8745
+ } = gridDimensions;
8746
+
8698
8747
  // First, compute some values that will be used in multiple computations.
8699
8748
  const effectiveNumColumns = paginationEnabled ? numColumns : numColumns * numPages;
8700
8749
 
8701
8750
  // Then, compute the button dimensions based on the provided parameters.
8702
- let buttonDimensions;
8703
- if (deviceType === DeviceType.PHONE) {
8704
- const isLandscape = deviceOrientation === DeviceOrientation.LANDSCAPE;
8705
-
8706
- // In many cases, the browser chrome will already have been factored
8707
- // into `pageHeightPx`. But we have no way of knowing if that's
8708
- // the case or not. As such, we take a conservative approach and
8709
- // assume that the chrome is _never_ included in `pageHeightPx`.
8710
- const browserChromeHeight = isLandscape ? maxLandscapeBrowserChrome : maxPortraitBrowserChrome;
8711
-
8712
- // Count up all the space that we need to reserve on the page.
8713
- // Namely, we need to account for:
8714
- // 1. Space between the keypad and the top of the page.
8715
- // 2. The presence of the exercise toolbar.
8716
- // 3. The presence of the view pager indicator.
8717
- // 4. Any browser chrome that may appear later.
8718
- const reservedSpace = minSpaceAboveKeypad + browserChromeHeight + (toolbarEnabled ? toolbarHeightPx : 0) + (paginationEnabled ? pageIndicatorHeightPx : 0);
8719
-
8720
- // Next, compute the effective width and height. We can use the page
8721
- // width as the effective width. For the height, though, we take
8722
- // another conservative measure when in portrait by assuming that
8723
- // the device has the worst possible aspect ratio. In other words,
8724
- // we ignore the device height in portrait and assume the worst.
8725
- // This prevents the keypad from changing size when browser chrome
8726
- // appears and disappears.
8727
- const effectiveWidth = pageWidthPx;
8728
- const effectiveHeight = isLandscape ? pageHeightPx : pageWidthPx / worstCaseAspectRatio;
8729
- const maxKeypadHeight = effectiveHeight - reservedSpace;
8730
-
8731
- // Finally, compute the button height and width. In computing the
8732
- // height, accommodate for the maximum number of rows that will ever be
8733
- // visible (since the toggling of popovers can increase the number of
8734
- // visible rows).
8735
- const buttonHeightPx = Math.max(Math.min(maxKeypadHeight / numMaxVisibleRows, maxButtonSize), minButtonHeight);
8736
- let buttonWidthPx;
8737
- if (numPages > 1) {
8738
- const effectiveNumColumns = paginationEnabled ? numColumns : numColumns * numPages;
8739
- buttonWidthPx = effectiveWidth / effectiveNumColumns;
8740
- } else {
8741
- buttonWidthPx = isLandscape ? maxButtonSize : effectiveWidth / numColumns;
8742
- }
8743
- buttonDimensions = {
8744
- widthPx: buttonWidthPx,
8745
- heightPx: buttonHeightPx
8746
- };
8747
- } else if (deviceType === DeviceType.TABLET) {
8748
- buttonDimensions = {
8749
- widthPx: maxButtonSize,
8750
- heightPx: maxButtonSize
8751
- };
8752
- } else {
8753
- throw new Error("Invalid device type: " + deviceType);
8754
- }
8751
+ const isLandscape = deviceOrientation === DeviceOrientation.LANDSCAPE;
8752
+ const buttonWidth = getButtonWidth(gridDimensions, containerDimensions, navigationPadEnabled, paginationEnabled, isLandscape);
8753
+ const buttonHeight = getButtonHeight(gridDimensions, pageDimensions, containerDimensions, paginationEnabled, toolbarEnabled, isLandscape);
8754
+ const buttonDimensions = {
8755
+ width: buttonWidth,
8756
+ height: buttonHeight
8757
+ };
8755
8758
 
8756
8759
  // Finally, determine whether the keypad should be rendered in the
8757
8760
  // fullscreen layout by determining its resultant width.
8758
8761
  const numSeparators = (navigationPadEnabled ? 1 : 0) + (!paginationEnabled ? numPages - 1 : 0);
8759
- const keypadWidth = effectiveNumColumns * buttonDimensions.widthPx + (navigationPadEnabled ? navigationPadWidthPx : 0) + numSeparators * innerBorderWidthPx;
8762
+ const keypadWidth = effectiveNumColumns * buttonDimensions.width + (navigationPadEnabled ? navigationPadWidthPx : 0) + numSeparators * innerBorderWidthPx;
8760
8763
  return {
8761
8764
  buttonDimensions,
8762
- layoutMode: keypadWidth >= pageWidthPx ? LayoutMode.FULLSCREEN : LayoutMode.COMPACT
8765
+ layoutMode: keypadWidth >= containerDimensions.width ? LayoutMode.FULLSCREEN : LayoutMode.COMPACT
8763
8766
  };
8764
8767
  };
8765
8768
 
8769
+ const expandedViewThreshold = 682;
8770
+ const navigationViewThreshold = 800;
8766
8771
  const initialLayoutState = {
8767
8772
  gridDimensions: {
8768
8773
  numRows: keypadForType[defaultKeypadType].rows,
@@ -8771,12 +8776,16 @@ const initialLayoutState = {
8771
8776
  numPages: keypadForType[defaultKeypadType].numPages
8772
8777
  },
8773
8778
  buttonDimensions: {
8774
- widthPx: 48,
8775
- heightPx: 48
8779
+ width: 48,
8780
+ height: 48
8776
8781
  },
8777
8782
  pageDimensions: {
8778
- pageWidthPx: 0,
8779
- pageHeightPx: 0
8783
+ width: 0,
8784
+ height: 0
8785
+ },
8786
+ containerDimensions: {
8787
+ width: 0,
8788
+ height: 0
8780
8789
  },
8781
8790
  layoutMode: LayoutMode.FULLSCREEN,
8782
8791
  paginationEnabled: false,
@@ -8787,38 +8796,17 @@ const initialLayoutState = {
8787
8796
  * Compute the additional layout state based on the provided page and grid
8788
8797
  * dimensions.
8789
8798
  */
8790
- const layoutParametersForDimensions = (pageDimensions, gridDimensions) => {
8791
- const {
8792
- pageWidthPx,
8793
- pageHeightPx
8794
- } = pageDimensions;
8795
-
8799
+ const layoutParametersForDimensions = (pageDimensions, containerDimensions, gridDimensions) => {
8796
8800
  // Determine the device type and orientation.
8797
- const deviceOrientation = pageWidthPx > pageHeightPx ? DeviceOrientation.LANDSCAPE : DeviceOrientation.PORTRAIT;
8798
- const deviceType = Math.min(pageWidthPx, pageHeightPx) > tabletCutoffPx ? DeviceType.TABLET : DeviceType.PHONE;
8801
+ const deviceOrientation = containerDimensions.width > containerDimensions.height ? DeviceOrientation.LANDSCAPE : DeviceOrientation.PORTRAIT;
8799
8802
 
8800
8803
  // Using that information, make some decisions (or assumptions)
8801
8804
  // about the resulting layout.
8802
- const navigationPadEnabled = deviceType === DeviceType.TABLET;
8803
- const paginationEnabled = deviceType === DeviceType.PHONE && deviceOrientation === DeviceOrientation.PORTRAIT;
8804
- const deviceInfo = {
8805
- deviceOrientation,
8806
- deviceType
8807
- };
8808
- const layoutOptions = {
8809
- navigationPadEnabled,
8810
- paginationEnabled,
8811
- // HACK(charlie): It's not great that we're making assumptions about
8812
- // the toolbar (which is rendered by webapp, and should always be
8813
- // visible and anchored to the bottom of the page for phone and
8814
- // tablet exercises). But this is primarily a heuristic (the goal is
8815
- // to preserve a 'good' amount of space between the top of the
8816
- // keypad and the top of the page) so we afford to have some margin
8817
- // of error.
8818
- toolbarEnabled: true
8819
- };
8805
+ const navigationPadEnabled = containerDimensions.width > navigationViewThreshold;
8806
+ const paginationEnabled = containerDimensions.width < expandedViewThreshold;
8807
+ const toolbarEnabled = true;
8820
8808
  return {
8821
- ...computeLayoutParameters(gridDimensions, pageDimensions, deviceInfo, layoutOptions),
8809
+ ...computeLayoutParameters(gridDimensions, pageDimensions, containerDimensions, deviceOrientation, navigationPadEnabled, paginationEnabled, toolbarEnabled),
8822
8810
  // Pass along some of the layout information, so that other
8823
8811
  // components in the heirarchy can adapt appropriately.
8824
8812
  navigationPadEnabled,
@@ -8839,24 +8827,32 @@ const layoutReducer = function () {
8839
8827
  numMaxVisibleRows: keypadForType[keypadType].maxVisibleRows,
8840
8828
  numPages: keypadForType[keypadType].numPages
8841
8829
  };
8830
+ const layoutParams = layoutParametersForDimensions(state.pageDimensions, state.containerDimensions, gridDimensions);
8842
8831
  return {
8843
8832
  ...state,
8844
- ...layoutParametersForDimensions(state.pageDimensions, gridDimensions),
8833
+ ...layoutParams,
8845
8834
  gridDimensions
8846
8835
  };
8847
8836
  case "SetPageSize":
8848
8837
  const {
8849
- pageWidthPx,
8850
- pageHeightPx
8838
+ pageWidth,
8839
+ pageHeight,
8840
+ containerWidth,
8841
+ containerHeight
8851
8842
  } = action;
8852
8843
  const pageDimensions = {
8853
- pageWidthPx,
8854
- pageHeightPx
8844
+ width: pageWidth,
8845
+ height: pageHeight
8846
+ };
8847
+ const containerDimensions = {
8848
+ width: containerWidth,
8849
+ height: containerHeight
8855
8850
  };
8856
8851
  return {
8857
8852
  ...state,
8858
- ...layoutParametersForDimensions(pageDimensions, state.gridDimensions),
8859
- pageDimensions
8853
+ ...layoutParametersForDimensions(pageDimensions, containerDimensions, state.gridDimensions),
8854
+ pageDimensions,
8855
+ containerDimensions
8860
8856
  };
8861
8857
  default:
8862
8858
  return state;