@instructure/ui-number-input 10.6.1 → 10.6.2-snapshot-2

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 CHANGED
@@ -3,6 +3,17 @@
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
+ ## [10.6.2-snapshot-2](https://github.com/instructure/instructure-ui/compare/v10.6.1...v10.6.2-snapshot-2) (2024-11-28)
7
+
8
+
9
+ ### Features
10
+
11
+ * **ui-number-input:** add back options for string input ([14bbaea](https://github.com/instructure/instructure-ui/commit/14bbaea13b0829887de946363cd21639e5643749))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [10.6.1](https://github.com/instructure/instructure-ui/compare/v10.6.0...v10.6.1) (2024-11-26)
7
18
 
8
19
  **Note:** Version bump only for package @instructure/ui-number-input
@@ -178,7 +178,8 @@ let NumberInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle
178
178
  showArrows = _this$props4.showArrows,
179
179
  value = _this$props4.value,
180
180
  width = _this$props4.width,
181
- styles = _this$props4.styles;
181
+ styles = _this$props4.styles,
182
+ allowStringValue = _this$props4.allowStringValue;
182
183
  const interaction = this.interaction;
183
184
  const rawLabel = callRenderProp(renderLabel);
184
185
  const label = hasVisibleChildren(rawLabel) ? jsx(React.Fragment, null, rawLabel, isRequired && jsx("span", {
@@ -200,7 +201,7 @@ let NumberInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle
200
201
  css: (_this$props$styles6 = this.props.styles) === null || _this$props$styles6 === void 0 ? void 0 : _this$props$styles6.input,
201
202
  "aria-invalid": this.invalid ? 'true' : void 0,
202
203
  id: this.id,
203
- type: "number",
204
+ type: allowStringValue ? 'text' : 'number',
204
205
  inputMode: this.props.inputMode,
205
206
  placeholder: placeholder,
206
207
  ref: this.handleInputRef,
@@ -223,7 +224,8 @@ let NumberInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle
223
224
  size: 'medium',
224
225
  display: 'block',
225
226
  textAlign: 'start',
226
- inputMode: 'numeric'
227
+ inputMode: 'numeric',
228
+ allowStringValue: false
227
229
  }, _NumberInput)) || _class) || _class) || _class);
228
230
  export default NumberInput;
229
231
  export { NumberInput };
@@ -44,7 +44,8 @@ const propTypes = {
44
44
  onIncrement: PropTypes.func,
45
45
  onKeyDown: PropTypes.func,
46
46
  inputMode: PropTypes.oneOf(['numeric', 'decimal', 'tel']),
47
- textAlign: PropTypes.oneOf(['start', 'center'])
47
+ textAlign: PropTypes.oneOf(['start', 'center']),
48
+ allowStringValue: PropTypes.bool
48
49
  };
49
- const allowedProps = ['renderLabel', 'id', 'interaction', 'messages', 'placeholder', 'isRequired', 'showArrows', 'size', 'value', 'width', 'display', 'inputRef', 'onFocus', 'onBlur', 'onChange', 'onDecrement', 'onIncrement', 'onKeyDown', 'inputMode', 'textAlign'];
50
+ const allowedProps = ['renderLabel', 'id', 'interaction', 'messages', 'placeholder', 'isRequired', 'showArrows', 'size', 'value', 'width', 'display', 'inputRef', 'onFocus', 'onBlur', 'onChange', 'onDecrement', 'onIncrement', 'onKeyDown', 'inputMode', 'textAlign', 'allowStringValue'];
50
51
  export { propTypes, allowedProps };
