@charcoal-ui/react 4.0.1 → 4.2.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/_lib/createDivComponent.d.ts +2 -2
- package/dist/_lib/createDivComponent.d.ts.map +1 -1
- package/dist/components/Button/index.d.ts +14 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/styledButtonTypeTest.d.d.ts +2 -0
- package/dist/components/Button/styledButtonTypeTest.d.d.ts.map +1 -0
- package/dist/components/Clickable/index.d.ts +1 -1
- package/dist/components/Clickable/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/Divider/index.d.ts +1 -1
- package/dist/components/DropdownSelector/Divider/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/DropdownMenuItem/index.d.ts +1 -1
- package/dist/components/DropdownSelector/DropdownMenuItem/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/DropdownPopover.d.ts +1 -1
- package/dist/components/DropdownSelector/DropdownPopover.d.ts.map +1 -1
- package/dist/components/DropdownSelector/ListItem/index.d.ts +1 -1
- package/dist/components/DropdownSelector/ListItem/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/index.d.ts +1 -7
- package/dist/components/DropdownSelector/MenuItem/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuItemGroup/index.d.ts +1 -1
- package/dist/components/DropdownSelector/MenuItemGroup/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuList/index.d.ts +1 -1
- package/dist/components/DropdownSelector/MenuList/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/Popover/index.d.ts +1 -1
- package/dist/components/DropdownSelector/Popover/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.d.ts +1 -1
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/components/IconButton/index.d.ts +1 -1
- package/dist/components/IconButton/index.d.ts.map +1 -1
- package/dist/components/Modal/Dialog/index.d.ts +1 -1
- package/dist/components/Modal/ModalPlumbing.d.ts +7 -7
- package/dist/components/Modal/ModalPlumbing.d.ts.map +1 -1
- package/dist/components/Modal/index.d.ts +2 -2
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Switch/SwitchInput/index.d.ts.map +1 -1
- package/dist/components/TagItem/index.d.ts +1 -1
- package/dist/components/TextArea/index.d.ts +1 -1
- package/dist/components/TextArea/index.d.ts.map +1 -1
- package/dist/components/TextField/AssistiveText/index.d.ts +2 -2
- package/dist/components/TextField/AssistiveText/index.d.ts.map +1 -1
- package/dist/components/TextField/index.d.ts +1 -1
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/core/CharcoalProvider.d.ts +1 -1
- package/dist/core/CharcoalProvider.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 +2 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +2 -3
- package/dist/index.esm.js.map +1 -1
- package/package.json +11 -14
- package/src/components/Button/index.tsx +7 -1
- package/src/components/Button/styledButtonTypeTest.d.tsx +81 -0
- package/src/components/Switch/SwitchInput/index.tsx +0 -1
- package/src/components/TextField/__snapshots__/TextField.story.storyshot +1 -3
- package/src/components/TextField/index.tsx +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@charcoal-ui/react",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"test": "vitest run --passWithNoTests"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@charcoal-ui/esbuild-plugin-styled-components": "^4.0
|
|
36
|
+
"@charcoal-ui/esbuild-plugin-styled-components": "^4.2.0",
|
|
37
37
|
"@react-types/switch": "^3.1.2",
|
|
38
38
|
"@storybook/addon-actions": "^8.0.5",
|
|
39
39
|
"@storybook/react": "^8.0.5",
|
|
@@ -41,20 +41,17 @@
|
|
|
41
41
|
"@testing-library/react": "^12.1.2",
|
|
42
42
|
"@testing-library/user-event": "^13.5.0",
|
|
43
43
|
"@types/glob": "^8.1.0",
|
|
44
|
-
"@types/
|
|
45
|
-
"@types/
|
|
46
|
-
"@types/react": "^17.0.38",
|
|
47
|
-
"@types/react-dom": "^17.0.11",
|
|
44
|
+
"@types/react": "^18.3.3",
|
|
45
|
+
"@types/react-dom": "^18.3.0",
|
|
48
46
|
"@types/react-router-dom": "^5.3.3",
|
|
49
47
|
"@types/react-test-renderer": "^18.3.0",
|
|
50
48
|
"@types/warning": "^3.0.0",
|
|
51
49
|
"@vitejs/plugin-react": "^4.3.1",
|
|
52
50
|
"autoprefixer": "^10.4.19",
|
|
53
|
-
"jest-axe": "^5.0.1",
|
|
54
51
|
"jsdom": "^24.1.0",
|
|
55
52
|
"npm-run-all": "^4.1.5",
|
|
56
|
-
"react": "^
|
|
57
|
-
"react-dom": "^
|
|
53
|
+
"react": "^18.3.1",
|
|
54
|
+
"react-dom": "^18.3.1",
|
|
58
55
|
"react-router-dom": "^6.2.1",
|
|
59
56
|
"rimraf": "^3.0.2",
|
|
60
57
|
"tsup": "^6.5.0",
|
|
@@ -62,10 +59,10 @@
|
|
|
62
59
|
"vitest": "^2.0.1"
|
|
63
60
|
},
|
|
64
61
|
"dependencies": {
|
|
65
|
-
"@charcoal-ui/foundation": "^4.0
|
|
66
|
-
"@charcoal-ui/icons": "^4.0
|
|
67
|
-
"@charcoal-ui/theme": "^4.0
|
|
68
|
-
"@charcoal-ui/utils": "^4.0
|
|
62
|
+
"@charcoal-ui/foundation": "^4.2.0",
|
|
63
|
+
"@charcoal-ui/icons": "^4.2.0",
|
|
64
|
+
"@charcoal-ui/theme": "^4.2.0",
|
|
65
|
+
"@charcoal-ui/utils": "^4.2.0",
|
|
69
66
|
"@react-aria/button": "^3.9.1",
|
|
70
67
|
"@react-aria/checkbox": "^3.13.0",
|
|
71
68
|
"@react-aria/dialog": "^3.5.10",
|
|
@@ -98,5 +95,5 @@
|
|
|
98
95
|
"url": "https://github.com/pixiv/charcoal.git",
|
|
99
96
|
"directory": "packages/react"
|
|
100
97
|
},
|
|
101
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "45c93231d4b0feffe8f3a6bef2cdab96302c8eb4"
|
|
102
99
|
}
|
|
@@ -46,5 +46,11 @@ const Button = forwardRef(function Button<T extends React.ElementType>(
|
|
|
46
46
|
ref={ref}
|
|
47
47
|
/>
|
|
48
48
|
)
|
|
49
|
-
}) as <T extends React.ElementType = 'button'>(
|
|
49
|
+
}) as <T extends React.ElementType = 'button'>(
|
|
50
|
+
p: 'button' extends T
|
|
51
|
+
? ButtonProps<'button'>
|
|
52
|
+
: ButtonProps<T> & {
|
|
53
|
+
component: T // required
|
|
54
|
+
}
|
|
55
|
+
) => JSX.Element
|
|
50
56
|
export default Button
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// This file is for type testing only
|
|
2
|
+
|
|
3
|
+
// only use the type
|
|
4
|
+
import type { default as ButtonType } from './index'
|
|
5
|
+
import type styledType from 'styled-components'
|
|
6
|
+
|
|
7
|
+
declare const Button: typeof ButtonType
|
|
8
|
+
declare const styled: typeof styledType
|
|
9
|
+
|
|
10
|
+
const Custom = ({ custom }: { custom: string }) => <>{custom}</>
|
|
11
|
+
const CustomGeneric = <C extends string>({ custom }: { custom: C }) => (
|
|
12
|
+
<>{custom}</>
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
const StyledButton = styled(Button)``
|
|
16
|
+
const StyledButtonAsButton = styled(Button<'button'>)``
|
|
17
|
+
const StyledButtonA = styled(Button<'a'>)``
|
|
18
|
+
const StyledButtonCustom = styled(Button<typeof Custom>)``
|
|
19
|
+
const StyledButtonCustomAsButton = styled(
|
|
20
|
+
Button<typeof Custom>
|
|
21
|
+
)`` as typeof Button
|
|
22
|
+
const StyledButtonCustomGeneric = styled(Button<typeof CustomGeneric>)``
|
|
23
|
+
const StyledButtonCustomGenericFoo = styled(
|
|
24
|
+
Button<typeof CustomGeneric<'foo'>>
|
|
25
|
+
)``
|
|
26
|
+
|
|
27
|
+
// for type test only
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
29
|
+
function Tests() {
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
{/* OK */}
|
|
33
|
+
|
|
34
|
+
<StyledButton />
|
|
35
|
+
<StyledButton type="button" disabled />
|
|
36
|
+
<StyledButtonAsButton type="button" disabled />
|
|
37
|
+
<StyledButtonA component="a" href="#" />
|
|
38
|
+
<StyledButtonCustom component={Custom} custom="" />
|
|
39
|
+
<StyledButtonCustomAsButton<'a'> component="a" href="#" />
|
|
40
|
+
<StyledButtonCustomAsButton<typeof CustomGeneric<'bar'>>
|
|
41
|
+
component={CustomGeneric}
|
|
42
|
+
custom="bar"
|
|
43
|
+
/>
|
|
44
|
+
<StyledButtonCustomAsButton component="a" href="#" />
|
|
45
|
+
<StyledButtonCustomGeneric component={CustomGeneric} custom="" />
|
|
46
|
+
<StyledButtonCustomGenericFoo component={CustomGeneric} custom="foo" />
|
|
47
|
+
<StyledButtonCustomGenericFoo
|
|
48
|
+
component={CustomGeneric<'foo'>}
|
|
49
|
+
custom="foo"
|
|
50
|
+
/>
|
|
51
|
+
|
|
52
|
+
{/* NG */}
|
|
53
|
+
|
|
54
|
+
{/* @ts-expect-error Property 'href' does not exist on type */}
|
|
55
|
+
<StyledButton href="" />
|
|
56
|
+
{/* @ts-expect-error Property 'href' does not exist on type */}
|
|
57
|
+
<StyledButtonAsButton href="" />
|
|
58
|
+
{/* @ts-expect-error Property 'component' is missing */}
|
|
59
|
+
<StyledButtonA href="#" />
|
|
60
|
+
{/* @ts-expect-error Property 'disabled' does not exist on type */}
|
|
61
|
+
<StyledButtonA disabled />
|
|
62
|
+
{/* @ts-expect-error Type '"button"' is not assignable to type '"a"' */}
|
|
63
|
+
<StyledButtonA component="button" href="" />
|
|
64
|
+
{/* @ts-expect-error Property 'component' is missing */}
|
|
65
|
+
<StyledButtonCustom custom="" />
|
|
66
|
+
{/* @ts-expect-error Type 'string' is not assignable */}
|
|
67
|
+
<StyledButtonCustom component="a" custom="" />
|
|
68
|
+
{/* @ts-expect-error Property 'custom' does not exist on type */}
|
|
69
|
+
<StyledButtonCustomAsButton custom="" />
|
|
70
|
+
{/* @ts-expect-error Type 'href' is not assignable */}
|
|
71
|
+
<StyledButtonCustomAsButton<'button'> href="#" />
|
|
72
|
+
<StyledButtonCustomGenericFoo
|
|
73
|
+
/* @ts-expect-error Type '"foo"' is not assignable to type '"bar"' */
|
|
74
|
+
component={CustomGeneric<'bar'>}
|
|
75
|
+
custom="foo"
|
|
76
|
+
/>
|
|
77
|
+
{/* @ts-expect-error '""' is not assignable to type '"foo"' */}
|
|
78
|
+
<StyledButtonCustomGenericFoo custom="" />
|
|
79
|
+
</>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
@@ -108,7 +108,9 @@ const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(
|
|
|
108
108
|
data-invalid={invalid === true}
|
|
109
109
|
ref={containerRef}
|
|
110
110
|
>
|
|
111
|
-
{prefix &&
|
|
111
|
+
{prefix !== null && (
|
|
112
|
+
<div className="charcoal-text-field-prefix">{prefix}</div>
|
|
113
|
+
)}
|
|
112
114
|
<input
|
|
113
115
|
className="charcoal-text-field-input"
|
|
114
116
|
aria-describedby={showAssistiveText ? describedbyId : undefined}
|
|
@@ -124,7 +126,7 @@ const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(
|
|
|
124
126
|
value={value}
|
|
125
127
|
{...props}
|
|
126
128
|
/>
|
|
127
|
-
{(suffix || showCount) && (
|
|
129
|
+
{(suffix !== null || showCount) && (
|
|
128
130
|
<div className="charcoal-text-field-suffix">
|
|
129
131
|
{suffix}
|
|
130
132
|
{showCount && (
|