@instructure/ui-text-input 11.7.8 → 11.7.9-pr-snapshot-1792147648392
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 +13 -0
- package/es/TextInput/v1/index.js +228 -296
- package/es/TextInput/v1/props.js +27 -26
- package/es/TextInput/v1/styles.js +158 -214
- package/es/TextInput/v1/theme.js +37 -73
- package/es/TextInput/v2/index.js +198 -252
- package/es/TextInput/v2/props.js +31 -26
- package/es/TextInput/v2/styles.js +202 -254
- package/es/exports/a.js +1 -24
- package/es/exports/b.js +1 -24
- package/package.json +15 -21
- package/tsconfig.build.json +0 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/lib/TextInput/v1/index.js +0 -329
- package/lib/TextInput/v1/props.js +0 -31
- package/lib/TextInput/v1/styles.js +0 -224
- package/lib/TextInput/v1/theme.js +0 -80
- package/lib/TextInput/v2/index.js +0 -281
- package/lib/TextInput/v2/props.js +0 -31
- package/lib/TextInput/v2/styles.js +0 -262
- package/lib/exports/a.js +0 -12
- package/lib/exports/b.js +0 -12
- package/lib/package.json +0 -1
|
@@ -1,218 +1,162 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* ---
|
|
27
|
-
* private: true
|
|
28
|
-
* ---
|
|
29
|
-
* Generates the style object from the theme and provided additional information
|
|
30
|
-
* @param {Object} componentTheme The theme variable object.
|
|
31
|
-
* @param {Object} props the props of the component, the style is applied to
|
|
32
|
-
* @param {Object} state the state of the component, the style is applied to
|
|
33
|
-
* @return {Object} The final style object, which will be used in the component
|
|
34
|
-
*/
|
|
35
|
-
const generateStyle = (componentTheme, props, state) => {
|
|
36
|
-
const {
|
|
37
|
-
size,
|
|
38
|
-
textAlign,
|
|
39
|
-
shouldNotWrap
|
|
40
|
-
} = props;
|
|
41
|
-
const {
|
|
42
|
-
disabled,
|
|
43
|
-
invalid,
|
|
44
|
-
focused,
|
|
45
|
-
afterElementHasWidth,
|
|
46
|
-
beforeElementExists
|
|
47
|
-
} = state;
|
|
48
|
-
const sizeVariants = {
|
|
49
|
-
small: {
|
|
50
|
-
fontSize: componentTheme.smallFontSize,
|
|
51
|
-
height: `calc(${componentTheme.smallHeight} - (2 * ${componentTheme.borderWidth}))`,
|
|
52
|
-
lineHeight: `calc(${componentTheme.smallHeight} - (2 * ${componentTheme.borderWidth}))`
|
|
53
|
-
},
|
|
54
|
-
medium: {
|
|
55
|
-
fontSize: componentTheme.mediumFontSize,
|
|
56
|
-
height: `calc(${componentTheme.mediumHeight} - (2 * ${componentTheme.borderWidth}))`,
|
|
57
|
-
lineHeight: `calc(${componentTheme.mediumHeight} - (2 * ${componentTheme.borderWidth}))`
|
|
58
|
-
},
|
|
59
|
-
large: {
|
|
60
|
-
fontSize: componentTheme.largeFontSize,
|
|
61
|
-
height: `calc(${componentTheme.largeHeight} - (2 * ${componentTheme.borderWidth}))`,
|
|
62
|
-
lineHeight: `calc(${componentTheme.largeHeight} - (2 * ${componentTheme.borderWidth}))`
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
const disabledStyle = disabled ? {
|
|
66
|
-
cursor: 'not-allowed',
|
|
67
|
-
pointerEvents: 'none',
|
|
68
|
-
opacity: '0.5'
|
|
69
|
-
} : {};
|
|
70
|
-
const focusedStyle = focused ? {
|
|
71
|
-
opacity: 1,
|
|
72
|
-
transform: 'scale(1)'
|
|
73
|
-
} : {
|
|
74
|
-
opacity: 0,
|
|
75
|
-
transform: 'scale(0.95)'
|
|
76
|
-
};
|
|
77
|
-
const invalidStyle = invalid ? {
|
|
78
|
-
borderColor: componentTheme.errorBorderColor
|
|
79
|
-
} : {};
|
|
80
|
-
const invalidAndFocusedStyle = invalid && focused ? {
|
|
81
|
-
borderColor: componentTheme.errorBorderColor
|
|
82
|
-
} : {};
|
|
83
|
-
const inputStyle = {
|
|
84
|
-
all: 'initial',
|
|
85
|
-
'&::-ms-clear': {
|
|
86
|
-
display: 'none'
|
|
87
|
-
},
|
|
88
|
-
width: '100%',
|
|
89
|
-
WebkitFontSmoothing: 'antialiased',
|
|
90
|
-
MozOsxFontSmoothing: 'grayscale',
|
|
91
|
-
appearance: 'none',
|
|
92
|
-
margin: 0,
|
|
93
|
-
display: 'block',
|
|
94
|
-
boxSizing: 'border-box',
|
|
95
|
-
outline: 'none',
|
|
96
|
-
fontFamily: componentTheme.fontFamily,
|
|
97
|
-
fontWeight: componentTheme.fontWeight,
|
|
98
|
-
color: componentTheme.color,
|
|
99
|
-
padding: `0 ${componentTheme.padding}`,
|
|
100
|
-
background: 'transparent',
|
|
101
|
-
border: 'none',
|
|
102
|
-
verticalAlign: 'baseline',
|
|
103
|
-
'&[autocomplete="off"]::-webkit-contacts-auto-fill-button': {
|
|
104
|
-
display: 'none !important'
|
|
105
|
-
},
|
|
106
|
-
'&:focus': {
|
|
107
|
-
boxShadow: 'initial'
|
|
108
|
-
},
|
|
109
|
-
'&::placeholder': {
|
|
110
|
-
color: componentTheme.placeholderColor
|
|
111
|
-
},
|
|
112
|
-
...sizeVariants[size],
|
|
113
|
-
textAlign: textAlign
|
|
114
|
-
};
|
|
115
|
-
const viewBase = {
|
|
116
|
-
boxSizing: 'border-box',
|
|
117
|
-
fontFamily: componentTheme.fontFamily,
|
|
118
|
-
maxWidth: '100%',
|
|
119
|
-
overflow: 'visible',
|
|
120
|
-
unicodeBidi: 'isolate'
|
|
121
|
-
};
|
|
122
|
-
const flexBase = {
|
|
123
|
-
...viewBase,
|
|
124
|
-
display: 'flex',
|
|
125
|
-
alignItems: 'center',
|
|
126
|
-
justifyContent: 'flex-start',
|
|
127
|
-
flexDirection: 'row'
|
|
128
|
-
};
|
|
129
|
-
return {
|
|
130
|
-
requiredInvalid: {
|
|
131
|
-
color: componentTheme.requiredInvalidColor
|
|
132
|
-
},
|
|
133
|
-
textInput: {
|
|
134
|
-
label: 'textInput',
|
|
135
|
-
...inputStyle,
|
|
136
|
-
'&:is(input)[type]': inputStyle,
|
|
137
|
-
'&:-webkit-any(input)[type]': inputStyle
|
|
138
|
-
},
|
|
139
|
-
facade: {
|
|
140
|
-
label: 'textInput__facade',
|
|
141
|
-
position: 'relative',
|
|
142
|
-
display: 'block',
|
|
143
|
-
boxSizing: 'border-box',
|
|
144
|
-
border: `${componentTheme.borderWidth} ${componentTheme.borderStyle} ${componentTheme.borderColor}`,
|
|
145
|
-
borderRadius: componentTheme.borderRadius,
|
|
146
|
-
background: componentTheme.background,
|
|
147
|
-
color: componentTheme.color,
|
|
148
|
-
'&::before': {
|
|
149
|
-
content: '""',
|
|
1
|
+
const generateStyle = (componentTheme, props, state)=>{
|
|
2
|
+
const { size, textAlign, shouldNotWrap } = props;
|
|
3
|
+
const { disabled, invalid, focused, afterElementHasWidth, beforeElementExists } = state;
|
|
4
|
+
const sizeVariants = {
|
|
5
|
+
small: {
|
|
6
|
+
fontSize: componentTheme.smallFontSize,
|
|
7
|
+
height: `calc(${componentTheme.smallHeight} - (2 * ${componentTheme.borderWidth}))`,
|
|
8
|
+
lineHeight: `calc(${componentTheme.smallHeight} - (2 * ${componentTheme.borderWidth}))`
|
|
9
|
+
},
|
|
10
|
+
medium: {
|
|
11
|
+
fontSize: componentTheme.mediumFontSize,
|
|
12
|
+
height: `calc(${componentTheme.mediumHeight} - (2 * ${componentTheme.borderWidth}))`,
|
|
13
|
+
lineHeight: `calc(${componentTheme.mediumHeight} - (2 * ${componentTheme.borderWidth}))`
|
|
14
|
+
},
|
|
15
|
+
large: {
|
|
16
|
+
fontSize: componentTheme.largeFontSize,
|
|
17
|
+
height: `calc(${componentTheme.largeHeight} - (2 * ${componentTheme.borderWidth}))`,
|
|
18
|
+
lineHeight: `calc(${componentTheme.largeHeight} - (2 * ${componentTheme.borderWidth}))`
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const disabledStyle = disabled ? {
|
|
22
|
+
cursor: 'not-allowed',
|
|
150
23
|
pointerEvents: 'none',
|
|
151
|
-
|
|
24
|
+
opacity: '0.5'
|
|
25
|
+
} : {};
|
|
26
|
+
const focusedStyle = focused ? {
|
|
27
|
+
opacity: 1,
|
|
28
|
+
transform: 'scale(1)'
|
|
29
|
+
} : {
|
|
30
|
+
opacity: 0,
|
|
31
|
+
transform: 'scale(0.95)'
|
|
32
|
+
};
|
|
33
|
+
const invalidStyle = invalid ? {
|
|
34
|
+
borderColor: componentTheme.errorBorderColor
|
|
35
|
+
} : {};
|
|
36
|
+
const invalidAndFocusedStyle = invalid && focused ? {
|
|
37
|
+
borderColor: componentTheme.errorBorderColor
|
|
38
|
+
} : {};
|
|
39
|
+
const inputStyle = {
|
|
40
|
+
all: 'initial',
|
|
41
|
+
'&::-ms-clear': {
|
|
42
|
+
display: 'none'
|
|
43
|
+
},
|
|
44
|
+
width: '100%',
|
|
45
|
+
WebkitFontSmoothing: 'antialiased',
|
|
46
|
+
MozOsxFontSmoothing: 'grayscale',
|
|
47
|
+
appearance: 'none',
|
|
48
|
+
margin: 0,
|
|
152
49
|
display: 'block',
|
|
153
50
|
boxSizing: 'border-box',
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
51
|
+
outline: 'none',
|
|
52
|
+
fontFamily: componentTheme.fontFamily,
|
|
53
|
+
fontWeight: componentTheme.fontWeight,
|
|
54
|
+
color: componentTheme.color,
|
|
55
|
+
padding: `0 ${componentTheme.padding}`,
|
|
56
|
+
background: 'transparent',
|
|
57
|
+
border: 'none',
|
|
58
|
+
verticalAlign: 'baseline',
|
|
59
|
+
'&[autocomplete="off"]::-webkit-contacts-auto-fill-button': {
|
|
60
|
+
display: 'none !important'
|
|
61
|
+
},
|
|
62
|
+
'&:focus': {
|
|
63
|
+
boxShadow: 'initial'
|
|
64
|
+
},
|
|
65
|
+
'&::placeholder': {
|
|
66
|
+
color: componentTheme.placeholderColor
|
|
67
|
+
},
|
|
68
|
+
...sizeVariants[size],
|
|
69
|
+
textAlign: textAlign
|
|
70
|
+
};
|
|
71
|
+
const viewBase = {
|
|
72
|
+
boxSizing: 'border-box',
|
|
73
|
+
fontFamily: componentTheme.fontFamily,
|
|
74
|
+
maxWidth: '100%',
|
|
75
|
+
overflow: 'visible',
|
|
76
|
+
unicodeBidi: 'isolate'
|
|
77
|
+
};
|
|
78
|
+
const flexBase = {
|
|
79
|
+
...viewBase,
|
|
80
|
+
display: 'flex',
|
|
81
|
+
alignItems: 'center',
|
|
82
|
+
justifyContent: 'flex-start',
|
|
83
|
+
flexDirection: 'row'
|
|
84
|
+
};
|
|
85
|
+
return {
|
|
86
|
+
requiredInvalid: {
|
|
87
|
+
color: componentTheme.requiredInvalidColor
|
|
88
|
+
},
|
|
89
|
+
textInput: {
|
|
90
|
+
label: 'textInput',
|
|
91
|
+
...inputStyle,
|
|
92
|
+
'&:is(input)[type]': inputStyle,
|
|
93
|
+
'&:-webkit-any(input)[type]': inputStyle
|
|
94
|
+
},
|
|
95
|
+
facade: {
|
|
96
|
+
label: 'textInput__facade',
|
|
97
|
+
position: 'relative',
|
|
98
|
+
display: 'block',
|
|
99
|
+
boxSizing: 'border-box',
|
|
100
|
+
border: `${componentTheme.borderWidth} ${componentTheme.borderStyle} ${componentTheme.borderColor}`,
|
|
101
|
+
borderRadius: componentTheme.borderRadius,
|
|
102
|
+
background: componentTheme.background,
|
|
103
|
+
color: componentTheme.color,
|
|
104
|
+
'&::before': {
|
|
105
|
+
content: '""',
|
|
106
|
+
pointerEvents: 'none',
|
|
107
|
+
position: 'absolute',
|
|
108
|
+
display: 'block',
|
|
109
|
+
boxSizing: 'border-box',
|
|
110
|
+
top: '-0.25rem',
|
|
111
|
+
bottom: '-0.25rem',
|
|
112
|
+
left: '-0.25rem',
|
|
113
|
+
right: '-0.25rem',
|
|
114
|
+
border: `${componentTheme.focusOutlineWidth} ${componentTheme.focusOutlineStyle} ${componentTheme.focusOutlineColor}`,
|
|
115
|
+
borderRadius: `calc(${componentTheme.borderRadius} * 1.5)`,
|
|
116
|
+
transition: 'all 0.2s',
|
|
117
|
+
...focusedStyle,
|
|
118
|
+
...invalidAndFocusedStyle
|
|
119
|
+
},
|
|
120
|
+
...disabledStyle,
|
|
121
|
+
...invalidStyle
|
|
122
|
+
},
|
|
123
|
+
layout: {
|
|
124
|
+
label: 'textInput__layout',
|
|
125
|
+
...viewBase,
|
|
126
|
+
display: 'flex',
|
|
127
|
+
alignItems: 'center',
|
|
128
|
+
justifyContent: 'flex-start',
|
|
129
|
+
flexDirection: 'row',
|
|
130
|
+
...!shouldNotWrap && {
|
|
131
|
+
flexWrap: 'wrap'
|
|
132
|
+
},
|
|
133
|
+
...beforeElementExists && {
|
|
134
|
+
paddingInlineStart: componentTheme.padding
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
inputLayout: {
|
|
138
|
+
label: 'textInput__inputLayout',
|
|
139
|
+
flexGrow: 1,
|
|
140
|
+
...flexBase
|
|
141
|
+
},
|
|
142
|
+
afterElement: {
|
|
143
|
+
'& > :not(button):not([data-position^="Popover"])': {
|
|
144
|
+
marginRight: componentTheme.padding,
|
|
145
|
+
...sizeVariants[size] && {
|
|
146
|
+
lineHeight: sizeVariants[size].lineHeight
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
display: 'flex',
|
|
150
|
+
alignItems: 'center',
|
|
151
|
+
...sizeVariants[size] ? (({ lineHeight, ...rest })=>rest)(sizeVariants[size]) : {},
|
|
152
|
+
label: 'textInput__afterElement',
|
|
153
|
+
...viewBase,
|
|
154
|
+
borderRadius: componentTheme.borderRadius,
|
|
155
|
+
flexShrink: 0,
|
|
156
|
+
...afterElementHasWidth === false && {
|
|
157
|
+
paddingInlineEnd: 0
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
217
161
|
};
|
|
218
|
-
export default generateStyle;
|
|
162
|
+
export default generateStyle;
|
package/es/TextInput/v1/theme.js
CHANGED
|
@@ -1,74 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
key: themeName
|
|
38
|
-
} = theme;
|
|
39
|
-
const themeSpecificStyle = {
|
|
40
|
-
canvas: {
|
|
41
|
-
color: theme['ic-brand-font-color-dark'],
|
|
42
|
-
focusOutlineColor: theme['ic-brand-primary']
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const componentVariables = {
|
|
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
|
|
68
|
-
};
|
|
69
|
-
return {
|
|
70
|
-
...componentVariables,
|
|
71
|
-
...themeSpecificStyle[themeName]
|
|
72
|
-
};
|
|
1
|
+
const generateComponentTheme = (theme)=>{
|
|
2
|
+
const { colors, typography, borders, spacing, forms, key: themeName } = theme;
|
|
3
|
+
const themeSpecificStyle = {
|
|
4
|
+
canvas: {
|
|
5
|
+
color: theme['ic-brand-font-color-dark'],
|
|
6
|
+
focusOutlineColor: theme['ic-brand-primary']
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
const componentVariables = {
|
|
10
|
+
fontFamily: typography?.fontFamily,
|
|
11
|
+
fontWeight: typography?.fontWeightNormal,
|
|
12
|
+
borderWidth: borders?.widthSmall,
|
|
13
|
+
borderStyle: borders?.style,
|
|
14
|
+
borderColor: colors?.contrasts?.grey3045,
|
|
15
|
+
borderRadius: borders?.radiusMedium,
|
|
16
|
+
color: colors?.contrasts?.grey125125,
|
|
17
|
+
background: colors?.contrasts?.white1010,
|
|
18
|
+
requiredInvalidColor: colors?.contrasts?.red5782,
|
|
19
|
+
padding: spacing?.small,
|
|
20
|
+
focusOutlineWidth: borders?.widthMedium,
|
|
21
|
+
focusOutlineStyle: borders?.style,
|
|
22
|
+
focusOutlineColor: colors?.contrasts?.blue4570,
|
|
23
|
+
errorBorderColor: colors?.contrasts?.red4570,
|
|
24
|
+
errorOutlineColor: colors?.contrasts?.red4570,
|
|
25
|
+
placeholderColor: colors?.contrasts?.grey4570,
|
|
26
|
+
smallFontSize: typography?.fontSizeSmall,
|
|
27
|
+
smallHeight: forms?.inputHeightSmall,
|
|
28
|
+
mediumFontSize: typography?.fontSizeMedium,
|
|
29
|
+
mediumHeight: forms?.inputHeightMedium,
|
|
30
|
+
largeFontSize: typography?.fontSizeLarge,
|
|
31
|
+
largeHeight: forms?.inputHeightLarge
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
...componentVariables,
|
|
35
|
+
...themeSpecificStyle[themeName]
|
|
36
|
+
};
|
|
73
37
|
};
|
|
74
|
-
export default generateComponentTheme;
|
|
38
|
+
export default generateComponentTheme;
|