@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
@@ -4,8 +4,7 @@ import styled, { css } from 'styled-components'
4
4
  import { useCheckbox } from '@react-aria/checkbox'
5
5
  import { useObjectRef } from '@react-aria/utils'
6
6
  import { useToggleState } from 'react-stately'
7
- import { disabledSelector, px } from '@charcoal-ui/utils'
8
- import { theme } from '../../styled'
7
+ import { disabledSelector } from '@charcoal-ui/utils'
9
8
 
10
9
  import type { AriaCheckboxProps } from '@react-types/checkbox'
11
10
  import Icon from '../Icon'
@@ -40,6 +39,7 @@ const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
40
39
  const ariaCheckboxProps = useMemo<AriaCheckboxProps>(
41
40
  () => ({
42
41
  ...props,
42
+ isInValid: invalid,
43
43
  isSelected: props.checked,
44
44
  defaultSelected: props.defaultChecked,
45
45
  validationState: invalid ? 'invalid' : 'valid',
@@ -58,7 +58,7 @@ const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
58
58
  return (
59
59
  <InputRoot aria-disabled={isDisabled} className={props.className}>
60
60
  <CheckboxRoot>
61
- <CheckboxInput type="checkbox" {...inputProps} invalid={invalid} />
61
+ <CheckboxInput type="checkbox" {...inputProps} />
62
62
  <CheckboxInputOverlay aria-hidden={true} checked={inputProps.checked}>
63
63
  <Icon name="24/Check" unsafeNonGuidelineScale={2 / 3} />
64
64
  </CheckboxInputOverlay>
@@ -85,15 +85,18 @@ const InputRoot = styled.label`
85
85
  cursor: default;
86
86
  }
87
87
 
88
- gap: ${({ theme }) => px(theme.spacing[4])};
89
- ${theme((o) => [o.disabled])}
88
+ gap: 4px;
89
+ &:disabled,
90
+ &[aria-disabled]:not([aria-disabled='false']) {
91
+ opacity: 0.32;
92
+ }
90
93
  `
91
94
 
92
95
  const CheckboxRoot = styled.div`
93
96
  position: relative;
94
97
  `
95
98
 
96
- const CheckboxInput = styled.input<{ invalid: boolean }>`
99
+ const CheckboxInput = styled.input`
97
100
  &[type='checkbox'] {
98
101
  appearance: none;
99
102
  display: block;
@@ -101,20 +104,47 @@ const CheckboxInput = styled.input<{ invalid: boolean }>`
101
104
  margin: 0;
102
105
  width: 20px;
103
106
  height: 20px;
107
+ border-radius: 4px;
108
+ transition: 0.2s box-shadow, 0.2s background-color;
104
109
 
105
110
  &:checked {
106
- ${theme((o) => o.bg.brand.hover.press)}
111
+ background-color: var(--charcoal-brand);
112
+
113
+ &:not(:disabled):not([aria-disabled]),
114
+ &[aria-disabled='false'] {
115
+ &:hover {
116
+ background-color: var(--charcoal-brand-hover);
117
+ }
118
+ &:active {
119
+ background-color: var(--charcoal-brand-press);
120
+ }
121
+ }
122
+ }
123
+
124
+ &:not(:disabled):not([aria-disabled]),
125
+ &[aria-disabled='false'] {
126
+ &:focus,
127
+ &:active {
128
+ outline: none;
129
+ box-shadow: 0 0 0 4px rgba(0, 150, 250, 0.32);
130
+ &:not(:focus-visible) {
131
+ outline: none;
132
+ }
133
+ }
134
+ &:focus-visible {
135
+ outline: none;
136
+ box-shadow: 0 0 0 4px rgba(0, 150, 250, 0.32);
137
+ }
138
+ &[aria-invalid='true'] {
139
+ box-shadow: 0 0 0 4px rgba(255, 43, 0, 0.32);
140
+ }
107
141
  }
142
+
108
143
  &:not(:checked) {
109
144
  border-width: 2px;
110
145
  border-style: solid;
111
- border-color: ${({ theme }) => theme.color.text4};
146
+ border-color: var(--charcoal-text4);
112
147
  }
113
- ${theme((o) => [o.outline.default.focus, o.borderRadius(4)])}
114
- ${(p) => p.invalid && theme((o) => [o.outline.assertive])}
115
-
116
- /* FIXME: o.outline.default.focus の transition に o.bg.brand の transition が打ち消されてしまう */
117
- transition: all 0.2s !important;
118
148
  }
119
149
  `
120
150
 
@@ -126,15 +156,15 @@ const CheckboxInputOverlay = styled.div<{ checked?: boolean }>`
126
156
  display: flex;
127
157
  align-items: center;
128
158
  justify-content: center;
129
-
130
- ${theme((o) => [o.width.px(24), o.height.px(24), o.font.text5])}
159
+ width: 24px;
160
+ height: 24px;
161
+ color: var(--charcoal-text5);
131
162
 
132
163
  ${({ checked }) => checked !== true && hiddenCss};
133
164
  `
134
165
 
135
166
  const InputLabel = styled.div`
136
- ${theme((o) => [o.font.text2])}
137
-
167
+ color: var(--charcoal-text2);
138
168
  font-size: 14px;
139
169
  /** checkbox の height が 20px なのでcheckbox と text が揃っているように見せるために行ボックスの高さを 20px にしている */
140
170
  line-height: 20px;
@@ -17,6 +17,8 @@ exports[`Storyshots Clickable Button 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;
@@ -66,6 +68,8 @@ exports[`Storyshots Clickable Link 1`] = `
66
68
  -ms-letter-spacing: inherit;
67
69
  letter-spacing: inherit;
68
70
  word-spacing: inherit;
71
+ -webkit-text-decoration: none;
72
+ text-decoration: none;
69
73
  font: inherit;
70
74
  margin: 0;
71
75
  overflow: visible;
@@ -65,6 +65,7 @@ const StyledClickableDiv = styled.div`
65
65
  text-rendering: inherit;
66
66
  letter-spacing: inherit;
67
67
  word-spacing: inherit;
68
+ text-decoration: none;
68
69
 
69
70
  &:focus {
70
71
  outline: none;
@@ -2,7 +2,6 @@ import styled from 'styled-components'
2
2
  import MenuItem, { MenuItemProps } from './MenuItem'
3
3
  import { MenuListContext } from './MenuList/MenuListContext'
4
4
  import { useContext } from 'react'
5
- import { theme } from '../../styled'
6
5
  import Icon from '../Icon'
7
6
 
8
7
  export type DropdownMenuItemProps = Omit<MenuItemProps<'div'>, 'as'>
@@ -27,7 +26,24 @@ export default function DropdownMenuItem(props: DropdownMenuItemProps) {
27
26
  * アイコンがない時を考慮して20px(16pxのwidthと4pxのgap)の余白をとる
28
27
  */
29
28
  const StyledSpan = styled.span<{ isSelected?: boolean }>`
30
- ${theme((o) => [o.typography(14), o.font.text2])};
29
+ font-size: 14px;
30
+ line-height: 22px;
31
+ color: var(--charcoal-text2);
32
+ &::before {
33
+ display: block;
34
+ width: 0;
35
+ height: 0;
36
+ content: '';
37
+ margin-top: -4px;
38
+ }
39
+ &::after {
40
+ display: block;
41
+ width: 0;
42
+ height: 0;
43
+ content: '';
44
+ margin-bottom: -4px;
45
+ }
46
+
31
47
  display: flex;
32
48
  align-items: center;
33
49
  width: 100%;
@@ -35,6 +51,6 @@ const StyledSpan = styled.span<{ isSelected?: boolean }>`
35
51
  `
36
52
 
37
53
  const Text2ColorIcon = styled(Icon)`
38
- ${theme((o) => [o.font.text2])}
54
+ color: var(--charcoal-text2);
39
55
  padding-right: 4px;
40
56
  `
@@ -13,19 +13,15 @@ exports[`Storyshots DropdownSelector/ListItem Basic 1`] = `
13
13
  }
14
14
 
15
15
  .c3:disabled,
16
- .c3[aria-disabled]:not([aria-disabled=false]) {
16
+ .c3[aria-disabled]:not([aria-disabled='false']) {
17
17
  opacity: 0.32;
18
+ cursor: default;
18
19
  }
19
20
 
20
21
  .c3:active > input {
21
22
  box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
22
23
  }
23
24
 
24
- .c3:disabled,
25
- .c3[aria-disabled]:not([aria-disabled=false]) {
26
- cursor: default;
27
- }
28
-
29
25
  .c4 {
30
26
  -webkit-appearance: none;
31
27
  -moz-appearance: none;
@@ -130,11 +126,8 @@ exports[`Storyshots DropdownSelector/ListItem Basic 1`] = `
130
126
  }
131
127
 
132
128
  .c1:disabled,
133
- .c1[aria-disabled]:not([aria-disabled=false]) {
129
+ .c1[aria-disabled]:not([aria-disabled='false']) {
134
130
  opacity: 0.32;
135
- }
136
-
137
- .c1[aria-disabled="true"] {
138
131
  cursor: default;
139
132
  }
140
133
 
@@ -1,6 +1,5 @@
1
1
  import { ReactNode } from 'react'
2
2
  import styled from 'styled-components'
3
- import { theme } from '../../../styled'
4
3
 
5
4
  export type CustomJSXElement =
6
5
  | keyof JSX.IntrinsicElements
@@ -44,15 +43,18 @@ const ItemDiv = styled.div`
44
43
  cursor: pointer;
45
44
  outline: none;
46
45
 
47
- ${theme((o) => [o.padding.horizontal(16), o.disabled])}
46
+ padding-right: 16px;
47
+ padding-left: 16px;
48
48
 
49
- &[aria-disabled="true"] {
49
+ &:disabled,
50
+ &[aria-disabled]:not([aria-disabled='false']) {
51
+ opacity: 0.32;
50
52
  cursor: default;
51
53
  }
52
54
 
53
55
  :hover,
54
56
  :focus,
55
57
  :focus-within {
56
- ${theme((o) => [o.bg.surface3])}
58
+ background-color: var(--charcoal-surface3);
57
59
  }
58
60
  `
@@ -23,7 +23,7 @@ export default function MenuItemGroup(props: MenuItemGroupProps) {
23
23
 
24
24
  const TextSpan = styled.span`
25
25
  display: block;
26
- color: ${({ theme }) => theme.color.text3};
26
+ color: var(--charcoal-text3);
27
27
  font-size: 12px;
28
28
  font-weight: bold;
29
29
  padding: 12px 0 8px 16px;
@@ -22,11 +22,8 @@ exports[`Storyshots DropdownSelector/MenuList Basic 1`] = `
22
22
  }
23
23
 
24
24
  .c2:disabled,
25
- .c2[aria-disabled]:not([aria-disabled=false]) {
25
+ .c2[aria-disabled]:not([aria-disabled='false']) {
26
26
  opacity: 0.32;
27
- }
28
-
29
- .c2[aria-disabled="true"] {
30
27
  cursor: default;
31
28
  }
32
29
 
@@ -233,11 +230,8 @@ exports[`Storyshots DropdownSelector/MenuList Disabled 1`] = `
233
230
  }
234
231
 
235
232
  .c2:disabled,
236
- .c2[aria-disabled]:not([aria-disabled=false]) {
233
+ .c2[aria-disabled]:not([aria-disabled='false']) {
237
234
  opacity: 0.32;
238
- }
239
-
240
- .c2[aria-disabled="true"] {
241
235
  cursor: default;
242
236
  }
243
237
 
@@ -315,11 +309,8 @@ exports[`Storyshots DropdownSelector/MenuList Group 1`] = `
315
309
  }
316
310
 
317
311
  .c5:disabled,
318
- .c5[aria-disabled]:not([aria-disabled=false]) {
312
+ .c5[aria-disabled]:not([aria-disabled='false']) {
319
313
  opacity: 0.32;
320
- }
321
-
322
- .c5[aria-disabled="true"] {
323
314
  cursor: default;
324
315
  }
325
316
 
@@ -336,7 +327,7 @@ exports[`Storyshots DropdownSelector/MenuList Group 1`] = `
336
327
 
337
328
  .c2 {
338
329
  display: block;
339
- color: #858585;
330
+ color: var(--charcoal-text3);
340
331
  font-size: 12px;
341
332
  font-weight: bold;
342
333
  padding: 12px 0 8px 16px;
@@ -17,6 +17,8 @@ exports[`Storyshots DropdownSelector/Popover Basic 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;
@@ -56,65 +58,46 @@ exports[`Storyshots DropdownSelector/Popover Basic 1`] = `
56
58
  -ms-user-select: none;
57
59
  user-select: none;
58
60
  white-space: nowrap;
59
- color: var(--charcoal-text2);
60
- background-color: var(--charcoal-surface3);
61
+ border-radius: 999999px;
61
62
  font-size: 14px;
62
63
  line-height: 22px;
63
64
  font-weight: bold;
64
65
  padding-right: 24px;
65
66
  padding-left: 24px;
66
- border-radius: 999999px;
67
+ color: var(--charcoal-text2);
68
+ background-color: var(--charcoal-surface3);
67
69
  -webkit-transition: 0.2s color,0.2s background-color,0.2s box-shadow;
68
70
  transition: 0.2s color,0.2s background-color,0.2s box-shadow;
69
71
  height: 40px;
70
72
  }
71
73
 
72
- .c1:hover:not(:disabled):not([aria-disabled]),
73
- .c1:hover[aria-disabled=false] {
74
- color: var(--charcoal-text2-hover);
75
- }
76
-
77
- .c1:active:not(:disabled):not([aria-disabled]),
78
- .c1:active[aria-disabled=false] {
79
- color: var(--charcoal-text2-press);
74
+ .c1:not(:disabled):not([aria-disabled]):active,
75
+ .c1[aria-disabled='false']:active,
76
+ .c1:not(:disabled):not([aria-disabled]):focus,
77
+ .c1[aria-disabled='false']:focus,
78
+ .c1:not(:disabled):not([aria-disabled]):focus-visible,
79
+ .c1[aria-disabled='false']:focus-visible {
80
+ outline: none;
81
+ box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
80
82
  }
81
83
 
82
- .c1:hover:not(:disabled):not([aria-disabled]),
83
- .c1:hover[aria-disabled=false] {
84
+ .c1:not(:disabled):not([aria-disabled]):hover,
85
+ .c1[aria-disabled='false']:hover {
86
+ color: var(--charcoal-text2-hover);
84
87
  background-color: var(--charcoal-surface3-hover);
85
88
  }
86
89
 
87
- .c1:active:not(:disabled):not([aria-disabled]),
88
- .c1:active[aria-disabled=false] {
90
+ .c1:not(:disabled):not([aria-disabled]):active,
91
+ .c1[aria-disabled='false']:active {
92
+ color: var(--charcoal-text2-press);
89
93
  background-color: var(--charcoal-surface3-press);
90
94
  }
91
95
 
92
96
  .c1:disabled,
93
- .c1[aria-disabled]:not([aria-disabled=false]) {
97
+ .c1[aria-disabled]:not([aria-disabled='false']) {
94
98
  opacity: 0.32;
95
99
  }
96
100
 
97
- .c1:not(:disabled):not([aria-disabled]):focus,
98
- .c1[aria-disabled=false]:focus,
99
- .c1:not(:disabled):not([aria-disabled]):active,
100
- .c1[aria-disabled=false]:active {
101
- outline: none;
102
- box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
103
- }
104
-
105
- .c1:not(:disabled):not([aria-disabled]):focus:not(:focus-visible),
106
- .c1[aria-disabled=false]:focus:not(:focus-visible),
107
- .c1:not(:disabled):not([aria-disabled]):active:not(:focus-visible),
108
- .c1[aria-disabled=false]:active:not(:focus-visible) {
109
- outline: none;
110
- }
111
-
112
- .c1:not(:disabled):not([aria-disabled]):focus-visible,
113
- .c1[aria-disabled=false]:focus-visible {
114
- outline: none;
115
- box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
116
- }
117
-
118
101
  <div
119
102
  data-dark={false}
120
103
  >
@@ -2,7 +2,6 @@ import { RefObject, useContext, useRef } from 'react'
2
2
  import { ReactNode } from 'react'
3
3
  import { DismissButton, Overlay, usePopover } from '@react-aria/overlays'
4
4
  import styled from 'styled-components'
5
- import { theme } from '../../../styled'
6
5
  import { ModalBackgroundContext } from '../../Modal/ModalBackgroundContext'
7
6
  import { usePreventScroll } from './usePreventScroll'
8
7
 
@@ -74,11 +73,9 @@ const DropdownPopoverDiv = styled.div`
74
73
  list-style: none;
75
74
  overflow: auto;
76
75
  max-height: inherit;
77
-
78
- ${theme((o) => [
79
- o.bg.background1,
80
- o.border.default,
81
- o.borderRadius(8),
82
- o.padding.vertical(8),
83
- ])}
76
+ background-color: var(--charcoal-background1);
77
+ border: solid 1px var(--charcoal-border-default);
78
+ border-radius: 8px;
79
+ padding-top: 8px;
80
+ padding-bottom: 8px;
84
81
  `