@charcoal-ui/react 3.4.0 → 3.5.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/components/TextArea/index.d.ts.map +1 -1
- package/dist/components/TextField/index.d.ts +4 -0
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/components/TextField/useFocusWithClick.d.ts +3 -0
- package/dist/components/TextField/useFocusWithClick.d.ts.map +1 -0
- package/dist/index.cjs.js +201 -184
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +156 -139
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -6
- package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +88 -245
- package/src/components/TextArea/index.tsx +38 -43
- package/src/components/TextField/TextField.story.tsx +2 -3
- package/src/components/TextField/__snapshots__/TextField.story.storyshot +258 -455
- package/src/components/TextField/index.tsx +86 -84
- package/src/components/TextField/useFocusWithClick.tsx +22 -0
|
@@ -2,10 +2,11 @@ import { useTextField } from '@react-aria/textfield'
|
|
|
2
2
|
import { useVisuallyHidden } from '@react-aria/visually-hidden'
|
|
3
3
|
import { forwardRef, useCallback, useEffect, useRef, useState } from 'react'
|
|
4
4
|
import styled, { css } from 'styled-components'
|
|
5
|
-
import
|
|
5
|
+
import { FieldLabelProps } from '../FieldLabel'
|
|
6
6
|
import { countCodePointsInString, mergeRefs } from '../../_lib'
|
|
7
7
|
import { ReactAreaUseTextFieldCompat } from '../../_lib/compat'
|
|
8
|
-
import {
|
|
8
|
+
import { AssistiveText, TextFieldLabel } from '../TextField'
|
|
9
|
+
import { useFocusWithClick } from '../TextField/useFocusWithClick'
|
|
9
10
|
|
|
10
11
|
type DOMProps = Omit<
|
|
11
12
|
React.TextareaHTMLAttributes<HTMLTextAreaElement>,
|
|
@@ -115,6 +116,10 @@ const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
|
|
|
115
116
|
}
|
|
116
117
|
}, [autoHeight, syncHeight])
|
|
117
118
|
|
|
119
|
+
const containerRef = useRef(null)
|
|
120
|
+
|
|
121
|
+
useFocusWithClick(containerRef, ariaRef)
|
|
122
|
+
|
|
118
123
|
return (
|
|
119
124
|
<TextFieldRoot className={className} isDisabled={disabled}>
|
|
120
125
|
<TextFieldLabel
|
|
@@ -126,8 +131,10 @@ const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
|
|
|
126
131
|
{...(!showLabel ? visuallyHiddenProps : {})}
|
|
127
132
|
/>
|
|
128
133
|
<StyledTextareaContainer
|
|
134
|
+
ref={containerRef}
|
|
129
135
|
invalid={invalid}
|
|
130
136
|
rows={showCount ? rows + 1 : rows}
|
|
137
|
+
aria-disabled={disabled === true ? 'true' : undefined}
|
|
131
138
|
>
|
|
132
139
|
<StyledTextarea
|
|
133
140
|
ref={mergeRefs(textareaRef, forwardRef, ariaRef)}
|
|
@@ -163,32 +170,34 @@ const TextFieldRoot = styled.div<{ isDisabled: boolean }>`
|
|
|
163
170
|
${(p) => p.isDisabled && { opacity: p.theme.elementEffect.disabled.opacity }}
|
|
164
171
|
`
|
|
165
172
|
|
|
166
|
-
const TextFieldLabel = styled(FieldLabel)`
|
|
167
|
-
${theme((o) => o.margin.bottom(8))}
|
|
168
|
-
`
|
|
169
|
-
|
|
170
173
|
const StyledTextareaContainer = styled.div<{ rows: number; invalid: boolean }>`
|
|
171
174
|
position: relative;
|
|
172
175
|
overflow: hidden;
|
|
173
|
-
padding: 0 8px;
|
|
174
176
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
p.invalid && o.outline.assertive,
|
|
180
|
-
o.font.text2,
|
|
181
|
-
o.borderRadius(4),
|
|
182
|
-
])}
|
|
183
|
-
|
|
184
|
-
&:focus-within {
|
|
185
|
-
${(p) =>
|
|
186
|
-
theme((o) => (p.invalid ? o.outline.assertive : o.outline.default))}
|
|
187
|
-
}
|
|
177
|
+
color: var(--charcoal-text2);
|
|
178
|
+
background-color: var(--charcoal-surface3);
|
|
179
|
+
border-radius: 4px;
|
|
180
|
+
transition: 0.2s background-color, 0.2s box-shadow;
|
|
188
181
|
|
|
189
182
|
${({ rows }) => css`
|
|
190
183
|
height: calc(22px * ${rows} + 18px);
|
|
191
184
|
`};
|
|
185
|
+
|
|
186
|
+
:not([aria-disabled]):hover,
|
|
187
|
+
[aria-disabled='false']:hover {
|
|
188
|
+
background-color: var(--charcoal-surface3-hover);
|
|
189
|
+
}
|
|
190
|
+
:focus-within {
|
|
191
|
+
outline: none;
|
|
192
|
+
box-shadow: 0 0 0 4px
|
|
193
|
+
${(p) => (p.invalid ? `rgba(255,43,0,0.32)` : `rgba(0, 150, 250, 0.32);`)};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
${(p) =>
|
|
197
|
+
p.invalid &&
|
|
198
|
+
css`
|
|
199
|
+
box-shadow: 0 0 0 4px rgba(255, 43, 0, 0.32);
|
|
200
|
+
`}
|
|
192
201
|
`
|
|
193
202
|
|
|
194
203
|
const StyledTextarea = styled.textarea<{ noBottomPadding: boolean }>`
|
|
@@ -197,6 +206,7 @@ const StyledTextarea = styled.textarea<{ noBottomPadding: boolean }>`
|
|
|
197
206
|
resize: none;
|
|
198
207
|
font-family: inherit;
|
|
199
208
|
color: inherit;
|
|
209
|
+
box-sizing: border-box;
|
|
200
210
|
|
|
201
211
|
/* Prevent zooming for iOS Safari */
|
|
202
212
|
transform-origin: top left;
|
|
@@ -204,10 +214,11 @@ const StyledTextarea = styled.textarea<{ noBottomPadding: boolean }>`
|
|
|
204
214
|
width: calc(100% / 0.875);
|
|
205
215
|
font-size: calc(14px / 0.875);
|
|
206
216
|
line-height: calc(22px / 0.875);
|
|
207
|
-
padding: calc(9px / 0.875)
|
|
217
|
+
padding: calc(9px / 0.875) calc(8px / 0.875)
|
|
218
|
+
${(p) => (p.noBottomPadding ? 0 : '')};
|
|
208
219
|
|
|
209
|
-
${({ rows = 1 }) => css`
|
|
210
|
-
height: calc(22px / 0.875 * ${rows});
|
|
220
|
+
${({ rows = 1, noBottomPadding }) => css`
|
|
221
|
+
height: calc(22px / 0.875 * ${rows} + ${noBottomPadding ? 9 : 20}px);
|
|
211
222
|
`};
|
|
212
223
|
|
|
213
224
|
/* Display box-shadow for iOS Safari */
|
|
@@ -216,16 +227,8 @@ const StyledTextarea = styled.textarea<{ noBottomPadding: boolean }>`
|
|
|
216
227
|
background: none;
|
|
217
228
|
|
|
218
229
|
&::placeholder {
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/* Hide scrollbar for Chrome, Safari and Opera */
|
|
223
|
-
&::-webkit-scrollbar {
|
|
224
|
-
display: none;
|
|
230
|
+
color: var(--charcoal-text3);
|
|
225
231
|
}
|
|
226
|
-
/* Hide scrollbar for IE, Edge and Firefox */
|
|
227
|
-
-ms-overflow-style: none; /* IE and Edge */
|
|
228
|
-
scrollbar-width: none; /* Firefox */
|
|
229
232
|
`
|
|
230
233
|
|
|
231
234
|
const MultiLineCounter = styled.span`
|
|
@@ -233,15 +236,7 @@ const MultiLineCounter = styled.span`
|
|
|
233
236
|
bottom: 9px;
|
|
234
237
|
right: 8px;
|
|
235
238
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
const AssistiveText = styled.p<{ invalid: boolean }>`
|
|
240
|
-
${(p) =>
|
|
241
|
-
theme((o) => [
|
|
242
|
-
o.typography(14),
|
|
243
|
-
o.margin.top(8),
|
|
244
|
-
o.margin.bottom(0),
|
|
245
|
-
o.font[p.invalid ? 'assertive' : 'text1'],
|
|
246
|
-
])}
|
|
239
|
+
line-height: 22px;
|
|
240
|
+
font-size: 14px;
|
|
241
|
+
color: var(--charcoal-text3);
|
|
247
242
|
`
|
|
@@ -67,7 +67,7 @@ HasAffix.args = {
|
|
|
67
67
|
export const PrefixIcon: Story<Partial<TextFieldProps>> = (args) => (
|
|
68
68
|
<TextField
|
|
69
69
|
label="Label"
|
|
70
|
-
placeholder="
|
|
70
|
+
placeholder="作品を検索"
|
|
71
71
|
prefix={
|
|
72
72
|
<PrefixIconWrap>
|
|
73
73
|
<pixiv-icon name="16/Search" />
|
|
@@ -79,7 +79,6 @@ export const PrefixIcon: Story<Partial<TextFieldProps>> = (args) => (
|
|
|
79
79
|
)
|
|
80
80
|
|
|
81
81
|
const PrefixIconWrap = styled.div`
|
|
82
|
+
height: 16px;
|
|
82
83
|
color: ${({ theme }) => theme.color.text3};
|
|
83
|
-
margin-top: 2px;
|
|
84
|
-
margin-right: 4px;
|
|
85
84
|
`
|