@toptal/picasso-outlined-input 1.1.5 → 2.0.0
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/dist-package/src/OutlinedInput/OutlinedInput.d.ts +1 -48
- package/dist-package/src/OutlinedInput/OutlinedInput.d.ts.map +1 -1
- package/dist-package/src/OutlinedInput/OutlinedInput.js +58 -35
- package/dist-package/src/OutlinedInput/OutlinedInput.js.map +1 -1
- package/dist-package/src/OutlinedInput/index.d.ts +2 -1
- package/dist-package/src/OutlinedInput/index.d.ts.map +1 -1
- package/dist-package/src/OutlinedInput/stylesInput.d.ts +24 -0
- package/dist-package/src/OutlinedInput/stylesInput.d.ts.map +1 -0
- package/dist-package/src/OutlinedInput/stylesInput.js +60 -0
- package/dist-package/src/OutlinedInput/stylesInput.js.map +1 -0
- package/dist-package/src/OutlinedInput/stylesRoot.d.ts +66 -0
- package/dist-package/src/OutlinedInput/stylesRoot.d.ts.map +1 -0
- package/dist-package/src/OutlinedInput/stylesRoot.js +142 -0
- package/dist-package/src/OutlinedInput/stylesRoot.js.map +1 -0
- package/dist-package/src/OutlinedInput/types.d.ts +62 -0
- package/dist-package/src/OutlinedInput/types.d.ts.map +1 -0
- package/dist-package/src/OutlinedInput/types.js +2 -0
- package/dist-package/src/OutlinedInput/types.js.map +1 -0
- package/dist-package/src/OutlinedInput/utils.d.ts +2 -0
- package/dist-package/src/OutlinedInput/utils.d.ts.map +1 -0
- package/dist-package/src/OutlinedInput/utils.js +2 -0
- package/dist-package/src/OutlinedInput/utils.js.map +1 -0
- package/package.json +10 -9
- package/src/OutlinedInput/OutlinedInput.tsx +95 -129
- package/src/OutlinedInput/index.ts +2 -1
- package/src/OutlinedInput/stylesInput.test.ts +152 -0
- package/src/OutlinedInput/stylesInput.ts +87 -0
- package/src/OutlinedInput/stylesRoot.test.ts +195 -0
- package/src/OutlinedInput/stylesRoot.ts +217 -0
- package/src/OutlinedInput/types.ts +87 -0
- package/src/OutlinedInput/utils.ts +2 -0
- package/dist-package/src/OutlinedInput/styles.d.ts +0 -4
- package/dist-package/src/OutlinedInput/styles.d.ts.map +0 -1
- package/dist-package/src/OutlinedInput/styles.js +0 -157
- package/dist-package/src/OutlinedInput/styles.js.map +0 -1
- package/dist-package/src/styles.d.ts +0 -2
- package/dist-package/src/styles.d.ts.map +0 -1
- package/dist-package/src/styles.js +0 -2
- package/dist-package/src/styles.js.map +0 -1
- package/src/OutlinedInput/styles.ts +0 -183
- package/src/styles.ts +0 -1
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import type { FieldLayout } from '@toptal/picasso-form'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
getRootClassName,
|
|
5
|
+
spacingBySize,
|
|
6
|
+
heightClasses,
|
|
7
|
+
fontColorClass,
|
|
8
|
+
cursorClass,
|
|
9
|
+
bgClasses,
|
|
10
|
+
widthClasses,
|
|
11
|
+
rootBasicClasses,
|
|
12
|
+
} from './stylesRoot'
|
|
13
|
+
import type { WidthType, Size } from './types'
|
|
14
|
+
|
|
15
|
+
describe('getRootClassName', () => {
|
|
16
|
+
const baseProps = {
|
|
17
|
+
isDark: false,
|
|
18
|
+
layout: 'vertical' as FieldLayout,
|
|
19
|
+
isError: false,
|
|
20
|
+
size: 'medium' as Size,
|
|
21
|
+
width: 'auto' as WidthType,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
describe('when determining spacing by size', () => {
|
|
25
|
+
it.each([
|
|
26
|
+
['small', spacingBySize.small],
|
|
27
|
+
['medium', spacingBySize.medium],
|
|
28
|
+
['large', spacingBySize.large],
|
|
29
|
+
])(
|
|
30
|
+
'returns the correct spacing class for size "%s"',
|
|
31
|
+
(size, expectedClass) => {
|
|
32
|
+
const result = getRootClassName({ ...baseProps, size: size as Size })
|
|
33
|
+
|
|
34
|
+
expect(result).toContain(expectedClass)
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
describe('when determining height classes', () => {
|
|
40
|
+
describe('when multiline is false', () => {
|
|
41
|
+
it.each([
|
|
42
|
+
['small', heightClasses.singleline.small],
|
|
43
|
+
['medium', heightClasses.singleline.medium],
|
|
44
|
+
['large', heightClasses.singleline.large],
|
|
45
|
+
])(
|
|
46
|
+
'returns the correct height class for singleline "%s"',
|
|
47
|
+
(size, expectedClass) => {
|
|
48
|
+
const result = getRootClassName({
|
|
49
|
+
...baseProps,
|
|
50
|
+
multiline: false,
|
|
51
|
+
size: size as Size,
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
expect(result).toContain(expectedClass)
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
describe('when multiline is true', () => {
|
|
60
|
+
it('returns the correct class for multiline', () => {
|
|
61
|
+
const result = getRootClassName({ ...baseProps, multiline: true })
|
|
62
|
+
|
|
63
|
+
expect(result).toContain(heightClasses.multiline)
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
describe('when determining width classes', () => {
|
|
69
|
+
describe('when layout is horizontal', () => {
|
|
70
|
+
it('returns the correct width class for horizontal layout', () => {
|
|
71
|
+
const result = getRootClassName({ ...baseProps, layout: 'horizontal' })
|
|
72
|
+
|
|
73
|
+
expect(result).toContain(widthClasses.horizontal)
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it.each([
|
|
78
|
+
['full', widthClasses.full],
|
|
79
|
+
['shrink', widthClasses.shrink],
|
|
80
|
+
['auto', widthClasses.auto],
|
|
81
|
+
])('returns the correct width class for "%s"', (width, expectedClass) => {
|
|
82
|
+
const result = getRootClassName({
|
|
83
|
+
...baseProps,
|
|
84
|
+
width: width as WidthType,
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
expect(result).toContain(expectedClass)
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
describe('when determining background color classes', () => {
|
|
92
|
+
describe('when input is disabled', () => {
|
|
93
|
+
it('returns the correct bg class for disabled', () => {
|
|
94
|
+
const result = getRootClassName({ ...baseProps, disabled: true })
|
|
95
|
+
|
|
96
|
+
expect(result).toContain(bgClasses.disabled)
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
describe('when in dark mode', () => {
|
|
101
|
+
it('returns the correct bg class for dark mode', () => {
|
|
102
|
+
const result = getRootClassName({ ...baseProps, isDark: true })
|
|
103
|
+
|
|
104
|
+
expect(result).toContain(bgClasses.dark)
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
describe('when highlight is "autofill"', () => {
|
|
109
|
+
it('returns the correct bg class for highlight "autofill"', () => {
|
|
110
|
+
const result = getRootClassName({ ...baseProps, highlight: 'autofill' })
|
|
111
|
+
|
|
112
|
+
expect(result).toContain(bgClasses.highlight)
|
|
113
|
+
})
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
describe('in the default case', () => {
|
|
117
|
+
it('returns the default bg class', () => {
|
|
118
|
+
const result = getRootClassName(baseProps)
|
|
119
|
+
|
|
120
|
+
expect(result).toContain(bgClasses.default)
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
describe('when determining border pseudo element classes', () => {
|
|
126
|
+
// Example only, needs additional detail on how it is structured
|
|
127
|
+
it('returns correct classes for default state', () => {
|
|
128
|
+
const result = getRootClassName(baseProps)
|
|
129
|
+
|
|
130
|
+
expect(result).toContainEqual(expect.arrayContaining(rootBasicClasses))
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
describe('when input is disabled', () => {
|
|
134
|
+
it('returns correct classes for disabled state', () => {
|
|
135
|
+
const result = getRootClassName({ ...baseProps, disabled: true })
|
|
136
|
+
|
|
137
|
+
expect(result).toContainEqual(expect.arrayContaining(rootBasicClasses))
|
|
138
|
+
})
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
describe('when there is an error', () => {
|
|
142
|
+
it('returns correct classes for error state', () => {
|
|
143
|
+
const result = getRootClassName({ ...baseProps, isError: true })
|
|
144
|
+
|
|
145
|
+
expect(result).toContainEqual(expect.arrayContaining(rootBasicClasses))
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
describe('when determining text color classes', () => {
|
|
150
|
+
describe('when input is disabled', () => {
|
|
151
|
+
it('returns correct text color class for disabled state', () => {
|
|
152
|
+
const result = getRootClassName({ ...baseProps, disabled: true })
|
|
153
|
+
|
|
154
|
+
expect(result).toContain(fontColorClass.disabled)
|
|
155
|
+
})
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
describe('in the default case', () => {
|
|
159
|
+
it('returns correct text color class for default state', () => {
|
|
160
|
+
const result = getRootClassName(baseProps)
|
|
161
|
+
|
|
162
|
+
expect(result).toContain(fontColorClass.default)
|
|
163
|
+
})
|
|
164
|
+
})
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
describe('when determining cursor classes', () => {
|
|
168
|
+
describe('when input is disabled', () => {
|
|
169
|
+
it('returns correct cursor class for disabled state', () => {
|
|
170
|
+
const result = getRootClassName({ ...baseProps, disabled: true })
|
|
171
|
+
|
|
172
|
+
expect(result).toContain(cursorClass.disabled)
|
|
173
|
+
})
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
describe('in the default case', () => {
|
|
177
|
+
it('returns correct cursor class for default state', () => {
|
|
178
|
+
const result = getRootClassName(baseProps)
|
|
179
|
+
|
|
180
|
+
expect(result).toContain(cursorClass.default)
|
|
181
|
+
})
|
|
182
|
+
})
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
describe('when determining visibility based on input type', () => {
|
|
186
|
+
describe('when type is "hidden"', () => {
|
|
187
|
+
it('returns "hidden" class for input type hidden', () => {
|
|
188
|
+
const result = getRootClassName({ ...baseProps, type: 'hidden' })
|
|
189
|
+
|
|
190
|
+
expect(result).toContain('hidden')
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
})
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
2
|
+
import type { FieldLayout } from '@toptal/picasso-form'
|
|
3
|
+
|
|
4
|
+
import type { WidthType, Size, Props } from './types'
|
|
5
|
+
|
|
6
|
+
export const spacingBySize: Record<Size, string> = {
|
|
7
|
+
small: 'py-1 px-[0.625rem]',
|
|
8
|
+
medium: 'p-2',
|
|
9
|
+
large: 'p-3',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const heightClasses = {
|
|
13
|
+
singleline: {
|
|
14
|
+
small: 'h-6',
|
|
15
|
+
medium: 'h-8',
|
|
16
|
+
large: 'h-12',
|
|
17
|
+
} as Record<Size, string>,
|
|
18
|
+
multiline: 'h-auto',
|
|
19
|
+
} as const
|
|
20
|
+
|
|
21
|
+
export const fontColorClass = {
|
|
22
|
+
default: 'text-black',
|
|
23
|
+
disabled: 'text-gray-500',
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const cursorClass = {
|
|
27
|
+
default: 'cursor-[inherit]',
|
|
28
|
+
disabled: 'cursor-default',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const bgClasses = {
|
|
32
|
+
disabled: 'bg-gray-100',
|
|
33
|
+
dark: 'bg-[#081237]',
|
|
34
|
+
highlight: 'bg-yellow-100/60',
|
|
35
|
+
default: 'bg-white',
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const widthClasses: Record<WidthType | FieldLayout, string> = {
|
|
39
|
+
full: 'w-full',
|
|
40
|
+
shrink: 'w-auto',
|
|
41
|
+
auto: 'w-[18.75rem]',
|
|
42
|
+
horizontal: 'w-full',
|
|
43
|
+
vertical: '',
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const borderPseudoCoreClasses = [
|
|
47
|
+
'after:content-[""]',
|
|
48
|
+
'after:inline-block',
|
|
49
|
+
'after:absolute',
|
|
50
|
+
|
|
51
|
+
'after:top-0',
|
|
52
|
+
'after:bottom-0',
|
|
53
|
+
'after:right-0',
|
|
54
|
+
'after:left-0',
|
|
55
|
+
|
|
56
|
+
'after:pointer-events-none',
|
|
57
|
+
|
|
58
|
+
'after:border-solid',
|
|
59
|
+
'after:rounded-sm',
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
export const borderPseudoClassesByState = {
|
|
63
|
+
borderColor: {
|
|
64
|
+
dark: '',
|
|
65
|
+
default: [
|
|
66
|
+
'after:border-gray-400',
|
|
67
|
+
'[&:has(input:focus)]:after:border-blue-500',
|
|
68
|
+
],
|
|
69
|
+
disabled: 'after:border-gray-200',
|
|
70
|
+
error: [
|
|
71
|
+
'after:border-red-500',
|
|
72
|
+
'[&:has(input:focus)]:after:border-red-500',
|
|
73
|
+
],
|
|
74
|
+
hoverWithoutFocus: 'hover:[&:not(:has(input:focus))]:after:border-gray-600',
|
|
75
|
+
},
|
|
76
|
+
border: {
|
|
77
|
+
dark: 'after:border-none',
|
|
78
|
+
default: 'after:border',
|
|
79
|
+
disabled: '',
|
|
80
|
+
error: '',
|
|
81
|
+
},
|
|
82
|
+
shadow: {
|
|
83
|
+
dark: '[&:has(input:focus)]:after:shadow-0',
|
|
84
|
+
default: [
|
|
85
|
+
'[&:has(input:focus)]:after:shadow-[0_0_0_3px]',
|
|
86
|
+
'[&:has(input:focus)]:after:shadow-blue-500/[.48]',
|
|
87
|
+
],
|
|
88
|
+
disabled: '',
|
|
89
|
+
error: [
|
|
90
|
+
'[&:has(input:focus)]:after:shadow-[0_0_0_3px]',
|
|
91
|
+
'[&:has(input:focus)]:after:shadow-red-500/[.48]',
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export const rootBasicClasses = [
|
|
97
|
+
'relative',
|
|
98
|
+
'text-black',
|
|
99
|
+
'inline-flex',
|
|
100
|
+
'gap-y-1',
|
|
101
|
+
'gap-x-2',
|
|
102
|
+
'items-center',
|
|
103
|
+
'rounded-sm',
|
|
104
|
+
'[font-size:_unset]',
|
|
105
|
+
'hover:[&_.resetButtonDirty]:visible',
|
|
106
|
+
]
|
|
107
|
+
|
|
108
|
+
export const getHeightClasses = ({
|
|
109
|
+
size,
|
|
110
|
+
multiline,
|
|
111
|
+
}: {
|
|
112
|
+
size: Size
|
|
113
|
+
multiline: boolean | undefined
|
|
114
|
+
}) => (multiline ? heightClasses.multiline : heightClasses.singleline[size])
|
|
115
|
+
|
|
116
|
+
export const getWidthClasses = ({
|
|
117
|
+
width,
|
|
118
|
+
layout,
|
|
119
|
+
}: {
|
|
120
|
+
width: WidthType
|
|
121
|
+
layout: FieldLayout
|
|
122
|
+
}) => (layout === 'horizontal' ? widthClasses.horizontal : widthClasses[width])
|
|
123
|
+
|
|
124
|
+
export const getBackgroundColorClasses = ({
|
|
125
|
+
isDark,
|
|
126
|
+
disabled,
|
|
127
|
+
highlight,
|
|
128
|
+
}: {
|
|
129
|
+
isDark: boolean
|
|
130
|
+
disabled: boolean | undefined
|
|
131
|
+
highlight: string | undefined
|
|
132
|
+
}) => {
|
|
133
|
+
if (disabled) {
|
|
134
|
+
return bgClasses.disabled
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (isDark) {
|
|
138
|
+
return bgClasses.dark
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (highlight === 'autofill') {
|
|
142
|
+
return bgClasses.highlight
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return bgClasses.default
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const getTextColorClass = (disabled: boolean | undefined) =>
|
|
149
|
+
disabled ? fontColorClass.disabled : fontColorClass.default
|
|
150
|
+
|
|
151
|
+
const getCursorClass = (disabled: boolean | undefined) =>
|
|
152
|
+
disabled ? cursorClass.disabled : cursorClass.default
|
|
153
|
+
|
|
154
|
+
type State = 'default' | 'disabled' | 'error' | 'dark'
|
|
155
|
+
type StateConditions = Partial<Record<State, boolean>> & {
|
|
156
|
+
isDark: boolean
|
|
157
|
+
isError: boolean
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const getClassForState = (
|
|
161
|
+
state: State,
|
|
162
|
+
{ borderColor, border, shadow }: typeof borderPseudoClassesByState
|
|
163
|
+
) => {
|
|
164
|
+
return [
|
|
165
|
+
borderColor[state] || borderColor.default,
|
|
166
|
+
border[state] || border.default,
|
|
167
|
+
shadow[state] || shadow.default,
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const borderPseudoElement = (conditions: StateConditions) => {
|
|
172
|
+
const { disabled, isDark, isError } = conditions
|
|
173
|
+
const { borderColor } = borderPseudoClassesByState
|
|
174
|
+
const primaryState = isError
|
|
175
|
+
? 'error'
|
|
176
|
+
: disabled
|
|
177
|
+
? 'disabled'
|
|
178
|
+
: isDark
|
|
179
|
+
? 'dark'
|
|
180
|
+
: 'default'
|
|
181
|
+
|
|
182
|
+
const hoverClass = !disabled && !isError ? borderColor.hoverWithoutFocus : ''
|
|
183
|
+
|
|
184
|
+
return [
|
|
185
|
+
borderPseudoCoreClasses,
|
|
186
|
+
getClassForState(primaryState, borderPseudoClassesByState),
|
|
187
|
+
hoverClass,
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export const getRootClassName = ({
|
|
192
|
+
size,
|
|
193
|
+
width,
|
|
194
|
+
type,
|
|
195
|
+
layout,
|
|
196
|
+
isDark,
|
|
197
|
+
multiline,
|
|
198
|
+
highlight,
|
|
199
|
+
disabled,
|
|
200
|
+
isError,
|
|
201
|
+
}: Partial<Props> & {
|
|
202
|
+
isDark: boolean
|
|
203
|
+
layout: FieldLayout
|
|
204
|
+
isError: boolean
|
|
205
|
+
size: Size
|
|
206
|
+
width: WidthType
|
|
207
|
+
}) => [
|
|
208
|
+
rootBasicClasses,
|
|
209
|
+
spacingBySize[size],
|
|
210
|
+
getHeightClasses({ size, multiline }),
|
|
211
|
+
getWidthClasses({ width, layout }),
|
|
212
|
+
getBackgroundColorClasses({ isDark, disabled, highlight }),
|
|
213
|
+
borderPseudoElement({ isDark, disabled, isError }),
|
|
214
|
+
getTextColorClass(disabled),
|
|
215
|
+
getCursorClass(disabled),
|
|
216
|
+
type === 'hidden' && 'hidden',
|
|
217
|
+
]
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ChangeEventHandler,
|
|
3
|
+
ReactType,
|
|
4
|
+
ReactNode,
|
|
5
|
+
InputHTMLAttributes,
|
|
6
|
+
MouseEvent,
|
|
7
|
+
} from 'react'
|
|
8
|
+
import type { SizeType, BaseProps } from '@toptal/picasso-shared'
|
|
9
|
+
// TODO: replace with mui/base
|
|
10
|
+
import type { InputBaseComponentProps } from '@material-ui/core/InputBase'
|
|
11
|
+
|
|
12
|
+
export type WidthType = 'full' | 'shrink' | 'auto'
|
|
13
|
+
|
|
14
|
+
export type Size = SizeType<'small' | 'medium' | 'large'>
|
|
15
|
+
|
|
16
|
+
export type ValueType =
|
|
17
|
+
| (string | number | boolean | object)[]
|
|
18
|
+
| string
|
|
19
|
+
| number
|
|
20
|
+
| boolean
|
|
21
|
+
| object
|
|
22
|
+
|
|
23
|
+
export type Status = 'error' | 'success' | 'default'
|
|
24
|
+
|
|
25
|
+
export type BaseInputProps = InputBaseComponentProps & {
|
|
26
|
+
variant?: 'dark' | 'light'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface InputProps
|
|
30
|
+
extends React.HTMLAttributes<HTMLInputElement>,
|
|
31
|
+
BaseProps {
|
|
32
|
+
size?: number | 'small' | 'medium' | 'large'
|
|
33
|
+
multiple?: boolean | undefined
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface Props
|
|
37
|
+
extends BaseProps,
|
|
38
|
+
Omit<
|
|
39
|
+
InputHTMLAttributes<HTMLInputElement>,
|
|
40
|
+
'value' | 'defaultValue' | 'size' | 'color'
|
|
41
|
+
> {
|
|
42
|
+
/** Classes for input and root */
|
|
43
|
+
classes?: { input?: string; root?: string }
|
|
44
|
+
/** Width of the component */
|
|
45
|
+
width?: WidthType
|
|
46
|
+
inputComponent?: ReactType<InputBaseComponentProps>
|
|
47
|
+
inputProps?: BaseInputProps
|
|
48
|
+
defaultValue?: ValueType
|
|
49
|
+
value?: ValueType
|
|
50
|
+
/** Whether `Input` should be rendered as `TextArea` or not */
|
|
51
|
+
multiline?: boolean
|
|
52
|
+
/** If true, `TextArea` would be resizable vertical */
|
|
53
|
+
multilineResizable?: boolean
|
|
54
|
+
/** If true, the input element will be focused during the first mount */
|
|
55
|
+
autoFocus?: boolean
|
|
56
|
+
/** Specify rows amount for `TextArea` */
|
|
57
|
+
rows?: string | number
|
|
58
|
+
/* Maximum number of rows to display when multiline option is set to true. */
|
|
59
|
+
rowsMax?: string | number
|
|
60
|
+
/** Type attribute of the Input element. It should be a valid HTML5 input type */
|
|
61
|
+
type?: string
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated [FX-4715] Use the `status` prop instead to both support success and error states
|
|
64
|
+
* Indicate whether input is in error state
|
|
65
|
+
*/
|
|
66
|
+
error?: boolean
|
|
67
|
+
/** Indicate input status */
|
|
68
|
+
status?: Status
|
|
69
|
+
startAdornment?: ReactNode
|
|
70
|
+
endAdornment?: ReactNode
|
|
71
|
+
onChange?: ChangeEventHandler<HTMLInputElement>
|
|
72
|
+
/** Component size */
|
|
73
|
+
size?: Size
|
|
74
|
+
/** Whether to render reset icon when there is a value in the input */
|
|
75
|
+
enableReset?: boolean
|
|
76
|
+
/** Callback invoked when reset button was clicked */
|
|
77
|
+
onResetClick?: (
|
|
78
|
+
event: MouseEvent<HTMLButtonElement & HTMLAnchorElement>
|
|
79
|
+
) => void
|
|
80
|
+
/** Ref of the input element */
|
|
81
|
+
inputRef?: React.Ref<HTMLInputElement>
|
|
82
|
+
testIds?: {
|
|
83
|
+
resetButton?: string
|
|
84
|
+
validIcon?: string
|
|
85
|
+
}
|
|
86
|
+
highlight?: 'autofill'
|
|
87
|
+
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Theme } from '@material-ui/core/styles';
|
|
2
|
-
declare const _default: ({ palette, sizes: { input } }: Theme) => import("@material-ui/styles").StyleRules<{}, "root" | "focused" | "error" | "notchedOutline" | "input" | "inputMultiline" | "hidden" | "rootSmall" | "rootMedium" | "rootLarge" | "rootFull" | "rootShrink" | "rootAuto" | "inputSmall" | "inputMedium" | "inputLarge" | "resetButton" | "resetButtonDirty" | "rootDark" | "notchedOutlineDark" | "inputDark" | "highlightAutofill" | "horizontalLayout">;
|
|
3
|
-
export default _default;
|
|
4
|
-
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/OutlinedInput/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;wDAwFN,KAAK;AAApD,wBA8FI"}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { createStyles } from '@material-ui/core/styles';
|
|
2
|
-
import { darken, outline, alpha } from '@toptal/picasso-shared';
|
|
3
|
-
import { PicassoProvider } from '@toptal/picasso-provider';
|
|
4
|
-
PicassoProvider.override(({ palette, sizes: { input, borderRadius } }) => ({
|
|
5
|
-
MuiOutlinedInput: {
|
|
6
|
-
root: {
|
|
7
|
-
width: input.width,
|
|
8
|
-
color: palette.common.black,
|
|
9
|
-
'& $notchedOutline': {
|
|
10
|
-
borderColor: palette.grey.light2,
|
|
11
|
-
borderRadius: borderRadius.small,
|
|
12
|
-
top: 0,
|
|
13
|
-
'& legend': {
|
|
14
|
-
height: 0,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
'&$focused': {
|
|
18
|
-
'& $notchedOutline': Object.assign({ borderWidth: '1px', borderColor: palette.blue.main }, outline(palette.primary.main)),
|
|
19
|
-
},
|
|
20
|
-
'&$disabled': {
|
|
21
|
-
'& $notchedOutline': {
|
|
22
|
-
borderColor: palette.grey.lighter2,
|
|
23
|
-
},
|
|
24
|
-
backgroundColor: palette.grey.lighter,
|
|
25
|
-
color: palette.grey.main,
|
|
26
|
-
},
|
|
27
|
-
'&:hover:not($disabled)': {
|
|
28
|
-
'&:not($error)&:not($focused) $notchedOutline': {
|
|
29
|
-
borderColor: palette.grey.main2,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
input: {
|
|
34
|
-
display: 'flex',
|
|
35
|
-
alignItems: 'center',
|
|
36
|
-
boxSizing: 'border-box',
|
|
37
|
-
height: '100%',
|
|
38
|
-
padding: 0,
|
|
39
|
-
border: 'none',
|
|
40
|
-
'&::placeholder': {
|
|
41
|
-
color: palette.grey.main2,
|
|
42
|
-
opacity: 1,
|
|
43
|
-
},
|
|
44
|
-
'&$disabled': {
|
|
45
|
-
color: palette.grey.main2,
|
|
46
|
-
// On Safari the text gets a bit lighter as if it had some transparency applied to it
|
|
47
|
-
// We need this webkit-specific property to achieve the exact font color
|
|
48
|
-
'-webkit-text-fill-color': palette.grey.main2,
|
|
49
|
-
'&::placeholder': {
|
|
50
|
-
color: palette.grey.main2,
|
|
51
|
-
opacity: 1,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
inputMultiline: {
|
|
56
|
-
padding: 0,
|
|
57
|
-
},
|
|
58
|
-
multiline: {
|
|
59
|
-
padding: 0,
|
|
60
|
-
},
|
|
61
|
-
error: {
|
|
62
|
-
backgroundColor: 'transparent',
|
|
63
|
-
color: palette.common.black,
|
|
64
|
-
'&$focused': {
|
|
65
|
-
'& $notchedOutline': Object.assign({ borderWidth: '1px', borderColor: palette.red.main }, outline(palette.red.main)),
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
}));
|
|
70
|
-
export default ({ palette, sizes: { input } }) => createStyles({
|
|
71
|
-
root: {
|
|
72
|
-
cursor: 'inherit',
|
|
73
|
-
gap: '0.25rem 0.5rem',
|
|
74
|
-
'&:hover': {
|
|
75
|
-
'& $resetButtonDirty': {
|
|
76
|
-
visibility: 'visible',
|
|
77
|
-
},
|
|
78
|
-
'& $notchedOutline$notchedOutlineDark': Object.assign({}, outline(palette.common.white)),
|
|
79
|
-
},
|
|
80
|
-
'&$focused': {
|
|
81
|
-
'& $notchedOutline$notchedOutlineDark': Object.assign({}, outline(palette.common.white)),
|
|
82
|
-
},
|
|
83
|
-
'&$error': {
|
|
84
|
-
backgroundColor: palette.common.white,
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
hidden: {
|
|
88
|
-
display: 'none',
|
|
89
|
-
},
|
|
90
|
-
rootSmall: {
|
|
91
|
-
padding: '0.25rem 0.625rem',
|
|
92
|
-
height: '1.5rem',
|
|
93
|
-
},
|
|
94
|
-
rootMedium: {
|
|
95
|
-
padding: input.padding,
|
|
96
|
-
height: input.height,
|
|
97
|
-
},
|
|
98
|
-
rootLarge: {
|
|
99
|
-
padding: '0.75rem',
|
|
100
|
-
height: '3rem',
|
|
101
|
-
},
|
|
102
|
-
rootFull: {
|
|
103
|
-
width: '100%',
|
|
104
|
-
},
|
|
105
|
-
rootShrink: {
|
|
106
|
-
width: 'auto',
|
|
107
|
-
},
|
|
108
|
-
rootAuto: {},
|
|
109
|
-
focused: {},
|
|
110
|
-
input: {
|
|
111
|
-
cursor: 'inherit',
|
|
112
|
-
'&:focus + $resetButtonDirty': {
|
|
113
|
-
visibility: 'visible',
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
inputSmall: {
|
|
117
|
-
fontSize: '0.75rem',
|
|
118
|
-
lineHeight: '1rem',
|
|
119
|
-
},
|
|
120
|
-
inputMedium: {
|
|
121
|
-
fontSize: '0.875rem',
|
|
122
|
-
lineHeight: '1rem',
|
|
123
|
-
},
|
|
124
|
-
inputLarge: {
|
|
125
|
-
fontSize: '1rem',
|
|
126
|
-
lineHeight: '1rem',
|
|
127
|
-
},
|
|
128
|
-
inputMultiline: {},
|
|
129
|
-
resetButton: {
|
|
130
|
-
visibility: 'hidden',
|
|
131
|
-
},
|
|
132
|
-
resetButtonDirty: {},
|
|
133
|
-
rootDark: {
|
|
134
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
135
|
-
backgroundColor: `${darken(palette.blue.darker, 0.5)} !important`,
|
|
136
|
-
},
|
|
137
|
-
notchedOutline: {},
|
|
138
|
-
notchedOutlineDark: {
|
|
139
|
-
border: 'none',
|
|
140
|
-
},
|
|
141
|
-
inputDark: {
|
|
142
|
-
color: palette.common.white,
|
|
143
|
-
'&::placeholder': {
|
|
144
|
-
color: palette.common.white,
|
|
145
|
-
opacity: 0.64,
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
highlightAutofill: {
|
|
149
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
150
|
-
backgroundColor: alpha(palette.yellow.lighter, 0.6),
|
|
151
|
-
},
|
|
152
|
-
horizontalLayout: {
|
|
153
|
-
width: '100%',
|
|
154
|
-
},
|
|
155
|
-
error: {},
|
|
156
|
-
});
|
|
157
|
-
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/OutlinedInput/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE1D,eAAe,CAAC,QAAQ,CACtB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,EAAS,EAAE,EAAE,CAAC,CAAC;IACvD,gBAAgB,EAAE;QAChB,IAAI,EAAE;YACJ,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,KAAK,EAAE,OAAO,CAA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AE,EAAE;IACZ,OAAO,EAAE,EAAE;IACX,KAAK,EAAE;QACL,MAAM,EAAE,SAAS;QAEjB,6BAA6B,EAAE;YAC7B,UAAU,EAAE,SAAS;SACtB;KACF;IACD,UAAU,EAAE;QACV,QAAQ,EAAE,SAAS;QACnB,UAAU,EAAE,MAAM;KACnB;IACD,WAAW,EAAE;QACX,QAAQ,EAAE,UAAU;QACpB,UAAU,EAAE,MAAM;KACnB;IACD,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM;QAChB,UAAU,EAAE,MAAM;KACnB;IACD,cAAc,EAAE,EAAE;IAClB,WAAW,EAAE;QACX,UAAU,EAAE,QAAQ;KACrB;IACD,gBAAgB,EAAE,EAAE;IACpB,QAAQ,EAAE;QACR,oEAAoE;QACpE,eAAe,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAO,EAAE,GAAG,CAAC,aAAa;KACnE;IACD,cAAc,EAAE,EAAE;IAClB,kBAAkB,EAAE;QAClB,MAAM,EAAE,MAAM;KACf;IACD,SAAS,EAAE;QACT,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK;QAC3B,gBAAgB,EAAE;YAChB,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK;YAC3B,OAAO,EAAE,IAAI;SACd;KACF;IACD,iBAAiB,EAAE;QACjB,oEAAoE;QACpE,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAQ,EAAE,GAAG,CAAC;KACrD;IACD,gBAAgB,EAAE;QAChB,KAAK,EAAE,MAAM;KACd;IACD,KAAK,EAAE,EAAE;CACV,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/styles.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/styles.ts"],"names":[],"mappings":""}
|