@charcoal-ui/react 5.4.1 → 5.4.3
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/DropdownSelector/DropdownMenuItem/index.d.ts +4 -1
- package/dist/components/DropdownSelector/DropdownMenuItem/index.d.ts.map +1 -1
- package/dist/components/TextEllipsis/index.d.ts +15 -2
- package/dist/components/TextEllipsis/index.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +20 -7
- package/dist/index.css.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/layered.css +20 -7
- package/dist/layered.css.map +1 -1
- package/package.json +6 -5
- package/src/components/DropdownSelector/DropdownMenuItem/index.css +16 -0
- package/src/components/DropdownSelector/DropdownMenuItem/index.tsx +26 -15
- package/src/components/DropdownSelector/index.story.tsx +29 -0
- package/src/components/TextEllipsis/TextEllipsis.story.tsx +29 -0
- package/src/components/TextEllipsis/index.css +4 -7
- package/src/components/TextEllipsis/index.tsx +17 -1
|
@@ -424,3 +424,32 @@ export const Section: StoryObj<typeof DropdownSelector> = {
|
|
|
424
424
|
)
|
|
425
425
|
},
|
|
426
426
|
}
|
|
427
|
+
|
|
428
|
+
export const WithSeconday: StoryObj<typeof DropdownSelector> = {
|
|
429
|
+
render: function Render(props) {
|
|
430
|
+
const [selected, setSelected] = useState('option-3')
|
|
431
|
+
return (
|
|
432
|
+
<div style={{ width: 288 }}>
|
|
433
|
+
<DropdownSelector
|
|
434
|
+
{...props}
|
|
435
|
+
onChange={(value) => {
|
|
436
|
+
setSelected(value)
|
|
437
|
+
}}
|
|
438
|
+
value={selected}
|
|
439
|
+
label="label"
|
|
440
|
+
>
|
|
441
|
+
<MenuItemGroup text="fruits">
|
|
442
|
+
<DropdownMenuItem value={'option-1'}>Option 1</DropdownMenuItem>
|
|
443
|
+
<DropdownMenuItem value={'option-2'}>Option 2</DropdownMenuItem>
|
|
444
|
+
<DropdownMenuItem
|
|
445
|
+
value={'option-3'}
|
|
446
|
+
secondary={<span>Option 3 Secondary</span>}
|
|
447
|
+
>
|
|
448
|
+
Option 3
|
|
449
|
+
</DropdownMenuItem>
|
|
450
|
+
</MenuItemGroup>
|
|
451
|
+
</DropdownSelector>
|
|
452
|
+
</div>
|
|
453
|
+
)
|
|
454
|
+
},
|
|
455
|
+
}
|
|
@@ -119,3 +119,32 @@ export const ShowTooltipFalse: StoryObj<typeof TextEllipsis> = {
|
|
|
119
119
|
'showTooltip=false の場合、ホバーしてもツールチップは表示されません。',
|
|
120
120
|
},
|
|
121
121
|
}
|
|
122
|
+
|
|
123
|
+
export const useLineClamp: StoryObj<typeof TextEllipsis> = {
|
|
124
|
+
render() {
|
|
125
|
+
return (
|
|
126
|
+
<div
|
|
127
|
+
style={{
|
|
128
|
+
width: 240,
|
|
129
|
+
borderInline: '2px solid var(--charcoal-border)',
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
<div style={{ width: '100%', display: 'flex', gap: 8 }}>
|
|
133
|
+
<div>
|
|
134
|
+
<TextEllipsis>これは非常に長いテキストです。</TextEllipsis>
|
|
135
|
+
</div>
|
|
136
|
+
<div>{'useNowrap={false}'}</div>
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
<div style={{ width: '100%', display: 'flex', gap: 8 }}>
|
|
140
|
+
<div>
|
|
141
|
+
<TextEllipsis useNowrap>
|
|
142
|
+
これは非常に長いテキストです。
|
|
143
|
+
</TextEllipsis>
|
|
144
|
+
</div>
|
|
145
|
+
<div>{'useNowrap={true}'}</div>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
)
|
|
149
|
+
},
|
|
150
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
.charcoal-text-ellipsis {
|
|
2
2
|
overflow: hidden;
|
|
3
3
|
overflow-wrap: break-word;
|
|
4
|
+
display: -webkit-box;
|
|
5
|
+
-webkit-box-orient: vertical;
|
|
6
|
+
-webkit-line-clamp: var(--charcoal-text-ellipsis-line-limit);
|
|
4
7
|
}
|
|
5
8
|
|
|
6
9
|
.charcoal-text-ellipsis[data-has-line-height='true'] {
|
|
@@ -11,13 +14,7 @@
|
|
|
11
14
|
line-height: inherit;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
.charcoal-text-ellipsis[data-line-limit='1'] {
|
|
17
|
+
.charcoal-text-ellipsis[data-line-limit='1'][data-use-nowrap='true'] {
|
|
15
18
|
text-overflow: ellipsis;
|
|
16
19
|
white-space: nowrap;
|
|
17
20
|
}
|
|
18
|
-
|
|
19
|
-
.charcoal-text-ellipsis[data-line-limit]:not([data-line-limit='1']) {
|
|
20
|
-
display: -webkit-box;
|
|
21
|
-
-webkit-box-orient: vertical;
|
|
22
|
-
-webkit-line-clamp: var(--charcoal-text-ellipsis-line-limit);
|
|
23
|
-
}
|
|
@@ -7,9 +7,22 @@ import { CSSProperties } from 'react'
|
|
|
7
7
|
export type TextEllipsisProps = {
|
|
8
8
|
lineHeight?: number
|
|
9
9
|
lineLimit?: number
|
|
10
|
+
/**
|
|
11
|
+
* @default 'auto'
|
|
12
|
+
*/
|
|
10
13
|
hyphens?: CSSProperties['hyphens']
|
|
11
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* html title属性を付与。false のときは付与せず、空文字のときは表示しない
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
12
18
|
showTooltip?: boolean
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @default false
|
|
22
|
+
* true: use white-space: nowrap if lineLimit is 1
|
|
23
|
+
* false: use -webkit-line-clamp if lineLimit is 1
|
|
24
|
+
*/
|
|
25
|
+
useNowrap?: boolean
|
|
13
26
|
} & React.ComponentPropsWithoutRef<'div'>
|
|
14
27
|
|
|
15
28
|
/**
|
|
@@ -22,8 +35,10 @@ export default function TextEllipsis({
|
|
|
22
35
|
title,
|
|
23
36
|
hyphens = 'auto',
|
|
24
37
|
showTooltip = true,
|
|
38
|
+
useNowrap = false,
|
|
25
39
|
...props
|
|
26
40
|
}: TextEllipsisProps) {
|
|
41
|
+
'use memo'
|
|
27
42
|
const finalTitle = getFinalTitle(showTooltip, title, children)
|
|
28
43
|
|
|
29
44
|
const classNames = useClassNames('charcoal-text-ellipsis', props.className)
|
|
@@ -35,6 +50,7 @@ export default function TextEllipsis({
|
|
|
35
50
|
className={classNames}
|
|
36
51
|
data-line-limit={lineLimit}
|
|
37
52
|
data-has-line-height={hasLineHeight}
|
|
53
|
+
{...(useNowrap ? { 'data-use-nowrap': useNowrap } : {})}
|
|
38
54
|
style={
|
|
39
55
|
{
|
|
40
56
|
...(hasLineHeight && {
|