@charcoal-ui/react 3.4.0 → 3.6.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.
Files changed (77) hide show
  1. package/dist/components/Button/index.d.ts.map +1 -1
  2. package/dist/components/Checkbox/index.d.ts.map +1 -1
  3. package/dist/components/Checkbox/index.story.d.ts +1 -0
  4. package/dist/components/Checkbox/index.story.d.ts.map +1 -1
  5. package/dist/components/DropdownSelector/DropdownMenuItem.d.ts.map +1 -1
  6. package/dist/components/DropdownSelector/ListItem/index.d.ts.map +1 -1
  7. package/dist/components/DropdownSelector/Popover/index.d.ts.map +1 -1
  8. package/dist/components/DropdownSelector/index.d.ts.map +1 -1
  9. package/dist/components/FieldLabel/index.d.ts.map +1 -1
  10. package/dist/components/IconButton/index.d.ts.map +1 -1
  11. package/dist/components/LoadingSpinner/index.d.ts.map +1 -1
  12. package/dist/components/Modal/ModalPlumbing.d.ts.map +1 -1
  13. package/dist/components/Modal/index.d.ts.map +1 -1
  14. package/dist/components/Modal/index.story.d.ts +1 -0
  15. package/dist/components/Modal/index.story.d.ts.map +1 -1
  16. package/dist/components/MultiSelect/index.d.ts.map +1 -1
  17. package/dist/components/MultiSelect/index.story.d.ts +2 -0
  18. package/dist/components/MultiSelect/index.story.d.ts.map +1 -1
  19. package/dist/components/Radio/index.d.ts.map +1 -1
  20. package/dist/components/SegmentedControl/index.d.ts.map +1 -1
  21. package/dist/components/Switch/index.d.ts.map +1 -1
  22. package/dist/components/TagItem/index.d.ts.map +1 -1
  23. package/dist/components/TextArea/index.d.ts.map +1 -1
  24. package/dist/components/TextField/TextField.story.d.ts.map +1 -1
  25. package/dist/components/TextField/index.d.ts +4 -0
  26. package/dist/components/TextField/index.d.ts.map +1 -1
  27. package/dist/components/TextField/useFocusWithClick.d.ts +3 -0
  28. package/dist/components/TextField/useFocusWithClick.d.ts.map +1 -0
  29. package/dist/index.cjs.js +935 -494
  30. package/dist/index.cjs.js.map +1 -1
  31. package/dist/index.esm.js +863 -422
  32. package/dist/index.esm.js.map +1 -1
  33. package/dist/styled.d.ts +4 -4
  34. package/package.json +9 -9
  35. package/src/components/Button/__snapshots__/index.story.storyshot +312 -592
  36. package/src/components/Button/index.tsx +50 -14
  37. package/src/components/Checkbox/__snapshots__/index.story.storyshot +209 -40
  38. package/src/components/Checkbox/__snapshots__/snapshot.test.tsx.snap +410 -80
  39. package/src/components/Checkbox/index.story.tsx +24 -0
  40. package/src/components/Checkbox/index.tsx +47 -17
  41. package/src/components/Clickable/__snapshots__/index.story.storyshot +4 -0
  42. package/src/components/Clickable/index.tsx +1 -0
  43. package/src/components/DropdownSelector/DropdownMenuItem.tsx +19 -3
  44. package/src/components/DropdownSelector/ListItem/__snapshots__/index.story.storyshot +3 -10
  45. package/src/components/DropdownSelector/ListItem/index.tsx +6 -4
  46. package/src/components/DropdownSelector/MenuItemGroup/index.tsx +1 -1
  47. package/src/components/DropdownSelector/MenuList/__snapshots__/index.story.storyshot +4 -13
  48. package/src/components/DropdownSelector/Popover/__snapshots__/index.story.storyshot +20 -37
  49. package/src/components/DropdownSelector/Popover/index.tsx +5 -8
  50. package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +60 -191
  51. package/src/components/DropdownSelector/index.tsx +70 -20
  52. package/src/components/FieldLabel/index.tsx +77 -12
  53. package/src/components/IconButton/__snapshots__/index.story.storyshot +30 -54
  54. package/src/components/IconButton/index.tsx +51 -26
  55. package/src/components/LoadingSpinner/index.tsx +3 -6
  56. package/src/components/Modal/Dialog/index.tsx +1 -1
  57. package/src/components/Modal/ModalPlumbing.tsx +26 -5
  58. package/src/components/Modal/__snapshots__/index.story.storyshot +2454 -108
  59. package/src/components/Modal/index.story.tsx +27 -0
  60. package/src/components/Modal/index.tsx +19 -4
  61. package/src/components/MultiSelect/__snapshots__/index.story.storyshot +528 -25
  62. package/src/components/MultiSelect/index.story.tsx +60 -0
  63. package/src/components/MultiSelect/index.tsx +82 -22
  64. package/src/components/Radio/__snapshots__/index.story.storyshot +32 -49
  65. package/src/components/Radio/index.tsx +71 -23
  66. package/src/components/SegmentedControl/__snapshots__/index.story.storyshot +18 -19
  67. package/src/components/SegmentedControl/index.tsx +35 -15
  68. package/src/components/Switch/__snapshots__/index.story.storyshot +6 -18
  69. package/src/components/Switch/index.tsx +10 -15
  70. package/src/components/TagItem/__snapshots__/index.story.storyshot +39 -158
  71. package/src/components/TagItem/index.tsx +84 -19
  72. package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +126 -321
  73. package/src/components/TextArea/index.tsx +38 -43
  74. package/src/components/TextField/TextField.story.tsx +35 -19
  75. package/src/components/TextField/__snapshots__/TextField.story.storyshot +309 -563
  76. package/src/components/TextField/index.tsx +85 -84
  77. package/src/components/TextField/useFocusWithClick.tsx +22 -0
