@charcoal-ui/react 6.0.0-rc.0 → 6.0.0-rc.1
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/Modal/index.d.ts +1 -1
- package/dist/components/TagItem/index.d.ts +5 -4
- package/dist/components/TagItem/index.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/TagItem/__snapshots__/index.story.storyshot +17 -17
- package/src/components/TagItem/index.tsx +25 -7
- package/src/index.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@charcoal-ui/react",
|
|
3
|
-
"version": "6.0.0-rc.
|
|
3
|
+
"version": "6.0.0-rc.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"polished": "^4.1.4",
|
|
43
43
|
"react-compiler-runtime": "1.0.0",
|
|
44
44
|
"warning": "^4.0.3",
|
|
45
|
-
"@charcoal-ui/
|
|
46
|
-
"@charcoal-ui/
|
|
47
|
-
"@charcoal-ui/
|
|
48
|
-
"@charcoal-ui/
|
|
45
|
+
"@charcoal-ui/foundation": "6.0.0-rc.1",
|
|
46
|
+
"@charcoal-ui/theme": "6.0.0-rc.1",
|
|
47
|
+
"@charcoal-ui/icons": "6.0.0-rc.1",
|
|
48
|
+
"@charcoal-ui/utils": "6.0.0-rc.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"react": ">=17.0.0",
|
|
@@ -5,7 +5,7 @@ exports[`Storybook Tests > react/TagItem > Active 1`] = `
|
|
|
5
5
|
<div
|
|
6
6
|
data-dark="false"
|
|
7
7
|
>
|
|
8
|
-
<
|
|
8
|
+
<a
|
|
9
9
|
class="charcoal-tag-item charcoal-tag-item__bg"
|
|
10
10
|
data-bg-variant="color"
|
|
11
11
|
data-size="M"
|
|
@@ -28,7 +28,7 @@ exports[`Storybook Tests > react/TagItem > Active 1`] = `
|
|
|
28
28
|
name="16/Remove"
|
|
29
29
|
style="--charcoal-icon-size: 16px;"
|
|
30
30
|
/>
|
|
31
|
-
</
|
|
31
|
+
</a>
|
|
32
32
|
</div>
|
|
33
33
|
</div>
|
|
34
34
|
`;
|
|
@@ -38,7 +38,7 @@ exports[`Storybook Tests > react/TagItem > BGColor 1`] = `
|
|
|
38
38
|
<div
|
|
39
39
|
data-dark="false"
|
|
40
40
|
>
|
|
41
|
-
<
|
|
41
|
+
<a
|
|
42
42
|
class="charcoal-tag-item charcoal-tag-item__bg"
|
|
43
43
|
data-bg-variant="color"
|
|
44
44
|
data-size="M"
|
|
@@ -56,7 +56,7 @@ exports[`Storybook Tests > react/TagItem > BGColor 1`] = `
|
|
|
56
56
|
女の子
|
|
57
57
|
</span>
|
|
58
58
|
</div>
|
|
59
|
-
</
|
|
59
|
+
</a>
|
|
60
60
|
</div>
|
|
61
61
|
</div>
|
|
62
62
|
`;
|
|
@@ -66,7 +66,7 @@ exports[`Storybook Tests > react/TagItem > BGImage 1`] = `
|
|
|
66
66
|
<div
|
|
67
67
|
data-dark="false"
|
|
68
68
|
>
|
|
69
|
-
<
|
|
69
|
+
<a
|
|
70
70
|
class="charcoal-tag-item charcoal-tag-item__bg"
|
|
71
71
|
data-bg-variant="image"
|
|
72
72
|
data-size="M"
|
|
@@ -84,7 +84,7 @@ exports[`Storybook Tests > react/TagItem > BGImage 1`] = `
|
|
|
84
84
|
#女の子
|
|
85
85
|
</span>
|
|
86
86
|
</div>
|
|
87
|
-
</
|
|
87
|
+
</a>
|
|
88
88
|
</div>
|
|
89
89
|
</div>
|
|
90
90
|
`;
|
|
@@ -94,7 +94,7 @@ exports[`Storybook Tests > react/TagItem > Default 1`] = `
|
|
|
94
94
|
<div
|
|
95
95
|
data-dark="false"
|
|
96
96
|
>
|
|
97
|
-
<
|
|
97
|
+
<a
|
|
98
98
|
class="charcoal-tag-item charcoal-tag-item__bg"
|
|
99
99
|
data-bg-variant="color"
|
|
100
100
|
data-size="M"
|
|
@@ -112,7 +112,7 @@ exports[`Storybook Tests > react/TagItem > Default 1`] = `
|
|
|
112
112
|
#女の子
|
|
113
113
|
</span>
|
|
114
114
|
</div>
|
|
115
|
-
</
|
|
115
|
+
</a>
|
|
116
116
|
</div>
|
|
117
117
|
</div>
|
|
118
118
|
`;
|
|
@@ -122,12 +122,12 @@ exports[`Storybook Tests > react/TagItem > Disabled 1`] = `
|
|
|
122
122
|
<div
|
|
123
123
|
data-dark="false"
|
|
124
124
|
>
|
|
125
|
-
<
|
|
125
|
+
<a
|
|
126
|
+
aria-disabled="true"
|
|
126
127
|
class="charcoal-tag-item charcoal-tag-item__bg"
|
|
127
128
|
data-bg-variant="color"
|
|
128
129
|
data-size="M"
|
|
129
130
|
data-state="default"
|
|
130
|
-
disabled=""
|
|
131
131
|
style="--charcoal-tag-item-bg: #7ACCB1;"
|
|
132
132
|
>
|
|
133
133
|
<div
|
|
@@ -141,7 +141,7 @@ exports[`Storybook Tests > react/TagItem > Disabled 1`] = `
|
|
|
141
141
|
#女の子
|
|
142
142
|
</span>
|
|
143
143
|
</div>
|
|
144
|
-
</
|
|
144
|
+
</a>
|
|
145
145
|
</div>
|
|
146
146
|
</div>
|
|
147
147
|
`;
|
|
@@ -151,7 +151,7 @@ exports[`Storybook Tests > react/TagItem > InActive 1`] = `
|
|
|
151
151
|
<div
|
|
152
152
|
data-dark="false"
|
|
153
153
|
>
|
|
154
|
-
<
|
|
154
|
+
<a
|
|
155
155
|
class="charcoal-tag-item charcoal-tag-item__bg"
|
|
156
156
|
data-bg-variant="color"
|
|
157
157
|
data-size="M"
|
|
@@ -169,7 +169,7 @@ exports[`Storybook Tests > react/TagItem > InActive 1`] = `
|
|
|
169
169
|
#女の子
|
|
170
170
|
</span>
|
|
171
171
|
</div>
|
|
172
|
-
</
|
|
172
|
+
</a>
|
|
173
173
|
</div>
|
|
174
174
|
</div>
|
|
175
175
|
`;
|
|
@@ -179,7 +179,7 @@ exports[`Storybook Tests > react/TagItem > Small 1`] = `
|
|
|
179
179
|
<div
|
|
180
180
|
data-dark="false"
|
|
181
181
|
>
|
|
182
|
-
<
|
|
182
|
+
<a
|
|
183
183
|
class="charcoal-tag-item charcoal-tag-item__bg"
|
|
184
184
|
data-bg-variant="color"
|
|
185
185
|
data-size="S"
|
|
@@ -197,7 +197,7 @@ exports[`Storybook Tests > react/TagItem > Small 1`] = `
|
|
|
197
197
|
#女の子
|
|
198
198
|
</span>
|
|
199
199
|
</div>
|
|
200
|
-
</
|
|
200
|
+
</a>
|
|
201
201
|
</div>
|
|
202
202
|
</div>
|
|
203
203
|
`;
|
|
@@ -207,7 +207,7 @@ exports[`Storybook Tests > react/TagItem > TranslatedLabel 1`] = `
|
|
|
207
207
|
<div
|
|
208
208
|
data-dark="false"
|
|
209
209
|
>
|
|
210
|
-
<
|
|
210
|
+
<a
|
|
211
211
|
class="charcoal-tag-item charcoal-tag-item__bg"
|
|
212
212
|
data-bg-variant="color"
|
|
213
213
|
data-size="M"
|
|
@@ -230,7 +230,7 @@ exports[`Storybook Tests > react/TagItem > TranslatedLabel 1`] = `
|
|
|
230
230
|
#女の子
|
|
231
231
|
</span>
|
|
232
232
|
</div>
|
|
233
|
-
</
|
|
233
|
+
</a>
|
|
234
234
|
</div>
|
|
235
235
|
</div>
|
|
236
236
|
`;
|
|
@@ -4,27 +4,29 @@ import { useClassNames } from '../../_lib/useClassNames'
|
|
|
4
4
|
import './index.css'
|
|
5
5
|
|
|
6
6
|
import { useObjectRef } from 'react-aria/useObjectRef'
|
|
7
|
+
import { useLink } from 'react-aria'
|
|
7
8
|
|
|
8
9
|
type SizeMap = {
|
|
9
10
|
S: 32
|
|
10
11
|
M: 40
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
export type TagItemProps<T extends React.ElementType = '
|
|
14
|
+
export type TagItemProps<T extends React.ElementType = 'a'> = {
|
|
14
15
|
label: string
|
|
15
16
|
translatedLabel?: string
|
|
16
17
|
bgColor?: string
|
|
17
18
|
bgImage?: string
|
|
18
19
|
status?: 'default' | 'active' | 'inactive'
|
|
19
20
|
size?: keyof SizeMap
|
|
21
|
+
disabled?: boolean
|
|
20
22
|
/**
|
|
21
23
|
* The component used for root element.
|
|
22
|
-
* @type T extends React.ElementType = '
|
|
24
|
+
* @type T extends React.ElementType = 'a'
|
|
23
25
|
*/
|
|
24
26
|
component?: T
|
|
25
|
-
} & Omit<React.ComponentPropsWithRef<T>, 'children'>
|
|
27
|
+
} & Omit<React.ComponentPropsWithRef<T>, 'children' | 'disabled'>
|
|
26
28
|
|
|
27
|
-
const TagItem = forwardRef<
|
|
29
|
+
const TagItem = forwardRef<HTMLAnchorElement, TagItemProps>(
|
|
28
30
|
function TagItemInner<T extends React.ElementType>(
|
|
29
31
|
{
|
|
30
32
|
component,
|
|
@@ -34,9 +36,11 @@ const TagItem = forwardRef<HTMLButtonElement, TagItemProps>(
|
|
|
34
36
|
bgImage,
|
|
35
37
|
size = 'M',
|
|
36
38
|
status = 'default',
|
|
39
|
+
disabled,
|
|
40
|
+
'aria-disabled': ariaDisabled,
|
|
37
41
|
...props
|
|
38
42
|
}: TagItemProps<T>,
|
|
39
|
-
_ref: ForwardedRef<
|
|
43
|
+
_ref: ForwardedRef<HTMLAnchorElement>,
|
|
40
44
|
) {
|
|
41
45
|
const ref = useObjectRef(_ref)
|
|
42
46
|
|
|
@@ -52,11 +56,25 @@ const TagItem = forwardRef<HTMLButtonElement, TagItemProps>(
|
|
|
52
56
|
bgImage !== undefined && bgImage.length > 0 ? 'image' : 'color'
|
|
53
57
|
const bg = bgVariant === 'color' ? bgColor : `url(${bgImage ?? ''})`
|
|
54
58
|
|
|
55
|
-
const Component = useMemo(() => component ?? '
|
|
59
|
+
const Component = useMemo(() => component ?? 'a', [component])
|
|
60
|
+
const isButton = Component === 'button'
|
|
61
|
+
|
|
62
|
+
const { linkProps } = useLink(
|
|
63
|
+
{
|
|
64
|
+
isDisabled: disabled,
|
|
65
|
+
elementType: typeof Component === 'string' ? Component : 'a',
|
|
66
|
+
},
|
|
67
|
+
ref,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
const disabledProps = isButton
|
|
71
|
+
? { disabled, 'aria-disabled': ariaDisabled }
|
|
72
|
+
: linkProps
|
|
56
73
|
|
|
57
74
|
return (
|
|
58
75
|
<Component
|
|
59
76
|
{...props}
|
|
77
|
+
{...disabledProps}
|
|
60
78
|
ref={ref}
|
|
61
79
|
className={className}
|
|
62
80
|
data-state={status}
|
|
@@ -84,6 +102,6 @@ const TagItem = forwardRef<HTMLButtonElement, TagItemProps>(
|
|
|
84
102
|
</Component>
|
|
85
103
|
)
|
|
86
104
|
},
|
|
87
|
-
) as <T extends React.ElementType = '
|
|
105
|
+
) as <T extends React.ElementType = 'a'>(p: TagItemProps<T>) => JSX.Element
|
|
88
106
|
|
|
89
107
|
export default memo(TagItem)
|
package/src/index.ts
CHANGED
|
@@ -88,11 +88,11 @@ export {
|
|
|
88
88
|
type HintTextContext,
|
|
89
89
|
} from './components/HintText'
|
|
90
90
|
export {
|
|
91
|
-
default as
|
|
91
|
+
default as TextEllipsis,
|
|
92
92
|
type TextEllipsisProps,
|
|
93
93
|
} from './components/TextEllipsis'
|
|
94
94
|
export {
|
|
95
|
-
default as
|
|
95
|
+
default as Pagination,
|
|
96
96
|
type PaginationProps,
|
|
97
97
|
} from './components/Pagination'
|
|
98
98
|
import './components/FocusRing/index.css'
|