@khanacademy/math-input 10.0.0 → 10.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.
- package/CHANGELOG.md +12 -0
- package/dist/components/keypad/keypad.d.ts +1 -0
- package/dist/components/keypad/mobile-keypad.d.ts +8 -0
- package/dist/components/keypad/navigation-button.d.ts +8 -0
- package/dist/components/keypad/navigation-pad.d.ts +6 -0
- package/dist/components/keypad/utils.d.ts +1 -0
- package/dist/es/index.css +3 -5
- package/dist/es/index.js +322 -29
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +3 -5
- package/dist/index.js +326 -29
- package/dist/index.js.map +1 -1
- package/less/overrides.less +8 -9
- package/package.json +1 -1
- package/src/components/keypad/__tests__/__snapshots__/keypad.test.tsx.snap +1855 -0
- package/src/components/keypad/__tests__/keypad.test.tsx +94 -0
- package/src/components/keypad/button-assets.tsx +77 -4
- package/src/components/keypad/keypad-button.tsx +1 -1
- package/src/components/keypad/keypad.stories.tsx +4 -0
- package/src/components/keypad/keypad.tsx +83 -53
- package/src/components/keypad/mobile-keypad.tsx +55 -1
- package/src/components/keypad/navigation-button.tsx +127 -0
- package/src/components/keypad/navigation-pad.stories.tsx +25 -0
- package/src/components/keypad/navigation-pad.tsx +67 -0
- package/src/components/keypad/utils.ts +4 -0
- package/src/components/keypad-legacy/keypad-button.tsx +2 -1
- package/src/full-math-input.stories.tsx +17 -18
- package/tsconfig-build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @khanacademy/math-input
|
|
2
2
|
|
|
3
|
+
## 10.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 781551f9: Add an expanded view in the v2 MobileKeypad for larger screens
|
|
8
|
+
|
|
9
|
+
## 10.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 7b11736e: Fix cursor animation for MathInput
|
|
14
|
+
|
|
3
15
|
## 10.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
|
@@ -20,13 +20,21 @@ type Props = {
|
|
|
20
20
|
};
|
|
21
21
|
type State = {
|
|
22
22
|
active: boolean;
|
|
23
|
+
containerWidth: number;
|
|
23
24
|
keypadConfig?: KeypadConfiguration;
|
|
24
25
|
keyHandler?: KeyHandler;
|
|
25
26
|
cursor?: Cursor;
|
|
26
27
|
};
|
|
27
28
|
declare class MobileKeypad extends React.Component<Props, State> implements KeypadAPI {
|
|
29
|
+
_containerRef: React.RefObject<HTMLDivElement>;
|
|
30
|
+
_containerResizeObserver: ResizeObserver | null;
|
|
31
|
+
_throttleResize: boolean;
|
|
28
32
|
hasMounted: boolean;
|
|
29
33
|
state: State;
|
|
34
|
+
componentDidMount(): void;
|
|
35
|
+
componentWillUnMount(): void;
|
|
36
|
+
_resize: () => void;
|
|
37
|
+
_throttleResizeHandler: () => void;
|
|
30
38
|
activate: () => void;
|
|
31
39
|
dismiss: () => void;
|
|
32
40
|
configure: (configuration: KeypadConfiguration, cb: () => void) => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { KeyConfig, ClickKeyCallback } from "../../types";
|
|
3
|
+
export type KeypadButtonProps = {
|
|
4
|
+
coord: readonly [number, number];
|
|
5
|
+
keyConfig: KeyConfig;
|
|
6
|
+
onClickKey: ClickKeyCallback;
|
|
7
|
+
};
|
|
8
|
+
export default function NavigationButton({ coord, keyConfig, onClickKey, }: KeypadButtonProps): JSX.Element;
|
package/dist/es/index.css
CHANGED
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
outline: none !important;
|
|
45
45
|
}
|
|
46
46
|
.keypad-input .mq-editable-field .mq-root-block {
|
|
47
|
-
overflow-x:
|
|
47
|
+
overflow-x: auto;
|
|
48
48
|
}
|
|
49
49
|
.keypad-input .mq-editable-field .mq-cursor:not(:only-child),
|
|
50
50
|
.keypad-input .mq-editable-field .mq-root-block.mq-hasCursor > .mq-cursor:only-child {
|
|
@@ -63,12 +63,11 @@
|
|
|
63
63
|
margin-left: -1px !important;
|
|
64
64
|
margin-right: -1px !important;
|
|
65
65
|
opacity: 1 !important;
|
|
66
|
-
transition: opacity
|
|
66
|
+
transition: opacity 300ms ease !important;
|
|
67
67
|
visibility: visible !important;
|
|
68
68
|
}
|
|
69
69
|
.keypad-input .mq-editable-field .mq-cursor.mq-blink {
|
|
70
70
|
opacity: 0 !important;
|
|
71
|
-
transition: opacity 500ms ease-in !important;
|
|
72
71
|
visibility: visible !important;
|
|
73
72
|
}
|
|
74
73
|
.keypad-input .mq-editable-field .mq-non-leaf .mq-cursor:only-child {
|
|
@@ -77,12 +76,11 @@
|
|
|
77
76
|
border-radius: 1px;
|
|
78
77
|
opacity: 1 !important;
|
|
79
78
|
padding: 0 4px 0 4px;
|
|
80
|
-
transition: border-color
|
|
79
|
+
transition: border-color 300ms ease !important;
|
|
81
80
|
}
|
|
82
81
|
.keypad-input .mq-editable-field .mq-non-leaf .mq-cursor:only-child.mq-blink {
|
|
83
82
|
border-color: #1865f2 !important;
|
|
84
83
|
opacity: 1 !important;
|
|
85
|
-
transition: border-color 500ms ease-in !important;
|
|
86
84
|
}
|
|
87
85
|
.keypad-input .mq-empty {
|
|
88
86
|
background: transparent !important;
|
package/dist/es/index.js
CHANGED
|
@@ -40,7 +40,7 @@ class Text extends React.Component {
|
|
|
40
40
|
numberOfLines,
|
|
41
41
|
style
|
|
42
42
|
} = this.props;
|
|
43
|
-
const className = css(styles$
|
|
43
|
+
const className = css(styles$k.initial, ...(Array.isArray(style) ? style : [style]), numberOfLines === 1 && styles$k.singleLineStyle);
|
|
44
44
|
return /*#__PURE__*/React.createElement("span", {
|
|
45
45
|
className: className,
|
|
46
46
|
style: this.props.dynamicStyle
|
|
@@ -49,7 +49,7 @@ class Text extends React.Component {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// https://github.com/necolas/react-native-web/blob/master/src/components/Text/index.js
|
|
52
|
-
const styles$
|
|
52
|
+
const styles$k = StyleSheet.create({
|
|
53
53
|
initial: {
|
|
54
54
|
color: "inherit",
|
|
55
55
|
display: "inline",
|
|
@@ -2079,7 +2079,7 @@ class MathInput extends React.Component {
|
|
|
2079
2079
|
// to the open the keyboard, and then remove the second half of this label.
|
|
2080
2080
|
const ariaLabel = i18n._("Math input box") + " " + i18n._("Tap with one or two fingers to open keyboard");
|
|
2081
2081
|
return /*#__PURE__*/React.createElement(View, {
|
|
2082
|
-
style: styles$
|
|
2082
|
+
style: styles$j.input,
|
|
2083
2083
|
onTouchStart: this.handleTouchStart,
|
|
2084
2084
|
onTouchMove: this.handleTouchMove,
|
|
2085
2085
|
onTouchEnd: this.handleTouchEnd,
|
|
@@ -2125,7 +2125,7 @@ const numeralHeightPx = 20;
|
|
|
2125
2125
|
const totalDesiredPadding = 12;
|
|
2126
2126
|
const minHeightPx = numeralHeightPx + totalDesiredPadding * 2;
|
|
2127
2127
|
const minWidthPx = 64;
|
|
2128
|
-
const styles$
|
|
2128
|
+
const styles$j = StyleSheet.create({
|
|
2129
2129
|
input: {
|
|
2130
2130
|
position: "relative",
|
|
2131
2131
|
display: "inline-block",
|
|
@@ -2269,7 +2269,7 @@ const IconAsset = function IconAsset({
|
|
|
2269
2269
|
}
|
|
2270
2270
|
};
|
|
2271
2271
|
|
|
2272
|
-
const styles$
|
|
2272
|
+
const styles$i = StyleSheet.create({
|
|
2273
2273
|
base: {
|
|
2274
2274
|
display: "flex",
|
|
2275
2275
|
width: 44,
|
|
@@ -2340,7 +2340,7 @@ class TabbarItem extends React.Component {
|
|
|
2340
2340
|
onClick: onClick,
|
|
2341
2341
|
disabled: itemState === "disabled",
|
|
2342
2342
|
"aria-label": itemType,
|
|
2343
|
-
style: styles$
|
|
2343
|
+
style: styles$i.clickable,
|
|
2344
2344
|
"aria-selected": itemState === "active",
|
|
2345
2345
|
role: "tab"
|
|
2346
2346
|
}, ({
|
|
@@ -2350,14 +2350,14 @@ class TabbarItem extends React.Component {
|
|
|
2350
2350
|
}) => {
|
|
2351
2351
|
const tintColor = imageTintColor(itemState, hovered, focused, pressed);
|
|
2352
2352
|
return /*#__PURE__*/React.createElement(View$1, {
|
|
2353
|
-
style: [styles$
|
|
2353
|
+
style: [styles$i.base, itemState !== "disabled" && hovered && styles$i.hovered, focused && styles$i.focused, pressed && styles$i.pressed]
|
|
2354
2354
|
}, /*#__PURE__*/React.createElement(View$1, {
|
|
2355
|
-
style: [styles$
|
|
2355
|
+
style: [styles$i.innerBox, pressed && styles$i.innerBoxPressed]
|
|
2356
2356
|
}, /*#__PURE__*/React.createElement(IconAsset, {
|
|
2357
2357
|
type: itemType,
|
|
2358
2358
|
tintColor: tintColor
|
|
2359
2359
|
})), itemState === "active" && /*#__PURE__*/React.createElement(View$1, {
|
|
2360
|
-
style: [styles$
|
|
2360
|
+
style: [styles$i.activeIndicator, {
|
|
2361
2361
|
backgroundColor: tintColor
|
|
2362
2362
|
}]
|
|
2363
2363
|
}));
|
|
@@ -2365,7 +2365,7 @@ class TabbarItem extends React.Component {
|
|
|
2365
2365
|
}
|
|
2366
2366
|
}
|
|
2367
2367
|
|
|
2368
|
-
const styles$
|
|
2368
|
+
const styles$h = StyleSheet.create({
|
|
2369
2369
|
tabbar: {
|
|
2370
2370
|
display: "flex",
|
|
2371
2371
|
flexDirection: "row",
|
|
@@ -2387,10 +2387,10 @@ function Tabbar(props) {
|
|
|
2387
2387
|
style
|
|
2388
2388
|
} = props;
|
|
2389
2389
|
return /*#__PURE__*/React.createElement(View$1, {
|
|
2390
|
-
style: [styles$
|
|
2390
|
+
style: [styles$h.tabbar, style],
|
|
2391
2391
|
role: "tablist"
|
|
2392
2392
|
}, /*#__PURE__*/React.createElement(View$1, {
|
|
2393
|
-
style: [styles$
|
|
2393
|
+
style: [styles$h.pages]
|
|
2394
2394
|
}, items.map(item => /*#__PURE__*/React.createElement(TabbarItem, {
|
|
2395
2395
|
key: `tabbar-item-${item}`,
|
|
2396
2396
|
itemState: item === selectedItem ? "active" : "inactive",
|
|
@@ -4234,16 +4234,99 @@ function ButtonAsset({
|
|
|
4234
4234
|
transform: "translate(8 19)",
|
|
4235
4235
|
d: "M0 0h12v2H0z"
|
|
4236
4236
|
}))));
|
|
4237
|
+
case "UP":
|
|
4238
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
4239
|
+
width: "48",
|
|
4240
|
+
height: "48",
|
|
4241
|
+
viewBox: "0 0 48 48"
|
|
4242
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
4243
|
+
fill: "none",
|
|
4244
|
+
fillRule: "evenodd",
|
|
4245
|
+
transform: "rotate(90 24 24)"
|
|
4246
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
4247
|
+
fill: "none",
|
|
4248
|
+
d: "M0 0h48v48H0z"
|
|
4249
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
4250
|
+
fill: "none",
|
|
4251
|
+
d: "M12 12h24v24H12z"
|
|
4252
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
4253
|
+
stroke: "#21242C",
|
|
4254
|
+
strokeWidth: "2",
|
|
4255
|
+
strokeLinecap: "round",
|
|
4256
|
+
strokeLinejoin: "round",
|
|
4257
|
+
d: "M22 18l-6 6 6 6M16 24h16"
|
|
4258
|
+
})));
|
|
4259
|
+
case "DOWN":
|
|
4260
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
4261
|
+
width: "48",
|
|
4262
|
+
height: "48",
|
|
4263
|
+
viewBox: "0 0 48 48"
|
|
4264
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
4265
|
+
fill: "none",
|
|
4266
|
+
fillRule: "evenodd",
|
|
4267
|
+
transform: "rotate(270 24 24)"
|
|
4268
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
4269
|
+
fill: "none",
|
|
4270
|
+
d: "M0 0h48v48H0z"
|
|
4271
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
4272
|
+
fill: "none",
|
|
4273
|
+
d: "M12 12h24v24H12z"
|
|
4274
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
4275
|
+
stroke: "#21242C",
|
|
4276
|
+
strokeWidth: "2",
|
|
4277
|
+
strokeLinecap: "round",
|
|
4278
|
+
strokeLinejoin: "round",
|
|
4279
|
+
d: "M22 18l-6 6 6 6M16 24h16"
|
|
4280
|
+
})));
|
|
4281
|
+
case "LEFT":
|
|
4282
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
4283
|
+
width: "48",
|
|
4284
|
+
height: "48",
|
|
4285
|
+
viewBox: "0 0 48 48"
|
|
4286
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
4287
|
+
fill: "none",
|
|
4288
|
+
fillRule: "evenodd"
|
|
4289
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
4290
|
+
fill: "none",
|
|
4291
|
+
d: "M0 0h48v48H0z"
|
|
4292
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
4293
|
+
fill: "none",
|
|
4294
|
+
d: "M12 12h24v24H12z"
|
|
4295
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
4296
|
+
stroke: "#21242C",
|
|
4297
|
+
strokeWidth: "2",
|
|
4298
|
+
strokeLinecap: "round",
|
|
4299
|
+
strokeLinejoin: "round",
|
|
4300
|
+
d: "M22 18l-6 6 6 6M16 24h16"
|
|
4301
|
+
})));
|
|
4302
|
+
case "RIGHT":
|
|
4303
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
4304
|
+
width: "48",
|
|
4305
|
+
height: "48",
|
|
4306
|
+
viewBox: "0 0 48 48"
|
|
4307
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
4308
|
+
fill: "none",
|
|
4309
|
+
fillRule: "evenodd",
|
|
4310
|
+
transform: "rotate(180 24 24)"
|
|
4311
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
4312
|
+
fill: "none",
|
|
4313
|
+
d: "M0 0h48v48H0z"
|
|
4314
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
4315
|
+
fill: "none",
|
|
4316
|
+
d: "M12 12h24v24H12z"
|
|
4317
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
4318
|
+
stroke: "#21242C",
|
|
4319
|
+
strokeWidth: "2",
|
|
4320
|
+
strokeLinecap: "round",
|
|
4321
|
+
strokeLinejoin: "round",
|
|
4322
|
+
d: "M22 18l-6 6 6 6M16 24h16"
|
|
4323
|
+
})));
|
|
4237
4324
|
|
|
4238
4325
|
/**
|
|
4239
4326
|
* ANYTHING BELOW IS NOT YET HANDLED
|
|
4240
4327
|
*/
|
|
4241
4328
|
case "MANY":
|
|
4242
4329
|
case "NOOP":
|
|
4243
|
-
case "UP":
|
|
4244
|
-
case "DOWN":
|
|
4245
|
-
case "LEFT":
|
|
4246
|
-
case "RIGHT":
|
|
4247
4330
|
case "PHI":
|
|
4248
4331
|
case "NTHROOT3":
|
|
4249
4332
|
case "POW":
|
|
@@ -4289,7 +4372,7 @@ const KeypadButton$2 = ({
|
|
|
4289
4372
|
}, style)
|
|
4290
4373
|
}, /*#__PURE__*/React.createElement(Clickable, {
|
|
4291
4374
|
onClick: e => onClickKey(keyConfig.id, e),
|
|
4292
|
-
style: styles$
|
|
4375
|
+
style: styles$g.clickable,
|
|
4293
4376
|
"aria-label": keyConfig.ariaLabel
|
|
4294
4377
|
}, ({
|
|
4295
4378
|
hovered,
|
|
@@ -4297,22 +4380,22 @@ const KeypadButton$2 = ({
|
|
|
4297
4380
|
pressed
|
|
4298
4381
|
}) => {
|
|
4299
4382
|
return /*#__PURE__*/React.createElement(View$1, {
|
|
4300
|
-
style: [styles$
|
|
4383
|
+
style: [styles$g.outerBoxBase]
|
|
4301
4384
|
}, /*#__PURE__*/React.createElement(View$1, {
|
|
4302
|
-
style: [styles$
|
|
4385
|
+
style: [styles$g.base, tintColor != null ? {
|
|
4303
4386
|
background: tintColor
|
|
4304
|
-
} : undefined, hovered && styles$
|
|
4387
|
+
} : undefined, hovered && styles$g.hovered, focused && styles$g.focused, pressed && styles$g.pressed]
|
|
4305
4388
|
}, /*#__PURE__*/React.createElement(ButtonAsset, {
|
|
4306
4389
|
id: keyConfig.id
|
|
4307
4390
|
})));
|
|
4308
4391
|
}));
|
|
4309
4392
|
};
|
|
4310
|
-
const styles$
|
|
4393
|
+
const styles$g = StyleSheet.create({
|
|
4311
4394
|
base: {
|
|
4312
4395
|
display: "flex",
|
|
4313
4396
|
justifyContent: "center",
|
|
4314
4397
|
alignItems: "center",
|
|
4315
|
-
boxShadow:
|
|
4398
|
+
boxShadow: `0px 1px 0px ${Color.offBlack32}`,
|
|
4316
4399
|
boxSizing: "border-box",
|
|
4317
4400
|
background: Color.white,
|
|
4318
4401
|
borderRadius: 4,
|
|
@@ -4377,6 +4460,10 @@ function ExtrasPage(props) {
|
|
|
4377
4460
|
}));
|
|
4378
4461
|
}
|
|
4379
4462
|
|
|
4463
|
+
// This is just a magic number, I just played around with it
|
|
4464
|
+
// until the transition from expanded -> regular -> expanded felt natural
|
|
4465
|
+
const expandedViewThreshold$1 = 500;
|
|
4466
|
+
|
|
4380
4467
|
// This is a helper function that returns the correct context for the cursor
|
|
4381
4468
|
// based on the cursorContext prop. It is used in the keypad to determine
|
|
4382
4469
|
// which key to render as the "jump out" key.
|
|
@@ -4632,6 +4719,150 @@ function OperatorsPage(props) {
|
|
|
4632
4719
|
})));
|
|
4633
4720
|
}
|
|
4634
4721
|
|
|
4722
|
+
function getStyles(key) {
|
|
4723
|
+
switch (key) {
|
|
4724
|
+
case "UP":
|
|
4725
|
+
return styles$f.up;
|
|
4726
|
+
case "RIGHT":
|
|
4727
|
+
return styles$f.right;
|
|
4728
|
+
case "DOWN":
|
|
4729
|
+
return styles$f.down;
|
|
4730
|
+
case "LEFT":
|
|
4731
|
+
return styles$f.left;
|
|
4732
|
+
default:
|
|
4733
|
+
throw new Error(`Invalid key: ${key}`);
|
|
4734
|
+
}
|
|
4735
|
+
}
|
|
4736
|
+
function NavigationButton({
|
|
4737
|
+
coord,
|
|
4738
|
+
keyConfig,
|
|
4739
|
+
onClickKey
|
|
4740
|
+
}) {
|
|
4741
|
+
const key = keyConfig.id;
|
|
4742
|
+
const directionalStyles = getStyles(key);
|
|
4743
|
+
return /*#__PURE__*/React.createElement(View$1, {
|
|
4744
|
+
style: {
|
|
4745
|
+
gridColumn: coord[0] + 1,
|
|
4746
|
+
gridRow: coord[1] + 1
|
|
4747
|
+
}
|
|
4748
|
+
}, /*#__PURE__*/React.createElement(Clickable, {
|
|
4749
|
+
onClick: e => onClickKey(keyConfig.id, e),
|
|
4750
|
+
style: styles$f.clickable,
|
|
4751
|
+
"aria-label": keyConfig.ariaLabel
|
|
4752
|
+
}, ({
|
|
4753
|
+
hovered,
|
|
4754
|
+
focused,
|
|
4755
|
+
pressed
|
|
4756
|
+
}) => /*#__PURE__*/React.createElement(View$1, {
|
|
4757
|
+
style: styles$f.outerBoxBase
|
|
4758
|
+
}, /*#__PURE__*/React.createElement(View$1, {
|
|
4759
|
+
style: [styles$f.base, directionalStyles, hovered && styles$f.hovered, focused && styles$f.focused, pressed && styles$f.pressed]
|
|
4760
|
+
}, /*#__PURE__*/React.createElement(ButtonAsset, {
|
|
4761
|
+
id: keyConfig.id
|
|
4762
|
+
})))));
|
|
4763
|
+
}
|
|
4764
|
+
const borderRadiusPx$1 = 4;
|
|
4765
|
+
const styles$f = StyleSheet.create({
|
|
4766
|
+
clickable: {
|
|
4767
|
+
width: "100%",
|
|
4768
|
+
height: "100%",
|
|
4769
|
+
":focus": {
|
|
4770
|
+
outline: `none`
|
|
4771
|
+
}
|
|
4772
|
+
},
|
|
4773
|
+
outerBoxBase: {
|
|
4774
|
+
height: "100%",
|
|
4775
|
+
width: "100%"
|
|
4776
|
+
},
|
|
4777
|
+
base: {
|
|
4778
|
+
boxShadow: `0px 1px 0px ${Color.offBlack32}`,
|
|
4779
|
+
display: "flex",
|
|
4780
|
+
justifyContent: "center",
|
|
4781
|
+
alignItems: "center",
|
|
4782
|
+
background: Color.white,
|
|
4783
|
+
borderWidth: 2,
|
|
4784
|
+
borderColor: Color.white
|
|
4785
|
+
},
|
|
4786
|
+
up: {
|
|
4787
|
+
borderTopLeftRadius: borderRadiusPx$1,
|
|
4788
|
+
borderTopRightRadius: borderRadiusPx$1
|
|
4789
|
+
},
|
|
4790
|
+
right: {
|
|
4791
|
+
borderTopRightRadius: borderRadiusPx$1,
|
|
4792
|
+
borderBottomRightRadius: borderRadiusPx$1
|
|
4793
|
+
},
|
|
4794
|
+
down: {
|
|
4795
|
+
borderBottomLeftRadius: borderRadiusPx$1,
|
|
4796
|
+
borderBottomRightRadius: borderRadiusPx$1
|
|
4797
|
+
},
|
|
4798
|
+
left: {
|
|
4799
|
+
borderTopLeftRadius: borderRadiusPx$1,
|
|
4800
|
+
borderBottomLeftRadius: borderRadiusPx$1
|
|
4801
|
+
},
|
|
4802
|
+
hovered: {
|
|
4803
|
+
borderColor: Color.blue,
|
|
4804
|
+
boxShadow: "none"
|
|
4805
|
+
},
|
|
4806
|
+
focused: {
|
|
4807
|
+
borderColor: Color.blue,
|
|
4808
|
+
boxShadow: "none"
|
|
4809
|
+
},
|
|
4810
|
+
pressed: {
|
|
4811
|
+
border: "2px solid #1B50B3",
|
|
4812
|
+
background: `linear-gradient(0deg, rgba(24, 101, 242, 0.32), rgba(24, 101, 242, 0.32)), ${Color.white}`,
|
|
4813
|
+
boxShadow: "none"
|
|
4814
|
+
}
|
|
4815
|
+
});
|
|
4816
|
+
|
|
4817
|
+
function NavigationPad$1(props) {
|
|
4818
|
+
const {
|
|
4819
|
+
onClickKey
|
|
4820
|
+
} = props;
|
|
4821
|
+
return /*#__PURE__*/React.createElement(View$1, {
|
|
4822
|
+
style: styles$e.container
|
|
4823
|
+
}, /*#__PURE__*/React.createElement(View$1, {
|
|
4824
|
+
style: styles$e.grid
|
|
4825
|
+
}, /*#__PURE__*/React.createElement(NavigationButton, {
|
|
4826
|
+
keyConfig: KeyConfigs.UP,
|
|
4827
|
+
onClickKey: onClickKey,
|
|
4828
|
+
coord: [1, 0]
|
|
4829
|
+
}), /*#__PURE__*/React.createElement(NavigationButton, {
|
|
4830
|
+
keyConfig: KeyConfigs.RIGHT,
|
|
4831
|
+
onClickKey: onClickKey,
|
|
4832
|
+
coord: [2, 1]
|
|
4833
|
+
}), /*#__PURE__*/React.createElement(NavigationButton, {
|
|
4834
|
+
keyConfig: KeyConfigs.DOWN,
|
|
4835
|
+
onClickKey: onClickKey,
|
|
4836
|
+
coord: [1, 2]
|
|
4837
|
+
}), /*#__PURE__*/React.createElement(NavigationButton, {
|
|
4838
|
+
keyConfig: KeyConfigs.LEFT,
|
|
4839
|
+
onClickKey: onClickKey,
|
|
4840
|
+
coord: [0, 1]
|
|
4841
|
+
}), /*#__PURE__*/React.createElement(View$1, {
|
|
4842
|
+
style: styles$e.spacer
|
|
4843
|
+
})));
|
|
4844
|
+
}
|
|
4845
|
+
const styles$e = StyleSheet.create({
|
|
4846
|
+
container: {
|
|
4847
|
+
display: "flex",
|
|
4848
|
+
alignItems: "center",
|
|
4849
|
+
justifyContent: "center",
|
|
4850
|
+
padding: "0 1.5rem"
|
|
4851
|
+
},
|
|
4852
|
+
grid: {
|
|
4853
|
+
width: 140,
|
|
4854
|
+
height: 140,
|
|
4855
|
+
display: "grid",
|
|
4856
|
+
gridTemplateColumns: "repeat(3, 1fr)",
|
|
4857
|
+
gridTemplateRows: "repeat(3, 1fr)"
|
|
4858
|
+
},
|
|
4859
|
+
spacer: {
|
|
4860
|
+
gridColumn: 2,
|
|
4861
|
+
gridRow: 2,
|
|
4862
|
+
background: Color.white
|
|
4863
|
+
}
|
|
4864
|
+
});
|
|
4865
|
+
|
|
4635
4866
|
function SharedKeys(props) {
|
|
4636
4867
|
const {
|
|
4637
4868
|
onClickKey,
|
|
@@ -4739,7 +4970,8 @@ function Keypad$2(props) {
|
|
|
4739
4970
|
advancedRelations,
|
|
4740
4971
|
showDismiss,
|
|
4741
4972
|
onAnalyticsEvent,
|
|
4742
|
-
fractionsOnly
|
|
4973
|
+
fractionsOnly,
|
|
4974
|
+
expandedView
|
|
4743
4975
|
} = props;
|
|
4744
4976
|
|
|
4745
4977
|
// Use a different grid for our fraction keypad
|
|
@@ -4771,15 +5003,20 @@ function Keypad$2(props) {
|
|
|
4771
5003
|
}
|
|
4772
5004
|
};
|
|
4773
5005
|
}, [onAnalyticsEvent, isMounted]);
|
|
4774
|
-
return /*#__PURE__*/React.createElement(View$1,
|
|
5006
|
+
return /*#__PURE__*/React.createElement(View$1, {
|
|
5007
|
+
style: expandedView ? styles$d.keypadOuterContainer : null
|
|
5008
|
+
}, /*#__PURE__*/React.createElement(View$1, {
|
|
5009
|
+
style: [styles$d.wrapper, expandedView ? styles$d.expandedWrapper : null]
|
|
5010
|
+
}, /*#__PURE__*/React.createElement(Tabbar, {
|
|
4775
5011
|
items: availableTabs,
|
|
4776
5012
|
selectedItem: selectedPage,
|
|
4777
5013
|
onSelectItem: tabbarItem => {
|
|
4778
5014
|
setSelectedPage(tabbarItem);
|
|
4779
5015
|
},
|
|
4780
|
-
style: styles$d.tabbar,
|
|
4781
5016
|
onClickClose: showDismiss ? () => onClickKey("DISMISS") : undefined
|
|
4782
5017
|
}), /*#__PURE__*/React.createElement(View$1, {
|
|
5018
|
+
style: styles$d.keypadInnerContainer
|
|
5019
|
+
}, /*#__PURE__*/React.createElement(View$1, {
|
|
4783
5020
|
style: [styles$d.keypadGrid, gridStyle],
|
|
4784
5021
|
role: "grid",
|
|
4785
5022
|
tabIndex: 0,
|
|
@@ -4806,17 +5043,34 @@ function Keypad$2(props) {
|
|
|
4806
5043
|
multiplicationDot: multiplicationDot,
|
|
4807
5044
|
divisionKey: divisionKey,
|
|
4808
5045
|
selectedPage: selectedPage
|
|
4809
|
-
}))
|
|
5046
|
+
})), expandedView && /*#__PURE__*/React.createElement(NavigationPad$1, {
|
|
5047
|
+
onClickKey: onClickKey
|
|
5048
|
+
}))));
|
|
4810
5049
|
}
|
|
4811
5050
|
Keypad$2.defaultProps = defaultProps;
|
|
4812
5051
|
const styles$d = StyleSheet.create({
|
|
4813
|
-
|
|
5052
|
+
keypadOuterContainer: {
|
|
5053
|
+
display: "flex",
|
|
5054
|
+
alignItems: "center"
|
|
5055
|
+
},
|
|
5056
|
+
wrapper: {
|
|
4814
5057
|
background: Color.white
|
|
4815
5058
|
},
|
|
5059
|
+
expandedWrapper: {
|
|
5060
|
+
borderWidth: "1px 1px 0 1px",
|
|
5061
|
+
borderColor: Color.offBlack32,
|
|
5062
|
+
maxWidth: expandedViewThreshold$1,
|
|
5063
|
+
borderRadius: "3px 3px 0 0"
|
|
5064
|
+
},
|
|
5065
|
+
keypadInnerContainer: {
|
|
5066
|
+
display: "flex",
|
|
5067
|
+
flexDirection: "row",
|
|
5068
|
+
backgroundColor: "#DBDCDD"
|
|
5069
|
+
},
|
|
4816
5070
|
keypadGrid: {
|
|
4817
5071
|
display: "grid",
|
|
4818
5072
|
gridTemplateRows: "repeat(4, 1fr)",
|
|
4819
|
-
|
|
5073
|
+
flex: 1
|
|
4820
5074
|
},
|
|
4821
5075
|
expressionGrid: {
|
|
4822
5076
|
gridTemplateColumns: "repeat(6, 1fr)"
|
|
@@ -4840,10 +5094,31 @@ const styles$d = StyleSheet.create({
|
|
|
4840
5094
|
class MobileKeypad extends React.Component {
|
|
4841
5095
|
constructor(...args) {
|
|
4842
5096
|
super(...args);
|
|
5097
|
+
this._containerRef = /*#__PURE__*/React.createRef();
|
|
5098
|
+
this._containerResizeObserver = null;
|
|
5099
|
+
this._throttleResize = false;
|
|
4843
5100
|
this.hasMounted = false;
|
|
4844
5101
|
this.state = {
|
|
5102
|
+
containerWidth: 0,
|
|
4845
5103
|
active: false
|
|
4846
5104
|
};
|
|
5105
|
+
this._resize = () => {
|
|
5106
|
+
var _this$_containerRef$c;
|
|
5107
|
+
const containerWidth = ((_this$_containerRef$c = this._containerRef.current) == null ? void 0 : _this$_containerRef$c.clientWidth) || 0;
|
|
5108
|
+
this.setState({
|
|
5109
|
+
containerWidth
|
|
5110
|
+
});
|
|
5111
|
+
};
|
|
5112
|
+
this._throttleResizeHandler = () => {
|
|
5113
|
+
if (this._throttleResize) {
|
|
5114
|
+
return;
|
|
5115
|
+
}
|
|
5116
|
+
this._throttleResize = true;
|
|
5117
|
+
setTimeout(() => {
|
|
5118
|
+
this._resize();
|
|
5119
|
+
this._throttleResize = false;
|
|
5120
|
+
}, 100);
|
|
5121
|
+
};
|
|
4847
5122
|
this.activate = () => {
|
|
4848
5123
|
this.setState({
|
|
4849
5124
|
active: true
|
|
@@ -4887,6 +5162,21 @@ class MobileKeypad extends React.Component {
|
|
|
4887
5162
|
return ReactDOM.findDOMNode(this);
|
|
4888
5163
|
};
|
|
4889
5164
|
}
|
|
5165
|
+
componentDidMount() {
|
|
5166
|
+
this._resize();
|
|
5167
|
+
window.addEventListener("resize", this._throttleResizeHandler);
|
|
5168
|
+
window.addEventListener("orientationchange", this._throttleResizeHandler);
|
|
5169
|
+
this._containerResizeObserver = new ResizeObserver(this._throttleResizeHandler);
|
|
5170
|
+
if (this._containerRef.current) {
|
|
5171
|
+
this._containerResizeObserver.observe(this._containerRef.current);
|
|
5172
|
+
}
|
|
5173
|
+
}
|
|
5174
|
+
componentWillUnMount() {
|
|
5175
|
+
var _this$_containerResiz;
|
|
5176
|
+
window.removeEventListener("resize", this._throttleResizeHandler);
|
|
5177
|
+
window.removeEventListener("orientationchange", this._throttleResizeHandler);
|
|
5178
|
+
(_this$_containerResiz = this._containerResizeObserver) == null ? void 0 : _this$_containerResiz.disconnect();
|
|
5179
|
+
}
|
|
4890
5180
|
_handleClickKey(key) {
|
|
4891
5181
|
var _this$state$keyHandle, _this$state;
|
|
4892
5182
|
if (key === "DISMISS") {
|
|
@@ -4904,6 +5194,7 @@ class MobileKeypad extends React.Component {
|
|
|
4904
5194
|
} = this.props;
|
|
4905
5195
|
const {
|
|
4906
5196
|
active,
|
|
5197
|
+
containerWidth,
|
|
4907
5198
|
cursor,
|
|
4908
5199
|
keypadConfig
|
|
4909
5200
|
} = this.state;
|
|
@@ -4915,6 +5206,7 @@ class MobileKeypad extends React.Component {
|
|
|
4915
5206
|
const isExpression = (keypadConfig == null ? void 0 : keypadConfig.keypadType) === "EXPRESSION";
|
|
4916
5207
|
return /*#__PURE__*/React.createElement(View, {
|
|
4917
5208
|
style: containerStyle,
|
|
5209
|
+
forwardRef: this._containerRef,
|
|
4918
5210
|
ref: element => {
|
|
4919
5211
|
if (!this.hasMounted && element) {
|
|
4920
5212
|
var _this$props$onElement, _this$props2;
|
|
@@ -4949,6 +5241,7 @@ class MobileKeypad extends React.Component {
|
|
|
4949
5241
|
logarithms: isExpression,
|
|
4950
5242
|
basicRelations: isExpression,
|
|
4951
5243
|
advancedRelations: isExpression,
|
|
5244
|
+
expandedView: containerWidth > expandedViewThreshold$1,
|
|
4952
5245
|
showDismiss: true
|
|
4953
5246
|
}));
|
|
4954
5247
|
}
|
|
@@ -6791,7 +7084,7 @@ const styles$6 = StyleSheet.create({
|
|
|
6791
7084
|
backgroundColor: wonderBlocksBlue
|
|
6792
7085
|
},
|
|
6793
7086
|
light: {
|
|
6794
|
-
backgroundColor:
|
|
7087
|
+
backgroundColor: Color.offBlack32
|
|
6795
7088
|
},
|
|
6796
7089
|
iconWrapper: {
|
|
6797
7090
|
zIndex: focusBoxZIndex + 1
|