@@ -17,6 +17,8 @@ exports[`Storyshots IconButton Default M 1`] = `
17
17
  -ms-letter-spacing: inherit;
18
18
  letter-spacing: inherit;
19
19
  word-spacing: inherit;
20
+ -webkit-text-decoration: none;
21
+ text-decoration: none;
20
22
  font: inherit;
21
23
  margin: 0;
22
24
  overflow: visible;
@@ -63,40 +65,29 @@ exports[`Storyshots IconButton Default M 1`] = `
63
65
  transition: 0.2s background-color,0.2s box-shadow;
64
66
  }
65
67
 
66
- .c1:hover:not(:disabled):not([aria-disabled]),
67
- .c1:hover[aria-disabled=false] {
68
- background-color: var(--charcoal-transparent-hover);
68
+ .c1:not(:disabled):not([aria-disabled]):hover,
69
+ .c1[aria-disabled='false']:hover {
70
+ background-color: var( --charcoal-transparent-hover );
69
71
  }
70
72
 
71
- .c1:active:not(:disabled):not([aria-disabled]),
72
- .c1:active[aria-disabled=false] {
73
- background-color: var(--charcoal-transparent-press);
74
- }
75
-
76
- .c1:disabled,
77
- .c1[aria-disabled]:not([aria-disabled=false]) {
78
- opacity: 0.32;
73
+ .c1:not(:disabled):not([aria-disabled]):active,
74
+ .c1[aria-disabled='false']:active {
75
+ background-color: var( --charcoal-transparent-press );
79
76
  }
80
77
 
81
78
  .c1:not(:disabled):not([aria-disabled]):focus,
82
- .c1[aria-disabled=false]:focus,
79
+ .c1[aria-disabled='false']:focus,
83
80
  .c1:not(:disabled):not([aria-disabled]):active,
84
- .c1[aria-disabled=false]:active {
81
+ .c1[aria-disabled='false']:active,
82
+ .c1:not(:disabled):not([aria-disabled]):focus-visible,
83
+ .c1[aria-disabled='false']:focus-visible {
85
84
  outline: none;
86
85
  box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
87
86
  }
88
87
 
89
- .c1:not(:disabled):not([aria-disabled]):focus:not(:focus-visible),
90
- .c1[aria-disabled=false]:focus:not(:focus-visible),
91
- .c1:not(:disabled):not([aria-disabled]):active:not(:focus-visible),
92
- .c1[aria-disabled=false]:active:not(:focus-visible) {
93
- outline: none;
94
- }
95
-
96
- .c1:not(:disabled):not([aria-disabled]):focus-visible,
97
- .c1[aria-disabled=false]:focus-visible {
98
- outline: none;
99
- box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
88
+ .c1:disabled,
89
+ .c1[aria-disabled]:not([aria-disabled='false']) {
90
+ opacity: 0.32;
100
91
  }
101
92
 
102
93
  <div
@@ -104,10 +95,7 @@ exports[`Storyshots IconButton Default M 1`] = `
104
95
  >
105
96
  <button
106
97
  className="c0 c1"
107
- height={40}
108
- size="M"
109
98
  title="close"
110
- width={40}
111
99
  >
112
100
  <pixiv-icon
113
101
  name="24/Close"
@@ -133,6 +121,8 @@ exports[`Storyshots IconButton Overlay M 1`] = `
133
121
  -ms-letter-spacing: inherit;
134
122
  letter-spacing: inherit;
135
123
  word-spacing: inherit;
124
+ -webkit-text-decoration: none;
125
+ text-decoration: none;
136
126
  font: inherit;
137
127
  margin: 0;
138
128
  overflow: visible;
@@ -179,40 +169,29 @@ exports[`Storyshots IconButton Overlay M 1`] = `
179
169
  transition: 0.2s background-color,0.2s box-shadow;
180
170
  }
181
171
 
182
- .c1:hover:not(:disabled):not([aria-disabled]),
183
- .c1:hover[aria-disabled=false] {
184
- background-color: var(--charcoal-surface4-hover);
172
+ .c1:not(:disabled):not([aria-disabled]):hover,
173
+ .c1[aria-disabled='false']:hover {
174
+ background-color: var( --charcoal-surface4-hover );
185
175
  }
186
176
 
187
- .c1:active:not(:disabled):not([aria-disabled]),
188
- .c1:active[aria-disabled=false] {
189
- background-color: var(--charcoal-surface4-press);
190
- }
191
-
192
- .c1:disabled,
193
- .c1[aria-disabled]:not([aria-disabled=false]) {
194
- opacity: 0.32;
177
+ .c1:not(:disabled):not([aria-disabled]):active,
178
+ .c1[aria-disabled='false']:active {
179
+ background-color: var( --charcoal-surface4-press );
195
180
  }
196
181
 
197
182
  .c1:not(:disabled):not([aria-disabled]):focus,
198
- .c1[aria-disabled=false]:focus,
183
+ .c1[aria-disabled='false']:focus,
199
184
  .c1:not(:disabled):not([aria-disabled]):active,
200
- .c1[aria-disabled=false]:active {
185
+ .c1[aria-disabled='false']:active,
186
+ .c1:not(:disabled):not([aria-disabled]):focus-visible,
187
+ .c1[aria-disabled='false']:focus-visible {
201
188
  outline: none;
202
189
  box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
203
190
  }
204
191
 
205
- .c1:not(:disabled):not([aria-disabled]):focus:not(:focus-visible),
206
- .c1[aria-disabled=false]:focus:not(:focus-visible),
207
- .c1:not(:disabled):not([aria-disabled]):active:not(:focus-visible),
208
- .c1[aria-disabled=false]:active:not(:focus-visible) {
209
- outline: none;
210
- }
211
-
212
- .c1:not(:disabled):not([aria-disabled]):focus-visible,
213
- .c1[aria-disabled=false]:focus-visible {
214
- outline: none;
215
- box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
192
+ .c1:disabled,
193
+ .c1[aria-disabled]:not([aria-disabled='false']) {
194
+ opacity: 0.32;
216
195
  }
217
196
 
218
197
  <div
@@ -220,10 +199,7 @@ exports[`Storyshots IconButton Overlay M 1`] = `
220
199
  >
221
200
  <button
222
201
  className="c0 c1"
223
- height={40}
224
- size="M"
225
202
  title="close"
226
- width={40}
227
203
  >
228
204
  <pixiv-icon
229
205
  name="24/Close"
@@ -1,6 +1,5 @@
1
1
  import { forwardRef } from 'react'
2
2
  import styled from 'styled-components'
3
- import { theme } from '../../styled'
4
3
  import Clickable, { ClickableElement, ClickableProps } from '../Clickable'
5
4
  import type { KnownIconType } from '@charcoal-ui/icons'
6
5
 
@@ -22,7 +21,7 @@ const IconButton = forwardRef<ClickableElement, IconButtonProps>(
22
21
  ) {
23
22
  validateIconSize(size, icon)
24
23
  return (
25
- <StyledIconButton {...rest} ref={ref} variant={variant} size={size}>
24
+ <StyledIconButton {...rest} ref={ref} $size={size} $variant={variant}>
26
25
  <pixiv-icon name={icon} />
27
26
  </StyledIconButton>
28
27
  )
@@ -31,42 +30,68 @@ const IconButton = forwardRef<ClickableElement, IconButtonProps>(
31
30
 
32
31
  export default IconButton
33
32
 
33
+ type StyledIconButtonProps = Required<{
34
+ [key in keyof Pick<
35
+ StyledProps,
36
+ 'size' | 'variant'
37
+ > as `$${key}`]: StyledProps[key]
38
+ }>
39
+
34
40
  const StyledIconButton = styled(Clickable).attrs<
35
- Required<StyledProps>,
41
+ StyledIconButtonProps,
36
42
  ReturnType<typeof styledProps>
37
- >(styledProps)`
43
+ >(styledProps)<StyledIconButtonProps>`
38
44
  user-select: none;
39
45
 
40
- width: ${(p) => p.width}px;
41
- height: ${(p) => p.height}px;
46
+ width: ${(p) => p.$width}px;
47
+ height: ${(p) => p.$height}px;
42
48
  display: flex;
43
49
  align-items: center;
44
50
  justify-content: center;
51
+ color: var(${({ $font }) => `--charcoal-${$font}`});
52
+ background-color: var(${({ $background }) => `--charcoal-${$background}`});
53
+ border-radius: 999999px;
54
+ transition: 0.2s background-color, 0.2s box-shadow;
55
+
56
+ &:not(:disabled):not([aria-disabled]),
57
+ &[aria-disabled='false'] {
58
+ &:hover {
59
+ background-color: var(
60
+ ${({ $background }) => `--charcoal-${$background}-hover`}
61
+ );
62
+ }
63
+ &:active {
64
+ background-color: var(
65
+ ${({ $background }) => `--charcoal-${$background}-press`}
66
+ );
67
+ }
68
+ &:focus,
69
+ &:active,
70
+ &:focus-visible {
71
+ outline: none;
72
+ box-shadow: 0 0 0 4px rgba(0, 150, 250, 0.32);
73
+ }
74
+ }
45
75
 
46
- ${({ font, background }) =>
47
- theme((o) => [
48
- o.font[font],
49
- o.bg[background].hover.press,
50
- o.disabled,
51
- o.borderRadius('oval'),
52
- o.outline.default.focus,
53
- ])}
76
+ &:disabled,
77
+ &[aria-disabled]:not([aria-disabled='false']) {
78
+ opacity: 0.32;
79
+ }
54
80
  `
55
81
 
56
- function styledProps(props: Required<StyledProps>) {
82
+ function styledProps({ $size, $variant }: StyledIconButtonProps) {
57
83
  return {
58
- ...props,
59
- ...variantToProps(props.variant),
60
- ...sizeToProps(props.size),
84
+ ...variantToProps($variant),
85
+ ...sizeToProps($size),
61
86
  }
62
87
  }
63
88
 
64
89
  function variantToProps(variant: Variant) {
65
90
  switch (variant) {
66
91
  case 'Default':
67
- return { font: 'text3', background: 'transparent' } as const
92
+ return { $font: 'text3', $background: 'transparent' } as const
68
93
  case 'Overlay':
69
- return { font: 'text5', background: 'surface4' } as const
94
+ return { $font: 'text5', $background: 'surface4' } as const
70
95
  }
71
96
  }
72
97
 
@@ -74,18 +99,18 @@ function sizeToProps(size: Size) {
74
99
  switch (size) {
75
100
  case 'XS':
76
101
  return {
77
- width: 20,
78
- height: 20,
102
+ $width: 20,
103
+ $height: 20,
79
104
  }
80
105
  case 'S':
81
106
  return {
82
- width: 32,
83
- height: 32,
107
+ $width: 32,
108
+ $height: 32,
84
109
  }
85
110
  case 'M':
86
111
  return {
87
- width: 40,
88
- height: 40,
112
+ $width: 40,
113
+ $height: 40,
89
114
  }
90
115
  }
91
116
  }
@@ -1,6 +1,5 @@
1
1
  import { forwardRef, useImperativeHandle, useRef, memo } from 'react'
2
2
  import styled, { keyframes } from 'styled-components'
3
- import { theme } from '../../styled'
4
3
 
5
4
  export type LoadingSpinnerProps = {
6
5
  readonly size?: number
@@ -43,11 +42,9 @@ const LoadingSpinnerRoot = styled.div.attrs({ role: 'progressbar' })<{
43
42
  width: ${(props) => props.size}px;
44
43
  height: ${(props) => props.size}px;
45
44
  opacity: 0.84;
46
- ${({ transparent }) =>
47
- theme((o) => [
48
- o.font.text4,
49
- transparent ? o.bg.transparent : o.bg.background1,
50
- ])}
45
+ color: var(--charcoal-text4);
46
+ background-color: ${({ transparent }) =>
47
+ `var(--charcoal-${transparent ? 'transparent' : 'background1'})`};
51
48
  `
52
49
 
53
50
  const scaleOut = keyframes`
@@ -57,7 +57,7 @@ const AnimatedStyledDialogDiv = animated(styled.div<{
57
57
  }
58
58
  }}px;
59
59
 
60
- background-color: ${({ theme }) => theme.color.background1};
60
+ background-color: var(--charcoal-surface1);
61
61
  border-radius: 24px;
62
62
 
63
63
  @media ${({ theme }) => maxWidth(theme.breakpoint.screen1)} {
@@ -1,6 +1,5 @@
1
1
  import { BottomSheet, ModalContext, ModalTitle } from '.'
2
2
  import styled, { css } from 'styled-components'
3
- import { theme } from '../../styled'
4
3
  import { useContext } from 'react'
5
4
  import { maxWidth } from '@charcoal-ui/utils'
6
5
 
@@ -30,15 +29,35 @@ const ModalHeaderRoot = styled.div<{
30
29
  `
31
30
 
32
31
  const StyledModalTitle = styled(ModalTitle)`
33
- ${theme((o) => [o.font.text1, o.typography(16).bold])}
32
+ color: var(--charcoal-text1);
33
+ font-size: 16px;
34
+ line-height: 24px;
35
+ font-weight: bold;
36
+ display: flow-root;
37
+
38
+ &::before {
39
+ display: block;
40
+ width: 0;
41
+ height: 0;
42
+ content: '';
43
+ margin-top: -4px;
44
+ }
45
+ &::after {
46
+ display: block;
47
+ width: 0;
48
+ height: 0;
49
+ content: '';
50
+ margin-bottom: -4px;
51
+ }
34
52
  `
35
53
 
36
54
  export const ModalAlign = styled.div`
37
- ${theme((o) => [o.padding.horizontal(16)])}
55
+ padding-left: 16px;
56
+ padding-right: 16px;
38
57
  `
39
58
 
40
59
  export const ModalBody = styled.div`
41
- ${theme((o) => [o.padding.bottom(40)])}
60
+ padding-bottom: 40px;
42
61
  `
43
62
 
44
63
  export const ModalButtons = styled.div`
@@ -46,5 +65,7 @@ export const ModalButtons = styled.div`
46
65
  grid-auto-flow: row;
47
66
  grid-row-gap: 8px;
48
67
 
49
- ${theme((o) => [o.padding.horizontal(16).top(16)])}
68
+ padding-top: 16px;
69
+ padding-left: 16px;
70
+ padding-right: 16px;
50
71
  `