@charcoal-ui/react 4.0.0-beta.5 → 4.0.0-beta.7
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/README.md +1 -1
- package/dist/_lib/createDivComponent.d.ts +4 -0
- package/dist/_lib/createDivComponent.d.ts.map +1 -0
- package/dist/components/Modal/ModalPlumbing.d.ts.map +1 -1
- package/dist/components/Modal/index.d.ts +4 -0
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/TextArea/index.d.ts +1 -0
- package/dist/components/TextArea/index.d.ts.map +1 -1
- package/dist/components/TextField/AssistiveText/index.d.ts +5 -0
- package/dist/components/TextField/AssistiveText/index.d.ts.map +1 -0
- package/dist/components/TextField/index.d.ts +1 -3
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/core/SSRProvider.d.ts +3 -1
- package/dist/core/SSRProvider.d.ts.map +1 -1
- package/dist/index.cjs.js +250 -268
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +156 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +139 -158
- package/dist/index.esm.js.map +1 -1
- package/package.json +8 -8
- package/src/_lib/createDivComponent.tsx +11 -0
- package/src/components/Button/__snapshots__/index.story.storyshot +9 -9
- package/src/components/Button/index.story.tsx +1 -1
- package/src/components/Checkbox/CheckboxInput/__snapshots__/index.story.storyshot +5 -5
- package/src/components/Checkbox/CheckboxInput/index.story.tsx +1 -1
- package/src/components/Checkbox/__snapshots__/index.story.storyshot +6 -6
- package/src/components/Checkbox/index.story.tsx +2 -2
- package/src/components/Clickable/__snapshots__/index.story.storyshot +2 -2
- package/src/components/Clickable/index.story.tsx +1 -1
- package/src/components/DropdownSelector/ListItem/__snapshots__/index.story.storyshot +1 -1
- package/src/components/DropdownSelector/ListItem/index.story.tsx +1 -1
- package/src/components/DropdownSelector/MenuList/__snapshots__/index.story.storyshot +3 -3
- package/src/components/DropdownSelector/MenuList/index.story.tsx +1 -1
- package/src/components/DropdownSelector/Popover/__snapshots__/index.story.storyshot +1 -1
- package/src/components/DropdownSelector/Popover/index.story.tsx +1 -1
- package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +22 -579
- package/src/components/DropdownSelector/index.story.tsx +2 -2
- package/src/components/DropdownSelector/index.tsx +2 -2
- package/src/components/Icon/__snapshots__/index.story.storyshot +1 -1
- package/src/components/Icon/index.story.tsx +1 -1
- package/src/components/IconButton/__snapshots__/index.story.storyshot +3 -3
- package/src/components/IconButton/index.story.tsx +1 -1
- package/src/components/LoadingSpinner/__snapshots__/index.story.storyshot +4 -4
- package/src/components/LoadingSpinner/index.story.tsx +1 -1
- package/src/components/Modal/ModalPlumbing.tsx +2 -11
- package/src/components/Modal/__snapshots__/index.story.storyshot +104 -288
- package/src/components/Modal/index.story.tsx +2 -2
- package/src/components/Modal/index.tsx +17 -5
- package/src/components/Radio/__snapshots__/index.story.storyshot +5 -5
- package/src/components/Radio/index.story.tsx +1 -1
- package/src/components/SegmentedControl/__snapshots__/index.story.storyshot +2 -2
- package/src/components/SegmentedControl/index.story.tsx +1 -1
- package/src/components/Switch/__snapshots__/index.story.storyshot +4 -4
- package/src/components/Switch/index.story.tsx +1 -1
- package/src/components/TagItem/__snapshots__/index.story.storyshot +8 -8
- package/src/components/TagItem/index.story.tsx +1 -1
- package/src/components/TextArea/TextArea.story.tsx +1 -1
- package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +152 -824
- package/src/components/TextArea/index.css +78 -0
- package/src/components/TextArea/index.tsx +26 -96
- package/src/components/TextField/AssistiveText/index.css +10 -0
- package/src/components/TextField/AssistiveText/index.tsx +6 -0
- package/src/components/TextField/TextField.story.tsx +1 -1
- package/src/components/TextField/__snapshots__/TextField.story.storyshot +122 -1072
- package/src/components/TextField/index.css +87 -0
- package/src/components/TextField/index.tsx +24 -117
- package/src/core/SSRProvider.tsx +12 -1
- package/src/index.ts +5 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
.charcoal-text-area-root {
|
|
2
|
+
display: grid;
|
|
3
|
+
grid-template-columns: 1fr;
|
|
4
|
+
grid-gap: 4px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.charcoal-text-area-root[aria-disabled='true'] {
|
|
8
|
+
opacity: 0.32;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.charcoal-text-area-container {
|
|
12
|
+
position: relative;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
|
|
15
|
+
color: var(--charcoal-text2);
|
|
16
|
+
background-color: var(--charcoal-surface3);
|
|
17
|
+
border-radius: 4px;
|
|
18
|
+
transition: 0.2s background-color, 0.2s box-shadow;
|
|
19
|
+
height: calc(22px * var(--charcoal-text-area-rows) + 18px);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.charcoal-text-area-container[aria-invalid='true'] {
|
|
23
|
+
box-shadow: 0 0 0 4px rgba(255, 43, 0, 0.32);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.charcoal-text-area-container:focus-within {
|
|
27
|
+
outline: none;
|
|
28
|
+
box-shadow: 0 0 0 4px rgba(0, 150, 250, 0.32);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.charcoal-text-area-container:not(aria-disabled='true'):hover {
|
|
32
|
+
background-color: var(--charcoal-surface3-hover);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.charcoal-text-area-container[aria-invalid='true']:focus-within {
|
|
36
|
+
box-shadow: 0 0 0 4px rgba(255, 43, 0, 0.32);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.charcoal-text-area-textarea {
|
|
40
|
+
border: none;
|
|
41
|
+
outline: none;
|
|
42
|
+
resize: none;
|
|
43
|
+
font-family: inherit;
|
|
44
|
+
color: inherit;
|
|
45
|
+
box-sizing: border-box;
|
|
46
|
+
|
|
47
|
+
/* Prevent zooming for iOS Safari */
|
|
48
|
+
transform-origin: top left;
|
|
49
|
+
transform: scale(0.875);
|
|
50
|
+
width: calc(100% / 0.875);
|
|
51
|
+
font-size: calc(14px / 0.875);
|
|
52
|
+
line-height: calc(22px / 0.875);
|
|
53
|
+
padding: calc(9px / 0.875) calc(8px / 0.875);
|
|
54
|
+
height: calc(22px / 0.875 * var(--charcoal-text-area-rows) + 20px);
|
|
55
|
+
|
|
56
|
+
/* Display box-shadow for iOS Safari */
|
|
57
|
+
appearance: none;
|
|
58
|
+
|
|
59
|
+
background: none;
|
|
60
|
+
}
|
|
61
|
+
.charcoal-text-area-textarea[data-no-bottom-padding='true'] {
|
|
62
|
+
padding: calc(9px / 0.875) calc(8px / 0.875) 0;
|
|
63
|
+
height: calc(22px / 0.875 * (var(--charcoal-text-area-rows) - 1) + 9px);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.charcoal-text-area-textarea::placeholder {
|
|
67
|
+
color: var(--charcoal-text3);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.charcoal-text-area-counter {
|
|
71
|
+
position: absolute;
|
|
72
|
+
bottom: 9px;
|
|
73
|
+
right: 8px;
|
|
74
|
+
|
|
75
|
+
line-height: 22px;
|
|
76
|
+
font-size: 14px;
|
|
77
|
+
color: var(--charcoal-text3);
|
|
78
|
+
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import './index.css'
|
|
2
|
+
|
|
1
3
|
import { useVisuallyHidden } from '@react-aria/visually-hidden'
|
|
2
4
|
import { forwardRef, useCallback, useEffect, useRef, useState } from 'react'
|
|
3
|
-
import styled, { css } from 'styled-components'
|
|
4
5
|
import FieldLabel from '../FieldLabel'
|
|
5
6
|
import { countCodePointsInString, mergeRefs } from '../../_lib'
|
|
6
|
-
import { AssistiveText } from '../TextField'
|
|
7
7
|
import { useFocusWithClick } from '../TextField/useFocusWithClick'
|
|
8
8
|
import { useId } from '@react-aria/utils'
|
|
9
|
+
import { AssistiveText } from '../TextField/AssistiveText'
|
|
10
|
+
import { useClassNames } from '../../_lib/useClassNames'
|
|
9
11
|
|
|
10
12
|
export type TextAreaProps = {
|
|
11
13
|
value?: string
|
|
@@ -42,6 +44,7 @@ const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
|
|
|
42
44
|
maxLength,
|
|
43
45
|
autoHeight = false,
|
|
44
46
|
rows: initialRows = 4,
|
|
47
|
+
invalid,
|
|
45
48
|
getCount = countCodePointsInString,
|
|
46
49
|
...props
|
|
47
50
|
},
|
|
@@ -49,7 +52,6 @@ const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
|
|
|
49
52
|
) {
|
|
50
53
|
const { visuallyHiddenProps } = useVisuallyHidden()
|
|
51
54
|
const textareaRef = useRef<HTMLTextAreaElement>(null)
|
|
52
|
-
const textAreaRef = useRef<HTMLTextAreaElement>(null)
|
|
53
55
|
const [count, setCount] = useState(getCount(value ?? ''))
|
|
54
56
|
const [rows, setRows] = useState(initialRows)
|
|
55
57
|
|
|
@@ -92,17 +94,19 @@ const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
|
|
|
92
94
|
|
|
93
95
|
const containerRef = useRef(null)
|
|
94
96
|
|
|
95
|
-
useFocusWithClick(containerRef,
|
|
97
|
+
useFocusWithClick(containerRef, textareaRef)
|
|
96
98
|
|
|
97
99
|
const textAreaId = useId(props.id)
|
|
98
100
|
const describedbyId = useId()
|
|
99
101
|
const labelledbyId = useId()
|
|
100
102
|
|
|
103
|
+
const classNames = useClassNames('charcoal-text-area-root', className)
|
|
104
|
+
|
|
101
105
|
const showAssistiveText =
|
|
102
106
|
assistiveText != null && assistiveText.length !== 0
|
|
103
107
|
|
|
104
108
|
return (
|
|
105
|
-
<
|
|
109
|
+
<div className={classNames} aria-disabled={disabled}>
|
|
106
110
|
<FieldLabel
|
|
107
111
|
htmlFor={textAreaId}
|
|
108
112
|
id={labelledbyId}
|
|
@@ -112,118 +116,44 @@ const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
|
|
|
112
116
|
subLabel={subLabel}
|
|
113
117
|
{...(!showLabel ? visuallyHiddenProps : {})}
|
|
114
118
|
/>
|
|
115
|
-
<
|
|
119
|
+
<div
|
|
120
|
+
className="charcoal-text-area-container"
|
|
116
121
|
aria-disabled={disabled === true ? 'true' : undefined}
|
|
117
|
-
invalid={
|
|
122
|
+
aria-invalid={invalid === true}
|
|
118
123
|
ref={containerRef}
|
|
119
|
-
|
|
124
|
+
style={{
|
|
125
|
+
'--charcoal-text-area-rows': `${showCount ? rows + 1 : rows}`,
|
|
126
|
+
}}
|
|
120
127
|
>
|
|
121
|
-
<
|
|
128
|
+
<textarea
|
|
129
|
+
className="charcoal-text-area-textarea"
|
|
122
130
|
aria-describedby={showAssistiveText ? describedbyId : undefined}
|
|
123
|
-
aria-invalid={
|
|
131
|
+
aria-invalid={invalid}
|
|
124
132
|
aria-labelledby={labelledbyId}
|
|
125
133
|
id={textAreaId}
|
|
126
134
|
maxLength={maxLength}
|
|
127
|
-
|
|
135
|
+
data-no-bottom-padding={showCount}
|
|
128
136
|
onChange={handleChange}
|
|
129
|
-
ref={mergeRefs(forwardRef,
|
|
137
|
+
ref={mergeRefs(forwardRef, textareaRef)}
|
|
130
138
|
rows={rows}
|
|
131
139
|
value={value}
|
|
140
|
+
disabled={disabled}
|
|
132
141
|
{...props}
|
|
133
142
|
/>
|
|
134
143
|
{showCount && (
|
|
135
|
-
<
|
|
144
|
+
<span className="charcoal-text-area-counter">
|
|
136
145
|
{maxLength !== undefined ? `${count}/${maxLength}` : count}
|
|
137
|
-
</
|
|
146
|
+
</span>
|
|
138
147
|
)}
|
|
139
|
-
</
|
|
148
|
+
</div>
|
|
140
149
|
{showAssistiveText && (
|
|
141
|
-
<AssistiveText invalid={
|
|
150
|
+
<AssistiveText data-invalid={invalid === true} id={describedbyId}>
|
|
142
151
|
{assistiveText}
|
|
143
152
|
</AssistiveText>
|
|
144
153
|
)}
|
|
145
|
-
</
|
|
154
|
+
</div>
|
|
146
155
|
)
|
|
147
156
|
}
|
|
148
157
|
)
|
|
149
158
|
|
|
150
159
|
export default TextArea
|
|
151
|
-
|
|
152
|
-
const TextFieldRoot = styled.div<{ isDisabled: boolean }>`
|
|
153
|
-
display: grid;
|
|
154
|
-
grid-template-columns: 1fr;
|
|
155
|
-
grid-gap: 4px;
|
|
156
|
-
|
|
157
|
-
${(p) => p.isDisabled && { opacity: p.theme.elementEffect.disabled.opacity }}
|
|
158
|
-
`
|
|
159
|
-
|
|
160
|
-
const StyledTextareaContainer = styled.div<{ rows: number; invalid: boolean }>`
|
|
161
|
-
position: relative;
|
|
162
|
-
overflow: hidden;
|
|
163
|
-
|
|
164
|
-
color: var(--charcoal-text2);
|
|
165
|
-
background-color: var(--charcoal-surface3);
|
|
166
|
-
border-radius: 4px;
|
|
167
|
-
transition: 0.2s background-color, 0.2s box-shadow;
|
|
168
|
-
|
|
169
|
-
${({ rows }) => css`
|
|
170
|
-
height: calc(22px * ${rows} + 18px);
|
|
171
|
-
`};
|
|
172
|
-
|
|
173
|
-
:not([aria-disabled]):hover,
|
|
174
|
-
[aria-disabled='false']:hover {
|
|
175
|
-
background-color: var(--charcoal-surface3-hover);
|
|
176
|
-
}
|
|
177
|
-
:focus-within {
|
|
178
|
-
outline: none;
|
|
179
|
-
box-shadow: 0 0 0 4px
|
|
180
|
-
${(p) => (p.invalid ? `rgba(255,43,0,0.32)` : `rgba(0, 150, 250, 0.32);`)};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
${(p) =>
|
|
184
|
-
p.invalid &&
|
|
185
|
-
css`
|
|
186
|
-
box-shadow: 0 0 0 4px rgba(255, 43, 0, 0.32);
|
|
187
|
-
`}
|
|
188
|
-
`
|
|
189
|
-
|
|
190
|
-
const StyledTextarea = styled.textarea<{ noBottomPadding: boolean }>`
|
|
191
|
-
border: none;
|
|
192
|
-
outline: none;
|
|
193
|
-
resize: none;
|
|
194
|
-
font-family: inherit;
|
|
195
|
-
color: inherit;
|
|
196
|
-
box-sizing: border-box;
|
|
197
|
-
|
|
198
|
-
/* Prevent zooming for iOS Safari */
|
|
199
|
-
transform-origin: top left;
|
|
200
|
-
transform: scale(0.875);
|
|
201
|
-
width: calc(100% / 0.875);
|
|
202
|
-
font-size: calc(14px / 0.875);
|
|
203
|
-
line-height: calc(22px / 0.875);
|
|
204
|
-
padding: calc(9px / 0.875) calc(8px / 0.875)
|
|
205
|
-
${(p) => (p.noBottomPadding ? 0 : '')};
|
|
206
|
-
|
|
207
|
-
${({ rows = 1, noBottomPadding }) => css`
|
|
208
|
-
height: calc(22px / 0.875 * ${rows} + ${noBottomPadding ? 9 : 20}px);
|
|
209
|
-
`};
|
|
210
|
-
|
|
211
|
-
/* Display box-shadow for iOS Safari */
|
|
212
|
-
appearance: none;
|
|
213
|
-
|
|
214
|
-
background: none;
|
|
215
|
-
|
|
216
|
-
&::placeholder {
|
|
217
|
-
color: var(--charcoal-text3);
|
|
218
|
-
}
|
|
219
|
-
`
|
|
220
|
-
|
|
221
|
-
const MultiLineCounter = styled.span`
|
|
222
|
-
position: absolute;
|
|
223
|
-
bottom: 9px;
|
|
224
|
-
right: 8px;
|
|
225
|
-
|
|
226
|
-
line-height: 22px;
|
|
227
|
-
font-size: 14px;
|
|
228
|
-
color: var(--charcoal-text3);
|
|
229
|
-
`
|