@instructure/ui-text-input 8.8.1-snapshot.3 → 8.9.0

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.
@@ -11,10 +11,6 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
11
11
 
12
12
  var _react = require("react");
13
13
 
14
- var _propTypes = _interopRequireDefault(require("prop-types"));
15
-
16
- var _controllable = require("@instructure/ui-prop-types/lib/controllable.js");
17
-
18
14
  var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
19
15
 
20
16
  var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js");
@@ -25,8 +21,6 @@ var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js
25
21
 
26
22
  var _FormField = require("@instructure/ui-form-field/lib/FormField");
27
23
 
28
- var _FormPropTypes = require("@instructure/ui-form-field/lib/FormPropTypes.js");
29
-
30
24
  var _uid = require("@instructure/uid");
31
25
 
32
26
  var _testable = require("@instructure/ui-testable/lib/testable.js");
@@ -37,6 +31,8 @@ var _styles = _interopRequireDefault(require("./styles"));
37
31
 
38
32
  var _theme = _interopRequireDefault(require("./theme"));
39
33
 
34
+ var _props = require("./props");
35
+
40
36
  const _excluded = ["type", "size", "htmlSize", "display", "textAlign", "placeholder", "value", "defaultValue", "isRequired"];
41
37
 
42
38
  var _dec, _dec2, _class, _class2, _temp;
@@ -91,11 +87,15 @@ let TextInput = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default)
91
87
  }
92
88
 
93
89
  componentDidMount() {
94
- this.props.makeStyles(this.makeStyleProps());
90
+ var _this$props$makeStyle, _this$props;
91
+
92
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStyleProps());
95
93
  }
96
94
 
97
95
  componentDidUpdate(prevProps, prevState, snapshot) {
98
- this.props.makeStyles(this.makeStyleProps());
96
+ var _this$props$makeStyle2, _this$props2;
97
+
98
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStyleProps());
99
99
  }
100
100
 
101
101
  focus() {
@@ -131,17 +131,19 @@ let TextInput = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default)
131
131
  }
132
132
 
133
133
  renderInput() {
134
- const _this$props = this.props,
135
- type = _this$props.type,
136
- size = _this$props.size,
137
- htmlSize = _this$props.htmlSize,
138
- display = _this$props.display,
139
- textAlign = _this$props.textAlign,
140
- placeholder = _this$props.placeholder,
141
- value = _this$props.value,
142
- defaultValue = _this$props.defaultValue,
143
- isRequired = _this$props.isRequired,
144
- rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
134
+ var _this$props$styles;
135
+
136
+ const _this$props3 = this.props,
137
+ type = _this$props3.type,
138
+ size = _this$props3.size,
139
+ htmlSize = _this$props3.htmlSize,
140
+ display = _this$props3.display,
141
+ textAlign = _this$props3.textAlign,
142
+ placeholder = _this$props3.placeholder,
143
+ value = _this$props3.value,
144
+ defaultValue = _this$props3.defaultValue,
145
+ isRequired = _this$props3.isRequired,
146
+ rest = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
145
147
  const props = (0, _passthroughProps.passthroughProps)(rest);
146
148
  const interaction = this.interaction;
147
149
  let descriptionIds = '';
@@ -155,7 +157,7 @@ let TextInput = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default)
155
157
  }
156
158
 
