@charcoal-ui/react 3.7.0 → 3.9.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 (107) hide show
  1. package/dist/components/Button/StyledButton.d.ts +1 -0
  2. package/dist/components/Button/StyledButton.d.ts.map +1 -1
  3. package/dist/components/Button/index.d.ts +1 -0
  4. package/dist/components/Button/index.d.ts.map +1 -1
  5. package/dist/components/Button/index.story.d.ts +16 -32
  6. package/dist/components/Button/index.story.d.ts.map +1 -1
  7. package/dist/components/Checkbox/index.d.ts.map +1 -1
  8. package/dist/components/DropdownSelector/ListItem/index.story.d.ts +7 -7
  9. package/dist/components/DropdownSelector/ListItem/index.story.d.ts.map +1 -1
  10. package/dist/components/DropdownSelector/MenuList/index.story.d.ts +6 -9
  11. package/dist/components/DropdownSelector/MenuList/index.story.d.ts.map +1 -1
  12. package/dist/components/DropdownSelector/Popover/index.story.d.ts +3 -7
  13. package/dist/components/DropdownSelector/Popover/index.story.d.ts.map +1 -1
  14. package/dist/components/DropdownSelector/index.d.ts.map +1 -1
  15. package/dist/components/DropdownSelector/index.story.d.ts +9 -12
  16. package/dist/components/DropdownSelector/index.story.d.ts.map +1 -1
  17. package/dist/components/Icon/index.story.d.ts +4 -26
  18. package/dist/components/Icon/index.story.d.ts.map +1 -1
  19. package/dist/components/IconButton/index.d.ts +1 -0
  20. package/dist/components/IconButton/index.d.ts.map +1 -1
  21. package/dist/components/IconButton/index.story.d.ts +6 -25
  22. package/dist/components/IconButton/index.story.d.ts.map +1 -1
  23. package/dist/components/LoadingSpinner/LoadingSpinnerIcon.story.d.ts +8 -0
  24. package/dist/components/LoadingSpinner/LoadingSpinnerIcon.story.d.ts.map +1 -0
  25. package/dist/components/LoadingSpinner/index.d.ts +2 -2
  26. package/dist/components/LoadingSpinner/index.d.ts.map +1 -1
  27. package/dist/components/LoadingSpinner/index.story.d.ts +4 -7
  28. package/dist/components/LoadingSpinner/index.story.d.ts.map +1 -1
  29. package/dist/components/Modal/index.d.ts.map +1 -1
  30. package/dist/components/Modal/index.story.d.ts +16 -41
  31. package/dist/components/Modal/index.story.d.ts.map +1 -1
  32. package/dist/components/Modal/useCustomModalOverlay.d.ts +12 -0
  33. package/dist/components/Modal/useCustomModalOverlay.d.ts.map +1 -0
  34. package/dist/components/MultiSelect/index.d.ts.map +1 -1
  35. package/dist/components/Radio/index.d.ts +0 -2
  36. package/dist/components/Radio/index.d.ts.map +1 -1
  37. package/dist/components/Radio/index.story.d.ts +12 -23
  38. package/dist/components/Radio/index.story.d.ts.map +1 -1
  39. package/dist/components/SegmentedControl/index.story.d.ts +5 -8
  40. package/dist/components/SegmentedControl/index.story.d.ts.map +1 -1
  41. package/dist/components/Switch/index.d.ts.map +1 -1
  42. package/dist/components/Switch/index.story.d.ts +7 -12
  43. package/dist/components/Switch/index.story.d.ts.map +1 -1
  44. package/dist/components/TagItem/index.d.ts.map +1 -1
  45. package/dist/components/TagItem/index.story.d.ts +14 -24
  46. package/dist/components/TagItem/index.story.d.ts.map +1 -1
  47. package/dist/components/TextArea/TextArea.story.d.ts +7 -25
  48. package/dist/components/TextArea/TextArea.story.d.ts.map +1 -1
  49. package/dist/components/TextArea/index.d.ts.map +1 -1
  50. package/dist/components/TextField/TextField.story.d.ts +14 -20
  51. package/dist/components/TextField/TextField.story.d.ts.map +1 -1
  52. package/dist/components/TextField/index.d.ts.map +1 -1
  53. package/dist/index.cjs.js +1006 -2240
  54. package/dist/index.cjs.js.map +1 -1
  55. package/dist/index.esm.js +1001 -2241
  56. package/dist/index.esm.js.map +1 -1
  57. package/dist/styled.d.ts +4 -4
  58. package/package.json +7 -6
  59. package/src/components/Button/StyledButton.tsx +19 -14
  60. package/src/components/Button/__snapshots__/index.story.storyshot +314 -118
  61. package/src/components/Button/index.story.tsx +141 -138
  62. package/src/components/Button/index.tsx +3 -0
  63. package/src/components/Checkbox/__snapshots__/index.story.storyshot +55 -42
  64. package/src/components/Checkbox/index.tsx +15 -17
  65. package/src/components/Clickable/__snapshots__/index.story.storyshot +2 -2
  66. package/src/components/DropdownSelector/ListItem/__snapshots__/index.story.storyshot +42 -37
  67. package/src/components/DropdownSelector/ListItem/index.story.tsx +8 -4
  68. package/src/components/DropdownSelector/MenuList/__snapshots__/index.story.storyshot +38 -38
  69. package/src/components/DropdownSelector/MenuList/index.story.tsx +33 -27
  70. package/src/components/DropdownSelector/Popover/__snapshots__/index.story.storyshot +11 -5
  71. package/src/components/DropdownSelector/Popover/index.story.tsx +6 -6
  72. package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +148 -47
  73. package/src/components/DropdownSelector/index.story.tsx +207 -204
  74. package/src/components/DropdownSelector/index.tsx +17 -10
  75. package/src/components/Icon/__snapshots__/index.story.storyshot +1 -1
  76. package/src/components/Icon/index.story.tsx +8 -12
  77. package/src/components/IconButton/__snapshots__/index.story.storyshot +135 -13
  78. package/src/components/IconButton/index.story.tsx +30 -23
  79. package/src/components/IconButton/index.tsx +35 -20
  80. package/src/components/LoadingSpinner/LoadingSpinnerIcon.story.tsx +12 -0
  81. package/src/components/LoadingSpinner/__snapshots__/LoadingSpinnerIcon.story.storyshot +28 -0
  82. package/src/components/LoadingSpinner/__snapshots__/index.story.storyshot +1 -35
  83. package/src/components/LoadingSpinner/index.story.tsx +11 -54
  84. package/src/components/LoadingSpinner/index.tsx +1 -1
  85. package/src/components/Modal/__snapshots__/index.story.storyshot +224 -171
  86. package/src/components/Modal/index.story.tsx +139 -133
  87. package/src/components/Modal/index.tsx +15 -20
  88. package/src/components/Modal/useCustomModalOverlay.tsx +42 -0
  89. package/src/components/MultiSelect/__snapshots__/index.story.storyshot +56 -4
  90. package/src/components/MultiSelect/index.tsx +3 -0
  91. package/src/components/Radio/__snapshots__/index.story.storyshot +1001 -121
  92. package/src/components/Radio/index.story.tsx +128 -63
  93. package/src/components/Radio/index.tsx +15 -17
  94. package/src/components/SegmentedControl/__snapshots__/index.story.storyshot +2 -2
  95. package/src/components/SegmentedControl/index.story.tsx +24 -29
  96. package/src/components/Switch/__snapshots__/index.story.storyshot +184 -26
  97. package/src/components/Switch/index.story.tsx +72 -48
  98. package/src/components/Switch/index.tsx +2 -7
  99. package/src/components/TagItem/__snapshots__/index.story.storyshot +72 -33
  100. package/src/components/TagItem/index.story.tsx +154 -159
  101. package/src/components/TagItem/index.tsx +2 -6
  102. package/src/components/TextArea/TextArea.story.tsx +29 -32
  103. package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +127 -73
  104. package/src/components/TextArea/index.tsx +22 -14
  105. package/src/components/TextField/TextField.story.tsx +85 -64
  106. package/src/components/TextField/__snapshots__/TextField.story.storyshot +479 -167
  107. package/src/components/TextField/index.tsx +22 -21
