@instructure/ui-number-input 10.16.1-snapshot-0 → 10.16.1
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 +1 -1
- package/es/NumberInput/__new-tests__/NumberInput.test.js +21 -21
- package/es/NumberInput/index.js +59 -48
- package/lib/NumberInput/__new-tests__/NumberInput.test.js +42 -42
- package/lib/NumberInput/index.js +58 -48
- package/package.json +14 -14
- package/src/NumberInput/__new-tests__/NumberInput.test.tsx +0 -1
- package/src/NumberInput/index.tsx +4 -5
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/NumberInput/__new-tests__/NumberInput.test.d.ts.map +1 -1
- package/types/NumberInput/index.d.ts +3 -5
- package/types/NumberInput/index.d.ts.map +1 -1
package/lib/NumberInput/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.NumberInput = void 0;
|
|
9
|
-
var _react =
|
|
8
|
+
var _react = require("react");
|
|
10
9
|
var _keycode = _interopRequireDefault(require("keycode"));
|
|
11
10
|
var _FormField = require("@instructure/ui-form-field/lib/FormField");
|
|
12
11
|
var _IconArrowOpenDownLine = require("@instructure/ui-icons/lib/IconArrowOpenDownLine.js");
|
|
@@ -22,6 +21,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
22
21
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
23
22
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
24
23
|
var _props = require("./props");
|
|
24
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
25
25
|
var _dec, _dec2, _dec3, _class, _NumberInput, _IconArrowOpenUpLine, _IconArrowOpenDownLin;
|
|
26
26
|
/*
|
|
27
27
|
* The MIT License (MIT)
|
|
@@ -46,7 +46,6 @@ var _dec, _dec2, _dec3, _class, _NumberInput, _IconArrowOpenUpLine, _IconArrowOp
|
|
|
46
46
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
47
47
|
* SOFTWARE.
|
|
48
48
|
*/
|
|
49
|
-
/** @jsx jsx */
|
|
50
49
|
/**
|
|
51
50
|
---
|
|
52
51
|
category: components
|
|
@@ -164,21 +163,24 @@ let NumberInput = exports.NumberInput = (_dec = (0, _withDeterministicId.withDet
|
|
|
164
163
|
}
|
|
165
164
|
renderArrows(customIcons) {
|
|
166
165
|
var _this$props$styles, _this$props$styles2, _this$props$styles3;
|
|
167
|
-
return (0,
|
|
168
|
-
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.arrowContainer
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
"
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
166
|
+
return (0, _jsxRuntime.jsxs)("span", {
|
|
167
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.arrowContainer,
|
|
168
|
+
children: [(0, _jsxRuntime.jsx)("button", {
|
|
169
|
+
"aria-hidden": true,
|
|
170
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.arrow,
|
|
171
|
+
onMouseDown: this.handleClickUpArrow,
|
|
172
|
+
tabIndex: -1,
|
|
173
|
+
type: "button",
|
|
174
|
+
children: customIcons !== null && customIcons !== void 0 && customIcons.increase ? (0, _callRenderProp.callRenderProp)(customIcons.increase) : _IconArrowOpenUpLine || (_IconArrowOpenUpLine = (0, _jsxRuntime.jsx)(_IconArrowOpenUpLine2.IconArrowOpenUpLine, {}))
|
|
175
|
+
}), (0, _jsxRuntime.jsx)("button", {
|
|
176
|
+
"aria-hidden": true,
|
|
177
|
+
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.arrow,
|
|
178
|
+
onMouseDown: this.handleClickDownArrow,
|
|
179
|
+
tabIndex: -1,
|
|
180
|
+
type: "button",
|
|
181
|
+
children: customIcons !== null && customIcons !== void 0 && customIcons.decrease ? (0, _callRenderProp.callRenderProp)(customIcons.decrease) : _IconArrowOpenDownLin || (_IconArrowOpenDownLin = (0, _jsxRuntime.jsx)(_IconArrowOpenDownLine.IconArrowOpenDownLine, {}))
|
|
182
|
+
})]
|
|
183
|
+
});
|
|
182
184
|
}
|
|
183
185
|
render() {
|
|
184
186
|
var _this$props$styles4, _this$props$styles5, _this$props$styles6;
|
|
@@ -196,40 +198,48 @@ let NumberInput = exports.NumberInput = (_dec = (0, _withDeterministicId.withDet
|
|
|
196
198
|
margin = _this$props4.margin;
|
|
197
199
|
const interaction = this.interaction;
|
|
198
200
|
const rawLabel = (0, _callRenderProp.callRenderProp)(renderLabel);
|
|
199
|
-
const label = (0, _hasVisibleChildren.hasVisibleChildren)(rawLabel) ? (0,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
201
|
+
const label = (0, _hasVisibleChildren.hasVisibleChildren)(rawLabel) ? (0, _jsxRuntime.jsxs)(_react.Fragment, {
|
|
202
|
+
children: [rawLabel, isRequired && (0, _jsxRuntime.jsxs)("span", {
|
|
203
|
+
css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {},
|
|
204
|
+
"aria-hidden": true,
|
|
205
|
+
children: [' ', "*"]
|
|
206
|
+
})]
|
|
207
|
+
}) : rawLabel;
|
|
208
|
+
return (0, _jsxRuntime.jsx)(_FormField.FormField, {
|
|
209
|
+
...(0, _pickProps.pickProps)(this.props, _FormField.FormField.allowedProps),
|
|
204
210
|
label: label,
|
|
205
211
|
inline: display === 'inline-block',
|
|
206
212
|
id: this.id,
|
|
207
213
|
elementRef: this.handleRef,
|
|
208
|
-
margin: margin
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
214
|
+
margin: margin,
|
|
215
|
+
children: (0, _jsxRuntime.jsx)("span", {
|
|
216
|
+
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.inputWidth,
|
|
217
|
+
style: width ? {
|
|
218
|
+
width
|
|
219
|
+
} : void 0,
|
|
220
|
+
children: (0, _jsxRuntime.jsxs)("span", {
|
|
221
|
+
css: (_this$props$styles5 = this.props.styles) === null || _this$props$styles5 === void 0 ? void 0 : _this$props$styles5.inputContainer,
|
|
222
|
+
children: [(0, _jsxRuntime.jsx)("input", {
|
|
223
|
+
...(0, _omitProps.omitProps)(this.props, [..._FormField.FormField.allowedProps, ...NumberInput.allowedProps]),
|
|
224
|
+
css: (_this$props$styles6 = this.props.styles) === null || _this$props$styles6 === void 0 ? void 0 : _this$props$styles6.input,
|
|
225
|
+
"aria-invalid": this.invalid ? 'true' : void 0,
|
|
226
|
+
id: this.id,
|
|
227
|
+
type: allowStringValue ? 'text' : 'number',
|
|
228
|
+
inputMode: this.props.inputMode,
|
|
229
|
+
placeholder: placeholder,
|
|
230
|
+
ref: this.handleInputRef,
|
|
231
|
+
required: isRequired,
|
|
232
|
+
value: value,
|
|
233
|
+
disabled: interaction === 'disabled',
|
|
234
|
+
readOnly: interaction === 'readonly',
|
|
235
|
+
onFocus: this.handleFocus,
|
|
236
|
+
onBlur: this.handleBlur,
|
|
237
|
+
onChange: this.handleChange,
|
|
238
|
+
onKeyDown: this.handleKeyDown
|
|
239
|
+
}), showArrows ? this.renderArrows(renderIcons) : null]
|
|
240
|
+
})
|
|
241
|
+
})
|
|
242
|
+
});
|
|
233
243
|
}
|
|
234
244
|
}, _NumberInput.displayName = "NumberInput", _NumberInput.componentId = 'NumberInput', _NumberInput.allowedProps = _props.allowedProps, _NumberInput.propTypes = _props.propTypes, _NumberInput.defaultProps = {
|
|
235
245
|
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-number-input",
|
|
3
|
-
"version": "10.16.1
|
|
3
|
+
"version": "10.16.1",
|
|
4
4
|
"description": "A UI component library made by Instructure Inc.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"homepage": "https://instructure.github.io/instructure-ui/",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-axe-check": "10.16.1
|
|
27
|
-
"@instructure/ui-babel-preset": "10.16.1
|
|
28
|
-
"@instructure/ui-scripts": "10.16.1
|
|
29
|
-
"@instructure/ui-test-utils": "10.16.1
|
|
30
|
-
"@instructure/ui-themes": "10.16.1
|
|
26
|
+
"@instructure/ui-axe-check": "10.16.1",
|
|
27
|
+
"@instructure/ui-babel-preset": "10.16.1",
|
|
28
|
+
"@instructure/ui-scripts": "10.16.1",
|
|
29
|
+
"@instructure/ui-test-utils": "10.16.1",
|
|
30
|
+
"@instructure/ui-themes": "10.16.1",
|
|
31
31
|
"@testing-library/jest-dom": "^6.6.3",
|
|
32
32
|
"@testing-library/react": "^16.0.1",
|
|
33
33
|
"@testing-library/user-event": "^14.5.2",
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@babel/runtime": "^7.26.0",
|
|
38
|
-
"@instructure/emotion": "10.16.1
|
|
39
|
-
"@instructure/shared-types": "10.16.1
|
|
40
|
-
"@instructure/ui-form-field": "10.16.1
|
|
41
|
-
"@instructure/ui-icons": "10.16.1
|
|
42
|
-
"@instructure/ui-react-utils": "10.16.1
|
|
43
|
-
"@instructure/ui-testable": "10.16.1
|
|
44
|
-
"@instructure/ui-utils": "10.16.1
|
|
45
|
-
"@instructure/uid": "10.16.1
|
|
38
|
+
"@instructure/emotion": "10.16.1",
|
|
39
|
+
"@instructure/shared-types": "10.16.1",
|
|
40
|
+
"@instructure/ui-form-field": "10.16.1",
|
|
41
|
+
"@instructure/ui-icons": "10.16.1",
|
|
42
|
+
"@instructure/ui-react-utils": "10.16.1",
|
|
43
|
+
"@instructure/ui-testable": "10.16.1",
|
|
44
|
+
"@instructure/ui-utils": "10.16.1",
|
|
45
|
+
"@instructure/uid": "10.16.1",
|
|
46
46
|
"keycode": "^2",
|
|
47
47
|
"prop-types": "^15.8.1"
|
|
48
48
|
},
|
|
@@ -22,8 +22,7 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
import React, { Component } from 'react'
|
|
25
|
+
import { Fragment, Component } from 'react'
|
|
27
26
|
import keycode from 'keycode'
|
|
28
27
|
|
|
29
28
|
import { FormField } from '@instructure/ui-form-field'
|
|
@@ -41,7 +40,7 @@ import {
|
|
|
41
40
|
} from '@instructure/ui-react-utils'
|
|
42
41
|
import { hasVisibleChildren } from '@instructure/ui-a11y-utils'
|
|
43
42
|
|
|
44
|
-
import { withStyle
|
|
43
|
+
import { withStyle } from '@instructure/emotion'
|
|
45
44
|
|
|
46
45
|
import generateStyle from './styles'
|
|
47
46
|
import generateComponentTheme from './theme'
|
|
@@ -256,7 +255,7 @@ class NumberInput extends Component<NumberInputProps, NumberInputState> {
|
|
|
256
255
|
|
|
257
256
|
const rawLabel = callRenderProp(renderLabel)
|
|
258
257
|
const label = hasVisibleChildren(rawLabel) ? (
|
|
259
|
-
<
|
|
258
|
+
<Fragment>
|
|
260
259
|
{rawLabel}
|
|
261
260
|
{isRequired && (
|
|
262
261
|
<span
|
|
@@ -267,7 +266,7 @@ class NumberInput extends Component<NumberInputProps, NumberInputState> {
|
|
|
267
266
|
*
|
|
268
267
|
</span>
|
|
269
268
|
)}
|
|
270
|
-
</
|
|
269
|
+
</Fragment>
|
|
271
270
|
) : (
|
|
272
271
|
rawLabel
|
|
273
272
|
)
|