@instructure/ui-text-input 11.6.0 → 11.6.1-snapshot-129

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +47 -305
  2. package/es/TextInput/{index.js → v1/index.js} +2 -2
  3. package/es/TextInput/v2/index.js +308 -0
  4. package/es/TextInput/v2/props.js +26 -0
  5. package/es/TextInput/v2/styles.js +234 -0
  6. package/es/TextInput/v2/theme.js +73 -0
  7. package/es/{index.js → exports/a.js} +1 -1
  8. package/{src/index.ts → es/exports/b.js} +1 -2
  9. package/lib/TextInput/{index.js → v1/index.js} +3 -3
  10. package/lib/TextInput/v2/index.js +319 -0
  11. package/lib/TextInput/v2/props.js +31 -0
  12. package/lib/TextInput/v2/styles.js +239 -0
  13. package/lib/TextInput/v2/theme.js +79 -0
  14. package/lib/{index.js → exports/a.js} +2 -2
  15. package/lib/exports/b.js +12 -0
  16. package/package.json +45 -24
  17. package/src/TextInput/{index.tsx → v1/index.tsx} +2 -2
  18. package/src/TextInput/{props.ts → v1/props.ts} +1 -1
  19. package/src/TextInput/v2/README.md +334 -0
  20. package/src/TextInput/v2/index.tsx +406 -0
  21. package/src/TextInput/v2/props.ts +244 -0
  22. package/src/TextInput/v2/styles.ts +245 -0
  23. package/src/TextInput/v2/theme.ts +84 -0
  24. package/src/exports/a.ts +25 -0
  25. package/src/exports/b.ts +25 -0
  26. package/tsconfig.build.json +0 -3
  27. package/tsconfig.build.tsbuildinfo +1 -1
  28. package/types/TextInput/{index.d.ts → v1/index.d.ts} +1 -1
  29. package/types/TextInput/v1/index.d.ts.map +1 -0
  30. package/types/TextInput/{props.d.ts → v1/props.d.ts} +1 -1
  31. package/types/TextInput/v1/props.d.ts.map +1 -0
  32. package/types/TextInput/v1/styles.d.ts.map +1 -0
  33. package/types/TextInput/v1/theme.d.ts.map +1 -0
  34. package/types/TextInput/v2/index.d.ts +79 -0
  35. package/types/TextInput/v2/index.d.ts.map +1 -0
  36. package/types/TextInput/v2/props.d.ts +138 -0
  37. package/types/TextInput/v2/props.d.ts.map +1 -0
  38. package/types/TextInput/v2/styles.d.ts +16 -0
  39. package/types/TextInput/v2/styles.d.ts.map +1 -0
  40. package/types/TextInput/v2/theme.d.ts +10 -0
  41. package/types/TextInput/v2/theme.d.ts.map +1 -0
  42. package/types/exports/a.d.ts +3 -0
  43. package/types/exports/a.d.ts.map +1 -0
  44. package/types/exports/b.d.ts +3 -0
  45. package/types/exports/b.d.ts.map +1 -0
  46. package/types/TextInput/index.d.ts.map +0 -1
  47. package/types/TextInput/props.d.ts.map +0 -1
  48. package/types/TextInput/styles.d.ts.map +0 -1
  49. package/types/TextInput/theme.d.ts.map +0 -1
  50. package/types/index.d.ts +0 -3
  51. package/types/index.d.ts.map +0 -1
  52. /package/es/TextInput/{props.js → v1/props.js} +0 -0
  53. /package/es/TextInput/{styles.js → v1/styles.js} +0 -0
  54. /package/es/TextInput/{theme.js → v1/theme.js} +0 -0
  55. /package/lib/TextInput/{props.js → v1/props.js} +0 -0
  56. /package/lib/TextInput/{styles.js → v1/styles.js} +0 -0
  57. /package/lib/TextInput/{theme.js → v1/theme.js} +0 -0
  58. /package/src/TextInput/{README.md → v1/README.md} +0 -0
  59. /package/src/TextInput/{styles.ts → v1/styles.ts} +0 -0
  60. /package/src/TextInput/{theme.ts → v1/theme.ts} +0 -0
  61. /package/types/TextInput/{styles.d.ts → v1/styles.d.ts} +0 -0
  62. /package/types/TextInput/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,245 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type { NewComponentTypes, SharedTokens } from '@instructure/ui-themes'
