@pie-lib/math-input 6.6.1-next.224 → 6.6.1-next.414
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 +95 -0
- package/lib/horizontal-keypad.js +24 -32
- package/lib/horizontal-keypad.js.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/keypad/index.js +67 -63
- package/lib/keypad/index.js.map +1 -1
- package/lib/keypad/keys-layout.js +1 -1
- package/lib/keypad/keys-layout.js.map +1 -1
- package/lib/keys/basic-operators.js.map +1 -1
- package/lib/keys/chars.js.map +1 -1
- package/lib/keys/comparison.js +5 -3
- package/lib/keys/comparison.js.map +1 -1
- package/lib/keys/constants.js.map +1 -1
- package/lib/keys/digits.js +2 -2
- package/lib/keys/digits.js.map +1 -1
- package/lib/keys/edit.js.map +1 -1
- package/lib/keys/exponent.js.map +1 -1
- package/lib/keys/fractions.js.map +1 -1
- package/lib/keys/geometry.js +5 -3
- package/lib/keys/geometry.js.map +1 -1
- package/lib/keys/grades.js +11 -23
- package/lib/keys/grades.js.map +1 -1
- package/lib/keys/index.js +3 -3
- package/lib/keys/index.js.map +1 -1
- package/lib/keys/log.js.map +1 -1
- package/lib/keys/logic.js.map +1 -1
- package/lib/keys/matrices.js.map +1 -1
- package/lib/keys/misc.js.map +1 -1
- package/lib/keys/navigation.js.map +1 -1
- package/lib/keys/operators.js.map +1 -1
- package/lib/keys/statistics.js.map +1 -1
- package/lib/keys/sub-sup.js.map +1 -1
- package/lib/keys/trigonometry.js.map +1 -1
- package/lib/keys/utils.js +7 -17
- package/lib/keys/utils.js.map +1 -1
- package/lib/keys/vars.js.map +1 -1
- package/lib/math-input.js +27 -41
- package/lib/math-input.js.map +1 -1
- package/lib/mq/custom-elements.js.map +1 -1
- package/lib/mq/index.js +2 -2
- package/lib/mq/index.js.map +1 -1
- package/lib/mq/input.js +23 -35
- package/lib/mq/input.js.map +1 -1
- package/lib/mq/static.js +19 -29
- package/lib/mq/static.js.map +1 -1
- package/package.json +2 -2
- package/src/horizontal-keypad.jsx +3 -1
- package/src/keypad/index.jsx +44 -9
- package/src/keys/grades.js +1 -1
package/lib/mq/static.js
CHANGED
|
@@ -1,46 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
24
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
var _react = _interopRequireDefault(require("react"));
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
31
29
|
|
|
32
|
-
|
|
30
|
+
var _mathquill = _interopRequireDefault(require("@pie-framework/mathquill"));
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
var _index = require("../index");
|
|
35
33
|
|
|
36
|
-
function
|
|
34
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
37
35
|
|
|
38
36
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
37
|
|
|
40
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
41
|
-
|
|
42
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
43
|
-
|
|
44
38
|
var MQ;
|
|
45
39
|
|
|
46
40
|
if (typeof window !== 'undefined') {
|
|
@@ -61,22 +55,21 @@ function stripSpaces() {
|
|
|
61
55
|
|
|
62
56
|
|
|
63
57
|
var Static = /*#__PURE__*/function (_React$Component) {
|
|
64
|
-
|
|
58
|
+
(0, _inherits2["default"])(Static, _React$Component);
|
|
65
59
|
|
|
66
60
|
var _super = _createSuper(Static);
|
|
67
61
|
|
|
68
62
|
function Static() {
|
|
69
63
|
var _this;
|
|
70
64
|
|
|
71
|
-
|
|
65
|
+
(0, _classCallCheck2["default"])(this, Static);
|
|
72
66
|
|
|
73
67
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
74
68
|
args[_key] = arguments[_key];
|
|
75
69
|
}
|
|
76
70
|
|
|
77
71
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
78
|
-
|
|
79
|
-
_defineProperty(_assertThisInitialized(_this), "onFocus", function (e) {
|
|
72
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onFocus", function (e) {
|
|
80
73
|
try {
|
|
81
74
|
var rootBlock = e.target.parentElement.nextSibling;
|
|
82
75
|
var id = parseInt(rootBlock.getAttribute('mathquill-block-id'), 10);
|
|
@@ -104,11 +97,10 @@ var Static = /*#__PURE__*/function (_React$Component) {
|
|
|
104
97
|
console.error('error finding root block', err.message);
|
|
105
98
|
}
|
|
106
99
|
});
|
|
107
|
-
|
|
108
100
|
return _this;
|
|
109
101
|
}
|
|
110
102
|
|
|
111
|
-
|
|
103
|
+
(0, _createClass2["default"])(Static, [{
|
|
112
104
|
key: "componentDidMount",
|
|
113
105
|
value: function componentDidMount() {
|
|
114
106
|
this.update();
|
|
@@ -205,13 +197,11 @@ var Static = /*#__PURE__*/function (_React$Component) {
|
|
|
205
197
|
});
|
|
206
198
|
}
|
|
207
199
|
}]);
|
|
208
|
-
|
|
209
200
|
return Static;
|
|
210
201
|
}(_react["default"].Component);
|
|
211
202
|
|
|
212
203
|
exports["default"] = Static;
|
|
213
|
-
|
|
214
|
-
_defineProperty(Static, "propTypes", {
|
|
204
|
+
(0, _defineProperty2["default"])(Static, "propTypes", {
|
|
215
205
|
latex: _propTypes["default"].string.isRequired,
|
|
216
206
|
onFocus: _propTypes["default"].func,
|
|
217
207
|
onBlur: _propTypes["default"].func,
|
package/lib/mq/static.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"static.js","names":["MQ","window","MathQuill","getInterface","log","debug","REGEX","WHITESPACE_REGEX","stripSpaces","string","replace","Static","e","rootBlock","target","parentElement","nextSibling","id","parseInt","getAttribute","innerField","mathField","innerFields","find","f","name","props","getFieldName","setInput","onSubFieldFocus","err","console","error","message","update","updateSpans","field","onSubFieldChange","latex","Error","StaticMath","input","handlers","edit","onInputEdit","bind","parseLatex","blur","focus","nextProps","parsedLatex","stripped","newFieldCount","match","length","out","trim","Object","keys","warn","onBlur","className","onFocus","r","React","Component","PropTypes","isRequired","func"],"sources":["../../src/mq/static.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\nimport debug from 'debug';\nimport MathQuill from '@pie-framework/mathquill';\nimport { updateSpans } from '../index';\n\nlet MQ;\nif (typeof window !== 'undefined') {\n MQ = MathQuill.getInterface(2);\n}\n\nconst log = debug('pie-lib:math-input:mq:static');\nconst REGEX = /\\\\MathQuillMathField\\[r\\d*\\]\\{(.*?)\\}/g;\nconst WHITESPACE_REGEX = / /g;\n\nfunction stripSpaces(string = '') {\n return string.replace(WHITESPACE_REGEX, '');\n}\n\n/**\n * Wrapper for MathQuill MQ.MathField.\n */\nexport default class Static extends React.Component {\n static propTypes = {\n latex: PropTypes.string.isRequired,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n className: PropTypes.string,\n getFieldName: PropTypes.func,\n onSubFieldChange: PropTypes.func,\n onSubFieldFocus: PropTypes.func,\n setInput: PropTypes.func\n };\n\n componentDidMount() {\n this.update();\n updateSpans();\n }\n\n componentDidUpdate() {\n this.update();\n updateSpans();\n }\n\n onInputEdit(field) {\n if (!this.mathField) {\n return;\n }\n const name = this.props.getFieldName(field, this.mathField.innerFields);\n if (this.props.onSubFieldChange) {\n this.props.onSubFieldChange(name, field.latex());\n }\n }\n\n update() {\n if (!MQ) {\n throw new Error('MQ is not defined - but component has mounted?');\n }\n // this.input.innerHTML = this.props.latex;\n if (!this.mathField) {\n this.mathField = MQ.StaticMath(this.input, {\n handlers: {\n edit: this.onInputEdit.bind(this)\n }\n });\n }\n\n try {\n this.mathField.parseLatex(this.props.latex);\n this.mathField.latex(this.props.latex);\n } catch (e) {\n // default latex if received has errors\n this.mathField.latex('\\\\MathQuillMathField[r1]{}');\n }\n }\n\n blur() {\n log('blur mathfield');\n this.mathField.blur();\n }\n\n focus() {\n log('focus mathfield...');\n this.mathField.focus();\n }\n\n shouldComponentUpdate(nextProps) {\n try {\n const parsedLatex = this.mathField.parseLatex(nextProps.latex);\n const stripped = stripSpaces(parsedLatex);\n const newFieldCount = (nextProps.latex.match(REGEX) || []).length;\n\n const out =\n stripped !== stripSpaces(this.mathField.latex().trim()) ||\n newFieldCount !== Object.keys(this.mathField.innerFields).length / 2;\n\n log('[shouldComponentUpdate] ', out);\n return out;\n } catch (e) {\n // eslint-disable-next-line no-console\n console.warn('Error parsing latex:', e.message, 'skip update');\n // eslint-disable-next-line no-console\n console.warn(e);\n return false;\n }\n }\n\n onFocus = e => {\n try {\n let rootBlock = e.target.parentElement.nextSibling;\n let id = parseInt(rootBlock.getAttribute('mathquill-block-id'), 10);\n\n if (!id) {\n rootBlock = rootBlock.parentElement;\n id = parseInt(rootBlock.getAttribute('mathquill-block-id'), 10);\n }\n\n const innerField = this.mathField.innerFields.find(f => f.id === id);\n\n if (innerField) {\n const name = this.props.getFieldName(innerField, this.mathField.innerFields);\n if (this.props.setInput) {\n this.props.setInput(innerField);\n }\n this.props.onSubFieldFocus(name, innerField);\n }\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error('error finding root block', err.message);\n }\n };\n\n render() {\n const { onBlur, className } = this.props;\n\n return (\n <span\n className={className}\n onFocus={this.onFocus}\n onBlur={onBlur}\n ref={r => (this.input = r)}\n />\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAIA,EAAJ;;A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AAA,CAAMC,S;;;iCAArBtD,M,eACA;EACjB2B,KAAK,EAAE4B,qBAAA,CAAUzD,MAAV,CAAiB0D,UADP;EAEjBL,OAAO,EAAEI,qBAAA,CAAUE,IAFF;EAGjBR,MAAM,EAAEM,qBAAA,CAAUE,IAHD;EAIjBP,SAAS,EAAEK,qBAAA,CAAUzD,MAJJ;EAKjBkB,YAAY,EAAEuC,qBAAA,CAAUE,IALP;EAMjB/B,gBAAgB,EAAE6B,qBAAA,CAAUE,IANX;EAOjBvC,eAAe,EAAEqC,qBAAA,CAAUE,IAPV;EAQjBxC,QAAQ,EAAEsC,qBAAA,CAAUE;AARH,C"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "6.6.1-next.
|
|
6
|
+
"version": "6.6.1-next.414+e2932997",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
8
|
"module": "src/index.jsx",
|
|
9
9
|
"dependencies": {
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"react-dom": "^16.9.0"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "e2932997d4237f56981af5ca83cbc68447e2feb6"
|
|
26
26
|
}
|
|
@@ -18,6 +18,7 @@ export default class HorizontalKeypad extends React.Component {
|
|
|
18
18
|
static propTypes = {
|
|
19
19
|
className: PropTypes.string,
|
|
20
20
|
mode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
21
|
+
layoutForKeyPad: PropTypes.object,
|
|
21
22
|
onClick: PropTypes.func.isRequired,
|
|
22
23
|
onFocus: PropTypes.func,
|
|
23
24
|
noDecimal: PropTypes.bool,
|
|
@@ -37,7 +38,7 @@ export default class HorizontalKeypad extends React.Component {
|
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
render() {
|
|
40
|
-
const { mode, onFocus, noDecimal, className, additionalKeys } = this.props;
|
|
41
|
+
const { mode, onFocus, noDecimal, className, additionalKeys, layoutForKeyPad } = this.props;
|
|
41
42
|
const normalizedKeys = normalizeAdditionalKeys(additionalKeys);
|
|
42
43
|
|
|
43
44
|
return (
|
|
@@ -45,6 +46,7 @@ export default class HorizontalKeypad extends React.Component {
|
|
|
45
46
|
className={className}
|
|
46
47
|
onFocus={onFocus}
|
|
47
48
|
noDecimal={noDecimal}
|
|
49
|
+
layoutForKeyPad={layoutForKeyPad}
|
|
48
50
|
additionalKeys={extendKeySet(keysForGrade(mode), normalizedKeys)}
|
|
49
51
|
onPress={this.keypadPress}
|
|
50
52
|
mode={mode}
|
package/src/keypad/index.jsx
CHANGED
|
@@ -40,14 +40,17 @@ const LatexButton = withStyles(theme => ({
|
|
|
40
40
|
width: '30px',
|
|
41
41
|
marginTop: '0 !important',
|
|
42
42
|
borderTop: '2px solid black',
|
|
43
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
44
|
+
|
|
43
45
|
'&.mq-arrow-both': {
|
|
46
|
+
top: '5px !important',
|
|
44
47
|
'& *': {
|
|
45
48
|
lineHeight: '1 !important'
|
|
46
49
|
},
|
|
47
50
|
'&:before': {
|
|
48
51
|
fontSize: '80%',
|
|
49
52
|
left: 'calc(-13%)',
|
|
50
|
-
top: '-0.
|
|
53
|
+
top: '-0.31em'
|
|
51
54
|
},
|
|
52
55
|
'&:after': {
|
|
53
56
|
fontSize: '80% !important',
|
|
@@ -57,12 +60,12 @@ const LatexButton = withStyles(theme => ({
|
|
|
57
60
|
'&.mq-empty:before': {
|
|
58
61
|
fontSize: '80%',
|
|
59
62
|
left: 'calc(-13%)',
|
|
60
|
-
top: '-0.
|
|
63
|
+
top: '-0.26em'
|
|
61
64
|
},
|
|
62
65
|
'&.mq-empty:after': {
|
|
63
66
|
fontSize: '80%',
|
|
64
67
|
right: 'calc(-13%)',
|
|
65
|
-
top: '-0.
|
|
68
|
+
top: '-0.26em'
|
|
66
69
|
},
|
|
67
70
|
'&.mq-empty': {
|
|
68
71
|
minHeight: '1.4em'
|
|
@@ -123,7 +126,7 @@ const LatexButton = withStyles(theme => ({
|
|
|
123
126
|
paddingTop: '0 !important'
|
|
124
127
|
},
|
|
125
128
|
'&:after': {
|
|
126
|
-
top: '-
|
|
129
|
+
top: '-2.8em !important'
|
|
127
130
|
}
|
|
128
131
|
}
|
|
129
132
|
}
|
|
@@ -166,12 +169,25 @@ const LatexButton = withStyles(theme => ({
|
|
|
166
169
|
);
|
|
167
170
|
});
|
|
168
171
|
|
|
172
|
+
const createCustomLayout = layoutObj => {
|
|
173
|
+
if (layoutObj) {
|
|
174
|
+
return {
|
|
175
|
+
gridTemplateColumns: `repeat(${layoutObj.columns}, minmax(min-content, 150px))`,
|
|
176
|
+
gridTemplateRows: `repeat(${layoutObj.rows}, minmax(40px, 60px))`,
|
|
177
|
+
gridAutoFlow: 'initial'
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return {};
|
|
182
|
+
};
|
|
183
|
+
|
|
169
184
|
export class KeyPad extends React.Component {
|
|
170
185
|
static propTypes = {
|
|
171
186
|
classes: PropTypes.object.isRequired,
|
|
172
187
|
className: PropTypes.string,
|
|
173
188
|
baseSet: PropTypes.array,
|
|
174
189
|
additionalKeys: PropTypes.array,
|
|
190
|
+
layoutForKeyPad: PropTypes.object,
|
|
175
191
|
onPress: PropTypes.func.isRequired,
|
|
176
192
|
onFocus: PropTypes.func,
|
|
177
193
|
noDecimal: PropTypes.bool,
|
|
@@ -207,14 +223,23 @@ export class KeyPad extends React.Component {
|
|
|
207
223
|
};
|
|
208
224
|
|
|
209
225
|
render() {
|
|
210
|
-
const {
|
|
226
|
+
const {
|
|
227
|
+
classes,
|
|
228
|
+
className,
|
|
229
|
+
baseSet,
|
|
230
|
+
additionalKeys,
|
|
231
|
+
layoutForKeyPad,
|
|
232
|
+
onFocus,
|
|
233
|
+
mode
|
|
234
|
+
} = this.props;
|
|
211
235
|
|
|
212
236
|
const noBaseSet = [
|
|
213
237
|
'non-negative-integers',
|
|
214
238
|
'integers',
|
|
215
239
|
'decimals',
|
|
216
240
|
'fractions',
|
|
217
|
-
'item-authoring'
|
|
241
|
+
'item-authoring',
|
|
242
|
+
'language'
|
|
218
243
|
];
|
|
219
244
|
|
|
220
245
|
const keysWithoutBaseSet = noBaseSet.includes(mode);
|
|
@@ -225,10 +250,15 @@ export class KeyPad extends React.Component {
|
|
|
225
250
|
const shift = allKeys.length % 5 ? 1 : 0;
|
|
226
251
|
const style = {
|
|
227
252
|
gridTemplateColumns: `repeat(${Math.floor(allKeys.length / 5) +
|
|
228
|
-
shift}, minmax(min-content, 150px))
|
|
253
|
+
shift}, minmax(min-content, 150px))`,
|
|
254
|
+
...createCustomLayout(layoutForKeyPad)
|
|
229
255
|
};
|
|
230
256
|
return (
|
|
231
|
-
<div
|
|
257
|
+
<div
|
|
258
|
+
className={classNames(classes.keys, className, classes[mode])}
|
|
259
|
+
style={style}
|
|
260
|
+
onFocus={onFocus}
|
|
261
|
+
>
|
|
232
262
|
{allKeys.map((k, index) => {
|
|
233
263
|
const onClick = this.buttonClick.bind(this, k);
|
|
234
264
|
|
|
@@ -241,11 +271,13 @@ export class KeyPad extends React.Component {
|
|
|
241
271
|
className: classNames(
|
|
242
272
|
classes.labelButton,
|
|
243
273
|
!keysWithoutBaseSet && classes[k.category],
|
|
274
|
+
classes[k.extraClass],
|
|
244
275
|
k.label === ',' && classes.comma,
|
|
245
276
|
k.label === '.' && classes.dot
|
|
246
277
|
),
|
|
247
278
|
disabled: this.keyIsNotAllowed(k),
|
|
248
|
-
key: `${k.label || k.latex || k.command}-${index}
|
|
279
|
+
key: `${k.label || k.latex || k.command}-${index}`,
|
|
280
|
+
...(k.actions || {})
|
|
249
281
|
};
|
|
250
282
|
|
|
251
283
|
if (k.latex) {
|
|
@@ -281,6 +313,9 @@ const styles = theme => ({
|
|
|
281
313
|
gridColumnGap: '0px',
|
|
282
314
|
gridAutoFlow: 'column'
|
|
283
315
|
},
|
|
316
|
+
character: {
|
|
317
|
+
textTransform: 'initial !important'
|
|
318
|
+
},
|
|
284
319
|
holder: {
|
|
285
320
|
position: 'relative',
|
|
286
321
|
width: '100%',
|
package/src/keys/grades.js
CHANGED