@instructure/ui-number-input 11.6.0 → 11.6.1-snapshot-129
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 +40 -299
- package/es/NumberInput/{index.js → v1/index.js} +2 -2
- package/es/NumberInput/v2/index.js +292 -0
- package/es/NumberInput/v2/props.js +26 -0
- package/es/NumberInput/v2/styles.js +208 -0
- package/es/{index.js → exports/a.js} +1 -1
- package/{src/index.ts → es/exports/b.js} +1 -2
- package/lib/NumberInput/{index.js → v1/index.js} +7 -7
- package/lib/NumberInput/v2/index.js +301 -0
- package/lib/NumberInput/v2/props.js +31 -0
- package/lib/NumberInput/v2/styles.js +214 -0
- package/lib/{index.js → exports/a.js} +2 -2
- package/lib/exports/b.js +12 -0
- package/package.json +41 -19
- package/src/NumberInput/{index.tsx → v1/index.tsx} +2 -2
- package/src/NumberInput/{props.ts → v1/props.ts} +4 -1
- package/src/NumberInput/v2/README.md +205 -0
- package/src/NumberInput/v2/index.tsx +382 -0
- package/src/NumberInput/v2/props.ts +240 -0
- package/src/NumberInput/v2/styles.ts +219 -0
- package/src/exports/a.ts +25 -0
- package/src/exports/b.ts +25 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/NumberInput/{index.d.ts → v1/index.d.ts} +1 -1
- package/types/NumberInput/v1/index.d.ts.map +1 -0
- package/types/NumberInput/{props.d.ts → v1/props.d.ts} +1 -1
- package/types/NumberInput/v1/props.d.ts.map +1 -0
- package/types/NumberInput/v1/styles.d.ts.map +1 -0
- package/types/NumberInput/v1/theme.d.ts.map +1 -0
- package/types/NumberInput/v2/index.d.ts +104 -0
- package/types/NumberInput/v2/index.d.ts.map +1 -0
- package/types/NumberInput/v2/props.d.ts +127 -0
- package/types/NumberInput/v2/props.d.ts.map +1 -0
- package/types/NumberInput/v2/styles.d.ts +22 -0
- package/types/NumberInput/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +3 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +3 -0
- package/types/exports/b.d.ts.map +1 -0
- package/types/NumberInput/index.d.ts.map +0 -1
- package/types/NumberInput/props.d.ts.map +0 -1
- package/types/NumberInput/styles.d.ts.map +0 -1
- package/types/NumberInput/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -3
- package/types/index.d.ts.map +0 -1
- /package/es/NumberInput/{props.js → v1/props.js} +0 -0
- /package/es/NumberInput/{styles.js → v1/styles.js} +0 -0
- /package/es/NumberInput/{theme.js → v1/theme.js} +0 -0
- /package/lib/NumberInput/{props.js → v1/props.js} +0 -0
- /package/lib/NumberInput/{styles.js → v1/styles.js} +0 -0
- /package/lib/NumberInput/{theme.js → v1/theme.js} +0 -0
- /package/src/NumberInput/{README.md → v1/README.md} +0 -0
- /package/src/NumberInput/{styles.ts → v1/styles.ts} +0 -0
- /package/src/NumberInput/{theme.ts → v1/theme.ts} +0 -0
- /package/types/NumberInput/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/NumberInput/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -0,0 +1,301 @@
|
|
|
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 _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _keycode = _interopRequireDefault(require("keycode"));
|
|
12
|
+
var _latest = require("@instructure/ui-form-field/latest");
|
|
13
|
+
var _uiIcons = require("@instructure/ui-icons");
|
|
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 _useDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/useDeterministicId.js");
|
|
18
|
+
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
19
|
+
var _emotion = require("@instructure/emotion");
|
|
20
|
+
var _styles = _interopRequireDefault(require("./styles"));
|
|
21
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
22
|
+
const _excluded = ["messages", "isRequired", "showArrows", "size", "display", "textAlign", "inputMode", "allowStringValue", "renderLabel", "placeholder", "value", "width", "renderIcons", "margin", "inputRef", "onFocus", "onBlur", "onChange", "onKeyDown", "onDecrement", "onIncrement", "id", "themeOverride"];
|
|
23
|
+
/*
|
|
24
|
+
* The MIT License (MIT)
|
|
25
|
+
*
|
|
26
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
27
|
+
*
|
|
28
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
29
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
30
|
+
* in the Software without restriction, including without limitation the rights
|
|
31
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
32
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
33
|
+
* furnished to do so, subject to the following conditions:
|
|
34
|
+
*
|
|
35
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
36
|
+
* copies or substantial portions of the Software.
|
|
37
|
+
*
|
|
38
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
39
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
40
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
41
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
42
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
43
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
44
|
+
* SOFTWARE.
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
---
|
|
48
|
+
category: components
|
|
49
|
+
id: NumberInput
|
|
50
|
+
---
|
|
51
|
+
**/
|
|
52
|
+
const NumberInput = exports.NumberInput = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
53
|
+
var _ChevronUpInstUIIcon, _ChevronDownInstUIIco;
|
|
54
|
+
const _props$messages = props.messages,
|
|
55
|
+
messages = _props$messages === void 0 ? [] : _props$messages,
|
|
56
|
+
_props$isRequired = props.isRequired,
|
|
57
|
+
isRequired = _props$isRequired === void 0 ? false : _props$isRequired,
|
|
58
|
+
_props$showArrows = props.showArrows,
|
|
59
|
+
showArrows = _props$showArrows === void 0 ? true : _props$showArrows,
|
|
60
|
+
_props$size = props.size,
|
|
61
|
+
size = _props$size === void 0 ? 'medium' : _props$size,
|
|
62
|
+
_props$display = props.display,
|
|
63
|
+
display = _props$display === void 0 ? 'block' : _props$display,
|
|
64
|
+
_props$textAlign = props.textAlign,
|
|
65
|
+
textAlign = _props$textAlign === void 0 ? 'start' : _props$textAlign,
|
|
66
|
+
_props$inputMode = props.inputMode,
|
|
67
|
+
inputMode = _props$inputMode === void 0 ? 'numeric' : _props$inputMode,
|
|
68
|
+
_props$allowStringVal = props.allowStringValue,
|
|
69
|
+
allowStringValue = _props$allowStringVal === void 0 ? false : _props$allowStringVal,
|
|
70
|
+
renderLabel = props.renderLabel,
|
|
71
|
+
placeholder = props.placeholder,
|
|
72
|
+
value = props.value,
|
|
73
|
+
width = props.width,
|
|
74
|
+
renderIcons = props.renderIcons,
|
|
75
|
+
margin = props.margin,
|
|
76
|
+
inputRefProp = props.inputRef,
|
|
77
|
+
onFocus = props.onFocus,
|
|
78
|
+
onBlur = props.onBlur,
|
|
79
|
+
onChange = props.onChange,
|
|
80
|
+
onKeyDown = props.onKeyDown,
|
|
81
|
+
onDecrement = props.onDecrement,
|
|
82
|
+
onIncrement = props.onIncrement,
|
|
83
|
+
idProp = props.id,
|
|
84
|
+
themeOverride = props.themeOverride,
|
|
85
|
+
rest = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
86
|
+
// these are icon tokens
|
|
87
|
+
|
|
88
|
+
const _useState = (0, _react.useState)('actionSecondaryBaseColor'),
|
|
89
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
90
|
+
upButtonState = _useState2[0],
|
|
91
|
+
setUpButtonState = _useState2[1];
|
|
92
|
+
const _useState3 = (0, _react.useState)('actionSecondaryBaseColor'),
|
|
93
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
94
|
+
downButtonState = _useState4[0],
|
|
95
|
+
setDownButtonState = _useState4[1];
|
|
96
|
+
// Refs
|
|
97
|
+
const containerRef = (0, _react.useRef)(null);
|
|
98
|
+
const inputRef = (0, _react.useRef)(null);
|
|
99
|
+
|
|
100
|
+
// Deterministic ID generation
|
|
101
|
+
const _useState5 = (0, _react.useState)(),
|
|
102
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
103
|
+
deterministicId = _useState6[0],
|
|
104
|
+
setDeterministicId = _useState6[1];
|
|
105
|
+
const getId = (0, _useDeterministicId.useDeterministicId)('NumberInput');
|
|
106
|
+
(0, _react.useEffect)(() => {
|
|
107
|
+
setDeterministicId(getId());
|
|
108
|
+
}, []); // Empty deps array - only run once on mount
|
|
109
|
+
const id = idProp || deterministicId;
|
|
110
|
+
|
|
111
|
+
// Computed values
|
|
112
|
+
const invalid = !!messages && messages.some(message => message.type === 'error' || message.type === 'newError');
|
|
113
|
+
const success = !!messages && messages.some(message => message.type === 'success');
|
|
114
|
+
const interaction = (0, _getInteraction.getInteraction)({
|
|
115
|
+
props
|
|
116
|
+
});
|
|
117
|
+
if (interaction === 'disabled' && upButtonState !== 'actionSecondaryDisabledColor') {
|
|
118
|
+
setUpButtonState('actionSecondaryDisabledColor');
|
|
119
|
+
setDownButtonState('actionSecondaryDisabledColor');
|
|
120
|
+
} else if (interaction === 'enabled' && downButtonState !== 'actionSecondaryBaseColor') {
|
|
121
|
+
setUpButtonState('actionSecondaryBaseColor');
|
|
122
|
+
setDownButtonState('actionSecondaryBaseColor');
|
|
123
|
+
}
|
|
124
|
+
// Styles - useStyle will pass these to generateStyle(componentTheme, params as props, params as state)
|
|
125
|
+
// We need to provide all values that generateStyle needs from both props and state
|
|
126
|
+
const styles = (0, _emotion.useStyle)({
|
|
127
|
+
generateStyle: _styles.default,
|
|
128
|
+
themeOverride,
|
|
129
|
+
params: {
|
|
130
|
+
size,
|
|
131
|
+
textAlign,
|
|
132
|
+
interaction,
|
|
133
|
+
invalid,
|
|
134
|
+
success
|
|
135
|
+
},
|
|
136
|
+
componentId: 'NumberInput',
|
|
137
|
+
displayName: 'NumberInput',
|
|
138
|
+
useTokensFrom: 'TextInput'
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// Event handlers
|
|
142
|
+
const handleInputRef = (0, _react.useCallback)(element => {
|
|
143
|
+
inputRef.current = element;
|
|
144
|
+
if (typeof inputRefProp === 'function') {
|
|
145
|
+
inputRefProp(element);
|
|
146
|
+
}
|
|
147
|
+
}, [inputRefProp]);
|
|
148
|
+
const handleRef = (0, _react.useCallback)(el => {
|
|
149
|
+
containerRef.current = el;
|
|
150
|
+
}, []);
|
|
151
|
+
const handleFocus = (0, _react.useCallback)(event => {
|
|
152
|
+
if (typeof onFocus === 'function') {
|
|
153
|
+
onFocus(event);
|
|
154
|
+
}
|
|
155
|
+
}, [onFocus]);
|
|
156
|
+
const handleBlur = (0, _react.useCallback)(event => {
|
|
157
|
+
if (typeof onBlur === 'function') {
|
|
158
|
+
onBlur(event);
|
|
159
|
+
}
|
|
160
|
+
}, [onBlur]);
|
|
161
|
+
const handleChange = (0, _react.useCallback)(event => {
|
|
162
|
+
if (typeof onChange === 'function') {
|
|
163
|
+
onChange(event, event.target.value);
|
|
164
|
+
}
|
|
165
|
+
}, [onChange]);
|
|
166
|
+
const handleKeyDown = (0, _react.useCallback)(event => {
|
|
167
|
+
if (typeof onKeyDown === 'function') {
|
|
168
|
+
onKeyDown(event);
|
|
169
|
+
}
|
|
170
|
+
if (event.keyCode === _keycode.default.codes.down) {
|
|
171
|
+
event.preventDefault();
|
|
172
|
+
if (typeof onDecrement === 'function') {
|
|
173
|
+
onDecrement(event);
|
|
174
|
+
}
|
|
175
|
+
} else if (event.keyCode === _keycode.default.codes.up) {
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
if (typeof onIncrement === 'function') {
|
|
178
|
+
onIncrement(event);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}, [onKeyDown, onDecrement, onIncrement]);
|
|
182
|
+
const arrowClicked = (0, _react.useCallback)((event, callback) => {
|
|
183
|
+
event.preventDefault();
|
|
184
|
+
if (interaction === 'enabled') {
|
|
185
|
+
var _inputRef$current;
|
|
186
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
187
|
+
if (typeof callback === 'function') {
|
|
188
|
+
callback(event);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}, [interaction]);
|
|
192
|
+
const handleClickUpArrow = (0, _react.useCallback)(event => {
|
|
193
|
+
setUpButtonState('actionSecondaryActiveColor');
|
|
194
|
+
arrowClicked(event, onIncrement);
|
|
195
|
+
}, [arrowClicked, onIncrement]);
|
|
196
|
+
const handleClickDownArrow = (0, _react.useCallback)(event => {
|
|
197
|
+
setDownButtonState('actionSecondaryActiveColor');
|
|
198
|
+
arrowClicked(event, onDecrement);
|
|
199
|
+
}, [arrowClicked, onDecrement]);
|
|
200
|
+
|
|
201
|
+
// Expose imperative API via ref
|
|
202
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
203
|
+
focus: () => {
|
|
204
|
+
var _inputRef$current2;
|
|
205
|
+
(_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus();
|
|
206
|
+
},
|
|
207
|
+
get id() {
|
|
208
|
+
return id;
|
|
209
|
+
},
|
|
210
|
+
get invalid() {
|
|
211
|
+
return invalid;
|
|
212
|
+
},
|
|
213
|
+
get interaction() {
|
|
214
|
+
return interaction;
|
|
215
|
+
},
|
|
216
|
+
get value() {
|
|
217
|
+
var _inputRef$current3;
|
|
218
|
+
return (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.value;
|
|
219
|
+
}
|
|
220
|
+
}), [id, invalid, interaction]);
|
|
221
|
+
|
|
222
|
+
// Render methods
|
|
223
|
+
const renderArrows = customIcons => {
|
|
224
|
+
return (0, _jsxRuntime.jsxs)("span", {
|
|
225
|
+
css: styles === null || styles === void 0 ? void 0 : styles.arrowContainer,
|
|
226
|
+
children: [(0, _jsxRuntime.jsx)("button", {
|
|
227
|
+
"aria-hidden": true,
|
|
228
|
+
css: styles === null || styles === void 0 ? void 0 : styles.arrow,
|
|
229
|
+
onMouseDown: handleClickUpArrow,
|
|
230
|
+
onMouseOver: () => setUpButtonState('actionSecondaryHoverColor'),
|
|
231
|
+
onMouseOut: () => setUpButtonState('actionSecondaryBaseColor'),
|
|
232
|
+
tabIndex: -1,
|
|
233
|
+
type: "button",
|
|
234
|
+
children: customIcons !== null && customIcons !== void 0 && customIcons.increase ? (0, _callRenderProp.callRenderProp)(customIcons.increase) : _ChevronUpInstUIIcon || (_ChevronUpInstUIIcon = (0, _jsxRuntime.jsx)(_uiIcons.ChevronUpInstUIIcon, {
|
|
235
|
+
size: "sm",
|
|
236
|
+
color: upButtonState
|
|
237
|
+
}))
|
|
238
|
+
}), (0, _jsxRuntime.jsx)("button", {
|
|
239
|
+
"aria-hidden": true,
|
|
240
|
+
css: styles === null || styles === void 0 ? void 0 : styles.arrow,
|
|
241
|
+
onMouseDown: handleClickDownArrow,
|
|
242
|
+
onMouseOver: () => setDownButtonState('actionSecondaryHoverColor'),
|
|
243
|
+
onMouseOut: () => setDownButtonState('actionSecondaryBaseColor'),
|
|
244
|
+
tabIndex: -1,
|
|
245
|
+
type: "button",
|
|
246
|
+
children: customIcons !== null && customIcons !== void 0 && customIcons.decrease ? (0, _callRenderProp.callRenderProp)(customIcons.decrease) : _ChevronDownInstUIIco || (_ChevronDownInstUIIco = (0, _jsxRuntime.jsx)(_uiIcons.ChevronDownInstUIIcon, {
|
|
247
|
+
size: "sm",
|
|
248
|
+
color: downButtonState
|
|
249
|
+
}))
|
|
250
|
+
})]
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
const label = (0, _callRenderProp.callRenderProp)(renderLabel);
|
|
254
|
+
const passedProps = (0, _passthroughProps.passthroughProps)(rest);
|
|
255
|
+
|
|
256
|
+
// Don't render until we have an ID
|
|
257
|
+
if (!id) {
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
return (0, _jsxRuntime.jsx)(_latest.FormField, {
|
|
261
|
+
...(0, _pickProps.pickProps)(props, _latest.FormField.allowedProps),
|
|
262
|
+
label: label,
|
|
263
|
+
inline: display === 'inline-block',
|
|
264
|
+
id: id,
|
|
265
|
+
elementRef: handleRef,
|
|
266
|
+
margin: margin,
|
|
267
|
+
isRequired: isRequired,
|
|
268
|
+
disabled: interaction === 'disabled',
|
|
269
|
+
readOnly: interaction === 'readonly',
|
|
270
|
+
"data-cid": "NumberInput",
|
|
271
|
+
children: (0, _jsxRuntime.jsx)("span", {
|
|
272
|
+
css: styles === null || styles === void 0 ? void 0 : styles.inputWidth,
|
|
273
|
+
style: width ? {
|
|
274
|
+
width
|
|
275
|
+
} : void 0,
|
|
276
|
+
children: (0, _jsxRuntime.jsxs)("span", {
|
|
277
|
+
css: styles === null || styles === void 0 ? void 0 : styles.inputContainer,
|
|
278
|
+
children: [(0, _jsxRuntime.jsx)("input", {
|
|
279
|
+
...passedProps,
|
|
280
|
+
css: styles === null || styles === void 0 ? void 0 : styles.input,
|
|
281
|
+
"aria-invalid": invalid ? 'true' : void 0,
|
|
282
|
+
id: id,
|
|
283
|
+
type: allowStringValue ? 'text' : 'number',
|
|
284
|
+
inputMode: inputMode,
|
|
285
|
+
placeholder: interaction === 'enabled' ? placeholder : void 0,
|
|
286
|
+
ref: handleInputRef,
|
|
287
|
+
required: isRequired,
|
|
288
|
+
value: value,
|
|
289
|
+
disabled: interaction === 'disabled',
|
|
290
|
+
readOnly: interaction === 'readonly',
|
|
291
|
+
onFocus: handleFocus,
|
|
292
|
+
onBlur: handleBlur,
|
|
293
|
+
onChange: handleChange,
|
|
294
|
+
onKeyDown: handleKeyDown
|
|
295
|
+
}), showArrows && interaction !== 'readonly' ? renderArrows(renderIcons) : null]
|
|
296
|
+
})
|
|
297
|
+
})
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
NumberInput.displayName = 'NumberInput';
|
|
301
|
+
var _default = exports.default = NumberInput;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.allowedProps = 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
|
+
const allowedProps = exports.allowedProps = ['renderLabel', 'id', 'interaction', 'messages', 'placeholder', 'isRequired', 'showArrows', 'size', 'value', 'width', 'display', 'inputRef', 'onFocus', 'onBlur', 'onChange', 'onDecrement', 'onIncrement', 'onKeyDown', 'inputMode', 'textAlign', 'allowStringValue', 'renderIcons', 'margin'];
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _emotion = require("@instructure/emotion");
|
|
8
|
+
/*
|
|
9
|
+
* The MIT License (MIT)
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
* in the Software without restriction, including without limitation the rights
|
|
16
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
* furnished to do so, subject to the following conditions:
|
|
19
|
+
*
|
|
20
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
* copies or substantial portions of the Software.
|
|
22
|
+
*
|
|
23
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
* SOFTWARE.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* ---
|
|
34
|
+
* private: true
|
|
35
|
+
* ---
|
|
36
|
+
* Generates the style object from the theme and provided additional information
|
|
37
|
+
* @param componentTheme The theme variable object.
|
|
38
|
+
* @param params Additional parameters to customize the style.
|
|
39
|
+
* @param sharedTokens Shared token object that stores common values for the theme.
|
|
40
|
+
* @return The final style object, which will be used in the component
|
|
41
|
+
*/
|
|
42
|
+
const generateStyle = (componentTheme, params, sharedTokens) => {
|
|
43
|
+
const size = params.size,
|
|
44
|
+
textAlign = params.textAlign,
|
|
45
|
+
interaction = params.interaction,
|
|
46
|
+
success = params.success,
|
|
47
|
+
invalid = params.invalid;
|
|
48
|
+
const containerInteractionStates = {
|
|
49
|
+
...(interaction === 'enabled' && {
|
|
50
|
+
backgroundColor: componentTheme.backgroundColor,
|
|
51
|
+
borderColor: componentTheme.borderColor,
|
|
52
|
+
...(success && {
|
|
53
|
+
borderColor: componentTheme.successBorderColor
|
|
54
|
+
}),
|
|
55
|
+
...(invalid && {
|
|
56
|
+
borderColor: componentTheme.errorBorderColor
|
|
57
|
+
}),
|
|
58
|
+
'&:hover': {
|
|
59
|
+
backgroundColor: componentTheme.backgroundHoverColor,
|
|
60
|
+
borderColor: componentTheme.borderHoverColor,
|
|
61
|
+
...(success && {
|
|
62
|
+
borderColor: componentTheme.successBorderColor
|
|
63
|
+
}),
|
|
64
|
+
...(invalid && {
|
|
65
|
+
borderColor: componentTheme.errorBorderColor
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
}),
|
|
69
|
+
...(interaction === 'readonly' && {
|
|
70
|
+
backgroundColor: componentTheme.backgroundReadonlyColor,
|
|
71
|
+
borderColor: componentTheme.borderReadonlyColor
|
|
72
|
+
}),
|
|
73
|
+
...(interaction === 'disabled' && {
|
|
74
|
+
cursor: 'not-allowed',
|
|
75
|
+
pointerEvents: 'none',
|
|
76
|
+
backgroundColor: componentTheme.backgroundDisabledColor,
|
|
77
|
+
borderColor: componentTheme.borderDisabledColor
|
|
78
|
+
})
|
|
79
|
+
};
|
|
80
|
+
const arrowInteractionStates = {
|
|
81
|
+
...(interaction === 'enabled' && {
|
|
82
|
+
backgroundColor: componentTheme.arrowsBackgroundColor,
|
|
83
|
+
borderColor: componentTheme.arrowsBorderColor,
|
|
84
|
+
'&:hover': {
|
|
85
|
+
backgroundColor: componentTheme.arrowsBackgroundHoverColor,
|
|
86
|
+
borderColor: componentTheme.arrowsBorderHoverColor
|
|
87
|
+
},
|
|
88
|
+
'&:active': {
|
|
89
|
+
backgroundColor: componentTheme.arrowsBackgroundActiveColor,
|
|
90
|
+
borderColor: componentTheme.arrowsBorderActiveColor
|
|
91
|
+
}
|
|
92
|
+
}),
|
|
93
|
+
...(interaction === 'disabled' && {
|
|
94
|
+
cursor: 'not-allowed',
|
|
95
|
+
pointerEvents: 'none',
|
|
96
|
+
backgroundColor: componentTheme.arrowsBackgroundDisabledColor,
|
|
97
|
+
borderColor: componentTheme.arrowsBorderDisabledColor
|
|
98
|
+
})
|
|
99
|
+
// arrow buttons are not rendered in the `readOnly` state
|
|
100
|
+
};
|
|
101
|
+
const inputInteractionStates = {
|
|
102
|
+
...(interaction === 'enabled' && {
|
|
103
|
+
color: componentTheme.textColor,
|
|
104
|
+
'&::placeholder': {
|
|
105
|
+
color: componentTheme.placeholderColor
|
|
106
|
+
},
|
|
107
|
+
'&:hover::placeholder': {
|
|
108
|
+
color: componentTheme.placeholderHoverColor
|
|
109
|
+
}
|
|
110
|
+
// placeholder is not rendered in the `readOnly` and `disabled` state
|
|
111
|
+
}),
|
|
112
|
+
...(interaction === 'readonly' && {
|
|
113
|
+
color: componentTheme.textReadonlyColor
|
|
114
|
+
}),
|
|
115
|
+
...(interaction === 'disabled' && {
|
|
116
|
+
color: componentTheme.textDisabledColor
|
|
117
|
+
})
|
|
118
|
+
};
|
|
119
|
+
const inputStyle = {
|
|
120
|
+
all: 'initial',
|
|
121
|
+
textAlign: textAlign,
|
|
122
|
+
direction: 'inherit',
|
|
123
|
+
WebkitFontSmoothing: 'antialiased',
|
|
124
|
+
MozOsxFontSmoothing: 'grayscale',
|
|
125
|
+
appearance: 'none',
|
|
126
|
+
lineHeight: 1,
|
|
127
|
+
margin: '0',
|
|
128
|
+
flex: 1,
|
|
129
|
+
minWidth: '0.0625rem',
|
|
130
|
+
boxSizing: 'border-box',
|
|
131
|
+
fontFamily: 'inherit',
|
|
132
|
+
fontSize: 'inherit',
|
|
133
|
+
fontWeight: 'inherit',
|
|
134
|
+
...(size === 'medium' ? {
|
|
135
|
+
padding: componentTheme.paddingHorizontalMd
|
|
136
|
+
} : {
|
|
137
|
+
padding: componentTheme.paddingHorizontalLg
|
|
138
|
+
}),
|
|
139
|
+
...inputInteractionStates
|
|
140
|
+
};
|
|
141
|
+
const focusOutline = (0, _emotion.calcFocusOutlineStyles)(sharedTokens.focusOutline, {
|
|
142
|
+
focusWithin: true
|
|
143
|
+
});
|
|
144
|
+
return {
|
|
145
|
+
numberInput: {
|
|
146
|
+
label: 'numberInput'
|
|
147
|
+
},
|
|
148
|
+
arrowContainer: {
|
|
149
|
+
label: 'numberInput_arrowContainer',
|
|
150
|
+
flex: `0 0 ${componentTheme.arrowsContainerWidth}`,
|
|
151
|
+
display: 'flex',
|
|
152
|
+
flexDirection: 'column'
|
|
153
|
+
},
|
|
154
|
+
arrow: {
|
|
155
|
+
label: 'numberInput_arrow',
|
|
156
|
+
cursor: 'pointer',
|
|
157
|
+
userSelect: 'none',
|
|
158
|
+
textAlign: 'center',
|
|
159
|
+
flex: 1,
|
|
160
|
+
display: 'flex',
|
|
161
|
+
justifyContent: 'center',
|
|
162
|
+
alignItems: 'center',
|
|
163
|
+
borderTop: 'none',
|
|
164
|
+
borderInlineEnd: 'none',
|
|
165
|
+
borderInlineStart: `${componentTheme.borderWidth} solid`,
|
|
166
|
+
borderBottom: `${componentTheme.borderWidth} solid`,
|
|
167
|
+
'&:last-child': {
|
|
168
|
+
borderBottom: 'none'
|
|
169
|
+
},
|
|
170
|
+
...arrowInteractionStates
|
|
171
|
+
},
|
|
172
|
+
inputWidth: {
|
|
173
|
+
label: 'numberInput_inputWidth',
|
|
174
|
+
display: 'block',
|
|
175
|
+
position: 'relative'
|
|
176
|
+
},
|
|
177
|
+
inputContainer: {
|
|
178
|
+
label: 'numberInput_inputContainer',
|
|
179
|
+
display: 'flex',
|
|
180
|
+
margin: '0',
|
|
181
|
+
boxSizing: 'border-box',
|
|
182
|
+
overflow: 'hidden',
|
|
183
|
+
fontFamily: componentTheme.fontFamily,
|
|
184
|
+
fontWeight: componentTheme.fontWeight,
|
|
185
|
+
border: `${componentTheme.borderWidth} solid`,
|
|
186
|
+
borderRadius: componentTheme.borderRadius,
|
|
187
|
+
...containerInteractionStates,
|
|
188
|
+
...focusOutline,
|
|
189
|
+
...(size === 'medium' ? {
|
|
190
|
+
fontSize: componentTheme.fontSizeMd,
|
|
191
|
+
height: componentTheme.heightMd
|
|
192
|
+
} : {
|
|
193
|
+
fontSize: componentTheme.fontSizeLg,
|
|
194
|
+
height: componentTheme.heightLg
|
|
195
|
+
})
|
|
196
|
+
},
|
|
197
|
+
input: {
|
|
198
|
+
label: 'numberInput_input',
|
|
199
|
+
...inputStyle,
|
|
200
|
+
'&:is(input)[type]': inputStyle,
|
|
201
|
+
'&:-webkit-any(input)[type]': inputStyle,
|
|
202
|
+
'&::-webkit-inner-spin-button': {
|
|
203
|
+
display: 'none'
|
|
204
|
+
},
|
|
205
|
+
'&::-webkit-outer-spin-button': {
|
|
206
|
+
display: 'none'
|
|
207
|
+
},
|
|
208
|
+
'&:is(input)[type="number"]': {
|
|
209
|
+
MozAppearance: 'textfield'
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
var _default = exports.default = generateStyle;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
Object.defineProperty(exports, "NumberInput", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _v.NumberInput;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
var
|
|
12
|
+
var _v = require("../NumberInput/v1");
|
package/lib/exports/b.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-number-input",
|
|
3
|
-
"version": "11.6.
|
|
3
|
+
"version": "11.6.1-snapshot-129",
|
|
4
4
|
"description": "A UI component library made by Instructure Inc.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -16,23 +16,23 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@babel/runtime": "^7.27.6",
|
|
18
18
|
"keycode": "^2",
|
|
19
|
-
"@instructure/emotion": "11.6.
|
|
20
|
-
"@instructure/shared-types": "11.6.
|
|
21
|
-
"@instructure/ui-
|
|
22
|
-
"@instructure/ui-
|
|
23
|
-
"@instructure/ui-
|
|
24
|
-
"@instructure/ui-
|
|
25
|
-
"@instructure/
|
|
26
|
-
"@instructure/
|
|
19
|
+
"@instructure/emotion": "11.6.1-snapshot-129",
|
|
20
|
+
"@instructure/shared-types": "11.6.1-snapshot-129",
|
|
21
|
+
"@instructure/ui-a11y-utils": "11.6.1-snapshot-129",
|
|
22
|
+
"@instructure/ui-form-field": "11.6.1-snapshot-129",
|
|
23
|
+
"@instructure/ui-icons": "11.6.1-snapshot-129",
|
|
24
|
+
"@instructure/ui-react-utils": "11.6.1-snapshot-129",
|
|
25
|
+
"@instructure/ui-utils": "11.6.1-snapshot-129",
|
|
26
|
+
"@instructure/uid": "11.6.1-snapshot-129"
|
|
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-
|
|
34
|
-
"@instructure/ui-
|
|
35
|
-
"@instructure/ui-themes": "11.6.
|
|
33
|
+
"@instructure/ui-scripts": "11.6.1-snapshot-129",
|
|
34
|
+
"@instructure/ui-babel-preset": "11.6.1-snapshot-129",
|
|
35
|
+
"@instructure/ui-themes": "11.6.1-snapshot-129"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"react": ">=18 <=19"
|
|
@@ -42,17 +42,39 @@
|
|
|
42
42
|
},
|
|
43
43
|
"sideEffects": false,
|
|
44
44
|
"exports": {
|
|
45
|
-
".": {
|
|
46
|
-
"types": "./types/index.d.ts",
|
|
47
|
-
"import": "./es/index.js",
|
|
48
|
-
"require": "./lib/index.js",
|
|
49
|
-
"default": "./es/index.js"
|
|
50
|
-
},
|
|
51
45
|
"./lib/*": "./lib/*",
|
|
52
46
|
"./es/*": "./es/*",
|
|
53
47
|
"./types/*": "./types/*",
|
|
54
48
|
"./package.json": "./package.json",
|
|
55
|
-
"./src/*": "./src/*"
|
|
49
|
+
"./src/*": "./src/*",
|
|
50
|
+
".": {
|
|
51
|
+
"src": "./src/exports/a.ts",
|
|
52
|
+
"types": "./types/exports/a.d.ts",
|
|
53
|
+
"import": "./es/exports/a.js",
|
|
54
|
+
"require": "./lib/exports/a.js",
|
|
55
|
+
"default": "./es/exports/a.js"
|
|
56
|
+
},
|
|
57
|
+
"./v11_6": {
|
|
58
|
+
"src": "./src/exports/a.ts",
|
|
59
|
+
"types": "./types/exports/a.d.ts",
|
|
60
|
+
"import": "./es/exports/a.js",
|
|
61
|
+
"require": "./lib/exports/a.js",
|
|
62
|
+
"default": "./es/exports/a.js"
|
|
63
|
+
},
|
|
64
|
+
"./v11_7": {
|
|
65
|
+
"src": "./src/exports/b.ts",
|
|
66
|
+
"types": "./types/exports/b.d.ts",
|
|
67
|
+
"import": "./es/exports/b.js",
|
|
68
|
+
"require": "./lib/exports/b.js",
|
|
69
|
+
"default": "./es/exports/b.js"
|
|
70
|
+
},
|
|
71
|
+
"./latest": {
|
|
72
|
+
"src": "./src/exports/b.ts",
|
|
73
|
+
"types": "./types/exports/b.d.ts",
|
|
74
|
+
"import": "./es/exports/b.js",
|
|
75
|
+
"require": "./lib/exports/b.js",
|
|
76
|
+
"default": "./es/exports/b.js"
|
|
77
|
+
}
|
|
56
78
|
},
|
|
57
79
|
"scripts": {
|
|
58
80
|
"lint": "ui-scripts lint",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
import { Fragment, Component } from 'react'
|
|
26
26
|
import keycode from 'keycode'
|
|
27
27
|
|
|
28
|
-
import { FormField } from '@instructure/ui-form-field'
|
|
28
|
+
import { FormField } from '@instructure/ui-form-field/v11_6'
|
|
29
29
|
import {
|
|
30
30
|
IconArrowOpenDownLine,
|
|
31
31
|
IconArrowOpenUpLine
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
} from '@instructure/ui-react-utils'
|
|
40
40
|
import { hasVisibleChildren } from '@instructure/ui-a11y-utils'
|
|
41
41
|
|
|
42
|
-
import { withStyle } from '@instructure/emotion'
|
|
42
|
+
import { withStyleLegacy as withStyle } from '@instructure/emotion'
|
|
43
43
|
|
|
44
44
|
import generateStyle from './styles'
|
|
45
45
|
import generateComponentTheme from './theme'
|