157
159
  return (0, _emotion.jsx)("input", Object.assign({}, props, {
158
- css: this.props.styles.textInput,
160
+ css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.textInput,
159
161
  defaultValue: defaultValue,
160
162
  value: value,
161
163
  placeholder: placeholder,
@@ -175,15 +177,15 @@ let TextInput = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default)
175
177
  }
176
178
 
177
179
  render() {
178
- const _this$props2 = this.props,
179
- width = _this$props2.width,
180
- display = _this$props2.display,
181
- renderLabel = _this$props2.renderLabel,
182
- renderBeforeInput = _this$props2.renderBeforeInput,
183
- renderAfterInput = _this$props2.renderAfterInput,
184
- messages = _this$props2.messages,
185
- inputContainerRef = _this$props2.inputContainerRef,
186
- styles = _this$props2.styles;
180
+ const _this$props4 = this.props,
181
+ width = _this$props4.width,
182
+ display = _this$props4.display,
183
+ renderLabel = _this$props4.renderLabel,
184
+ renderBeforeInput = _this$props4.renderBeforeInput,
185
+ renderAfterInput = _this$props4.renderAfterInput,
186
+ messages = _this$props4.messages,
187
+ inputContainerRef = _this$props4.inputContainerRef,
188
+ styles = _this$props4.styles;
187
189
  const hasBeforeElement = renderBeforeInput && (0, _callRenderProp.callRenderProp)(renderBeforeInput);
188
190
  const hasAfterElement = renderAfterInput && (0, _callRenderProp.callRenderProp)(renderAfterInput);
189
191
  const renderBeforeOrAfter = hasBeforeElement || hasAfterElement;
@@ -198,174 +200,39 @@ let TextInput = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default)
198
200
  layout: this.props.layout // eslint-disable-line react/prop-types
199
201
 
200
202
  }, (0, _emotion.jsx)("span", {
201
- css: styles.facade
203
+ css: styles === null || styles === void 0 ? void 0 : styles.facade
202
204
  }, renderBeforeOrAfter ? (0, _emotion.jsx)("div", null, (0, _emotion.jsx)("span", {
203
- css: styles.layout
205
+ css: styles === null || styles === void 0 ? void 0 : styles.layout
204
206
  }, hasBeforeElement && (0, _emotion.jsx)("span", {
205
- css: styles.beforeElement
207
+ css: styles === null || styles === void 0 ? void 0 : styles.beforeElement
206
208
  }, (0, _callRenderProp.callRenderProp)(renderBeforeInput)), (0, _emotion.jsx)("span", {
207
- css: styles.innerWrapper
209
+ css: styles === null || styles === void 0 ? void 0 : styles.innerWrapper
208
210
  }, (0, _emotion.jsx)("span", {
209
- css: styles.inputLayout
211
+ css: styles === null || styles === void 0 ? void 0 : styles.inputLayout
210
212
  }, (0, _emotion.jsx)("span", {
211
- css: styles.innerWrapper
213
+ css: styles === null || styles === void 0 ? void 0 : styles.innerWrapper
212
214
  }, this.renderInput()), hasAfterElement && (0, _emotion.jsx)("span", {
213
- css: styles.afterElement
215
+ css: styles === null || styles === void 0 ? void 0 : styles.afterElement
214
216
  }, (0, _callRenderProp.callRenderProp)(renderAfterInput)))))) :
215
217
  /* If no prepended or appended content, don't render Flex layout */
216
218
  this.renderInput()));
217
219
  }
218
220
 