@@ -190,7 +190,8 @@ let NumberInput = exports.NumberInput = (_dec = (0, _withDeterministicId.withDet
190
190
  showArrows = _this$props4.showArrows,
191
191
  value = _this$props4.value,
192
192
  width = _this$props4.width,
193
- styles = _this$props4.styles;
193
+ styles = _this$props4.styles,
194
+ allowStringValue = _this$props4.allowStringValue;
194
195
  const interaction = this.interaction;
195
196
  const rawLabel = (0, _callRenderProp.callRenderProp)(renderLabel);
196
197
  const label = (0, _hasVisibleChildren.hasVisibleChildren)(rawLabel) ? (0, _emotion.jsx)(_react.default.Fragment, null, rawLabel, isRequired && (0, _emotion.jsx)("span", {
@@ -212,7 +213,7 @@ let NumberInput = exports.NumberInput = (_dec = (0, _withDeterministicId.withDet
212
213
  css: (_this$props$styles6 = this.props.styles) === null || _this$props$styles6 === void 0 ? void 0 : _this$props$styles6.input,
213
214
  "aria-invalid": this.invalid ? 'true' : void 0,
214
215
  id: this.id,
215
- type: "number",
216
+ type: allowStringValue ? 'text' : 'number',
216
217
  inputMode: this.props.inputMode,
217
218
  placeholder: placeholder,
218
219
  ref: this.handleInputRef,
@@ -235,6 +236,7 @@ let NumberInput = exports.NumberInput = (_dec = (0, _withDeterministicId.withDet
235
236
  size: 'medium',
236
237
  display: 'block',
237
238
  textAlign: 'start',
238
- inputMode: 'numeric'
239
+ inputMode: 'numeric',
240
+ allowStringValue: false
239
241
  }, _NumberInput)) || _class) || _class) || _class);
240
242
  var _default = exports.default = NumberInput;
@@ -51,6 +51,7 @@ const propTypes = exports.propTypes = {
51
51
  onIncrement: _propTypes.default.func,
52
52
  onKeyDown: _propTypes.default.func,
53
53
  inputMode: _propTypes.default.oneOf(['numeric', 'decimal', 'tel']),
54
- textAlign: _propTypes.default.oneOf(['start', 'center'])
54
+ textAlign: _propTypes.default.oneOf(['start', 'center']),
55
+ allowStringValue: _propTypes.default.bool
55
56
  };
56
- const allowedProps = exports.allowedProps = ['renderLabel', 'id', 'interaction', 'messages', 'placeholder', 'isRequired', 'showArrows', 'size', 'value', 'width', 'display', 'inputRef', 'onFocus', 'onBlur', 'onChange', 'onDecrement', 'onIncrement', 'onKeyDown', 'inputMode', 'textAlign'];
57
+ 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'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-number-input",
3
- "version": "10.6.1",
3
+ "version": "10.6.2-snapshot-2",
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.6.1",
27
- "@instructure/ui-babel-preset": "10.6.1",
28
- "@instructure/ui-scripts": "10.6.1",
29
- "@instructure/ui-test-utils": "10.6.1",
30
- "@instructure/ui-themes": "10.6.1",
26
+ "@instructure/ui-axe-check": "10.6.2-snapshot-2",
27
+ "@instructure/ui-babel-preset": "10.6.2-snapshot-2",
28
+ "@instructure/ui-scripts": "10.6.2-snapshot-2",
29
+ "@instructure/ui-test-utils": "10.6.2-snapshot-2",
30
+ "@instructure/ui-themes": "10.6.2-snapshot-2",
31
31
  "@testing-library/jest-dom": "^6.4.6",
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.25.6",
38
- "@instructure/emotion": "10.6.1",
39
- "@instructure/shared-types": "10.6.1",
40
- "@instructure/ui-form-field": "10.6.1",
41
- "@instructure/ui-icons": "10.6.1",
42
- "@instructure/ui-react-utils": "10.6.1",
43
- "@instructure/ui-testable": "10.6.1",
44
- "@instructure/ui-utils": "10.6.1",
45
- "@instructure/uid": "10.6.1",
38
+ "@instructure/emotion": "10.6.2-snapshot-2",
39
+ "@instructure/shared-types": "10.6.2-snapshot-2",
40
+ "@instructure/ui-form-field": "10.6.2-snapshot-2",
41
+ "@instructure/ui-icons": "10.6.2-snapshot-2",
42
+ "@instructure/ui-react-utils": "10.6.2-snapshot-2",
43
+ "@instructure/ui-testable": "10.6.2-snapshot-2",
44
+ "@instructure/ui-utils": "10.6.2-snapshot-2",
45
+ "@instructure/uid": "10.6.2-snapshot-2",
46
46
  "keycode": "^2",
47
47
  "prop-types": "^15.8.1"
48
48
  },
@@ -2,7 +2,9 @@
2
2
  describes: NumberInput
3
3
  ---
4
4
 
5
- A controlled number input field. Note that this field **does not work
5
+ A controlled number input field.
6
+ By deafult, it renders a `<intput type="number">` to the DOM. However, if you need any string value, use the `allowStringValue` flag. Only use this if absolutely necessary, since it could be confusing for screenreader users.
7
+ Note that this field **does not work
6
8
  uncontrolled** - you must pass event handlers if you want it to respond to
7
9
  user input.
8
10
 
@@ -300,12 +302,11 @@ type: embed
300
302
  ---
301
303
  <Guidelines>
302
304
  <Figure recommendation="yes" title="Do">
303
- <Figure.Item>Use when the input is limited to a number (integer, rational, or irrational expressed with decimal points)</Figure.Item>
305
+ <Figure.Item>Use when you need increment/decrement functionality</Figure.Item>
304
306
  <Figure.Item>Use labels at the top or to the left of the input field</Figure.Item>
305
307
  </Figure>
306
308
  <Figure recommendation="no" title="Don't">
307
309
  <Figure.Item>Place labels or text strings to the right of the input field</Figure.Item>
308
- <Figure.Item>Use for alphanumeric input</Figure.Item>
309
310
  </Figure>
310
311
  </Guidelines>
311
312
  ```
@@ -75,7 +75,8 @@ class NumberInput extends Component<NumberInputProps, NumberInputState> {
75
75
  size: 'medium',
76
76
  display: 'block',
77
77
  textAlign: 'start',
78
- inputMode: 'numeric'
78
+ inputMode: 'numeric',
79
+ allowStringValue: false
79
80
  }
80
81
 
81
82
  state: NumberInputState = { hasFocus: false }
@@ -236,7 +237,8 @@ class NumberInput extends Component<NumberInputProps, NumberInputState> {
236
237
  showArrows,
237
238
  value,
238
239
  width,
239
- styles
240
+ styles,
241
+ allowStringValue
240
242
  } = this.props
241
243
 
242
244
  const { interaction } = this
@@ -274,7 +276,7 @@ class NumberInput extends Component<NumberInputProps, NumberInputState> {
274
276
  css={this.props.styles?.input}
275
277
  aria-invalid={this.invalid ? 'true' : undefined}
276
278
  id={this.id}
277
- type="number"
279
+ type={allowStringValue ? 'text' : 'number'}
278
280
  inputMode={this.props.inputMode}
279
281
  placeholder={placeholder}
280
282
  ref={this.handleInputRef}
@@ -161,6 +161,11 @@ type NumberInputOwnProps = {
161
161
  * The text alignment of the input.
162
162
  */
163
163
  textAlign?: 'start' | 'center'
164
+
165
+ /**
166
+ * sets the input type to string and allows string as value
167
+ */
168
+ allowStringValue?: boolean
164
169
  }
165
170
 
166
171
  type NumberInputState = {
@@ -220,7 +225,8 @@ const propTypes: PropValidators<PropKeys> = {
220
225
  onIncrement: PropTypes.func,
221
226
  onKeyDown: PropTypes.func,
222
227
  inputMode: PropTypes.oneOf(['numeric', 'decimal', 'tel']),
223
- textAlign: PropTypes.oneOf(['start', 'center'])
228
+ textAlign: PropTypes.oneOf(['start', 'center']),
229
+ allowStringValue: PropTypes.bool
224
230
  }
225
231
 
226
232
  const allowedProps: AllowedPropKeys = [
@@ -243,7 +249,8 @@ const allowedProps: AllowedPropKeys = [
243
249
  'onIncrement',
244
250
  'onKeyDown',
245
251
  'inputMode',
246
- 'textAlign'
252
+ 'textAlign',
253
+ 'allowStringValue'
247
254
  ]
248
255
 
249
256
  export type {