26
+ import { TextInputProps, TextInputStyle, TextInputStyleProps } from './props'
27
+ import { calcFocusOutlineStyles } from '@instructure/emotion'
28
+
29
+ /**
30
+ * ---
31
+ * private: true
32
+ * ---
33
+ * Generates the style object from the theme and provided additional information
34
+ * @param componentTheme The theme variable object.
35
+ * @param props the props of the component, the style is applied to
36
+ * @param sharedTokens Shared token object that stores common values for the theme.
37
+ * @param state the state of the component, the style is applied to
38
+ * @return The final style object, which will be used in the component
39
+ */
40
+ const generateStyle = (
41
+ componentTheme: NewComponentTypes['TextInput'],
42
+ props: TextInputProps,
43
+ sharedTokens: SharedTokens,
44
+ state: TextInputStyleProps
45
+ ): TextInputStyle => {
46
+ const { size, textAlign, shouldNotWrap } = props
47
+ const {
48
+ interaction,
49
+ success,
50
+ invalid,
51
+ afterElementHasWidth,
52
+ beforeElementExists
53
+ } = state
54
+
55
+ const sizeVariants = {
56
+ small: {
57
+ fontSize: componentTheme.fontSizeSm,
58
+ height: `calc(${componentTheme.heightSm} - (2 * ${componentTheme.borderWidth}))`,
59
+ lineHeight: `calc(${componentTheme.heightSm} - (2 * ${componentTheme.borderWidth}))`
60
+ },
61
+ medium: {
62
+ fontSize: componentTheme.fontSizeMd,
63
+ height: `calc(${componentTheme.heightMd} - (2 * ${componentTheme.borderWidth}))`,
64
+ lineHeight: `calc(${componentTheme.heightMd} - (2 * ${componentTheme.borderWidth}))`
65
+ },
66
+ large: {
67
+ fontSize: componentTheme.fontSizeLg,
68
+ height: `calc(${componentTheme.heightLg} - (2 * ${componentTheme.borderWidth}))`,
69
+ lineHeight: `calc(${componentTheme.heightLg} - (2 * ${componentTheme.borderWidth}))`
70
+ }
71
+ }
72
+ const paddingHorizontalVariants = {
73
+ small: componentTheme.paddingHorizontalSm,
74
+ medium: componentTheme.paddingHorizontalMd,
75
+ large: componentTheme.paddingHorizontalLg
76
+ }
77
+
78
+ const inputInteractionStates = {
79
+ ...(interaction === 'enabled' && {
80
+ color: componentTheme.textColor,
81
+ '&::placeholder': {
82
+ color: componentTheme.placeholderColor
83
+ },
84
+ '&:hover::placeholder': {
85
+ color: componentTheme.placeholderHoverColor
86
+ }
87
+ // placeholder is not rendered in the `readOnly` and `disabled` state
88
+ }),
89
+ ...(interaction === 'readonly' && {
90
+ color: componentTheme.textReadonlyColor
91
+ }),
92
+ ...(interaction === 'disabled' && {
93
+ color: componentTheme.textDisabledColor
94
+ })
95
+ }
96
+
97
+ const inputStyle = {
98
+ all: 'initial',
99
+ width: '100%',
100
+ WebkitFontSmoothing: 'antialiased',
101
+ MozOsxFontSmoothing: 'grayscale',
102
+ appearance: 'none',
103
+ margin: 0,
104
+ display: 'block',
105
+ boxSizing: 'border-box',
106
+ outline: 'none',
107
+ fontFamily: componentTheme.fontFamily,
108
+ fontWeight: componentTheme.fontWeight,
109
+ // padding of the text in the input
110
+ padding: `0 ${componentTheme.gapContent} 0 ${componentTheme.gapContent}`,
111
+ background: 'transparent',
112
+ border: 'none',
113
+ verticalAlign: 'baseline',
114
+ '&[autocomplete="off"]::-webkit-contacts-auto-fill-button': {
115
+ display: 'none !important'
116
+ },
117
+ '&:focus': {
118
+ boxShadow: 'initial'
119
+ },
120
+ ...sizeVariants[size!],
121
+ textAlign: textAlign,
122
+ ...inputInteractionStates
123
+ }
124
+
125
+ const viewBase = {
126
+ boxSizing: 'border-box',
127
+ fontFamily: componentTheme.fontFamily,
128
+ maxWidth: '100%',
129
+ overflow: 'visible',
130
+ unicodeBidi: 'isolate'
131
+ }
132
+
133
+ const containerInteractionStates = {
134
+ ...(interaction === 'enabled' && {
135
+ backgroundColor: componentTheme.backgroundColor,
136
+ borderColor: componentTheme.borderColor,
137
+ ...(success && {
138
+ borderColor: componentTheme.successBorderColor
139
+ }),
140
+ ...(invalid && {
141
+ borderColor: componentTheme.errorBorderColor
142
+ }),
143
+ '&:hover': {
144
+ backgroundColor: componentTheme.backgroundHoverColor,
145
+ borderColor: componentTheme.borderHoverColor,
146
+ ...(success && {
147
+ borderColor: componentTheme.successBorderColor
148
+ }),
149
+ ...(invalid && {
150
+ borderColor: componentTheme.errorBorderColor
151
+ })
152
+ }
153
+ }),
154
+ ...(interaction === 'readonly' && {
155
+ backgroundColor: componentTheme.backgroundReadonlyColor,
156
+ borderColor: componentTheme.borderReadonlyColor
157
+ }),
158
+ ...(interaction === 'disabled' && {
159
+ cursor: 'not-allowed',
160
+ pointerEvents: 'none',
161
+ backgroundColor: componentTheme.backgroundDisabledColor,
162
+ borderColor: componentTheme.borderDisabledColor
163
+ })
164
+ }
165
+
166
+ const focusOutline = calcFocusOutlineStyles(sharedTokens.focusOutline, {
167
+ focusColor: invalid ? 'danger' : success ? 'success' : undefined,
168
+ // Only display the focus outline when the input is focused.
169
+ // This is to prevent double focus ring when e.g., a Button is rendered in
170
+ // `renderBeforeInput`
171
+ customCSSSelector: '&:has(input:focus)'
172
+ })
173
+
174
+ return {
175
+ textInput: {
176
+ label: 'textInput',
177
+ ...inputStyle,
178
+ '&:is(input)[type]': inputStyle,
179
+ '&:-webkit-any(input)[type]': inputStyle
180
+ },
181
+ facade: {
182
+ label: 'textInput__facade',
183
+ position: 'relative',
184
+ display: 'block',
185
+ boxSizing: 'border-box',
186
+ border: `${componentTheme.borderWidth} solid`,
187
+ borderRadius: componentTheme.borderRadius,
188
+ color: componentTheme.textColor,
189
+ ...containerInteractionStates,
190
+ ...focusOutline
191
+ },
192
+ layout: {
193
+ label: 'textInput__layout',
194
+ ...viewBase,
195
+ display: 'flex',
196
+ alignItems: 'center',
197
+ justifyContent: 'flex-start',
198
+ flexDirection: 'row',
199
+ ...(!shouldNotWrap && { flexWrap: 'wrap' }),
200
+ // left padding of the `renderBeforeInput` element
201
+ ...(beforeElementExists && {
202
+ paddingInlineStart: paddingHorizontalVariants[size!]
203
+ })
204
+ },
205
+ inputLayout: {
206
+ label: 'textInput__inputLayout',
207
+ flexGrow: 1,
208
+ ...viewBase,
209
+ display: 'flex',
210
+ alignItems: 'center',
211
+ justifyContent: 'flex-start',
212
+ flexDirection: 'row'
213
+ },
214
+ afterElement: {
215
+ // the next couple lines (until the `label`) is needed so the IconButton looks OK inside the TextInput
216
+ // 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
217
+ // lineHeight is only needed if it is not popover or button
218
+ '& > :not(button):not([data-position^="Popover"])': {
219
+ marginRight: paddingHorizontalVariants[size!]
220
+ // TODO check if it looks OK with the new buttons. With this it does not look OK with new icons
221
+ //...(sizeVariants[size!] && {
222
+ // lineHeight: sizeVariants[size!]?.lineHeight
223
+ //})
224
+ },
225
+ display: 'flex',
226
+ alignItems: 'center',
227
+ // Spread all sizeVariants except lineHeight (handled above)
228
+ ...(sizeVariants[size!]
229
+ ? // eslint-disable-next-line @typescript-eslint/no-unused-vars
230
+ (({ lineHeight, ...rest }) => rest)(sizeVariants[size!])
231
+ : {}),
232
+ label: 'textInput__afterElement',
233
+ ...viewBase,
234
+ borderRadius: componentTheme.borderRadius,
235
+ flexShrink: 0,
236
+ // we only override the padding once the width is calculated,
237
+ // it needs the padding on render
238
+ ...(afterElementHasWidth === false && {
239
+ paddingInlineEnd: 0
240
+ })
241
+ }
242
+ }
243
+ }
244
+
245
+ export default generateStyle
@@ -0,0 +1,84 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type { Theme, ThemeSpecificStyle } from '@instructure/ui-themes'
26
+ import { TextInputTheme } from '@instructure/shared-types'
27
+
28
+ /**
29
+ * Generates the theme object for the component from the theme and provided additional information
30
+ * @param {Object} theme The actual theme object.
31
+ * @return {Object} The final theme object with the overrides and component variables
32
+ */
33
+ const generateComponentTheme = (theme: Theme): TextInputTheme => {
34
+ const { colors, typography, borders, spacing, forms, key: themeName } = theme
35
+
36
+ const themeSpecificStyle: ThemeSpecificStyle<TextInputTheme> = {
37
+ canvas: {
38
+ color: theme['ic-brand-font-color-dark'],
39
+ focusOutlineColor: theme['ic-brand-primary']
40
+ }
41
+ }
42
+
43
+ const componentVariables: TextInputTheme = {
44
+ fontFamily: typography?.fontFamily,
45
+ fontWeight: typography?.fontWeightNormal,
46
+
47
+ borderWidth: borders?.widthSmall,
48
+ borderStyle: borders?.style,
49
+ borderColor: colors?.contrasts?.grey3045,
50
+ borderRadius: borders?.radiusMedium,
51
+
52
+ color: colors?.contrasts?.grey125125,
53
+ background: colors?.contrasts?.white1010,
54
+
55
+ requiredInvalidColor: colors?.contrasts?.red5782,
56
+
57
+ padding: spacing?.small,
58
+
59
+ focusOutlineWidth: borders?.widthMedium,
60
+ focusOutlineStyle: borders?.style,
61
+ focusOutlineColor: colors?.contrasts?.blue4570,
62
+
63
+ errorBorderColor: colors?.contrasts?.red4570,
64
+ errorOutlineColor: colors?.contrasts?.red4570,
65
+
66
+ placeholderColor: colors?.contrasts?.grey4570,
67
+
68
+ smallFontSize: typography?.fontSizeSmall,
69
+ smallHeight: forms?.inputHeightSmall,
70
+
71
+ mediumFontSize: typography?.fontSizeMedium,
72
+ mediumHeight: forms?.inputHeightMedium,
73
+
74
+ largeFontSize: typography?.fontSizeLarge,
75
+ largeHeight: forms?.inputHeightLarge
76
+ }
77
+
78
+ return {
79
+ ...componentVariables,
80
+ ...themeSpecificStyle[themeName]
81
+ }
82
+ }
83
+
84
+ export default generateComponentTheme
@@ -0,0 +1,25 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ export { TextInput } from '../TextInput/v1'
25
+ export type { TextInputProps } from '../TextInput/v1/props'
@@ -0,0 +1,25 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ export { TextInput } from '../TextInput/v2'
25
+ export type { TextInputProps } from '../TextInput/v2/props'
@@ -34,9 +34,6 @@
34
34
  {
35
35
  "path": "../ui-form-field/tsconfig.build.json"
36
36
  },
37
- {
38
- "path": "../ui-icons/tsconfig.build.json"
39
- },
40
37
  {
41
38
  "path": "../ui-react-utils/tsconfig.build.json"
42
39
  },