219
- }, _class2.displayName = "TextInput", _class2.componentId = 'TextInput', _class2.propTypes = {
220
- /**
221
- * The form field label.
222
- */
223
- renderLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
224
-
225
- /**
226
- * Determines the underlying native HTML `<input>` element's `type`.
227
- * For more see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/url
228
- */
229
- type: _propTypes.default.oneOf(['text', 'email', 'url', 'tel', 'search', 'password']),
230
-
231
- /**
232
- * The id of the text input. One is generated if not supplied.
233
- */
234
- id: _propTypes.default.string,
235
-
236
- /**
237
- * the selected value (must be accompanied by an `onChange` prop)
238
- */
239
- value: (0, _controllable.controllable)(_propTypes.default.string),
240
-
241
- /**
242
- * value to set on initial render
243
- */
244
- defaultValue: _propTypes.default.string,
245
-
246
- /**
247
- * Specifies if interaction with the input is enabled, disabled, or readonly.
248
- * When "disabled", the input changes visibly to indicate that it cannot
249
- * receive user interactions. When "readonly" the input still cannot receive
250
- * user interactions but it keeps the same styles as if it were enabled.
251
- */
252
- interaction: _propTypes.default.oneOf(['enabled', 'disabled', 'readonly']),
253
-
254
- /**
255
- * object with shape: `{
256
- * text: PropTypes.string,
257
- * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
258
- * }`
259
- */
260
- messages: _propTypes.default.arrayOf(_FormPropTypes.FormPropTypes.message),
261
-
262
- /**
263
- * The size of the text input.
264
- */
265
- size: _propTypes.default.oneOf(['small', 'medium', 'large']),
266
-
267
- /**
268
- * The text alignment of the input.
269
- */
270
- textAlign: _propTypes.default.oneOf(['start', 'center']),
271
-
272
- /**
273
- * The width of the input.
274
- */
275
- width: _propTypes.default.string,
276
-
277
- /**
278
- * The width of the input, in characters, if a width is not explicitly
279
- * provided via the `width` prop. Only applicable if `isInline={true}`.
280
- */
281
- htmlSize: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
282
-
283
- /**
284
- * The display of the root element.
285
- */
286
- display: _propTypes.default.oneOf(['inline-block', 'block']),
287
-
288
- /**
289
- * Prevents the default behavior of wrapping the input and rendered content
290
- * when available space is exceeded.
291
- */
292
- shouldNotWrap: _propTypes.default.bool,
293
-
294
- /**
295
- * Html placeholder text to display when the input has no value. This should be hint text, not a label
296
- * replacement.
297
- */
298
- placeholder: _propTypes.default.string,
299
-
300
- /**
301
- * Whether or not the text input is required.
302
- */
303
- isRequired: _propTypes.default.bool,
304
-
305
- /**
306
- * a function that provides a reference to the actual input element
307
- */
308
- inputRef: _propTypes.default.func,
309
-
310
- /**
311
- * a function that provides a reference a parent of the input element
312
- */
313
- inputContainerRef: _propTypes.default.func,
314
-
315
- /**
316
- * Content to display before the input text, such as an icon
317
- */
318
- renderBeforeInput: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
319
-
320
- /**
321
- * Content to display after the input text, such as an icon
322
- */
323
- renderAfterInput: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
324
-
325
- /**
326
- * Callback executed when the input fires a change event.
327
- * @param {Object} event - the event object
328
- * @param {Object} value - the string value of the input
329
- */
330
- onChange: _propTypes.default.func,
331
-
332
- /**
333
- * Callback fired when input loses focus.
334
- */
335
- onBlur: _propTypes.default.func,
336
-
337
- /**
338
- * Callback fired when input receives focus.
339
- */
340
- onFocus: _propTypes.default.func,
341
- // eslint-disable-next-line react/require-default-props
342
- makeStyles: _propTypes.default.func,
343
- // eslint-disable-next-line react/require-default-props
344
- styles: _propTypes.default.object
345
- }, _class2.defaultProps = {
346
- renderLabel: void 0,
221
+ }, _class2.displayName = "TextInput", _class2.componentId = 'TextInput', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
347
222
  type: 'text',
348
- id: void 0,
349
223
  // Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
350
224
  interaction: void 0,
351
225
  isRequired: false,
352
- value: void 0,
353
- defaultValue: void 0,
354
226
  display: 'block',
355
227
  shouldNotWrap: false,
356
- placeholder: void 0,
357
- width: void 0,
358
228
  size: 'medium',
359
- htmlSize: void 0,
360
229
  textAlign: 'start',
361
230
  messages: [],
362
231
  inputRef: function (input) {},
363
232
  inputContainerRef: function (container) {},
364
233
  onChange: function (event, value) {},
365
234
  onBlur: function (event) {},
366
- onFocus: function (event) {},
367
- renderBeforeInput: void 0,
368
- renderAfterInput: void 0
235
+ onFocus: function (event) {}
369
236
  }, _temp)) || _class) || _class);
370
237
  exports.TextInput = TextInput;
