@instructure/ui-text-input 11.7.3-snapshot-7 → 11.7.3-snapshot-26
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 +5 -2
- package/es/TextInput/v1/index.js +128 -121
- package/es/TextInput/v1/styles.js +12 -8
- package/es/TextInput/v1/theme.js +30 -29
- package/es/TextInput/v2/index.js +104 -102
- package/es/TextInput/v2/styles.js +12 -8
- package/lib/TextInput/v1/index.js +128 -121
- package/lib/TextInput/v1/styles.js +12 -8
- package/lib/TextInput/v1/theme.js +30 -29
- package/lib/TextInput/v2/index.js +104 -102
- package/lib/TextInput/v2/styles.js +12 -8
- package/package.json +14 -14
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.TextInput = void 0;
|
|
8
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
8
|
var _react = require("react");
|
|
10
9
|
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
11
10
|
var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js");
|
|
@@ -19,8 +18,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
19
18
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
20
19
|
var _props = require("./props");
|
|
21
20
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
22
|
-
|
|
23
|
-
var _dec, _dec2, _class, _TextInput;
|
|
21
|
+
var _dec, _dec2, _class;
|
|
24
22
|
/*
|
|
25
23
|
* The MIT License (MIT)
|
|
26
24
|
*
|
|
@@ -50,61 +48,45 @@ category: components
|
|
|
50
48
|
tags: form, field, input
|
|
51
49
|
---
|
|
52
50
|
**/
|
|
53
|
-
let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default), _dec(_class = _dec2(_class =
|
|
51
|
+
let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default), _dec(_class = _dec2(_class = class TextInput extends _react.Component {
|
|
52
|
+
static displayName = "TextInput";
|
|
53
|
+
static componentId = 'TextInput';
|
|
54
|
+
static allowedProps = _props.allowedProps;
|
|
55
|
+
static defaultProps = {
|
|
56
|
+
type: 'text',
|
|
57
|
+
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
58
|
+
interaction: undefined,
|
|
59
|
+
isRequired: false,
|
|
60
|
+
display: 'block',
|
|
61
|
+
shouldNotWrap: false,
|
|
62
|
+
size: 'medium',
|
|
63
|
+
textAlign: 'start',
|
|
64
|
+
messages: []
|
|
65
|
+
};
|
|
54
66
|
constructor(props) {
|
|
55
67
|
super(props);
|
|
56
|
-
this.ref = null;
|
|
57
|
-
this._input = null;
|
|
58
|
-
this._defaultId = void 0;
|
|
59
|
-
this._messagesId = void 0;
|
|
60
|
-
this._focusListener = null;
|
|
61
|
-
this.handleRef = el => {
|
|
62
|
-
const elementRef = this.props.elementRef;
|
|
63
|
-
this.ref = el;
|
|
64
|
-
if (typeof elementRef === 'function') {
|
|
65
|
-
elementRef(el);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
this.makeStyleProps = () => {
|
|
69
|
-
const beforeElement = this.props.renderBeforeInput ? (0, _callRenderProp.callRenderProp)(this.props.renderBeforeInput) : null;
|
|
70
|
-
const success = !!this.props.messages && this.props.messages.some(message => message.type === 'success');
|
|
71
|
-
return {
|
|
72
|
-
interaction: this.interaction,
|
|
73
|
-
invalid: this.invalid,
|
|
74
|
-
success: success,
|
|
75
|
-
beforeElementExists: !!beforeElement
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
this.handleInputRef = node => {
|
|
79
|
-
this._input = node;
|
|
80
|
-
if (typeof this.props.inputRef === 'function') {
|
|
81
|
-
this.props.inputRef(node);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
this.handleChange = event => {
|
|
85
|
-
if (typeof this.props.onChange === 'function') {
|
|
86
|
-
this.props.onChange(event, event.target.value);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
this.handleBlur = event => {
|
|
90
|
-
if (typeof this.props.onBlur === 'function') {
|
|
91
|
-
this.props.onBlur(event);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
this.handleFocus = event => {
|
|
95
|
-
if (typeof this.props.onFocus === 'function') {
|
|
96
|
-
this.props.onFocus(event);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
68
|
this._defaultId = props.deterministicId();
|
|
100
69
|
this._messagesId = props.deterministicId('TextInput-messages');
|
|
101
70
|
}
|
|
71
|
+
ref = null;
|
|
72
|
+
_input = null;
|
|
73
|
+
_defaultId;
|
|
74
|
+
_messagesId;
|
|
75
|
+
_focusListener = null;
|
|
76
|
+
handleRef = el => {
|
|
77
|
+
const {
|
|
78
|
+
elementRef
|
|
79
|
+
} = this.props;
|
|
80
|
+
this.ref = el;
|
|
81
|
+
if (typeof elementRef === 'function') {
|
|
82
|
+
elementRef(el);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
102
85
|
componentDidMount() {
|
|
103
|
-
var _this$props$makeStyle, _this$props;
|
|
104
86
|
if (this._input) {
|
|
105
87
|
this._focusListener = (0, _addEventListener.addEventListener)(this._input, 'focus', this.handleFocus);
|
|
106
88
|
}
|
|
107
|
-
|
|
89
|
+
this.props.makeStyles?.(this.makeStyleProps());
|
|
108
90
|
}
|
|
109
91
|
componentWillUnmount() {
|
|
110
92
|
if (this._focusListener) {
|
|
@@ -112,11 +94,9 @@ let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
112
94
|
}
|
|
113
95
|
}
|
|
114
96
|
componentDidUpdate() {
|
|
115
|
-
|
|
116
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStyleProps());
|
|
97
|
+
this.props.makeStyles?.(this.makeStyleProps());
|
|
117
98
|
}
|
|
118
99
|
renderInstUIIcon(elementToRender) {
|
|
119
|
-
var _type;
|
|
120
100
|
if (!elementToRender) {
|
|
121
101
|
return null;
|
|
122
102
|
}
|
|
@@ -128,16 +108,25 @@ let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
128
108
|
large: 'lg'
|
|
129
109
|
};
|
|
130
110
|
const iconSize = linkSizeToIconSize[this.props.size || 'medium'];
|
|
131
|
-
if (/*#__PURE__*/(0, _react.isValidElement)(elementToRender) &&
|
|
111
|
+
if (/*#__PURE__*/(0, _react.isValidElement)(elementToRender) && elementToRender.type?.name === 'WrappedIcon') {
|
|
132
112
|
return (0, _safeCloneElement.safeCloneElement)(rendered, {
|
|
133
113
|
size: iconSize
|
|
134
114
|
});
|
|
135
115
|
}
|
|
136
116
|
return rendered;
|
|
137
117
|
}
|
|
118
|
+
makeStyleProps = () => {
|
|
119
|
+
const beforeElement = this.props.renderBeforeInput ? (0, _callRenderProp.callRenderProp)(this.props.renderBeforeInput) : null;
|
|
120
|
+
const success = !!this.props.messages && this.props.messages.some(message => message.type === 'success');
|
|
121
|
+
return {
|
|
122
|
+
interaction: this.interaction,
|
|
123
|
+
invalid: this.invalid,
|
|
124
|
+
success: success,
|
|
125
|
+
beforeElementExists: !!beforeElement
|
|
126
|
+
};
|
|
127
|
+
};
|
|
138
128
|
focus() {
|
|
139
|
-
|
|
140
|
-
(_this$_input = this._input) === null || _this$_input === void 0 ? void 0 : _this$_input.focus();
|
|
129
|
+
this._input?.focus();
|
|
141
130
|
}
|
|
142
131
|
get interaction() {
|
|
143
132
|
return (0, _getInteraction.getInteraction)({
|
|
@@ -156,65 +145,88 @@ let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
156
145
|
return (0, _isActiveElement.isActiveElement)(this._input);
|
|
157
146
|
}
|
|
158
147
|
get value() {
|
|
159
|
-
|
|
160
|
-
return (_this$_input2 = this._input) === null || _this$_input2 === void 0 ? void 0 : _this$_input2.value;
|
|
148
|
+
return this._input?.value;
|
|
161
149
|
}
|
|
162
150
|
get id() {
|
|
163
151
|
return this.props.id || this._defaultId;
|
|
164
152
|
}
|
|
153
|
+
handleInputRef = node => {
|
|
154
|
+
this._input = node;
|
|
155
|
+
if (typeof this.props.inputRef === 'function') {
|
|
156
|
+
this.props.inputRef(node);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
handleChange = event => {
|
|
160
|
+
if (typeof this.props.onChange === 'function') {
|
|
161
|
+
this.props.onChange(event, event.target.value);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
handleBlur = event => {
|
|
165
|
+
if (typeof this.props.onBlur === 'function') {
|
|
166
|
+
this.props.onBlur(event);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
handleFocus = event => {
|
|
170
|
+
if (typeof this.props.onFocus === 'function') {
|
|
171
|
+
this.props.onFocus(event);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
165
174
|
renderInput() {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
const {
|
|
176
|
+
type,
|
|
177
|
+
size,
|
|
178
|
+
htmlSize,
|
|
179
|
+
display,
|
|
180
|
+
textAlign,
|
|
181
|
+
placeholder,
|
|
182
|
+
value,
|
|
183
|
+
defaultValue,
|
|
184
|
+
isRequired,
|
|
185
|
+
onFocus,
|
|
186
|
+
...rest
|
|
187
|
+
} = this.props;
|
|
179
188
|
const props = (0, _passthroughProps.passthroughProps)(rest);
|
|
180
|
-
const
|
|
189
|
+
const {
|
|
190
|
+
interaction
|
|
191
|
+
} = this;
|
|
181
192
|
let descriptionIds = '';
|
|
182
193
|
if (props['aria-describedby']) {
|
|
183
194
|
descriptionIds = `${props['aria-describedby']}`;
|
|
184
195
|
}
|
|
185
196
|
return (0, _jsxRuntime.jsx)("input", {
|
|
186
197
|
...props,
|
|
187
|
-
css:
|
|
198
|
+
css: this.props.styles?.textInput,
|
|
188
199
|
defaultValue: defaultValue,
|
|
189
200
|
value: value,
|
|
190
|
-
placeholder: interaction === 'enabled' ? placeholder :
|
|
201
|
+
placeholder: interaction === 'enabled' ? placeholder : undefined,
|
|
191
202
|
ref: this.handleInputRef,
|
|
192
203
|
type: type,
|
|
193
204
|
id: this.id,
|
|
194
205
|
required: isRequired,
|
|
195
|
-
"aria-invalid": this.invalid ? 'true' :
|
|
206
|
+
"aria-invalid": this.invalid ? 'true' : undefined,
|
|
196
207
|
disabled: interaction === 'disabled',
|
|
197
208
|
readOnly: interaction === 'readonly',
|
|
198
|
-
"aria-describedby": descriptionIds !== '' ? descriptionIds :
|
|
209
|
+
"aria-describedby": descriptionIds !== '' ? descriptionIds : undefined,
|
|
199
210
|
size: htmlSize,
|
|
200
211
|
onChange: this.handleChange,
|
|
201
212
|
onBlur: this.handleBlur
|
|
202
213
|
});
|
|
203
214
|
}
|
|
204
215
|
render() {
|
|
205
|
-
const
|
|
206
|
-
width
|
|
207
|
-
display
|
|
208
|
-
renderLabel
|
|
209
|
-
renderBeforeInput
|
|
210
|
-
renderAfterInput
|
|
211
|
-
messages
|
|
212
|
-
inputContainerRef
|
|
213
|
-
isRequired
|
|
214
|
-
styles
|
|
216
|
+
const {
|
|
217
|
+
width,
|
|
218
|
+
display,
|
|
219
|
+
renderLabel,
|
|
220
|
+
renderBeforeInput,
|
|
221
|
+
renderAfterInput,
|
|
222
|
+
messages,
|
|
223
|
+
inputContainerRef,
|
|
224
|
+
isRequired,
|
|
225
|
+
styles
|
|
226
|
+
} = this.props;
|
|
215
227
|
const beforeElement = this.renderInstUIIcon(renderBeforeInput);
|
|
216
228
|
const afterElement = this.renderInstUIIcon(renderAfterInput);
|
|
217
|
-
const renderBeforeOrAfter = !!beforeElement || !!afterElement || renderBeforeInput !==
|
|
229
|
+
const renderBeforeOrAfter = !!beforeElement || !!afterElement || renderBeforeInput !== undefined || renderAfterInput !== undefined;
|
|
218
230
|
const label = (0, _callRenderProp.callRenderProp)(renderLabel);
|
|
219
231
|
return (0, _jsxRuntime.jsx)(_latest.FormField, {
|
|
220
232
|
id: this.id,
|
|
@@ -232,16 +244,16 @@ let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
232
244
|
readOnly: this.interaction === 'readonly',
|
|
233
245
|
"data-cid": "TextInput",
|
|
234
246
|
children: (0, _jsxRuntime.jsx)("span", {
|
|
235
|
-
css: styles
|
|
247
|
+
css: styles?.facade,
|
|
236
248
|
children: renderBeforeOrAfter ? (0, _jsxRuntime.jsxs)("span", {
|
|
237
|
-
css: styles
|
|
249
|
+
css: styles?.layout,
|
|
238
250
|
children: [beforeElement && (0, _jsxRuntime.jsx)("span", {
|
|
239
|
-
css: styles
|
|
251
|
+
css: styles?.beforeElement,
|
|
240
252
|
children: beforeElement
|
|
241
253
|
}), (0, _jsxRuntime.jsxs)("span", {
|
|
242
|
-
css: styles
|
|
254
|
+
css: styles?.inputLayout,
|
|
243
255
|
children: [this.renderInput(), afterElement && (0, _jsxRuntime.jsx)("span", {
|
|
244
|
-
css: styles
|
|
256
|
+
css: styles?.afterElement,
|
|
245
257
|
children: afterElement
|
|
246
258
|
})]
|
|
247
259
|
})]
|
|
@@ -250,15 +262,5 @@ let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
250
262
|
})
|
|
251
263
|
});
|
|
252
264
|
}
|
|
253
|
-
}
|
|
254
|
-
type: 'text',
|
|
255
|
-
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
256
|
-
interaction: void 0,
|
|
257
|
-
isRequired: false,
|
|
258
|
-
display: 'block',
|
|
259
|
-
shouldNotWrap: false,
|
|
260
|
-
size: 'medium',
|
|
261
|
-
textAlign: 'start',
|
|
262
|
-
messages: []
|
|
263
|
-
}, _TextInput)) || _class) || _class);
|
|
265
|
+
}) || _class) || _class);
|
|
264
266
|
var _default = exports.default = TextInput;
|
|
@@ -41,13 +41,17 @@ var _emotion = require("@instructure/emotion");
|
|
|
41
41
|
* @return The final style object, which will be used in the component
|
|
42
42
|
*/
|
|
43
43
|
const generateStyle = (componentTheme, props, sharedTokens, state) => {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
const {
|
|
45
|
+
size,
|
|
46
|
+
textAlign,
|
|
47
|
+
shouldNotWrap
|
|
48
|
+
} = props;
|
|
49
|
+
const {
|
|
50
|
+
interaction,
|
|
51
|
+
success,
|
|
52
|
+
invalid,
|
|
53
|
+
beforeElementExists
|
|
54
|
+
} = state;
|
|
51
55
|
const sizeVariants = {
|
|
52
56
|
small: {
|
|
53
57
|
fontSize: componentTheme.fontSizeSm,
|
|
@@ -155,7 +159,7 @@ const generateStyle = (componentTheme, props, sharedTokens, state) => {
|
|
|
155
159
|
})
|
|
156
160
|
};
|
|
157
161
|
const focusOutline = (0, _emotion.calcFocusOutlineStyles)(sharedTokens.focusOutline, {
|
|
158
|
-
focusColor: invalid ? 'danger' : success ? 'success' :
|
|
162
|
+
focusColor: invalid ? 'danger' : success ? 'success' : undefined,
|
|
159
163
|
// Only display the focus outline when the input is focused.
|
|
160
164
|
// This is to prevent double focus ring when e.g., a Button is rendered in
|
|
161
165
|
// `renderBeforeInput`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-text-input",
|
|
3
|
-
"version": "11.7.3-snapshot-
|
|
3
|
+
"version": "11.7.3-snapshot-26",
|
|
4
4
|
"description": "A styled HTML text input component.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -18,21 +18,21 @@
|
|
|
18
18
|
"@testing-library/react": "15.0.7",
|
|
19
19
|
"@testing-library/user-event": "^14.6.1",
|
|
20
20
|
"vitest": "^3.2.2",
|
|
21
|
-
"@instructure/ui-babel-preset": "11.7.3-snapshot-
|
|
22
|
-
"@instructure/ui-axe-check": "11.7.3-snapshot-
|
|
23
|
-
"@instructure/ui-badge": "11.7.3-snapshot-
|
|
24
|
-
"@instructure/ui-color-utils": "11.7.3-snapshot-
|
|
21
|
+
"@instructure/ui-babel-preset": "11.7.3-snapshot-26",
|
|
22
|
+
"@instructure/ui-axe-check": "11.7.3-snapshot-26",
|
|
23
|
+
"@instructure/ui-badge": "11.7.3-snapshot-26",
|
|
24
|
+
"@instructure/ui-color-utils": "11.7.3-snapshot-26"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@babel/runtime": "^7.
|
|
28
|
-
"@instructure/emotion": "11.7.3-snapshot-
|
|
29
|
-
"@instructure/
|
|
30
|
-
"@instructure/ui-dom-utils": "11.7.3-snapshot-
|
|
31
|
-
"@instructure/ui-
|
|
32
|
-
"@instructure/
|
|
33
|
-
"@instructure/ui-react-utils": "11.7.3-snapshot-
|
|
34
|
-
"@instructure/ui-tag": "11.7.3-snapshot-
|
|
35
|
-
"@instructure/ui-themes": "11.7.3-snapshot-
|
|
27
|
+
"@babel/runtime": "^7.29.2",
|
|
28
|
+
"@instructure/emotion": "11.7.3-snapshot-26",
|
|
29
|
+
"@instructure/shared-types": "11.7.3-snapshot-26",
|
|
30
|
+
"@instructure/ui-dom-utils": "11.7.3-snapshot-26",
|
|
31
|
+
"@instructure/ui-a11y-utils": "11.7.3-snapshot-26",
|
|
32
|
+
"@instructure/ui-form-field": "11.7.3-snapshot-26",
|
|
33
|
+
"@instructure/ui-react-utils": "11.7.3-snapshot-26",
|
|
34
|
+
"@instructure/ui-tag": "11.7.3-snapshot-26",
|
|
35
|
+
"@instructure/ui-themes": "11.7.3-snapshot-26"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"react": ">=18 <=19"
|