@@ -1,8 +1,7 @@
1
- import { action } from '@storybook/addon-actions'
2
1
  import { useRef } from 'react'
3
- import { Story } from '../../_lib/compat'
4
2
  import { ClickableElement } from '../Clickable'
5
3
  import Button, { ButtonProps } from '.'
4
+ import { Meta, StoryObj } from '@storybook/react'
6
5
 
7
6
  export default {
8
7
  title: 'Button',
@@ -21,167 +20,171 @@ export default {
21
20
  },
22
21
  },
23
22
  },
24
- }
25
-
26
- const DefaultStory = (args: ButtonProps) => (
27
- <Button {...args} onClick={action('click')}>
28
- Button
29
- </Button>
30
- )
23
+ render: (args) => <Button {...args}>Button</Button>,
24
+ } as Meta<typeof Button>
31
25
 
32
- export const Default: Story<ButtonProps> = DefaultStory.bind({})
26
+ export const Default: StoryObj<typeof Button> = {}
33
27
 
34
- export const Primary: Story<ButtonProps> = DefaultStory.bind({})
35
- Primary.args = {
36
- variant: 'Primary',
28
+ export const Primary: StoryObj<typeof Button> = {
29
+ args: {
30
+ variant: 'Primary',
31
+ },
37
32
  }
38
33
 
39
- export const Navigation: Story<ButtonProps> = DefaultStory.bind({})
40
- Navigation.args = {
41
- variant: 'Navigation',
34
+ export const Navigation: StoryObj<typeof Button> = {
35
+ args: {
36
+ variant: 'Navigation',
37
+ },
42
38
  }
43
39
 
44
- export const Overlay: Story<ButtonProps> = DefaultStory.bind({})
45
- Overlay.args = {
46
- variant: 'Overlay',
40
+ export const Overlay: StoryObj<typeof Button> = {
41
+ args: {
42
+ variant: 'Overlay',
43
+ },
47
44
  }
48
45
 
49
- export const Danger: Story<ButtonProps> = DefaultStory.bind({})
50
- Danger.args = {
51
- variant: 'Danger',
46
+ export const Danger: StoryObj<typeof Button> = {
47
+ args: {
48
+ variant: 'Danger',
49
+ },
52
50
  }
53
51
 
54
- export const Small: Story<ButtonProps> = DefaultStory.bind({})
55
- Small.args = {
56
- size: 'S',
52
+ export const Small: StoryObj<typeof Button> = {
53
+ args: {
54
+ size: 'S',
55
+ },
57
56
  }
58
57
 
59
- export const Fixed: Story<ButtonProps> = DefaultStory.bind({})
60
- Fixed.args = {
61
- fullWidth: true,
58
+ export const Fixed: StoryObj<typeof Button> = {
59
+ args: {
60
+ fullWidth: true,
61
+ },
62
62
  }
63
63
 
64
- export const Disabled: Story<ButtonProps> = DefaultStory.bind({})
65
- Disabled.args = {
66
- disabled: true,
64
+ export const Disabled: StoryObj<typeof Button> = {
65
+ args: {
66
+ disabled: true,
67
+ },
67
68
  }
68
69
 
69
- export const Link: Story<ButtonProps> = DefaultStory.bind({})
70
- Link.args = {
71
- to: '#',
70
+ export const Active: StoryObj<typeof Button> = {
71
+ args: {
72
+ isActive: true,
73
+ },
72
74
  }
73
75
 
74
- const NihongoStory = (args: ButtonProps) => (
75
- <Button {...args} onClick={action('click')}>
76
- 日本語だよ
77
- </Button>
78
- )
79
-
80
- export const Nihongo: Story<ButtonProps> = NihongoStory.bind({})
81
-
82
- const FocusStory = (args: ButtonProps) => <FocusStoryInternal {...args} />
83
- const FocusStoryInternal = (args: ButtonProps) => {
84
- const ref = useRef<ClickableElement>(null)
85
- const focus = () => ref.current?.focus()
86
- return (
87
- <Button {...args} onMouseOver={focus} ref={ref}>
88
- Mouse over to focus
89
- </Button>
90
- )
76
+ export const Link: StoryObj<typeof Button> = {
77
+ args: {
78
+ to: '#',
79
+ },
91
80
  }
92
81
 
93
- export const Focus: Story<ButtonProps> = FocusStory.bind({})
94
-
95
- const LayoutExampleStory = (args: ButtonProps) => (
96
- <div
97
- css={`
98
- display: grid;
99
- gap: 24px;
100
- `}
101
- >
102
- <div
103
- css={`
104
- display: grid;
105
- grid: auto / auto-flow min-content;
106
- gap: 8px;
107
- `}
108
- >
109
- <Button {...args}>Grid</Button>
110
- <Button {...args} variant="Navigation">
111
- Layout
112
- </Button>
113
- <Button {...args} variant="Danger">
114
- Sample
115
- </Button>
116
- </div>
117
- <div
118
- css={`
119
- display: grid;
120
- grid: auto-flow auto / 392px;
121
- gap: 8px;
122
- `}
123
- >
124
- <Button {...args} variant="Primary" fullWidth>
125
- Submit
126
- </Button>
127
- <Button {...args} variant="Default" fullWidth>
128
- Cancel
129
- </Button>
130
- </div>
131
- <div
132
- css={`
133
- display: flex;
82
+ export const Nihongo: StoryObj<typeof Button> = {
83
+ render: (args) => <Button {...args}>日本語だよ</Button>,
84
+ }
134
85
 
135
- & > * + * {
136
- margin-left: 8px;
137
- }
138
- `}
139
- >
140
- <Button {...args}>Flex</Button>
141
- <Button {...args} variant="Navigation">
142
- Layout
143
- </Button>
144
- <Button {...args} variant="Danger">
145
- Sample
86
+ export const Focus: StoryObj<typeof Button> = {
87
+ render: function Render(args) {
88
+ const ref = useRef<ClickableElement>(null)
89
+ const focus = () => ref.current?.focus()
90
+ return (
91
+ <Button {...args} onMouseOver={focus} ref={ref}>
92
+ Mouse over to focus
146
93
  </Button>
147
- </div>
148
- <div
149
- css={`
150
- display: flex;
151
- flex-direction: column;
152
- width: 392px;
94
+ )
95
+ },
96
+ }
153
97
 
154
- & > * + * {
155
- margin-top: 8px;
156
- }
157
- `}
158
- >
159
- <Button {...args} variant="Primary" fullWidth>
160
- Submit
161
- </Button>
162
- <Button {...args} variant="Default" fullWidth>
163
- Cancel
164
- </Button>
165
- </div>
98
+ export const LayoutExample: StoryObj<typeof Button> = {
99
+ render: (args: ButtonProps) => (
166
100
  <div
167
101
  css={`
168
- display: flex;
169
- flex-direction: column;
170
- width: 392px;
171
-
172
- & > * + * {
173
- margin-top: 8px;
174
- }
102
+ display: grid;
103
+ gap: 24px;
175
104
  `}
176
105
  >
177
- <Button {...args} variant="Primary" fullWidth>
178
- すべて見る
179
- </Button>
180
- <Button {...args} variant="Default">
181
- 作品を投稿
182
- </Button>
106
+ <div
107
+ css={`
108
+ display: grid;
109
+ grid: auto / auto-flow min-content;
110
+ gap: 8px;
111
+ `}
112
+ >
113
+ <Button {...args}>Grid</Button>
114
+ <Button {...args} variant="Navigation">
115
+ Layout
116
+ </Button>
117
+ <Button {...args} variant="Danger">
118
+ Sample
119
+ </Button>
120
+ </div>
121
+ <div
122
+ css={`
123
+ display: grid;
124
+ grid: auto-flow auto / 392px;
125
+ gap: 8px;
126
+ `}
127
+ >
128
+ <Button {...args} variant="Primary" fullWidth>
129
+ Submit
130
+ </Button>
131
+ <Button {...args} variant="Default" fullWidth>
132
+ Cancel
133
+ </Button>
134
+ </div>
135
+ <div
136
+ css={`
137
+ display: flex;
138
+
139
+ & > * + * {
140
+ margin-left: 8px;
141
+ }
142
+ `}
143
+ >
144
+ <Button {...args}>Flex</Button>
145
+ <Button {...args} variant="Navigation">
146
+ Layout
147
+ </Button>
148
+ <Button {...args} variant="Danger">
149
+ Sample
150
+ </Button>
151
+ </div>
152
+ <div
153
+ css={`
154
+ display: flex;
155
+ flex-direction: column;
156
+ width: 392px;
157
+
158
+ & > * + * {
159
+ margin-top: 8px;
160
+ }
161
+ `}
162
+ >
163
+ <Button {...args} variant="Primary" fullWidth>
164
+ Submit
165
+ </Button>
166
+ <Button {...args} variant="Default" fullWidth>
167
+ Cancel
168
+ </Button>
169
+ </div>
170
+ <div
171
+ css={`
172
+ display: flex;
173
+ flex-direction: column;
174
+ width: 392px;
175
+
176
+ & > * + * {
177
+ margin-top: 8px;
178
+ }
179
+ `}
180
+ >
181
+ <Button {...args} variant="Primary" fullWidth>
182
+ すべて見る
183
+ </Button>
184
+ <Button {...args} variant="Default">
185
+ 作品を投稿
186
+ </Button>
187
+ </div>
183
188
  </div>
184
- </div>
185
- )
186
-
187
- export const LayoutExample = LayoutExampleStory.bind({})
189
+ ),
190
+ }
@@ -17,6 +17,7 @@ export type ButtonProps = Partial<{
17
17
  variant: Variant
18
18
  size: Size
19
19
  fullWidth: boolean
20
+ isActive: boolean
20
21
  }> &
21
22
  ClickableProps
22
23
 
@@ -27,6 +28,7 @@ const Button = forwardRef<ClickableElement, ButtonProps>(function Button(
27
28
  size = 'M',
28
29
  fullWidth: fixed = false,
29
30
  disabled = false,
31
+ isActive = false,
30
32
  ...rest
31
33
  },
32
34
  ref
@@ -39,6 +41,7 @@ const Button = forwardRef<ClickableElement, ButtonProps>(function Button(
39
41
  $color={variantToFont(variant)}
40
42
  $size={size}
41
43
  $fullWidth={fixed}
44
+ $isActive={isActive}
42
45
  ref={ref}
43
46
  >
44
47
  {children}
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Storyshots Checkbox Invalid 1`] = `
3
+ exports[`Storybook Tests Checkbox Invalid 1`] = `
4
4
  .c0 {
5
5
  position: relative;
6
6
  display: -webkit-box;
@@ -11,13 +11,9 @@ exports[`Storyshots Checkbox Invalid 1`] = `
11
11
  gap: 4px;
12
12
  }
13
13
 
14
- .c0:disabled,
15
- .c0[aria-disabled]:not([aria-disabled=false]) {
16
- cursor: default;
17
- }
18
-
19
14
  .c0:disabled,
20
15
  .c0[aria-disabled]:not([aria-disabled='false']) {
16
+ cursor: default;
21
17
  opacity: 0.32;
22
18
  }
23
19
 
@@ -39,6 +35,18 @@ exports[`Storyshots Checkbox Invalid 1`] = `
39
35
  transition: 0.2s box-shadow,0.2s background-color;
40
36
  }
41
37
 
38
+ .c2[type='checkbox']:disabled {
39
+ cursor: default;
40
+ }
41
+
42
+ .c2[type='checkbox']:-moz-read-only {
43
+ cursor: default;
44
+ }
45
+
46
+ .c2[type='checkbox']:read-only {
47
+ cursor: default;
48
+ }
49
+
42
50
  .c2[type='checkbox']:checked {
43
51
  background-color: var(--charcoal-brand);
44
52
  }
@@ -54,23 +62,18 @@ exports[`Storyshots Checkbox Invalid 1`] = `
54
62
  }
55
63
 
56
64
  .c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus,
57
- .c2[type='checkbox'][aria-disabled='false']:focus,
58
- .c2[type='checkbox']:not(:disabled):not([aria-disabled]):active,
59
- .c2[type='checkbox'][aria-disabled='false']:active {
65
+ .c2[type='checkbox'][aria-disabled='false']:focus {
60
66
  outline: none;
61
67
  box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
62
68
  }
63
69
 
64
70
  .c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus:not(:focus-visible),
65
- .c2[type='checkbox'][aria-disabled='false']:focus:not(:focus-visible),
66
- .c2[type='checkbox']:not(:disabled):not([aria-disabled]):active:not(:focus-visible),
67
- .c2[type='checkbox'][aria-disabled='false']:active:not(:focus-visible) {
68
- outline: none;
71
+ .c2[type='checkbox'][aria-disabled='false']:focus:not(:focus-visible) {
72
+ box-shadow: none;
69
73
  }
70
74
 
71
75
  .c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus-visible,
72
76
  .c2[type='checkbox'][aria-disabled='false']:focus-visible {
73
- outline: none;
74
77
  box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
75
78
  }
76
79
 
@@ -145,6 +148,7 @@ exports[`Storyshots Checkbox Invalid 1`] = `
145
148
  onTouchEnd={[Function]}
146
149
  onTouchMove={[Function]}
147
150
  onTouchStart={[Function]}
151
+ readOnly={false}
148
152
  type="checkbox"
149
153
  />
150
154
  <div
@@ -167,7 +171,7 @@ exports[`Storyshots Checkbox Invalid 1`] = `
167
171
  </div>
168
172
  `;
169
173
 
170
- exports[`Storyshots Checkbox Labelled 1`] = `
174
+ exports[`Storybook Tests Checkbox Labelled 1`] = `
171
175
  .c0 {
172
176
  position: relative;
173
177
  display: -webkit-box;
@@ -178,13 +182,9 @@ exports[`Storyshots Checkbox Labelled 1`] = `
178
182
  gap: 4px;
179
183
  }
180
184
 
181
- .c0:disabled,
182
- .c0[aria-disabled]:not([aria-disabled=false]) {
183
- cursor: default;
184
- }
185
-
186
185
  .c0:disabled,
187
186
  .c0[aria-disabled]:not([aria-disabled='false']) {
187
+ cursor: default;
188
188
  opacity: 0.32;
189
189
  }
190
190
 
@@ -206,6 +206,18 @@ exports[`Storyshots Checkbox Labelled 1`] = `
206
206
  transition: 0.2s box-shadow,0.2s background-color;
207
207
  }
208
208
 
209
+ .c2[type='checkbox']:disabled {
210
+ cursor: default;
211
+ }
212
+
213
+ .c2[type='checkbox']:-moz-read-only {
214
+ cursor: default;
215
+ }
216
+
217
+ .c2[type='checkbox']:read-only {
218
+ cursor: default;
219
+ }
220
+
209
221
  .c2[type='checkbox']:checked {
210
222
  background-color: var(--charcoal-brand);
211
223
  }
@@ -221,23 +233,18 @@ exports[`Storyshots Checkbox Labelled 1`] = `
221
233
  }
222
234
 
223
235
  .c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus,
224
- .c2[type='checkbox'][aria-disabled='false']:focus,
225
- .c2[type='checkbox']:not(:disabled):not([aria-disabled]):active,
226
- .c2[type='checkbox'][aria-disabled='false']:active {
236
+ .c2[type='checkbox'][aria-disabled='false']:focus {
227
237
  outline: none;
228
238
  box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
229
239
  }
230
240
 
231
241
  .c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus:not(:focus-visible),
232
- .c2[type='checkbox'][aria-disabled='false']:focus:not(:focus-visible),
233
- .c2[type='checkbox']:not(:disabled):not([aria-disabled]):active:not(:focus-visible),
234
- .c2[type='checkbox'][aria-disabled='false']:active:not(:focus-visible) {
235
- outline: none;
242
+ .c2[type='checkbox'][aria-disabled='false']:focus:not(:focus-visible) {
243
+ box-shadow: none;
236
244
  }
237
245
 
238
246
  .c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus-visible,
239
247
  .c2[type='checkbox'][aria-disabled='false']:focus-visible {
240
- outline: none;
241
248
  box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
242
249
  }
243
250
 
@@ -319,6 +326,7 @@ exports[`Storyshots Checkbox Labelled 1`] = `
319
326
  onTouchEnd={[Function]}
320
327
  onTouchMove={[Function]}
321
328
  onTouchStart={[Function]}
329
+ readOnly={false}
322
330
  type="checkbox"
323
331
  />
324
332
  <div
@@ -367,6 +375,7 @@ exports[`Storyshots Checkbox Labelled 1`] = `
367
375
  onTouchEnd={[Function]}
368
376
  onTouchMove={[Function]}
369
377
  onTouchStart={[Function]}
378
+ readOnly={false}
370
379
  type="checkbox"
371
380
  />
372
381
  <div
@@ -400,7 +409,7 @@ exports[`Storyshots Checkbox Labelled 1`] = `
400
409
  </div>
401
410
  `;
402
411
 
403
- exports[`Storyshots Checkbox Unlabelled 1`] = `
412
+ exports[`Storybook Tests Checkbox Unlabelled 1`] = `
404
413
  .c0 {
405
414
  position: relative;
406
415
  display: -webkit-box;
@@ -411,13 +420,9 @@ exports[`Storyshots Checkbox Unlabelled 1`] = `
411
420
  gap: 4px;
412
421
  }
413
422
 
414
- .c0:disabled,
415
- .c0[aria-disabled]:not([aria-disabled=false]) {
416
- cursor: default;
417
- }
418
-
419
423
  .c0:disabled,
420
424
  .c0[aria-disabled]:not([aria-disabled='false']) {
425
+ cursor: default;
421
426
  opacity: 0.32;
422
427
  }
423
428
 
@@ -439,6 +444,18 @@ exports[`Storyshots Checkbox Unlabelled 1`] = `
439
444
  transition: 0.2s box-shadow,0.2s background-color;
440
445
  }
441
446
 
447
+ .c2[type='checkbox']:disabled {
448
+ cursor: default;
449
+ }
450
+
451
+ .c2[type='checkbox']:-moz-read-only {
452
+ cursor: default;
453
+ }
454
+
455
+ .c2[type='checkbox']:read-only {
456
+ cursor: default;
457
+ }
458
+
442
459
  .c2[type='checkbox']:checked {
443
460
  background-color: var(--charcoal-brand);
444
461
  }
@@ -454,23 +471,18 @@ exports[`Storyshots Checkbox Unlabelled 1`] = `
454
471
  }
455
472
 
456
473
  .c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus,
457
- .c2[type='checkbox'][aria-disabled='false']:focus,
458
- .c2[type='checkbox']:not(:disabled):not([aria-disabled]):active,
459
- .c2[type='checkbox'][aria-disabled='false']:active {
474
+ .c2[type='checkbox'][aria-disabled='false']:focus {
460
475
  outline: none;
461
476
  box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
462
477
  }
463
478
 
464
479
  .c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus:not(:focus-visible),
465
- .c2[type='checkbox'][aria-disabled='false']:focus:not(:focus-visible),
466
- .c2[type='checkbox']:not(:disabled):not([aria-disabled]):active:not(:focus-visible),
467
- .c2[type='checkbox'][aria-disabled='false']:active:not(:focus-visible) {
468
- outline: none;
480
+ .c2[type='checkbox'][aria-disabled='false']:focus:not(:focus-visible) {
481
+ box-shadow: none;
469
482
  }
470
483
 
471
484
  .c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus-visible,
472
485
  .c2[type='checkbox'][aria-disabled='false']:focus-visible {
473
- outline: none;
474
486
  box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
475
487
  }
476
488
 
@@ -540,6 +552,7 @@ exports[`Storyshots Checkbox Unlabelled 1`] = `
540
552
  onTouchEnd={[Function]}
541
553
  onTouchMove={[Function]}
542
554
  onTouchStart={[Function]}
555
+ readOnly={false}
543
556
  type="checkbox"
544
557
  />
545
558
  <div
@@ -4,10 +4,10 @@ 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 } from '@charcoal-ui/utils'
8
7
 
9
8
  import type { AriaCheckboxProps } from '@react-types/checkbox'
10
9
  import Icon from '../Icon'
10
+ import { focusVisibleFocusRingCss } from '@charcoal-ui/styled'
11
11
 
12
12
  type CheckboxLabelProps =
13
13
  | {
@@ -58,7 +58,11 @@ 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} />
61
+ <CheckboxInput
62
+ type="checkbox"
63
+ {...inputProps}
64
+ readOnly={props.readonly}
65
+ />
62
66
  <CheckboxInputOverlay aria-hidden={true} checked={inputProps.checked}>
63
67
  <Icon name="24/Check" unsafeNonGuidelineScale={2 / 3} />
64
68
  </CheckboxInputOverlay>
@@ -81,13 +85,11 @@ const InputRoot = styled.label`
81
85
  display: flex;
82
86
 
83
87
  cursor: pointer;
84
- ${disabledSelector} {
85
- cursor: default;
86
- }
87
88
 
88
89
  gap: 4px;
89
90
  &:disabled,
90
91
  &[aria-disabled]:not([aria-disabled='false']) {
92
+ cursor: default;
91
93
  opacity: 0.32;
92
94
  }
93
95
  `
@@ -107,6 +109,13 @@ const CheckboxInput = styled.input`
107
109
  border-radius: 4px;
108
110
  transition: 0.2s box-shadow, 0.2s background-color;
109
111
 
112
+ &:disabled {
113
+ cursor: default;
114
+ }
115
+ &:read-only {
116
+ cursor: default;
117
+ }
118
+
110
119
  &:checked {
111
120
  background-color: var(--charcoal-brand);
112
121
 
@@ -123,18 +132,7 @@ const CheckboxInput = styled.input`
123
132
 
124
133
  &:not(:disabled):not([aria-disabled]),
125
134
  &[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
- }
135
+ ${focusVisibleFocusRingCss}
138
136
  &[aria-invalid='true'] {
139
137
  box-shadow: 0 0 0 4px rgba(255, 43, 0, 0.32);
140
138
  }
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Storyshots Clickable Button 1`] = `
3
+ exports[`Storybook Tests Clickable Button 1`] = `
4
4
  .c0 {
5
5
  cursor: pointer;
6
6
  -webkit-appearance: none;
@@ -51,7 +51,7 @@ exports[`Storyshots Clickable Button 1`] = `
51
51
  </div>
52
52
  `;
53
53
 
54
- exports[`Storyshots Clickable Link 1`] = `
54
+ exports[`Storybook Tests Clickable Link 1`] = `
55
55
  .c0 {
56
56
  cursor: pointer;
57
57
  -webkit-appearance: none;