@charcoal-ui/react 5.11.0 → 5.12.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/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +11 -9
- package/src/__tests__/css-output.test.ts +2 -1
- package/src/components/Checkbox/__snapshots__/index.css.snap +1 -0
- package/src/components/Radio/__snapshots__/index.css.snap +1 -0
- package/src/components/Switch/__snapshots__/index.css.snap +1 -0
- package/src/components/TextArea/TextArea.test.tsx +17 -0
- package/src/components/TextArea/index.tsx +7 -6
- package/src/components/TextEllipsis/__snapshots__/index.css.snap +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@charcoal-ui/react",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.12.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -28,14 +28,15 @@
|
|
|
28
28
|
"@types/glob": "^8.1.0",
|
|
29
29
|
"@types/react": "^18.3.3",
|
|
30
30
|
"@types/react-dom": "^18.3.0",
|
|
31
|
-
"@types/react-router-dom": "^5.3.3",
|
|
32
31
|
"@types/warning": "^3.0.4",
|
|
32
|
+
"@vitejs/plugin-react": "^4.3.1",
|
|
33
|
+
"@vitest/browser": "^2.1.9",
|
|
33
34
|
"autoprefixer": "^10.4.19",
|
|
34
35
|
"jsdom": "^24.1.0",
|
|
36
|
+
"playwright": "^1.58.2",
|
|
35
37
|
"postcss-nested": "^7.0.2",
|
|
36
38
|
"react": "^18.3.1",
|
|
37
|
-
"react-dom": "^18.3.1"
|
|
38
|
-
"react-router-dom": "^6.2.1"
|
|
39
|
+
"react-dom": "^18.3.1"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
42
|
"@react-aria/button": "^3.9.1",
|
|
@@ -54,10 +55,10 @@
|
|
|
54
55
|
"react-compiler-runtime": "1.0.0",
|
|
55
56
|
"react-stately": "^3.26.0",
|
|
56
57
|
"warning": "^4.0.3",
|
|
57
|
-
"@charcoal-ui/foundation": "5.
|
|
58
|
-
"@charcoal-ui/icons": "5.
|
|
59
|
-
"@charcoal-ui/theme": "5.
|
|
60
|
-
"@charcoal-ui/utils": "5.
|
|
58
|
+
"@charcoal-ui/foundation": "5.12.0",
|
|
59
|
+
"@charcoal-ui/icons": "5.12.0",
|
|
60
|
+
"@charcoal-ui/theme": "5.12.0",
|
|
61
|
+
"@charcoal-ui/utils": "5.12.0"
|
|
61
62
|
},
|
|
62
63
|
"peerDependencies": {
|
|
63
64
|
"react": ">=17.0.0"
|
|
@@ -81,6 +82,7 @@
|
|
|
81
82
|
"build:dts": "tsc --project tsconfig.build.json --pretty --emitDeclarationOnly",
|
|
82
83
|
"typecheck": "tsc --project tsconfig.build.json --pretty --noEmit",
|
|
83
84
|
"clean": "rimraf dist .tsbuildinfo",
|
|
84
|
-
"test": "vitest run --passWithNoTests"
|
|
85
|
+
"test": "vitest run --passWithNoTests",
|
|
86
|
+
"test:browser": "vitest run --config vitest.browser.config.ts"
|
|
85
87
|
}
|
|
86
88
|
}
|
|
@@ -72,6 +72,7 @@ describe('CSS nesting output equivalence', () => {
|
|
|
72
72
|
'__snapshots__',
|
|
73
73
|
'index.css.snap',
|
|
74
74
|
)
|
|
75
|
-
await
|
|
75
|
+
const expected = await fs.readFile(snapshotPath, 'utf-8')
|
|
76
|
+
expect(canonicalize(result.root)).toBe(expected)
|
|
76
77
|
})
|
|
77
78
|
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react'
|
|
2
|
+
import TextArea from '.'
|
|
3
|
+
|
|
4
|
+
describe('TextArea component', () => {
|
|
5
|
+
it.each`
|
|
6
|
+
name | value | defaultValue | expectedValue | expectedCount
|
|
7
|
+
${'uncontrolled defaultValue'} | ${undefined} | ${'abc'} | ${'abc'} | ${'3'}
|
|
8
|
+
${'controlled null'} | ${null as unknown as string} | ${undefined} | ${''} | ${'0'}
|
|
9
|
+
${'controlled null with defaultValue'} | ${null as unknown as string} | ${'abc'} | ${'abc'} | ${'3'}
|
|
10
|
+
${'controlled value with defaultValue'} | ${'xy'} | ${'abc'} | ${'xy'} | ${'2'}
|
|
11
|
+
`('$name', ({ value, defaultValue, expectedValue, expectedCount }) => {
|
|
12
|
+
render(<TextArea showCount value={value} defaultValue={defaultValue} />)
|
|
13
|
+
|
|
14
|
+
expect(screen.getByRole('textbox')).toHaveValue(expectedValue)
|
|
15
|
+
expect(screen.getByText(expectedCount)).toBeInTheDocument()
|
|
16
|
+
})
|
|
17
|
+
})
|
|
@@ -78,17 +78,18 @@ const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
|
|
|
78
78
|
},
|
|
79
79
|
forwardRef,
|
|
80
80
|
) {
|
|
81
|
+
const isUncontrolled = value === undefined
|
|
82
|
+
// `null` is invalid for TextAreaProps, but may arrive at runtime. Keep the
|
|
83
|
+
// pre-f710d512 nullish fallback so getCount is never called with null.
|
|
84
|
+
const countValue = value ?? defaultValue?.toString() ?? ''
|
|
81
85
|
const [rows, setRows] = useState(initialRows)
|
|
82
|
-
const [count, setCount] = useState(
|
|
83
|
-
getCount(value ?? defaultValue?.toString() ?? ''),
|
|
84
|
-
)
|
|
86
|
+
const [count, setCount] = useState(getCount(countValue))
|
|
85
87
|
|
|
86
88
|
const textareaRef = useRef<HTMLTextAreaElement>(null)
|
|
87
89
|
const containerRef = useRef(null)
|
|
88
90
|
useFocusWithClick(containerRef, textareaRef)
|
|
89
91
|
const { visuallyHiddenProps } = useVisuallyHidden()
|
|
90
92
|
|
|
91
|
-
const isUncontrolled = value === undefined
|
|
92
93
|
const isEnableAutoHeight = useMemo(
|
|
93
94
|
() => autoHeight || (maxRows && maxRows >= 0),
|
|
94
95
|
[autoHeight, maxRows],
|
|
@@ -172,7 +173,7 @@ const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
|
|
|
172
173
|
useEffect(() => {
|
|
173
174
|
// 制御コンポーネントの時の挙動
|
|
174
175
|
if (!isUncontrolled) {
|
|
175
|
-
setCount(getCount(
|
|
176
|
+
setCount(getCount(countValue))
|
|
176
177
|
}
|
|
177
178
|
|
|
178
179
|
// autoHeight同期(valueが変更された時にsyncHeightしたい)
|
|
@@ -181,7 +182,7 @@ const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
|
|
|
181
182
|
}
|
|
182
183
|
}, [
|
|
183
184
|
isUncontrolled,
|
|
184
|
-
|
|
185
|
+
countValue,
|
|
185
186
|
getCount,
|
|
186
187
|
isEnableAutoHeight,
|
|
187
188
|
textareaRef,
|