@instructure/ui-text-input 11.6.0 → 11.6.1-pr-snapshot-1779894247159

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,14 @@
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.6.1-pr-snapshot-1779894247159](https://github.com/instructure/instructure-ui/compare/v11.6.0...v11.6.1-pr-snapshot-1779894247159) (2026-05-27)
7
+
8
+ **Note:** Version bump only for package @instructure/ui-text-input
9
+
10
+
11
+
12
+
13
+
6
14
  # [11.6.0](https://github.com/instructure/instructure-ui/compare/v11.5.0...v11.6.0) (2026-02-18)
7
15
 
8
16
  **Note:** Version bump only for package @instructure/ui-text-input
@@ -1,9 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.allowedProps = void 0;
7
1
  /*
8
2
  * The MIT License (MIT)
9
3
  *
@@ -28,4 +22,16 @@ exports.allowedProps = void 0;
28
22
  * SOFTWARE.
29
23
  */
30
24
 
31
- const allowedProps = exports.allowedProps = ['renderLabel', 'type', 'id', 'value', 'defaultValue', 'interaction', 'messages', 'size', 'textAlign', 'width', 'htmlSize', 'display', 'shouldNotWrap', 'placeholder', 'isRequired', 'elementRef', 'inputRef', 'inputContainerRef', 'renderBeforeInput', 'renderAfterInput', 'onChange', 'onBlur', 'onFocus', 'margin'];
25
+ module.exports = {
26
+ presets: [
27
+ [
28
+ require('@instructure/ui-babel-preset'),
29
+ {
30
+ coverage: Boolean(process.env.COVERAGE),
31
+ esModules: Boolean(process.env.ES_MODULES),
32
+ removeConsole: process.env.NODE_ENV === 'production',
33
+ transformImports: Boolean(process.env.TRANSFORM_IMPORTS)
34
+ }
35
+ ]
36
+ ]
37
+ }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@instructure/ui-text-input",
3
- "version": "11.6.0",
3
+ "version": "11.6.1-pr-snapshot-1779894247159",
4
+ "type": "module",
4
5
  "description": "A styled HTML text input component.",
5
6
  "author": "Instructure, Inc. Engineering and Product Design",
6
7
  "module": "./es/index.js",
7
- "main": "./lib/index.js",
8
8
  "types": "./types/index.d.ts",
9
9
  "repository": {
10
10
  "type": "git",
@@ -15,25 +15,25 @@
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
17
  "@babel/runtime": "^7.27.6",
18
- "@instructure/emotion": "11.6.0",
19
- "@instructure/shared-types": "11.6.0",
20
- "@instructure/ui-a11y-utils": "11.6.0",
21
- "@instructure/ui-dom-utils": "11.6.0",
22
- "@instructure/ui-form-field": "11.6.0",
23
- "@instructure/ui-icons": "11.6.0",
24
- "@instructure/ui-react-utils": "11.6.0",
25
- "@instructure/ui-tag": "11.6.0"
18
+ "@instructure/shared-types": "11.6.1-pr-snapshot-1779894247159",
19
+ "@instructure/emotion": "11.6.1-pr-snapshot-1779894247159",
20
+ "@instructure/ui-a11y-utils": "11.6.1-pr-snapshot-1779894247159",
21
+ "@instructure/ui-dom-utils": "11.6.1-pr-snapshot-1779894247159",
22
+ "@instructure/ui-form-field": "11.6.1-pr-snapshot-1779894247159",
23
+ "@instructure/ui-icons": "11.6.1-pr-snapshot-1779894247159",
24
+ "@instructure/ui-react-utils": "11.6.1-pr-snapshot-1779894247159",
25
+ "@instructure/ui-tag": "11.6.1-pr-snapshot-1779894247159"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@testing-library/jest-dom": "^6.6.3",
29
29
  "@testing-library/react": "15.0.7",
30
30
  "@testing-library/user-event": "^14.6.1",
31
31
  "vitest": "^3.2.2",
32
- "@instructure/ui-axe-check": "11.6.0",
33
- "@instructure/ui-badge": "11.6.0",
34
- "@instructure/ui-color-utils": "11.6.0",
35
- "@instructure/ui-babel-preset": "11.6.0",
36
- "@instructure/ui-themes": "11.6.0"
32
+ "@instructure/ui-axe-check": "11.6.1-pr-snapshot-1779894247159",
33
+ "@instructure/ui-babel-preset": "11.6.1-pr-snapshot-1779894247159",
34
+ "@instructure/ui-badge": "11.6.1-pr-snapshot-1779894247159",
35
+ "@instructure/ui-color-utils": "11.6.1-pr-snapshot-1779894247159",
36
+ "@instructure/ui-themes": "11.6.1-pr-snapshot-1779894247159"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "react": ">=18 <=19"
@@ -46,10 +46,8 @@
46
46
  ".": {
47
47
  "types": "./types/index.d.ts",
48
48
  "import": "./es/index.js",
49
- "require": "./lib/index.js",
50
49
  "default": "./es/index.js"
51
50
  },
52
- "./lib/*": "./lib/*",
53
51
  "./es/*": "./es/*",
54
52
  "./types/*": "./types/*",
55
53
  "./package.json": "./package.json",
@@ -59,7 +57,7 @@
59
57
  "lint": "ui-scripts lint",
60
58
  "lint:fix": "ui-scripts lint --fix",
61
59
  "clean": "ui-scripts clean",
62
- "build": "ui-scripts build --modules es,cjs",
60
+ "build": "ui-scripts build",
63
61
  "build:watch": "pnpm run ts:check -- --watch & ui-scripts build --watch",
64
62
  "build:types": "tsc -p tsconfig.build.json",
65
63
  "ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
@@ -1,322 +0,0 @@
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.TextInput = void 0;
8
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
- var _react = require("react");
10
- var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
11
- var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js");
12
- var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
13
- var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
14
- var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
15
- var _addEventListener = require("@instructure/ui-dom-utils/lib/addEventListener.js");
16
- var _getCSSStyleDeclaration = require("@instructure/ui-dom-utils/lib/getCSSStyleDeclaration.js");
17
- var _FormField = require("@instructure/ui-form-field/lib/FormField");
18
- var _emotion = require("@instructure/emotion");
19
- var _hasVisibleChildren = require("@instructure/ui-a11y-utils/lib/hasVisibleChildren.js");
20
- var _styles = _interopRequireDefault(require("./styles"));
21
- var _theme = _interopRequireDefault(require("./theme"));
22
- var _props = require("./props");
23
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
24
- const _excluded = ["type", "size", "htmlSize", "display", "textAlign", "placeholder", "value", "defaultValue", "isRequired", "onFocus"];
25
- var _dec, _dec2, _class, _TextInput;
26
- /*
27
- * The MIT License (MIT)
28
- *
29
- * Copyright (c) 2015 - present Instructure, Inc.
30
- *
31
- * Permission is hereby granted, free of charge, to any person obtaining a copy
32
- * of this software and associated documentation files (the "Software"), to deal
33
- * in the Software without restriction, including without limitation the rights
34
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
35
- * copies of the Software, and to permit persons to whom the Software is
36
- * furnished to do so, subject to the following conditions:
37
- *
38
- * The above copyright notice and this permission notice shall be included in all
39
- * copies or substantial portions of the Software.
40
- *
41
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
44
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
47
- * SOFTWARE.
48
- */
49
- /**
50
- ---
51
- category: components
52
- tags: form, field
53
- ---
54
- **/
55
- let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = _dec2(_class = (_TextInput = class TextInput extends _react.Component {
56
- constructor(props) {
57
- super(props);
58
- this.ref = null;
59
- this._input = null;
60
- this._afterElement = null;
61
- this._defaultId = void 0;
62
- this._messagesId = void 0;
63
- this._focusListener = null;
64
- this.handleRef = el => {
65
- const elementRef = this.props.elementRef;
66
- this.ref = el;
67
- if (typeof elementRef === 'function') {
68
- elementRef(el);
69
- }
70
- };
71
- this.makeStyleProps = () => {
72
- const interaction = this.interaction;
73
- const _this$state = this.state,
74
- hasFocus = _this$state.hasFocus,
75
- afterElementHasWidth = _this$state.afterElementHasWidth;
76
- const beforeElement = this.props.renderBeforeInput ? (0, _callRenderProp.callRenderProp)(this.props.renderBeforeInput) : null;
77
- return {
78
- disabled: interaction === 'disabled',
79
- invalid: this.invalid,
80
- focused: hasFocus,
81
- afterElementHasWidth: afterElementHasWidth,
82
- beforeElementExists: !!beforeElement
83
- };
84
- };
85
- this.handleInputRef = node => {
86
- this._input = node;
87
- if (typeof this.props.inputRef === 'function') {
88
- this.props.inputRef(node);
89
- }
90
- };
91
- this.handleChange = event => {
92
- if (typeof this.props.onChange === 'function') {
93
- this.props.onChange(event, event.target.value);
94
- }
95
- };
96
- this.handleBlur = event => {
97
- if (typeof this.props.onBlur === 'function') {
98
- this.props.onBlur(event);
99
- }
100
- this.setState({
101
- hasFocus: false
102
- });
103
- };
104
- this.handleFocus = event => {
105
- if (typeof this.props.onFocus === 'function') {
106
- this.props.onFocus(event);
107
- }
108
- this.setState({
109
- hasFocus: true
110
- });
111
- };
112
- this.state = {
113
- hasFocus: false,
114
- afterElementHasWidth: void 0
115
- };
116
- this._defaultId = props.deterministicId();
117
- this._messagesId = props.deterministicId('TextInput-messages');
118
- }
119
- componentDidMount() {
120
- var _this$props$makeStyle, _this$props;
121
- if (this._input) {
122
- this._focusListener = (0, _addEventListener.addEventListener)(this._input, 'focus', this.handleFocus);
123
- this.setState({
124
- afterElementHasWidth: this.getElementHasWidth(this._afterElement)
125
- });
126
- }
127
- this.adjustAfterElementHeight();
128
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStyleProps());
129
- }
130
- componentWillUnmount() {
131
- if (this._focusListener) {
132
- this._focusListener.remove();
133
- }
134
- }
135
- componentDidUpdate(prevProps) {
136
- var _this$props$makeStyle2, _this$props2;
137
- if (prevProps.renderAfterInput !== this.props.renderAfterInput) {
138
- this.setState({
139
- afterElementHasWidth: this.getElementHasWidth(this._afterElement)
140
- });
141
- }
142
- if ((0, _getInteraction.getInteraction)({
143
- props: prevProps
144
- }) !== 'disabled' && (0, _getInteraction.getInteraction)({
145
- props: this.props
146
- }) === 'disabled') {
147
- this.setState({
148
- hasFocus: false
149
- });
150
- }
151
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStyleProps());
152
- }
153
- adjustAfterElementHeight() {
154
- var _this$_afterElement, _afterElementChild$fi;
155
- const afterElementChild = (_this$_afterElement = this._afterElement) === null || _this$_afterElement === void 0 ? void 0 : _this$_afterElement.firstElementChild;
156
-
157
- // Check if the child is a button, then get the button's first child (the content span)
158
- const buttonContentSpan = (afterElementChild === null || afterElementChild === void 0 ? void 0 : afterElementChild.tagName) === 'BUTTON' ? afterElementChild.firstElementChild : null;
159
-
160
- // This is a necessary workaround for DateInput2 because it uses a Popover, which has a nested Button as an afterElement
161
- // Check if the child is a Popover's inner span containing a button, then get the button's first child (the content span)
162
- 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;
163
- const targetSpan = buttonContentSpan !== null && buttonContentSpan !== void 0 ? buttonContentSpan : popoverContentSpan;
164
- if (targetSpan) {
165
- // Set the height to 36px (the height of a medium TextInput) to avoid layout shift when the afterElement content changes
166
- // this temporary workaround is necessary because otherwise the layout breaks, later on IconButton's default height will be adjusted to the TextInput size
167
- // so this workaround will not be needed anymore
168
- targetSpan.style.height = '36px';
169
- }
170
- }
171
- focus() {
172
- var _this$_input;
173
- (_this$_input = this._input) === null || _this$_input === void 0 ? void 0 : _this$_input.focus();
174
- }
175
- get interaction() {
176
- return (0, _getInteraction.getInteraction)({
177
- props: this.props
178
- });
179
- }
180
- get hasMessages() {
181
- return !!this.props.messages && this.props.messages.length > 0;
182
- }
183
- get invalid() {
184
- return !!this.props.messages && this.props.messages.findIndex(message => {
185
- return message.type === 'error' || message.type === 'newError';
186
- }) >= 0;
187
- }
188
- get focused() {
189
- return (0, _isActiveElement.isActiveElement)(this._input);
190
- }
191
- get value() {
192
- var _this$_input2;
193
- return (_this$_input2 = this._input) === null || _this$_input2 === void 0 ? void 0 : _this$_input2.value;
194
- }
195
- get id() {
196
- return this.props.id || this._defaultId;
197
- }
198
- renderInput() {
199
- var _this$props$styles;
200
- const _this$props3 = this.props,
201
- type = _this$props3.type,
202
- size = _this$props3.size,
203
- htmlSize = _this$props3.htmlSize,
204
- display = _this$props3.display,
205
- textAlign = _this$props3.textAlign,
206
- placeholder = _this$props3.placeholder,
207
- value = _this$props3.value,
208
- defaultValue = _this$props3.defaultValue,
209
- isRequired = _this$props3.isRequired,
210
- onFocus = _this$props3.onFocus,
211
- rest = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
212
- const props = (0, _passthroughProps.passthroughProps)(rest);
213
- const interaction = this.interaction;
214
- let descriptionIds = '';
215
- if (props['aria-describedby']) {
216
- descriptionIds = `${props['aria-describedby']}`;
217
- }
218
- return (0, _jsxRuntime.jsx)("input", {
219
- ...props,
220
- css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.textInput,
221
- defaultValue: defaultValue,
222
- value: value,
223
- placeholder: placeholder,
224
- ref: this.handleInputRef,
225
- type: type,
226
- id: this.id,
227
- required: isRequired,
228
- "aria-invalid": this.invalid ? 'true' : void 0,
229
- disabled: interaction === 'disabled',
230
- readOnly: interaction === 'readonly',
231
- "aria-describedby": descriptionIds !== '' ? descriptionIds : void 0,
232
- size: htmlSize,
233
- onChange: this.handleChange,
234
- onBlur: this.handleBlur
235
- });
236
- }
237
- getElementHasWidth(element) {
238
- if (!element) {
239
- return void 0;
240
- }
241
- const computedStyle = (0, _getCSSStyleDeclaration.getCSSStyleDeclaration)(element);
242
- if (!computedStyle) {
243
- return void 0;
244
- }
245
- const width = computedStyle.width,
246
- paddingInlineStart = computedStyle.paddingInlineStart,
247
- paddingInlineEnd = computedStyle.paddingInlineEnd;
248
- if (width === 'auto' || width === '') {
249
- // This is a workaround for an edge-case, when the TextInput's parent
250
- // is hidden on load, so the element is not visible either.
251
- // In this case the computed width is going to be either 'auto' or '',
252
- // so we assume it has width so that the padding won't be removed.
253
- return true;
254
- }
255
- const elementWidth = parseFloat(width) - parseFloat(paddingInlineStart) - parseFloat(paddingInlineEnd);
256
- return elementWidth > 0;
257
- }
258
- render() {
259
- const _this$props4 = this.props,
260
- width = _this$props4.width,
261
- display = _this$props4.display,
262
- renderLabel = _this$props4.renderLabel,
263
- renderBeforeInput = _this$props4.renderBeforeInput,
264
- renderAfterInput = _this$props4.renderAfterInput,
265
- messages = _this$props4.messages,
266
- inputContainerRef = _this$props4.inputContainerRef,
267
- isRequired = _this$props4.isRequired,
268
- styles = _this$props4.styles;
269
- const beforeElement = renderBeforeInput ? (0, _callRenderProp.callRenderProp)(renderBeforeInput) : null;
270
- const afterElement = renderAfterInput ? (0, _callRenderProp.callRenderProp)(renderAfterInput) : null;
271
- const renderBeforeOrAfter = !!beforeElement || !!afterElement || renderBeforeInput !== void 0 || renderAfterInput !== void 0;
272
- const rawLabel = (0, _callRenderProp.callRenderProp)(renderLabel);
273
- const label = (0, _hasVisibleChildren.hasVisibleChildren)(rawLabel) ? (0, _jsxRuntime.jsxs)(_react.Fragment, {
274
- children: [rawLabel, isRequired && (0, _jsxRuntime.jsxs)("span", {
275
- css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {},
276
- "aria-hidden": true,
277
- children: [' ', "*"]
278
- })]
279
- }) : rawLabel;
280
- return (0, _jsxRuntime.jsx)(_FormField.FormField, {
281
- id: this.id,
282
- label: label,
283
- messagesId: this._messagesId,
284
- messages: messages,
285
- inline: display === 'inline-block',
286
- width: width,
287
- inputContainerRef: inputContainerRef,
288
- layout: this.props.layout,
289
- elementRef: this.handleRef,
290
- margin: this.props.margin,
291
- "data-cid": "TextInput",
292
- children: (0, _jsxRuntime.jsx)("span", {
293
- css: styles === null || styles === void 0 ? void 0 : styles.facade,
294
- children: renderBeforeOrAfter ? (0, _jsxRuntime.jsxs)("span", {
295
- css: styles === null || styles === void 0 ? void 0 : styles.layout,
296
- children: [beforeElement, (0, _jsxRuntime.jsxs)("span", {
297
- css: styles === null || styles === void 0 ? void 0 : styles.inputLayout,
298
- children: [this.renderInput(), afterElement && (0, _jsxRuntime.jsx)("span", {
299
- css: styles === null || styles === void 0 ? void 0 : styles.afterElement,
300
- ref: e => {
301
- this._afterElement = e;
302
- },
303
- children: afterElement
304
- })]
305
- })]
306
- }) : (/* If no prepended or appended content, don't render Flex layout */
307
- this.renderInput())
308
- })
309
- });
310
- }
311
- }, _TextInput.displayName = "TextInput", _TextInput.componentId = 'TextInput', _TextInput.allowedProps = _props.allowedProps, _TextInput.defaultProps = {
312
- type: 'text',
313
- // Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
314
- interaction: void 0,
315
- isRequired: false,
316
- display: 'block',
317
- shouldNotWrap: false,
318
- size: 'medium',
319
- textAlign: 'start',
320
- messages: []
321
- }, _TextInput)) || _class) || _class);
322
- var _default = exports.default = TextInput;
@@ -1,220 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = 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
- /**
32
- * ---
33
- * private: true
34
- * ---
35
- * Generates the style object from the theme and provided additional information
36
- * @param {Object} componentTheme The theme variable object.
37
- * @param {Object} props the props of the component, the style is applied to
38
- * @param {Object} state the state of the component, the style is applied to
39
- * @return {Object} The final style object, which will be used in the component
40
- */
41
- const generateStyle = (componentTheme, props, state) => {
42
- const size = props.size,
43
- textAlign = props.textAlign,
44
- shouldNotWrap = props.shouldNotWrap;
45
- const disabled = state.disabled,
46
- invalid = state.invalid,
47
- focused = state.focused,
48
- afterElementHasWidth = state.afterElementHasWidth,
49
- beforeElementExists = state.beforeElementExists;
50
- const sizeVariants = {
51
- small: {
52
- fontSize: componentTheme.smallFontSize,
53
- height: `calc(${componentTheme.smallHeight} - (2 * ${componentTheme.borderWidth}))`,
54
- lineHeight: `calc(${componentTheme.smallHeight} - (2 * ${componentTheme.borderWidth}))`
55
- },
56
- medium: {
57
- fontSize: componentTheme.mediumFontSize,
58
- height: `calc(${componentTheme.mediumHeight} - (2 * ${componentTheme.borderWidth}))`,
59
- lineHeight: `calc(${componentTheme.mediumHeight} - (2 * ${componentTheme.borderWidth}))`
60
- },
61
- large: {
62
- fontSize: componentTheme.largeFontSize,
63
- height: `calc(${componentTheme.largeHeight} - (2 * ${componentTheme.borderWidth}))`,
64
- lineHeight: `calc(${componentTheme.largeHeight} - (2 * ${componentTheme.borderWidth}))`
65
- }
66
- };
67
- const disabledStyle = disabled ? {
68
- cursor: 'not-allowed',
69
- pointerEvents: 'none',
70
- opacity: '0.5'
71
- } : {};
72
- const focusedStyle = focused ? {
73
- opacity: 1,
74
- transform: 'scale(1)'
75
- } : {
76
- opacity: 0,
77
- transform: 'scale(0.95)'
78
- };
79
- const invalidStyle = invalid ? {
80
- borderColor: componentTheme.errorBorderColor
81
- } : {};
82
- const invalidAndFocusedStyle = invalid && focused ? {
83
- borderColor: componentTheme.errorBorderColor
84
- } : {};
85
- const inputStyle = {
86
- all: 'initial',
87
- '&::-ms-clear': {
88
- display: 'none'
89
- },
90
- width: '100%',
91
- WebkitFontSmoothing: 'antialiased',
92
- MozOsxFontSmoothing: 'grayscale',
93
- appearance: 'none',
94
- margin: 0,
95
- display: 'block',
96
- boxSizing: 'border-box',
97
- outline: 'none',
98
- fontFamily: componentTheme.fontFamily,
99
- fontWeight: componentTheme.fontWeight,
100
- color: componentTheme.color,
101
- padding: `0 ${componentTheme.padding}`,
102
- background: 'transparent',
103
- border: 'none',
104
- verticalAlign: 'baseline',
105
- '&[autocomplete="off"]::-webkit-contacts-auto-fill-button': {
106
- display: 'none !important'
107
- },
108
- '&:focus': {
109
- boxShadow: 'initial'
110
- },
111
- '&::placeholder': {
112
- color: componentTheme.placeholderColor
113
- },
114
- ...sizeVariants[size],
115
- textAlign: textAlign
116
- };
117
- const viewBase = {
118
- boxSizing: 'border-box',
119
- fontFamily: componentTheme.fontFamily,
120
- maxWidth: '100%',
121
- overflow: 'visible',
122
- unicodeBidi: 'isolate'
123
- };
124
- const flexBase = {
125
- ...viewBase,
126
- display: 'flex',
127
- alignItems: 'center',
128
- justifyContent: 'flex-start',
129
- flexDirection: 'row'
130
- };
131
- return {
132
- requiredInvalid: {
133
- color: componentTheme.requiredInvalidColor
134
- },
135
- textInput: {
136
- label: 'textInput',
137
- ...inputStyle,
138
- '&:is(input)[type]': inputStyle,
139
- '&:-webkit-any(input)[type]': inputStyle
140
- },
141
- facade: {
142
- label: 'textInput__facade',
143
- position: 'relative',
144
- display: 'block',
145
- boxSizing: 'border-box',
146
- border: `${componentTheme.borderWidth} ${componentTheme.borderStyle} ${componentTheme.borderColor}`,
147
- borderRadius: componentTheme.borderRadius,
148
- background: componentTheme.background,
149
- color: componentTheme.color,
150
- '&::before': {
151
- content: '""',
152
- pointerEvents: 'none',
153
- position: 'absolute',
154
- display: 'block',
155
- boxSizing: 'border-box',
156
- top: '-0.25rem',
157
- bottom: '-0.25rem',
158
- left: '-0.25rem',
159
- right: '-0.25rem',
160
- border: `${componentTheme.focusOutlineWidth} ${componentTheme.focusOutlineStyle} ${componentTheme.focusOutlineColor}`,
161
- borderRadius: `calc(${componentTheme.borderRadius} * 1.5)`,
162
- transition: 'all 0.2s',
163
- ...focusedStyle,
164
- // properties to transition on :focus
165
- ...invalidAndFocusedStyle
166
- },
167
- ...disabledStyle,
168
- ...invalidStyle
169
- },
170
- layout: {
171
- label: 'textInput__layout',
172
- ...viewBase,
173
- display: 'flex',
174
- alignItems: 'center',
175
- justifyContent: 'flex-start',
176
- flexDirection: 'row',
177
- ...(!shouldNotWrap && {
178
- flexWrap: 'wrap'
179
- }),
180
- ...(beforeElementExists && {
181
- paddingInlineStart: componentTheme.padding
182
- })
183
- },
184
- inputLayout: {
185
- label: 'textInput__inputLayout',
186
- flexGrow: 1,
187
- ...flexBase
188
- },
189
- afterElement: {
190
- // the next couple lines (until the `label`) is needed so the IconButton looks OK inside the TextInput
191
- // explanation: if the content inside is not a button or a popover (which could contain a button) it should have some padding on the right
192
- // lineHeight is only needed if it is not popover or button
193
- '& > :not(button):not([data-position^="Popover"])': {
194
- marginRight: componentTheme.padding,
195
- ...(sizeVariants[size] && {
196
- lineHeight: sizeVariants[size].lineHeight
197
- })
198
- },
199
- display: 'flex',
200
- alignItems: 'center',
201
- // Spread all sizeVariants except lineHeight (handled above)
202
- ...(sizeVariants[size] ?
203
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
204
- (({
205
- lineHeight,
206
- ...rest
207
- }) => rest)(sizeVariants[size]) : {}),
208
- label: 'textInput__afterElement',
209
- ...viewBase,
210
- borderRadius: componentTheme.borderRadius,
211
- flexShrink: 0,
212
- // we only override the padding once the width is calculated,
213
- // it needs the padding on render
214
- ...(afterElementHasWidth === false && {
215
- paddingInlineEnd: 0
216
- })
217
- }
218
- };
219
- };
220
- var _default = exports.default = generateStyle;
@@ -1,79 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = 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
- /**
32
- * Generates the theme object for the component from the theme and provided additional information
33
- * @param {Object} theme The actual theme object.
34
- * @return {Object} The final theme object with the overrides and component variables
35
- */
36
- const generateComponentTheme = theme => {
37
- var _colors$contrasts, _colors$contrasts2, _colors$contrasts3, _colors$contrasts4, _colors$contrasts5, _colors$contrasts6, _colors$contrasts7, _colors$contrasts8;
38
- const colors = theme.colors,
39
- typography = theme.typography,
40
- borders = theme.borders,
41
- spacing = theme.spacing,
42
- forms = theme.forms,
43
- themeName = theme.key;
44
- const themeSpecificStyle = {
45
- canvas: {
46
- color: theme['ic-brand-font-color-dark'],
47
- focusOutlineColor: theme['ic-brand-primary']
48
- }
49
- };
50
- const componentVariables = {
51
- fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
52
- fontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightNormal,
53
- borderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
54
- borderStyle: borders === null || borders === void 0 ? void 0 : borders.style,
55
- borderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.grey3045,
56
- borderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusMedium,
57
- color: colors === null || colors === void 0 ? void 0 : (_colors$contrasts2 = colors.contrasts) === null || _colors$contrasts2 === void 0 ? void 0 : _colors$contrasts2.grey125125,
58
- background: colors === null || colors === void 0 ? void 0 : (_colors$contrasts3 = colors.contrasts) === null || _colors$contrasts3 === void 0 ? void 0 : _colors$contrasts3.white1010,
59
- requiredInvalidColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts4 = colors.contrasts) === null || _colors$contrasts4 === void 0 ? void 0 : _colors$contrasts4.red5782,
60
- padding: spacing === null || spacing === void 0 ? void 0 : spacing.small,
61
- focusOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
62
- focusOutlineStyle: borders === null || borders === void 0 ? void 0 : borders.style,
63
- focusOutlineColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts5 = colors.contrasts) === null || _colors$contrasts5 === void 0 ? void 0 : _colors$contrasts5.blue4570,
64
- errorBorderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts6 = colors.contrasts) === null || _colors$contrasts6 === void 0 ? void 0 : _colors$contrasts6.red4570,
65
- errorOutlineColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts7 = colors.contrasts) === null || _colors$contrasts7 === void 0 ? void 0 : _colors$contrasts7.red4570,
66
- placeholderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts8 = colors.contrasts) === null || _colors$contrasts8 === void 0 ? void 0 : _colors$contrasts8.grey4570,
67
- smallFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeSmall,
68
- smallHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightSmall,
69
- mediumFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
70
- mediumHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightMedium,
71
- largeFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeLarge,
72
- largeHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightLarge
73
- };
74
- return {
75
- ...componentVariables,
76
- ...themeSpecificStyle[themeName]
77
- };
78
- };
79
- var _default = exports.default = generateComponentTheme;
package/lib/index.js DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "TextInput", {
7
- enumerable: true,
8
- get: function () {
9
- return _TextInput.TextInput;
10
- }
11
- });
12
- var _TextInput = require("./TextInput");
package/lib/package.json DELETED
@@ -1 +0,0 @@
1
- {"type":"commonjs"}