@instructure/ui-number-input 11.6.0 → 11.6.1-pr-snapshot-1779894247159
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 +8 -0
- package/{lib/NumberInput/props.js → babel.config.cjs} +13 -7
- package/package.json +14 -16
- package/lib/NumberInput/index.js +0 -256
- package/lib/NumberInput/styles.js +0 -184
- package/lib/NumberInput/theme.js +0 -84
- package/lib/index.js +0 -12
- package/lib/package.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [11.6.1-pr-snapshot-1779894247159](https://github.com/instructure/instructure-ui/compare/v11.6.0...v11.6.1-pr-snapshot-1779894247159) (2026-05-27)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-number-input
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [11.6.0](https://github.com/instructure/instructure-ui/compare/v11.5.0...v11.6.0) (2026-02-18)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @instructure/ui-number-input
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.allowedProps = void 0;
|
|
7
1
|
/*
|
|
8
2
|
* The MIT License (MIT)
|
|
9
3
|
*
|
|
@@ -28,4 +22,16 @@ exports.allowedProps = void 0;
|
|
|
28
22
|
* SOFTWARE.
|
|
29
23
|
*/
|
|
30
24
|
|
|
31
|
-
|
|
25
|
+
module.exports = {
|
|
26
|
+
presets: [
|
|
27
|
+
[
|
|
28
|
+
require('@instructure/ui-babel-preset'),
|
|
29
|
+
{
|
|
30
|
+
coverage: Boolean(process.env.COVERAGE),
|
|
31
|
+
esModules: Boolean(process.env.ES_MODULES),
|
|
32
|
+
removeConsole: process.env.NODE_ENV === 'production',
|
|
33
|
+
transformImports: Boolean(process.env.TRANSFORM_IMPORTS)
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
]
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-number-input",
|
|
3
|
-
"version": "11.6.
|
|
3
|
+
"version": "11.6.1-pr-snapshot-1779894247159",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "A UI component library made by Instructure Inc.",
|
|
5
6
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
7
|
"module": "./es/index.js",
|
|
7
|
-
"main": "./lib/index.js",
|
|
8
8
|
"types": "./types/index.d.ts",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -16,23 +16,23 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@babel/runtime": "^7.27.6",
|
|
18
18
|
"keycode": "^2",
|
|
19
|
-
"@instructure/
|
|
20
|
-
"@instructure/
|
|
21
|
-
"@instructure/ui-
|
|
22
|
-
"@instructure/ui-
|
|
23
|
-
"@instructure/
|
|
24
|
-
"@instructure/ui-
|
|
25
|
-
"@instructure/
|
|
26
|
-
"@instructure/
|
|
19
|
+
"@instructure/ui-a11y-utils": "11.6.1-pr-snapshot-1779894247159",
|
|
20
|
+
"@instructure/emotion": "11.6.1-pr-snapshot-1779894247159",
|
|
21
|
+
"@instructure/ui-icons": "11.6.1-pr-snapshot-1779894247159",
|
|
22
|
+
"@instructure/ui-form-field": "11.6.1-pr-snapshot-1779894247159",
|
|
23
|
+
"@instructure/shared-types": "11.6.1-pr-snapshot-1779894247159",
|
|
24
|
+
"@instructure/ui-react-utils": "11.6.1-pr-snapshot-1779894247159",
|
|
25
|
+
"@instructure/ui-utils": "11.6.1-pr-snapshot-1779894247159",
|
|
26
|
+
"@instructure/uid": "11.6.1-pr-snapshot-1779894247159"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@testing-library/jest-dom": "^6.6.3",
|
|
30
30
|
"@testing-library/react": "15.0.7",
|
|
31
31
|
"@testing-library/user-event": "^14.6.1",
|
|
32
32
|
"vitest": "^3.2.2",
|
|
33
|
-
"@instructure/ui-babel-preset": "11.6.
|
|
34
|
-
"@instructure/ui-scripts": "11.6.
|
|
35
|
-
"@instructure/ui-themes": "11.6.
|
|
33
|
+
"@instructure/ui-babel-preset": "11.6.1-pr-snapshot-1779894247159",
|
|
34
|
+
"@instructure/ui-scripts": "11.6.1-pr-snapshot-1779894247159",
|
|
35
|
+
"@instructure/ui-themes": "11.6.1-pr-snapshot-1779894247159"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"react": ">=18 <=19"
|
|
@@ -45,10 +45,8 @@
|
|
|
45
45
|
".": {
|
|
46
46
|
"types": "./types/index.d.ts",
|
|
47
47
|
"import": "./es/index.js",
|
|
48
|
-
"require": "./lib/index.js",
|
|
49
48
|
"default": "./es/index.js"
|
|
50
49
|
},
|
|
51
|
-
"./lib/*": "./lib/*",
|
|
52
50
|
"./es/*": "./es/*",
|
|
53
51
|
"./types/*": "./types/*",
|
|
54
52
|
"./package.json": "./package.json",
|
|
@@ -58,7 +56,7 @@
|
|
|
58
56
|
"lint": "ui-scripts lint",
|
|
59
57
|
"lint:fix": "ui-scripts lint --fix",
|
|
60
58
|
"clean": "ui-scripts clean",
|
|
61
|
-
"build": "ui-scripts build
|
|
59
|
+
"build": "ui-scripts build",
|
|
62
60
|
"build:watch": "pnpm run ts:check -- --watch & ui-scripts build --watch",
|
|
63
61
|
"build:types": "tsc -p tsconfig.build.json",
|
|
64
62
|
"ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
|
package/lib/NumberInput/index.js
DELETED
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.NumberInput = void 0;
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _keycode = _interopRequireDefault(require("keycode"));
|
|
10
|
-
var _FormField = require("@instructure/ui-form-field/lib/FormField");
|
|
11
|
-
var _IconArrowOpenDownLine = require("@instructure/ui-icons/lib/IconArrowOpenDownLine.js");
|
|
12
|
-
var _IconArrowOpenUpLine2 = require("@instructure/ui-icons/lib/IconArrowOpenUpLine.js");
|
|
13
|
-
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
14
|
-
var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
|
|
15
|
-
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
16
|
-
var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js");
|
|
17
|
-
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
18
|
-
var _hasVisibleChildren = require("@instructure/ui-a11y-utils/lib/hasVisibleChildren.js");
|
|
19
|
-
var _emotion = require("@instructure/emotion");
|
|
20
|
-
var _styles = _interopRequireDefault(require("./styles"));
|
|
21
|
-
var _theme = _interopRequireDefault(require("./theme"));
|
|
22
|
-
var _props = require("./props");
|
|
23
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
24
|
-
var _dec, _dec2, _class, _NumberInput, _IconArrowOpenUpLine, _IconArrowOpenDownLin;
|
|
25
|
-
/*
|
|
26
|
-
* The MIT License (MIT)
|
|
27
|
-
*
|
|
28
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
29
|
-
*
|
|
30
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
31
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
32
|
-
* in the Software without restriction, including without limitation the rights
|
|
33
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
34
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
35
|
-
* furnished to do so, subject to the following conditions:
|
|
36
|
-
*
|
|
37
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
38
|
-
* copies or substantial portions of the Software.
|
|
39
|
-
*
|
|
40
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
41
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
42
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
43
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
44
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
45
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
46
|
-
* SOFTWARE.
|
|
47
|
-
*/
|
|
48
|
-
/**
|
|
49
|
-
---
|
|
50
|
-
category: components
|
|
51
|
-
id: NumberInput
|
|
52
|
-
---
|
|
53
|
-
**/
|
|
54
|
-
let NumberInput = exports.NumberInput = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = _dec2(_class = (_NumberInput = class NumberInput extends _react.Component {
|
|
55
|
-
constructor(...args) {
|
|
56
|
-
super(...args);
|
|
57
|
-
this.state = {
|
|
58
|
-
hasFocus: false
|
|
59
|
-
};
|
|
60
|
-
this.ref = null;
|
|
61
|
-
this._input = null;
|
|
62
|
-
this._id = void 0;
|
|
63
|
-
this.handleRef = el => {
|
|
64
|
-
this.ref = el;
|
|
65
|
-
};
|
|
66
|
-
this.handleInputRef = element => {
|
|
67
|
-
this._input = element;
|
|
68
|
-
if (typeof this.props.inputRef === 'function') {
|
|
69
|
-
this.props.inputRef(element);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
this.handleFocus = event => {
|
|
73
|
-
this.setState({
|
|
74
|
-
hasFocus: true
|
|
75
|
-
});
|
|
76
|
-
if (typeof this.props.onFocus === 'function') {
|
|
77
|
-
this.props.onFocus(event);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
this.handleBlur = event => {
|
|
81
|
-
this.setState({
|
|
82
|
-
hasFocus: false
|
|
83
|
-
});
|
|
84
|
-
if (typeof this.props.onBlur === 'function') {
|
|
85
|
-
this.props.onBlur(event);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
this.handleChange = event => {
|
|
89
|
-
if (typeof this.props.onChange === 'function') {
|
|
90
|
-
this.props.onChange(event, event.target.value);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
this.handleKeyDown = event => {
|
|
94
|
-
const _this$props = this.props,
|
|
95
|
-
onKeyDown = _this$props.onKeyDown,
|
|
96
|
-
onDecrement = _this$props.onDecrement,
|
|
97
|
-
onIncrement = _this$props.onIncrement;
|
|
98
|
-
if (typeof onKeyDown === 'function') {
|
|
99
|
-
onKeyDown(event);
|
|
100
|
-
}
|
|
101
|
-
if (event.keyCode === _keycode.default.codes.down) {
|
|
102
|
-
event.preventDefault();
|
|
103
|
-
if (typeof onDecrement === 'function') {
|
|
104
|
-
onDecrement(event);
|
|
105
|
-
}
|
|
106
|
-
} else if (event.keyCode === _keycode.default.codes.up) {
|
|
107
|
-
event.preventDefault();
|
|
108
|
-
if (typeof onIncrement === 'function') {
|
|
109
|
-
onIncrement(event);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
this.handleClickUpArrow = event => {
|
|
114
|
-
this.arrowClicked(event, this.props.onIncrement);
|
|
115
|
-
};
|
|
116
|
-
this.handleClickDownArrow = event => {
|
|
117
|
-
this.arrowClicked(event, this.props.onDecrement);
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
get id() {
|
|
121
|
-
if (this.props.id) {
|
|
122
|
-
return this.props.id;
|
|
123
|
-
}
|
|
124
|
-
if (!this._id) {
|
|
125
|
-
this._id = this.props.deterministicId();
|
|
126
|
-
}
|
|
127
|
-
return this._id;
|
|
128
|
-
}
|
|
129
|
-
get invalid() {
|
|
130
|
-
return !!this.props.messages && this.props.messages.some(message => message.type === 'error' || message.type === 'newError');
|
|
131
|
-
}
|
|
132
|
-
get interaction() {
|
|
133
|
-
return (0, _getInteraction.getInteraction)({
|
|
134
|
-
props: this.props
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
componentDidMount() {
|
|
138
|
-
var _this$props$makeStyle, _this$props2;
|
|
139
|
-
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2, this.makeStyleVariables);
|
|
140
|
-
}
|
|
141
|
-
componentDidUpdate() {
|
|
142
|
-
var _this$props$makeStyle2, _this$props3;
|
|
143
|
-
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3, this.makeStyleVariables);
|
|
144
|
-
}
|
|
145
|
-
get makeStyleVariables() {
|
|
146
|
-
return {
|
|
147
|
-
interaction: this.interaction,
|
|
148
|
-
hasFocus: this.state.hasFocus,
|
|
149
|
-
invalid: this.invalid
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
arrowClicked(event, callback) {
|
|
153
|
-
const interaction = this.interaction;
|
|
154
|
-
event.preventDefault();
|
|
155
|
-
if (interaction === 'enabled') {
|
|
156
|
-
var _this$_input;
|
|
157
|
-
(_this$_input = this._input) === null || _this$_input === void 0 ? void 0 : _this$_input.focus();
|
|
158
|
-
if (typeof callback === 'function') {
|
|
159
|
-
callback(event);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
renderArrows(customIcons) {
|
|
164
|
-
var _this$props$styles, _this$props$styles2, _this$props$styles3;
|
|
165
|
-
return (0, _jsxRuntime.jsxs)("span", {
|
|
166
|
-
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.arrowContainer,
|
|
167
|
-
children: [(0, _jsxRuntime.jsx)("button", {
|
|
168
|
-
"aria-hidden": true,
|
|
169
|
-
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.arrow,
|
|
170
|
-
onMouseDown: this.handleClickUpArrow,
|
|
171
|
-
tabIndex: -1,
|
|
172
|
-
type: "button",
|
|
173
|
-
children: customIcons !== null && customIcons !== void 0 && customIcons.increase ? (0, _callRenderProp.callRenderProp)(customIcons.increase) : _IconArrowOpenUpLine || (_IconArrowOpenUpLine = (0, _jsxRuntime.jsx)(_IconArrowOpenUpLine2.IconArrowOpenUpLine, {}))
|
|
174
|
-
}), (0, _jsxRuntime.jsx)("button", {
|
|
175
|
-
"aria-hidden": true,
|
|
176
|
-
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.arrow,
|
|
177
|
-
onMouseDown: this.handleClickDownArrow,
|
|
178
|
-
tabIndex: -1,
|
|
179
|
-
type: "button",
|
|
180
|
-
children: customIcons !== null && customIcons !== void 0 && customIcons.decrease ? (0, _callRenderProp.callRenderProp)(customIcons.decrease) : _IconArrowOpenDownLin || (_IconArrowOpenDownLin = (0, _jsxRuntime.jsx)(_IconArrowOpenDownLine.IconArrowOpenDownLine, {}))
|
|
181
|
-
})]
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
render() {
|
|
185
|
-
var _this$props$styles4, _this$props$styles5, _this$props$styles6;
|
|
186
|
-
const _this$props4 = this.props,
|
|
187
|
-
renderLabel = _this$props4.renderLabel,
|
|
188
|
-
display = _this$props4.display,
|
|
189
|
-
placeholder = _this$props4.placeholder,
|
|
190
|
-
isRequired = _this$props4.isRequired,
|
|
191
|
-
showArrows = _this$props4.showArrows,
|
|
192
|
-
value = _this$props4.value,
|
|
193
|
-
width = _this$props4.width,
|
|
194
|
-
styles = _this$props4.styles,
|
|
195
|
-
allowStringValue = _this$props4.allowStringValue,
|
|
196
|
-
renderIcons = _this$props4.renderIcons,
|
|
197
|
-
margin = _this$props4.margin;
|
|
198
|
-
const interaction = this.interaction;
|
|
199
|
-
const rawLabel = (0, _callRenderProp.callRenderProp)(renderLabel);
|
|
200
|
-
const label = (0, _hasVisibleChildren.hasVisibleChildren)(rawLabel) ? (0, _jsxRuntime.jsxs)(_react.Fragment, {
|
|
201
|
-
children: [rawLabel, isRequired && (0, _jsxRuntime.jsxs)("span", {
|
|
202
|
-
css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {},
|
|
203
|
-
"aria-hidden": true,
|
|
204
|
-
children: [' ', "*"]
|
|
205
|
-
})]
|
|
206
|
-
}) : rawLabel;
|
|
207
|
-
return (0, _jsxRuntime.jsx)(_FormField.FormField, {
|
|
208
|
-
...(0, _pickProps.pickProps)(this.props, _FormField.FormField.allowedProps),
|
|
209
|
-
label: label,
|
|
210
|
-
inline: display === 'inline-block',
|
|
211
|
-
id: this.id,
|
|
212
|
-
elementRef: this.handleRef,
|
|
213
|
-
margin: margin,
|
|
214
|
-
"data-cid": "NumberInput",
|
|
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
|
-
});
|
|
243
|
-
}
|
|
244
|
-
}, _NumberInput.displayName = "NumberInput", _NumberInput.componentId = 'NumberInput', _NumberInput.allowedProps = _props.allowedProps, _NumberInput.defaultProps = {
|
|
245
|
-
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
246
|
-
interaction: void 0,
|
|
247
|
-
messages: [],
|
|
248
|
-
isRequired: false,
|
|
249
|
-
showArrows: true,
|
|
250
|
-
size: 'medium',
|
|
251
|
-
display: 'block',
|
|
252
|
-
textAlign: 'start',
|
|
253
|
-
inputMode: 'numeric',
|
|
254
|
-
allowStringValue: false
|
|
255
|
-
}, _NumberInput)) || _class) || _class);
|
|
256
|
-
var _default = exports.default = NumberInput;
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
/*
|
|
8
|
-
* The MIT License (MIT)
|
|
9
|
-
*
|
|
10
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
-
*
|
|
12
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
-
* in the Software without restriction, including without limitation the rights
|
|
15
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
-
* furnished to do so, subject to the following conditions:
|
|
18
|
-
*
|
|
19
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
-
* copies or substantial portions of the Software.
|
|
21
|
-
*
|
|
22
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
-
* SOFTWARE.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* ---
|
|
33
|
-
* private: true
|
|
34
|
-
* ---
|
|
35
|
-
* Generates the style object from the theme and provided additional information
|
|
36
|
-
* @param {Object} componentTheme The theme variable object.
|
|
37
|
-
* @param {Object} props the props of the component, the style is applied to
|
|
38
|
-
* @param {Object} state the state of the component, the style is applied to
|
|
39
|
-
* @return {Object} The final style object, which will be used in the component
|
|
40
|
-
*/
|
|
41
|
-
const generateStyle = (componentTheme, props, state) => {
|
|
42
|
-
const size = props.size,
|
|
43
|
-
textAlign = props.textAlign;
|
|
44
|
-
const interaction = state.interaction,
|
|
45
|
-
hasFocus = state.hasFocus,
|
|
46
|
-
invalid = state.invalid;
|
|
47
|
-
const disabledStyles = interaction === 'disabled' ? {
|
|
48
|
-
cursor: 'not-allowed',
|
|
49
|
-
pointerEvents: 'none',
|
|
50
|
-
opacity: 0.5
|
|
51
|
-
} : {};
|
|
52
|
-
const focusStyles = hasFocus ? {
|
|
53
|
-
opacity: 1,
|
|
54
|
-
transform: 'scale(1)'
|
|
55
|
-
} : {};
|
|
56
|
-
const invalidStyles = invalid ? {
|
|
57
|
-
borderColor: componentTheme.errorOutlineColor
|
|
58
|
-
} : {};
|
|
59
|
-
const invalidContainerStyles = invalid ? {
|
|
60
|
-
borderColor: componentTheme.errorBorderColor
|
|
61
|
-
} : {};
|
|
62
|
-
const inputStyle = {
|
|
63
|
-
all: 'initial',
|
|
64
|
-
textAlign: textAlign,
|
|
65
|
-
direction: 'inherit',
|
|
66
|
-
WebkitFontSmoothing: 'antialiased',
|
|
67
|
-
MozOsxFontSmoothing: 'grayscale',
|
|
68
|
-
appearance: 'none',
|
|
69
|
-
lineHeight: 1,
|
|
70
|
-
margin: '0',
|
|
71
|
-
flex: 1,
|
|
72
|
-
minWidth: '0.0625rem',
|
|
73
|
-
boxSizing: 'border-box',
|
|
74
|
-
fontFamily: 'inherit',
|
|
75
|
-
fontSize: 'inherit',
|
|
76
|
-
fontWeight: componentTheme.fontWeight,
|
|
77
|
-
color: componentTheme.color,
|
|
78
|
-
background: componentTheme.background,
|
|
79
|
-
padding: componentTheme.padding,
|
|
80
|
-
textyAlign: textAlign,
|
|
81
|
-
'&::placeholder': {
|
|
82
|
-
color: componentTheme.placeholderColor
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
return {
|
|
86
|
-
requiredInvalid: {
|
|
87
|
-
color: componentTheme.requiredInvalidColor
|
|
88
|
-
},
|
|
89
|
-
numberInput: {
|
|
90
|
-
label: 'numberInput'
|
|
91
|
-
},
|
|
92
|
-
arrowContainer: {
|
|
93
|
-
label: 'numberInput_arrowContainer',
|
|
94
|
-
flex: `0 0 ${componentTheme.arrowsContainerWidth}`,
|
|
95
|
-
display: 'flex',
|
|
96
|
-
flexDirection: 'column',
|
|
97
|
-
...disabledStyles
|
|
98
|
-
},
|
|
99
|
-
arrow: {
|
|
100
|
-
label: 'numberInput_arrow',
|
|
101
|
-
cursor: 'pointer',
|
|
102
|
-
userSelect: 'none',
|
|
103
|
-
textAlign: 'center',
|
|
104
|
-
flex: 1,
|
|
105
|
-
display: 'flex',
|
|
106
|
-
justifyContent: 'center',
|
|
107
|
-
alignItems: 'center',
|
|
108
|
-
backgroundColor: componentTheme.arrowsBackgroundColor,
|
|
109
|
-
borderTop: 'none',
|
|
110
|
-
borderInlineEnd: 'none',
|
|
111
|
-
borderInlineStart: `${componentTheme.borderWidth} ${componentTheme.borderStyle} ${componentTheme.arrowsBorderColor}`,
|
|
112
|
-
borderBottom: `${componentTheme.borderWidth} ${componentTheme.borderStyle} ${componentTheme.arrowsBorderColor}`,
|
|
113
|
-
color: componentTheme.arrowsColor,
|
|
114
|
-
'&:last-child': {
|
|
115
|
-
borderBottom: 'none'
|
|
116
|
-
},
|
|
117
|
-
'&:hover': {
|
|
118
|
-
backgroundColor: componentTheme.arrowsHoverBackgroundColor
|
|
119
|
-
},
|
|
120
|
-
'&:active': {
|
|
121
|
-
boxShadow: componentTheme.arrowsActiveBoxShadow
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
inputWidth: {
|
|
125
|
-
label: 'numberInput_inputWidth',
|
|
126
|
-
display: 'block',
|
|
127
|
-
position: 'relative',
|
|
128
|
-
'&::before': {
|
|
129
|
-
content: '""',
|
|
130
|
-
pointerEvents: 'none',
|
|
131
|
-
boxSizing: 'border-box',
|
|
132
|
-
display: 'block',
|
|
133
|
-
position: 'absolute',
|
|
134
|
-
top: '-0.25rem',
|
|
135
|
-
bottom: '-0.25rem',
|
|
136
|
-
left: '-0.25rem',
|
|
137
|
-
right: '-0.25rem',
|
|
138
|
-
border: `${componentTheme.focusOutlineWidth} ${componentTheme.focusOutlineStyle} ${componentTheme.focusOutlineColor}`,
|
|
139
|
-
borderRadius: `calc(${componentTheme.borderRadius} * 1.5)`,
|
|
140
|
-
transition: 'all 0.2s',
|
|
141
|
-
opacity: 0,
|
|
142
|
-
transform: 'scale(0.95)',
|
|
143
|
-
...focusStyles,
|
|
144
|
-
...invalidStyles
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
inputContainer: {
|
|
148
|
-
label: 'numberInput_inputContainer',
|
|
149
|
-
display: 'flex',
|
|
150
|
-
margin: '0',
|
|
151
|
-
boxSizing: 'border-box',
|
|
152
|
-
transition: 'all 0.2s',
|
|
153
|
-
overflow: 'hidden',
|
|
154
|
-
fontFamily: componentTheme.fontFamily,
|
|
155
|
-
border: `${componentTheme.borderWidth} ${componentTheme.borderStyle} ${componentTheme.borderColor}`,
|
|
156
|
-
borderRadius: componentTheme.borderRadius,
|
|
157
|
-
...disabledStyles,
|
|
158
|
-
...invalidContainerStyles,
|
|
159
|
-
...(size === 'medium' ? {
|
|
160
|
-
fontSize: componentTheme.mediumFontSize,
|
|
161
|
-
height: componentTheme.mediumHeight
|
|
162
|
-
} : {
|
|
163
|
-
fontSize: componentTheme.largeFontSize,
|
|
164
|
-
height: componentTheme.largeHeight
|
|
165
|
-
})
|
|
166
|
-
},
|
|
167
|
-
input: {
|
|
168
|
-
label: 'numberInput_input',
|
|
169
|
-
...inputStyle,
|
|
170
|
-
'&:is(input)[type]': inputStyle,
|
|
171
|
-
'&:-webkit-any(input)[type]': inputStyle,
|
|
172
|
-
'&::-webkit-inner-spin-button': {
|
|
173
|
-
display: 'none'
|
|
174
|
-
},
|
|
175
|
-
'&::-webkit-outer-spin-button': {
|
|
176
|
-
display: 'none'
|
|
177
|
-
},
|
|
178
|
-
'&:is(input)[type="number"]': {
|
|
179
|
-
MozAppearance: 'textfield'
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
};
|
|
184
|
-
var _default = exports.default = generateStyle;
|
package/lib/NumberInput/theme.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
/*
|
|
8
|
-
* The MIT License (MIT)
|
|
9
|
-
*
|
|
10
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
-
*
|
|
12
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
-
* in the Software without restriction, including without limitation the rights
|
|
15
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
-
* furnished to do so, subject to the following conditions:
|
|
18
|
-
*
|
|
19
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
-
* copies or substantial portions of the Software.
|
|
21
|
-
*
|
|
22
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
-
* SOFTWARE.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Generates the theme object for the component from the theme and provided additional information
|
|
33
|
-
* @param {Object} theme The actual theme object.
|
|
34
|
-
* @return {Object} The final theme object with the overrides and component variables
|
|
35
|
-
*/
|
|
36
|
-
const generateComponentTheme = theme => {
|
|
37
|
-
var _colors$contrasts, _colors$contrasts2, _colors$contrasts3, _colors$contrasts4, _colors$contrasts5, _colors$contrasts6, _colors$contrasts7, _colors$contrasts8, _colors$contrasts9, _colors$contrasts0, _colors$contrasts1, _colors$contrasts10, _colors$contrasts11;
|
|
38
|
-
const colors = theme.colors,
|
|
39
|
-
spacing = theme.spacing,
|
|
40
|
-
borders = theme.borders,
|
|
41
|
-
typography = theme.typography,
|
|
42
|
-
forms = theme.forms,
|
|
43
|
-
themeName = theme.key;
|
|
44
|
-
const themeSpecificStyle = {
|
|
45
|
-
canvas: {
|
|
46
|
-
color: theme['ic-brand-font-color-dark'],
|
|
47
|
-
arrowsColor: theme['ic-brand-font-color-dark'],
|
|
48
|
-
focusOutlineColor: theme['ic-brand-primary']
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
const componentVariables = {
|
|
52
|
-
fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
|
|
53
|
-
fontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightNormal,
|
|
54
|
-
borderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
|
|
55
|
-
borderStyle: borders === null || borders === void 0 ? void 0 : borders.style,
|
|
56
|
-
borderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.grey3045,
|
|
57
|
-
borderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusMedium,
|
|
58
|
-
color: colors === null || colors === void 0 ? void 0 : (_colors$contrasts2 = colors.contrasts) === null || _colors$contrasts2 === void 0 ? void 0 : _colors$contrasts2.grey125125,
|
|
59
|
-
background: colors === null || colors === void 0 ? void 0 : (_colors$contrasts3 = colors.contrasts) === null || _colors$contrasts3 === void 0 ? void 0 : _colors$contrasts3.white1010,
|
|
60
|
-
requiredInvalidColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts4 = colors.contrasts) === null || _colors$contrasts4 === void 0 ? void 0 : _colors$contrasts4.red5782,
|
|
61
|
-
padding: `0 ${spacing === null || spacing === void 0 ? void 0 : spacing.small}`,
|
|
62
|
-
arrowsContainerWidth: '2rem',
|
|
63
|
-
arrowsColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts5 = colors.contrasts) === null || _colors$contrasts5 === void 0 ? void 0 : _colors$contrasts5.grey125125,
|
|
64
|
-
arrowsBackgroundColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts6 = colors.contrasts) === null || _colors$contrasts6 === void 0 ? void 0 : _colors$contrasts6.grey1111,
|
|
65
|
-
arrowsHoverBackgroundColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts7 = colors.contrasts) === null || _colors$contrasts7 === void 0 ? void 0 : _colors$contrasts7.grey1214,
|
|
66
|
-
arrowsBorderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts8 = colors.contrasts) === null || _colors$contrasts8 === void 0 ? void 0 : _colors$contrasts8.grey3045,
|
|
67
|
-
arrowsActiveBoxShadow: `inset 0 0 3px 1px ${colors === null || colors === void 0 ? void 0 : (_colors$contrasts9 = colors.contrasts) === null || _colors$contrasts9 === void 0 ? void 0 : _colors$contrasts9.grey1214}`,
|
|
68
|
-
focusOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
|
|
69
|
-
focusOutlineStyle: borders === null || borders === void 0 ? void 0 : borders.style,
|
|
70
|
-
focusOutlineColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts0 = colors.contrasts) === null || _colors$contrasts0 === void 0 ? void 0 : _colors$contrasts0.blue4570,
|
|
71
|
-
errorBorderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts1 = colors.contrasts) === null || _colors$contrasts1 === void 0 ? void 0 : _colors$contrasts1.red4570,
|
|
72
|
-
errorOutlineColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts10 = colors.contrasts) === null || _colors$contrasts10 === void 0 ? void 0 : _colors$contrasts10.red4570,
|
|
73
|
-
placeholderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts11 = colors.contrasts) === null || _colors$contrasts11 === void 0 ? void 0 : _colors$contrasts11.grey4570,
|
|
74
|
-
mediumFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
|
|
75
|
-
mediumHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightMedium,
|
|
76
|
-
largeFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeLarge,
|
|
77
|
-
largeHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightLarge
|
|
78
|
-
};
|
|
79
|
-
return {
|
|
80
|
-
...componentVariables,
|
|
81
|
-
...themeSpecificStyle[themeName]
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
var _default = exports.default = generateComponentTheme;
|
package/lib/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "NumberInput", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _NumberInput.NumberInput;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _NumberInput = require("./NumberInput");
|
package/lib/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|