@instructure/ui-text-input 11.7.3-snapshot-25 → 11.7.3-snapshot-27

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,9 +3,12 @@
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.7.3-snapshot-25](https://github.com/instructure/instructure-ui/compare/v11.7.2...v11.7.3-snapshot-25) (2026-04-30)
6
+ ## [11.7.3-snapshot-27](https://github.com/instructure/instructure-ui/compare/v11.7.2...v11.7.3-snapshot-27) (2026-05-05)
7
7
 
8
- **Note:** Version bump only for package @instructure/ui-text-input
8
+
9
+ ### Bug Fixes
10
+
11
+ * **many:** update dependencies, remove lots of Babel plugins, remove Webpack 4 support ([f916fca](https://github.com/instructure/instructure-ui/commit/f916fcafdddcb2d7de401f93e8ff92cfdfa47bba))
9
12
 
10
13
 
11
14
 
@@ -1,6 +1,4 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
- const _excluded = ["type", "size", "htmlSize", "display", "textAlign", "placeholder", "value", "defaultValue", "isRequired", "onFocus"];
3
- var _dec, _dec2, _class, _TextInput;
1
+ var _dec, _dec2, _class;
4
2
  /*
5
3
  * The MIT License (MIT)
6
4
  *
@@ -41,72 +39,46 @@ tags: form, field
41
39
  ---
42
40
  **/
43
41
  import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
44
- let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = (_TextInput = class TextInput extends Component {
42
+ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = class TextInput extends Component {
43
+ static displayName = "TextInput";
44
+ static componentId = 'TextInput';
45
+ static allowedProps = allowedProps;
46
+ static defaultProps = {
47
+ type: 'text',
48
+ // Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
49
+ interaction: undefined,
50
+ isRequired: false,
51
+ display: 'block',
52
+ shouldNotWrap: false,
53
+ size: 'medium',
54
+ textAlign: 'start',
55
+ messages: []
56
+ };
45
57
  constructor(props) {
46
58
  super(props);
47
- this.ref = null;
48
- this._input = null;
49
- this._afterElement = null;
50
- this._defaultId = void 0;
51
- this._messagesId = void 0;
52
- this._focusListener = null;
53
- this.handleRef = el => {
54
- const elementRef = this.props.elementRef;
55
- this.ref = el;
56
- if (typeof elementRef === 'function') {
57
- elementRef(el);
58
- }
59
- };
60
- this.makeStyleProps = () => {
61
- const interaction = this.interaction;
62
- const _this$state = this.state,
63
- hasFocus = _this$state.hasFocus,
64
- afterElementHasWidth = _this$state.afterElementHasWidth;
65
- const beforeElement = this.props.renderBeforeInput ? callRenderProp(this.props.renderBeforeInput) : null;
66
- return {
67
- disabled: interaction === 'disabled',
68
- invalid: this.invalid,
69
- focused: hasFocus,
70
- afterElementHasWidth: afterElementHasWidth,
71
- beforeElementExists: !!beforeElement
72
- };
73
- };
74
- this.handleInputRef = node => {
75
- this._input = node;
76
- if (typeof this.props.inputRef === 'function') {
77
- this.props.inputRef(node);
78
- }
79
- };
80
- this.handleChange = event => {
81
- if (typeof this.props.onChange === 'function') {
82
- this.props.onChange(event, event.target.value);
83
- }
84
- };
85
- this.handleBlur = event => {
86
- if (typeof this.props.onBlur === 'function') {
87
- this.props.onBlur(event);
88
- }
89
- this.setState({
90
- hasFocus: false
91
- });
92
- };
93
- this.handleFocus = event => {
94
- if (typeof this.props.onFocus === 'function') {
95
- this.props.onFocus(event);
96
- }
97
- this.setState({
98
- hasFocus: true
99
- });
100
- };
101
59
  this.state = {
102
60
  hasFocus: false,
103
- afterElementHasWidth: void 0
61
+ afterElementHasWidth: undefined
104
62
  };
105
63
  this._defaultId = props.deterministicId();
106
64
  this._messagesId = props.deterministicId('TextInput-messages');
107
65
  }
66
+ ref = null;
67
+ _input = null;
68
+ _afterElement = null;
69
+ _defaultId;
70
+ _messagesId;
71
+ _focusListener = null;
72
+ handleRef = el => {
73
+ const {
74
+ elementRef
75
+ } = this.props;
76
+ this.ref = el;
77
+ if (typeof elementRef === 'function') {
78
+ elementRef(el);
79
+ }
80
+ };
108
81
  componentDidMount() {
109
- var _this$props$makeStyle, _this$props;
110
82
  if (this._input) {
111
83
  this._focusListener = addEventListener(this._input, 'focus', this.handleFocus);
112
84
  this.setState({
@@ -114,7 +86,7 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
114
86
  });
115
87
  }
116
88
  this.adjustAfterElementHeight();
117
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStyleProps());
89
+ this.props.makeStyles?.(this.makeStyleProps());
118
90
  }
119
91
  componentWillUnmount() {
120
92
  if (this._focusListener) {
@@ -122,7 +94,6 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
122
94
  }
123
95
  }
124
96
  componentDidUpdate(prevProps) {
125
- var _this$props$makeStyle2, _this$props2;
126
97
  if (prevProps.renderAfterInput !== this.props.renderAfterInput) {
127
98
  this.setState({
128
99
  afterElementHasWidth: this.getElementHasWidth(this._afterElement)
@@ -137,19 +108,18 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
137
108
  hasFocus: false
138
109
  });
139
110
  }
140
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStyleProps());
111
+ this.props.makeStyles?.(this.makeStyleProps());
141
112
  }
142
113
  adjustAfterElementHeight() {
143
- var _this$_afterElement, _afterElementChild$fi;
144
- const afterElementChild = (_this$_afterElement = this._afterElement) === null || _this$_afterElement === void 0 ? void 0 : _this$_afterElement.firstElementChild;
114
+ const afterElementChild = this._afterElement?.firstElementChild;
145
115
 
146
116
  // Check if the child is a button, then get the button's first child (the content span)
147
- const buttonContentSpan = (afterElementChild === null || afterElementChild === void 0 ? void 0 : afterElementChild.tagName) === 'BUTTON' ? afterElementChild.firstElementChild : null;
117
+ const buttonContentSpan = afterElementChild?.tagName === 'BUTTON' ? afterElementChild.firstElementChild : null;
148
118
 
149
119
  // This is a necessary workaround for DateInput2 because it uses a Popover, which has a nested Button as an afterElement
150
120
  // Check if the child is a Popover's inner span containing a button, then get the button's first child (the content span)
151
- const popoverContentSpan = (afterElementChild === null || afterElementChild === void 0 ? void 0 : afterElementChild.tagName) === 'SPAN' && ((_afterElementChild$fi = afterElementChild.firstElementChild) === null || _afterElementChild$fi === void 0 ? void 0 : _afterElementChild$fi.tagName) === 'BUTTON' ? afterElementChild.firstElementChild.firstElementChild : null;
152
- const targetSpan = buttonContentSpan !== null && buttonContentSpan !== void 0 ? buttonContentSpan : popoverContentSpan;
121
+ const popoverContentSpan = afterElementChild?.tagName === 'SPAN' && afterElementChild.firstElementChild?.tagName === 'BUTTON' ? afterElementChild.firstElementChild.firstElementChild : null;
122
+ const targetSpan = buttonContentSpan ?? popoverContentSpan;
153
123
  if (targetSpan) {
154
124
  // Set the height to 36px (the height of a medium TextInput) to avoid layout shift when the afterElement content changes
155
125
  // this temporary workaround is necessary because otherwise the layout breaks, later on IconButton's default height will be adjusted to the TextInput size
@@ -157,9 +127,25 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
157
127
  targetSpan.style.height = '36px';
158
128
  }
159
129
  }
130
+ makeStyleProps = () => {
131
+ const {
132
+ interaction
133
+ } = this;
134
+ const {
135
+ hasFocus,
136
+ afterElementHasWidth
137
+ } = this.state;
138
+ const beforeElement = this.props.renderBeforeInput ? callRenderProp(this.props.renderBeforeInput) : null;
139
+ return {
140
+ disabled: interaction === 'disabled',
141
+ invalid: this.invalid,
142
+ focused: hasFocus,
143
+ afterElementHasWidth: afterElementHasWidth,
144
+ beforeElementExists: !!beforeElement
145
+ };
146
+ };
160
147
  focus() {
161
- var _this$_input;
162
- (_this$_input = this._input) === null || _this$_input === void 0 ? void 0 : _this$_input.focus();
148
+ this._input?.focus();
163
149
  }
164
150
  get interaction() {
165
151
  return getInteraction({
@@ -178,35 +164,63 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
178
164
  return isActiveElement(this._input);
179
165
  }
180
166
  get value() {
181
- var _this$_input2;
182
- return (_this$_input2 = this._input) === null || _this$_input2 === void 0 ? void 0 : _this$_input2.value;
167
+ return this._input?.value;
183
168
  }
184
169
  get id() {
185
170
  return this.props.id || this._defaultId;
186
171
  }
172
+ handleInputRef = node => {
173
+ this._input = node;
174
+ if (typeof this.props.inputRef === 'function') {
175
+ this.props.inputRef(node);
176
+ }
177
+ };
178
+ handleChange = event => {
179
+ if (typeof this.props.onChange === 'function') {
180
+ this.props.onChange(event, event.target.value);
181
+ }
182
+ };
183
+ handleBlur = event => {
184
+ if (typeof this.props.onBlur === 'function') {
185
+ this.props.onBlur(event);
186
+ }
187
+ this.setState({
188
+ hasFocus: false
189
+ });
190
+ };
191
+ handleFocus = event => {
192
+ if (typeof this.props.onFocus === 'function') {
193
+ this.props.onFocus(event);
194
+ }
195
+ this.setState({
196
+ hasFocus: true
197
+ });
198
+ };
187
199
  renderInput() {
188
- var _this$props$styles;
189
- const _this$props3 = this.props,
190
- type = _this$props3.type,
191
- size = _this$props3.size,
192
- htmlSize = _this$props3.htmlSize,
193
- display = _this$props3.display,
194
- textAlign = _this$props3.textAlign,
195
- placeholder = _this$props3.placeholder,
196
- value = _this$props3.value,
197
- defaultValue = _this$props3.defaultValue,
198
- isRequired = _this$props3.isRequired,
199
- onFocus = _this$props3.onFocus,
200
- rest = _objectWithoutProperties(_this$props3, _excluded);
200
+ const {
201
+ type,
202
+ size,
203
+ htmlSize,
204
+ display,
205
+ textAlign,
206
+ placeholder,
207
+ value,
208
+ defaultValue,
209
+ isRequired,
210
+ onFocus,
211
+ ...rest
212
+ } = this.props;
201
213
  const props = passthroughProps(rest);
202
- const interaction = this.interaction;
214
+ const {
215
+ interaction
216
+ } = this;
203
217
  let descriptionIds = '';
204
218
  if (props['aria-describedby']) {
205
219
  descriptionIds = `${props['aria-describedby']}`;
206
220
  }
207
221
  return _jsx("input", {
208
222
  ...props,
209
- css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.textInput,
223
+ css: this.props.styles?.textInput,
210
224
  defaultValue: defaultValue,
211
225
  value: value,
212
226
  placeholder: placeholder,
@@ -214,10 +228,10 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
214
228
  type: type,
215
229
  id: this.id,
216
230
  required: isRequired,
217
- "aria-invalid": this.invalid ? 'true' : void 0,
231
+ "aria-invalid": this.invalid ? 'true' : undefined,
218
232
  disabled: interaction === 'disabled',
219
233
  readOnly: interaction === 'readonly',
220
- "aria-describedby": descriptionIds !== '' ? descriptionIds : void 0,
234
+ "aria-describedby": descriptionIds !== '' ? descriptionIds : undefined,
221
235
  size: htmlSize,
222
236
  onChange: this.handleChange,
223
237
  onBlur: this.handleBlur
@@ -225,15 +239,17 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
225
239
  }
226
240
  getElementHasWidth(element) {
227
241
  if (!element) {
228
- return void 0;
242
+ return undefined;
229
243
  }
230
244
  const computedStyle = getCSSStyleDeclaration(element);
231
245
  if (!computedStyle) {
232
- return void 0;
246
+ return undefined;
233
247
  }
234
- const width = computedStyle.width,
235
- paddingInlineStart = computedStyle.paddingInlineStart,
236
- paddingInlineEnd = computedStyle.paddingInlineEnd;
248
+ const {
249
+ width,
250
+ paddingInlineStart,
251
+ paddingInlineEnd
252
+ } = computedStyle;
237
253
  if (width === 'auto' || width === '') {
238
254
  // This is a workaround for an edge-case, when the TextInput's parent
239
255
  // is hidden on load, so the element is not visible either.
@@ -245,23 +261,24 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
245
261
  return elementWidth > 0;
246
262
  }
247
263
  render() {
248
- const _this$props4 = this.props,
249
- width = _this$props4.width,
250
- display = _this$props4.display,
251
- renderLabel = _this$props4.renderLabel,
252
- renderBeforeInput = _this$props4.renderBeforeInput,
253
- renderAfterInput = _this$props4.renderAfterInput,
254
- messages = _this$props4.messages,
255
- inputContainerRef = _this$props4.inputContainerRef,
256
- isRequired = _this$props4.isRequired,
257
- styles = _this$props4.styles;
264
+ const {
265
+ width,
266
+ display,
267
+ renderLabel,
268
+ renderBeforeInput,
269
+ renderAfterInput,
270
+ messages,
271
+ inputContainerRef,
272
+ isRequired,
273
+ styles
274
+ } = this.props;
258
275
  const beforeElement = renderBeforeInput ? callRenderProp(renderBeforeInput) : null;
259
276
  const afterElement = renderAfterInput ? callRenderProp(renderAfterInput) : null;
260
- const renderBeforeOrAfter = !!beforeElement || !!afterElement || renderBeforeInput !== void 0 || renderAfterInput !== void 0;
277
+ const renderBeforeOrAfter = !!beforeElement || !!afterElement || renderBeforeInput !== undefined || renderAfterInput !== undefined;
261
278
  const rawLabel = callRenderProp(renderLabel);
262
279
  const label = hasVisibleChildren(rawLabel) ? _jsxs(Fragment, {
263
280
  children: [rawLabel, isRequired && _jsxs("span", {
264
- css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {},
281
+ css: this.invalid ? styles?.requiredInvalid : {},
265
282
  "aria-hidden": true,
266
283
  children: [' ', "*"]
267
284
  })]
@@ -279,13 +296,13 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
279
296
  margin: this.props.margin,
280
297
  "data-cid": "TextInput",
281
298
  children: _jsx("span", {
282
- css: styles === null || styles === void 0 ? void 0 : styles.facade,
299
+ css: styles?.facade,
283
300
  children: renderBeforeOrAfter ? _jsxs("span", {
284
- css: styles === null || styles === void 0 ? void 0 : styles.layout,
301
+ css: styles?.layout,
285
302
  children: [beforeElement, _jsxs("span", {
286
- css: styles === null || styles === void 0 ? void 0 : styles.inputLayout,
303
+ css: styles?.inputLayout,
287
304
  children: [this.renderInput(), afterElement && _jsx("span", {
288
- css: styles === null || styles === void 0 ? void 0 : styles.afterElement,
305
+ css: styles?.afterElement,
289
306
  ref: e => {
290
307
  this._afterElement = e;
291
308
  },
@@ -297,16 +314,6 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
297
314
  })
298
315
  });
299
316
  }
300
- }, _TextInput.displayName = "TextInput", _TextInput.componentId = 'TextInput', _TextInput.allowedProps = allowedProps, _TextInput.defaultProps = {
301
- type: 'text',
302
- // Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
303
- interaction: void 0,
304
- isRequired: false,
305
- display: 'block',
306
- shouldNotWrap: false,
307
- size: 'medium',
308
- textAlign: 'start',
309
- messages: []
310
- }, _TextInput)) || _class) || _class);
317
+ }) || _class) || _class);
311
318
  export default TextInput;
312
319
  export { TextInput };
@@ -33,14 +33,18 @@
33
33
  * @return {Object} The final style object, which will be used in the component
34
34
  */
35
35
  const generateStyle = (componentTheme, props, state) => {
36
- const size = props.size,
37
- textAlign = props.textAlign,
38
- shouldNotWrap = props.shouldNotWrap;
39
- const disabled = state.disabled,
40
- invalid = state.invalid,
41
- focused = state.focused,
42
- afterElementHasWidth = state.afterElementHasWidth,
43
- beforeElementExists = state.beforeElementExists;
36
+ const {
37
+ size,
38
+ textAlign,
39
+ shouldNotWrap
40
+ } = props;
41
+ const {
42
+ disabled,
43
+ invalid,
44
+ focused,
45
+ afterElementHasWidth,
46
+ beforeElementExists
47
+ } = state;
44
48
  const sizeVariants = {
45
49
  small: {
46
50
  fontSize: componentTheme.smallFontSize,
@@ -28,13 +28,14 @@
28
28
  * @return {Object} The final theme object with the overrides and component variables
29
29
  */
30
30
  const generateComponentTheme = theme => {
31
- var _colors$contrasts, _colors$contrasts2, _colors$contrasts3, _colors$contrasts4, _colors$contrasts5, _colors$contrasts6, _colors$contrasts7, _colors$contrasts8;
32
- const colors = theme.colors,
33
- typography = theme.typography,
34
- borders = theme.borders,
35
- spacing = theme.spacing,
36
- forms = theme.forms,
37
- themeName = theme.key;
31
+ const {
32
+ colors,
33
+ typography,
34
+ borders,
35
+ spacing,
36
+ forms,
37
+ key: themeName
38
+ } = theme;
38
39
  const themeSpecificStyle = {
39
40
  canvas: {
40
41
  color: theme['ic-brand-font-color-dark'],
@@ -42,28 +43,28 @@ const generateComponentTheme = theme => {
42
43
  }
43
44
  };
44
45
  const componentVariables = {
45
- fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
46
- fontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightNormal,
47
- borderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
48
- borderStyle: borders === null || borders === void 0 ? void 0 : borders.style,
49
- borderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.grey3045,
50
- borderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusMedium,
51
- color: colors === null || colors === void 0 ? void 0 : (_colors$contrasts2 = colors.contrasts) === null || _colors$contrasts2 === void 0 ? void 0 : _colors$contrasts2.grey125125,
52
- background: colors === null || colors === void 0 ? void 0 : (_colors$contrasts3 = colors.contrasts) === null || _colors$contrasts3 === void 0 ? void 0 : _colors$contrasts3.white1010,
53
- requiredInvalidColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts4 = colors.contrasts) === null || _colors$contrasts4 === void 0 ? void 0 : _colors$contrasts4.red5782,
54
- padding: spacing === null || spacing === void 0 ? void 0 : spacing.small,
55
- focusOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
56
- focusOutlineStyle: borders === null || borders === void 0 ? void 0 : borders.style,
57
- focusOutlineColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts5 = colors.contrasts) === null || _colors$contrasts5 === void 0 ? void 0 : _colors$contrasts5.blue4570,
58
- errorBorderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts6 = colors.contrasts) === null || _colors$contrasts6 === void 0 ? void 0 : _colors$contrasts6.red4570,
59
- errorOutlineColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts7 = colors.contrasts) === null || _colors$contrasts7 === void 0 ? void 0 : _colors$contrasts7.red4570,
60
- placeholderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts8 = colors.contrasts) === null || _colors$contrasts8 === void 0 ? void 0 : _colors$contrasts8.grey4570,
61
- smallFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeSmall,
62
- smallHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightSmall,
63
- mediumFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
64
- mediumHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightMedium,
65
- largeFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeLarge,
66
- largeHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightLarge
46
+ fontFamily: typography?.fontFamily,
47
+ fontWeight: typography?.fontWeightNormal,
48
+ borderWidth: borders?.widthSmall,
49
+ borderStyle: borders?.style,
50
+ borderColor: colors?.contrasts?.grey3045,
51
+ borderRadius: borders?.radiusMedium,
52
+ color: colors?.contrasts?.grey125125,
53
+ background: colors?.contrasts?.white1010,
54
+ requiredInvalidColor: colors?.contrasts?.red5782,
55
+ padding: spacing?.small,
56
+ focusOutlineWidth: borders?.widthMedium,
57
+ focusOutlineStyle: borders?.style,
58
+ focusOutlineColor: colors?.contrasts?.blue4570,
59
+ errorBorderColor: colors?.contrasts?.red4570,
60
+ errorOutlineColor: colors?.contrasts?.red4570,
61
+ placeholderColor: colors?.contrasts?.grey4570,
62
+ smallFontSize: typography?.fontSizeSmall,
63
+ smallHeight: forms?.inputHeightSmall,
64
+ mediumFontSize: typography?.fontSizeMedium,
65
+ mediumHeight: forms?.inputHeightMedium,
66
+ largeFontSize: typography?.fontSizeLarge,
67
+ largeHeight: forms?.inputHeightLarge
67
68
  };
68
69
  return {
69
70
  ...componentVariables,