371
238
  var _default = TextInput;
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.allowedProps = exports.propTypes = void 0;
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _FormPropTypes = require("@instructure/ui-form-field/lib/FormPropTypes.js");
13
+
14
+ var _controllable = require("@instructure/ui-prop-types/lib/controllable.js");
15
+
16
+ /*
17
+ * The MIT License (MIT)
18
+ *
19
+ * Copyright (c) 2015 - present Instructure, Inc.
20
+ *
21
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
22
+ * of this software and associated documentation files (the "Software"), to deal
23
+ * in the Software without restriction, including without limitation the rights
24
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25
+ * copies of the Software, and to permit persons to whom the Software is
26
+ * furnished to do so, subject to the following conditions:
27
+ *
28
+ * The above copyright notice and this permission notice shall be included in all
29
+ * copies or substantial portions of the Software.
30
+ *
31
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
+ * SOFTWARE.
38
+ */
39
+ const propTypes = {
40
+ /**
41
+ * The form field label.
42
+ */
43
+ renderLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
44
+
45
+ /**
46
+ * Determines the underlying native HTML `<input>` element's `type`.
47
+ * For more see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/url
48
+ */
49
+ type: _propTypes.default.oneOf(['text', 'email', 'url', 'tel', 'search', 'password']),
50
+
51
+ /**
52
+ * The id of the text input. One is generated if not supplied.
53
+ */
54
+ id: _propTypes.default.string,
55
+
56
+ /**
57
+ * the selected value (must be accompanied by an `onChange` prop)
58
+ */
59
+ value: (0, _controllable.controllable)(_propTypes.default.string),
60
+
61
+ /**
62
+ * value to set on initial render
63
+ */
64
+ defaultValue: _propTypes.default.string,
65
+
66
+ /**
67
+ * Specifies if interaction with the input is enabled, disabled, or readonly.
68
+ * When "disabled", the input changes visibly to indicate that it cannot
69
+ * receive user interactions. When "readonly" the input still cannot receive
70
+ * user interactions but it keeps the same styles as if it were enabled.
71
+ */
72
+ interaction: _propTypes.default.oneOf(['enabled', 'disabled', 'readonly']),
73
+
74
+ /**
75
+ * object with shape: `{
76
+ * text: PropTypes.string,
77
+ * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
78
+ * }`
79
+ */
80
+ messages: _propTypes.default.arrayOf(_FormPropTypes.FormPropTypes.message),
81
+
82
+ /**
83
+ * The size of the text input.
84
+ */
85
+ size: _propTypes.default.oneOf(['small', 'medium', 'large']),
86
+
87
+ /**
88
+ * The text alignment of the input.
89
+ */
90
+ textAlign: _propTypes.default.oneOf(['start', 'center']),
91
+
92
+ /**
93
+ * The width of the input.
94
+ */
95
+ width: _propTypes.default.string,
96
+
97
+ /**
98
+ * The width of the input, in characters, if a width is not explicitly
99
+ * provided via the `width` prop. Only applicable if `isInline={true}`.
100
+ */
101
+ htmlSize: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
102
+
103
+ /**
104
+ * The display of the root element.
105
+ */
106
+ display: _propTypes.default.oneOf(['inline-block', 'block']),
107
+
108
+ /**
109
+ * Prevents the default behavior of wrapping the input and rendered content
110
+ * when available space is exceeded.
111
+ */
112
+ shouldNotWrap: _propTypes.default.bool,
113
+
114
+ /**
115
+ * Html placeholder text to display when the input has no value. This should be hint text, not a label
116
+ * replacement.
117
+ */
118
+ placeholder: _propTypes.default.string,
119
+
120
+ /**
121
+ * Whether or not the text input is required.
122
+ */
123
+ isRequired: _propTypes.default.bool,
124
+
125
+ /**
126
+ * a function that provides a reference to the actual input element
127
+ */
128
+ inputRef: _propTypes.default.func,
129
+
130
+ /**
131
+ * a function that provides a reference a parent of the input element
132
+ */
133
+ inputContainerRef: _propTypes.default.func,
134
+
135
+ /**
136
+ * Content to display before the input text, such as an icon
137
+ */
138
+ renderBeforeInput: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
139
+
140
+ /**
141
+ * Content to display after the input text, such as an icon
142
+ */
143
+ renderAfterInput: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
144
+
145
+ /**
146
+ * Callback executed when the input fires a change event.
147
+ * @param {Object} event - the event object
148
+ * @param {Object} value - the string value of the input
149
+ */
150
+ onChange: _propTypes.default.func,
151
+
152
+ /**
153
+ * Callback fired when input loses focus.
154
+ */
155
+ onBlur: _propTypes.default.func,
156
+
157
+ /**
158
+ * Callback fired when input receives focus.
159
+ */
160
+ onFocus: _propTypes.default.func
161
+ };
162
+ exports.propTypes = propTypes;
163
+ const allowedProps = ['renderLabel', 'type', 'id', 'value', 'defaultValue', 'interaction', 'messages', 'size', 'textAlign', 'width', 'htmlSize', 'display', 'shouldNotWrap', 'placeholder', 'isRequired', 'inputRef', 'inputContainerRef', 'renderBeforeInput', 'renderAfterInput', 'onChange', 'onBlur', 'onFocus'];
164
+ exports.allowedProps = allowedProps;