@charcoal-ui/react 3.3.0 → 3.4.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 (59) hide show
  1. package/dist/_lib/useForwardedRef.d.ts +3 -0
  2. package/dist/_lib/useForwardedRef.d.ts.map +1 -0
  3. package/dist/components/Clickable/index.d.ts.map +1 -1
  4. package/dist/components/DropdownSelector/DropdownPopover.d.ts.map +1 -1
  5. package/dist/components/DropdownSelector/Popover/index.d.ts.map +1 -1
  6. package/dist/components/DropdownSelector/Popover/usePreventScroll.d.ts +2 -0
  7. package/dist/components/DropdownSelector/Popover/usePreventScroll.d.ts.map +1 -0
  8. package/dist/components/DropdownSelector/index.story.d.ts +1 -0
  9. package/dist/components/DropdownSelector/index.story.d.ts.map +1 -1
  10. package/dist/components/Icon/index.story.d.ts +1 -1
  11. package/dist/components/Modal/Dialog/index.d.ts +26 -0
  12. package/dist/components/Modal/Dialog/index.d.ts.map +1 -0
  13. package/dist/components/Modal/ModalBackgroundContext.d.ts +6 -0
  14. package/dist/components/Modal/ModalBackgroundContext.d.ts.map +1 -0
  15. package/dist/components/Modal/ModalPlumbing.d.ts.map +1 -1
  16. package/dist/components/Modal/__stories__/InternalScrollStory.d.ts +4 -0
  17. package/dist/components/Modal/__stories__/InternalScrollStory.d.ts.map +1 -0
  18. package/dist/components/Modal/index.d.ts +12 -2
  19. package/dist/components/Modal/index.d.ts.map +1 -1
  20. package/dist/components/Modal/index.story.d.ts +3 -2
  21. package/dist/components/Modal/index.story.d.ts.map +1 -1
  22. package/dist/index.cjs.js +388 -299
  23. package/dist/index.cjs.js.map +1 -1
  24. package/dist/index.esm.js +350 -262
  25. package/dist/index.esm.js.map +1 -1
  26. package/package.json +6 -6
  27. package/src/_lib/useForwardedRef.tsx +16 -0
  28. package/src/components/Button/__snapshots__/index.story.storyshot +1971 -0
  29. package/src/components/Checkbox/__snapshots__/index.story.storyshot +390 -0
  30. package/src/components/Clickable/__snapshots__/index.story.storyshot +100 -0
  31. package/src/components/Clickable/index.tsx +17 -35
  32. package/src/components/DropdownSelector/DropdownPopover.tsx +0 -1
  33. package/src/components/DropdownSelector/ListItem/__snapshots__/index.story.storyshot +245 -0
  34. package/src/components/DropdownSelector/MenuList/__snapshots__/index.story.storyshot +555 -0
  35. package/src/components/DropdownSelector/Popover/__snapshots__/index.story.storyshot +174 -0
  36. package/src/components/DropdownSelector/Popover/index.tsx +17 -2
  37. package/src/components/DropdownSelector/Popover/usePreventScroll.tsx +18 -0
  38. package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +1241 -0
  39. package/src/components/DropdownSelector/index.story.tsx +69 -13
  40. package/src/components/Icon/__snapshots__/index.story.storyshot +12 -0
  41. package/src/components/{Button/__snapshots__/index.test.tsx.snap → IconButton/__snapshots__/index.story.storyshot} +94 -91
  42. package/src/components/LoadingSpinner/__snapshots__/index.story.storyshot +81 -0
  43. package/src/components/Modal/Dialog/index.tsx +82 -0
  44. package/src/components/Modal/ModalBackgroundContext.tsx +8 -0
  45. package/src/components/Modal/ModalPlumbing.tsx +16 -4
  46. package/src/components/Modal/__snapshots__/index.story.storyshot +533 -0
  47. package/src/components/Modal/__stories__/InternalScrollStory.tsx +75 -0
  48. package/src/components/Modal/index.story.tsx +57 -38
  49. package/src/components/Modal/index.tsx +63 -94
  50. package/src/components/MultiSelect/__snapshots__/index.story.storyshot +511 -0
  51. package/src/components/Radio/__snapshots__/index.story.storyshot +319 -0
  52. package/src/components/SegmentedControl/__snapshots__/index.story.storyshot +483 -0
  53. package/src/components/Switch/__snapshots__/index.story.storyshot +454 -0
  54. package/src/components/TagItem/__snapshots__/index.story.storyshot +1181 -0
  55. package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +1271 -0
  56. package/src/components/TextField/__snapshots__/TextField.story.storyshot +1800 -0
  57. package/dist/components/Button/index.test.d.ts +0 -4
  58. package/dist/components/Button/index.test.d.ts.map +0 -1
  59. package/src/components/Button/index.test.tsx +0 -24
@@ -0,0 +1,390 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Storyshots Checkbox Labelled 1`] = `
4
+ .c0 {
5
+ position: relative;
6
+ display: -webkit-box;
7
+ display: -webkit-flex;
8
+ display: -ms-flexbox;
9
+ display: flex;
10
+ cursor: pointer;
11
+ gap: 4px;
12
+ }
13
+
14
+ .c0:disabled,
15
+ .c0[aria-disabled]:not([aria-disabled=false]) {
16
+ cursor: default;
17
+ }
18
+
19
+ .c0:disabled,
20
+ .c0[aria-disabled]:not([aria-disabled=false]) {
21
+ opacity: 0.32;
22
+ }
23
+
24
+ .c1 {
25
+ position: relative;
26
+ }
27
+
28
+ .c2[type='checkbox'] {
29
+ -webkit-appearance: none;
30
+ -moz-appearance: none;
31
+ appearance: none;
32
+ display: block;
33
+ cursor: pointer;
34
+ margin: 0;
35
+ width: 20px;
36
+ height: 20px;
37
+ border-radius: 4px;
38
+ -webkit-transition: 0.2s box-shadow;
39
+ transition: 0.2s box-shadow;
40
+ -webkit-transition: all 0.2s !important;
41
+ transition: all 0.2s !important;
42
+ }
43
+
44
+ .c2[type='checkbox']:checked {
45
+ background-color: var(--charcoal-brand);
46
+ -webkit-transition: 0.2s background-color;
47
+ transition: 0.2s background-color;
48
+ }
49
+
50
+ .c2[type='checkbox']:checked:hover:not(:disabled):not([aria-disabled]),
51
+ .c2[type='checkbox']:checked:hover[aria-disabled=false] {
52
+ background-color: var(--charcoal-brand-hover);
53
+ }
54
+
55
+ .c2[type='checkbox']:checked:active:not(:disabled):not([aria-disabled]),
56
+ .c2[type='checkbox']:checked:active[aria-disabled=false] {
57
+ background-color: var(--charcoal-brand-press);
58
+ }
59
+
60
+ .c2[type='checkbox']:not(:checked) {
61
+ border-width: 2px;
62
+ border-style: solid;
63
+ border-color: #adadad;
64
+ }
65
+
66
+ .c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus,
67
+ .c2[type='checkbox'][aria-disabled=false]:focus,
68
+ .c2[type='checkbox']:not(:disabled):not([aria-disabled]):active,
69
+ .c2[type='checkbox'][aria-disabled=false]:active {
70
+ outline: none;
71
+ box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
72
+ }
73
+
74
+ .c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus:not(:focus-visible),
75
+ .c2[type='checkbox'][aria-disabled=false]:focus:not(:focus-visible),
76
+ .c2[type='checkbox']:not(:disabled):not([aria-disabled]):active:not(:focus-visible),
77
+ .c2[type='checkbox'][aria-disabled=false]:active:not(:focus-visible) {
78
+ outline: none;
79
+ }
80
+
81
+ .c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus-visible,
82
+ .c2[type='checkbox'][aria-disabled=false]:focus-visible {
83
+ outline: none;
84
+ box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
85
+ }
86
+
87
+ .c3 {
88
+ position: absolute;
89
+ top: -2px;
90
+ left: -2px;
91
+ box-sizing: border-box;
92
+ display: -webkit-box;
93
+ display: -webkit-flex;
94
+ display: -ms-flexbox;
95
+ display: flex;
96
+ -webkit-align-items: center;
97
+ -webkit-box-align: center;
98
+ -ms-flex-align: center;
99
+ align-items: center;
100
+ -webkit-box-pack: center;
101
+ -webkit-justify-content: center;
102
+ -ms-flex-pack: center;
103
+ justify-content: center;
104
+ width: 24px;
105
+ height: 24px;
106
+ color: var(--charcoal-text5);
107
+ visibility: hidden;
108
+ }
109
+
110
+ .c4 {
111
+ color: var(--charcoal-text2);
112
+ font-size: 14px;
113
+ line-height: 20px;
114
+ }
115
+
116
+ <div
117
+ data-dark={false}
118
+ >
119
+ <div>
120
+ <div
121
+ style={
122
+ Object {
123
+ "marginBottom": "1em",
124
+ }
125
+ }
126
+ >
127
+ <label
128
+ aria-disabled={false}
129
+ className="c0"
130
+ >
131
+ <div
132
+ className="c1"
133
+ >
134
+ <input
135
+ checked={false}
136
+ className="c2"
137
+ disabled={false}
138
+ name="labelled"
139
+ onBlur={[Function]}
140
+ onChange={[Function]}
141
+ onClick={[Function]}
142
+ onDragStart={[Function]}
143
+ onFocus={[Function]}
144
+ onKeyDown={[Function]}
145
+ onKeyUp={[Function]}
146
+ onMouseDown={[Function]}
147
+ onMouseEnter={[Function]}
148
+ onMouseLeave={[Function]}
149
+ onMouseUp={[Function]}
150
+ onTouchCancel={[Function]}
151
+ onTouchEnd={[Function]}
152
+ onTouchMove={[Function]}
153
+ onTouchStart={[Function]}
154
+ type="checkbox"
155
+ />
156
+ <div
157
+ aria-hidden={true}
158
+ checked={false}
159
+ className="c3"
160
+ >
161
+ <pixiv-icon
162
+ name="24/Check"
163
+ unsafe-non-guideline-scale={0.6666666666666666}
164
+ />
165
+ </div>
166
+ </div>
167
+ <div
168
+ className="c4"
169
+ >
170
+ 同意する
171
+ </div>
172
+ </label>
173
+ </div>
174
+ <div>
175
+ <label
176
+ aria-disabled={false}
177
+ className="c0"
178
+ >
179
+ <div
180
+ className="c1"
181
+ >
182
+ <input
183
+ checked={false}
184
+ className="c2"
185
+ disabled={false}
186
+ name="labelled"
187
+ onBlur={[Function]}
188
+ onChange={[Function]}
189
+ onClick={[Function]}
190
+ onDragStart={[Function]}
191
+ onFocus={[Function]}
192
+ onKeyDown={[Function]}
193
+ onKeyUp={[Function]}
194
+ onMouseDown={[Function]}
195
+ onMouseEnter={[Function]}
196
+ onMouseLeave={[Function]}
197
+ onMouseUp={[Function]}
198
+ onTouchCancel={[Function]}
199
+ onTouchEnd={[Function]}
200
+ onTouchMove={[Function]}
201
+ onTouchStart={[Function]}
202
+ type="checkbox"
203
+ />
204
+ <div
205
+ aria-hidden={true}
206
+ checked={false}
207
+ className="c3"
208
+ >
209
+ <pixiv-icon
210
+ name="24/Check"
211
+ unsafe-non-guideline-scale={0.6666666666666666}
212
+ />
213
+ </div>
214
+ </div>
215
+ <div
216
+ className="c4"
217
+ >
218
+ <span
219
+ style={
220
+ Object {
221
+ "display": "block",
222
+ "width": 200,
223
+ }
224
+ }
225
+ >
226
+ 同意する同意する同意する同意する同意する同意する同意する同意する同意する同意する同意する同意する同意する
227
+ </span>
228
+ </div>
229
+ </label>
230
+ </div>
231
+ </div>
232
+ </div>
233
+ `;
234
+
235
+ exports[`Storyshots Checkbox Unlabelled 1`] = `
236
+ .c0 {
237
+ position: relative;
238
+ display: -webkit-box;
239
+ display: -webkit-flex;
240
+ display: -ms-flexbox;
241
+ display: flex;
242
+ cursor: pointer;
243
+ gap: 4px;
244
+ }
245
+
246
+ .c0:disabled,
247
+ .c0[aria-disabled]:not([aria-disabled=false]) {
248
+ cursor: default;
249
+ }
250
+
251
+ .c0:disabled,
252
+ .c0[aria-disabled]:not([aria-disabled=false]) {
253
+ opacity: 0.32;
254
+ }
255
+
256
+ .c1 {
257
+ position: relative;
258
+ }
259
+
260
+ .c2[type='checkbox'] {
261
+ -webkit-appearance: none;
262
+ -moz-appearance: none;
263
+ appearance: none;
264
+ display: block;
265
+ cursor: pointer;
266
+ margin: 0;
267
+ width: 20px;
268
+ height: 20px;
269
+ border-radius: 4px;
270
+ -webkit-transition: 0.2s box-shadow;
271
+ transition: 0.2s box-shadow;
272
+ -webkit-transition: all 0.2s !important;
273
+ transition: all 0.2s !important;
274
+ }
275
+
276
+ .c2[type='checkbox']:checked {
277
+ background-color: var(--charcoal-brand);
278
+ -webkit-transition: 0.2s background-color;
279
+ transition: 0.2s background-color;
280
+ }
281
+
282
+ .c2[type='checkbox']:checked:hover:not(:disabled):not([aria-disabled]),
283
+ .c2[type='checkbox']:checked:hover[aria-disabled=false] {
284
+ background-color: var(--charcoal-brand-hover);
285
+ }
286
+
287
+ .c2[type='checkbox']:checked:active:not(:disabled):not([aria-disabled]),
288
+ .c2[type='checkbox']:checked:active[aria-disabled=false] {
289
+ background-color: var(--charcoal-brand-press);
290
+ }
291
+
292
+ .c2[type='checkbox']:not(:checked) {
293
+ border-width: 2px;
294
+ border-style: solid;
295
+ border-color: #adadad;
296
+ }
297
+
298
+ .c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus,
299
+ .c2[type='checkbox'][aria-disabled=false]:focus,
300
+ .c2[type='checkbox']:not(:disabled):not([aria-disabled]):active,
301
+ .c2[type='checkbox'][aria-disabled=false]:active {
302
+ outline: none;
303
+ box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
304
+ }
305
+
306
+ .c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus:not(:focus-visible),
307
+ .c2[type='checkbox'][aria-disabled=false]:focus:not(:focus-visible),
308
+ .c2[type='checkbox']:not(:disabled):not([aria-disabled]):active:not(:focus-visible),
309
+ .c2[type='checkbox'][aria-disabled=false]:active:not(:focus-visible) {
310
+ outline: none;
311
+ }
312
+
313
+ .c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus-visible,
314
+ .c2[type='checkbox'][aria-disabled=false]:focus-visible {
315
+ outline: none;
316
+ box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
317
+ }
318
+
319
+ .c3 {
320
+ position: absolute;
321
+ top: -2px;
322
+ left: -2px;
323
+ box-sizing: border-box;
324
+ display: -webkit-box;
325
+ display: -webkit-flex;
326
+ display: -ms-flexbox;
327
+ display: flex;
328
+ -webkit-align-items: center;
329
+ -webkit-box-align: center;
330
+ -ms-flex-align: center;
331
+ align-items: center;
332
+ -webkit-box-pack: center;
333
+ -webkit-justify-content: center;
334
+ -ms-flex-pack: center;
335
+ justify-content: center;
336
+ width: 24px;
337
+ height: 24px;
338
+ color: var(--charcoal-text5);
339
+ visibility: hidden;
340
+ }
341
+
342
+ <div
343
+ data-dark={false}
344
+ >
345
+ <div>
346
+ <label
347
+ aria-disabled={false}
348
+ className="c0"
349
+ >
350
+ <div
351
+ className="c1"
352
+ >
353
+ <input
354
+ aria-label="label"
355
+ checked={false}
356
+ className="c2"
357
+ disabled={false}
358
+ name="unlabelled"
359
+ onBlur={[Function]}
360
+ onChange={[Function]}
361
+ onClick={[Function]}
362
+ onDragStart={[Function]}
363
+ onFocus={[Function]}
364
+ onKeyDown={[Function]}
365
+ onKeyUp={[Function]}
366
+ onMouseDown={[Function]}
367
+ onMouseEnter={[Function]}
368
+ onMouseLeave={[Function]}
369
+ onMouseUp={[Function]}
370
+ onTouchCancel={[Function]}
371
+ onTouchEnd={[Function]}
372
+ onTouchMove={[Function]}
373
+ onTouchStart={[Function]}
374
+ type="checkbox"
375
+ />
376
+ <div
377
+ aria-hidden={true}
378
+ checked={false}
379
+ className="c3"
380
+ >
381
+ <pixiv-icon
382
+ name="24/Check"
383
+ unsafe-non-guideline-scale={0.6666666666666666}
384
+ />
385
+ </div>
386
+ </div>
387
+ </label>
388
+ </div>
389
+ </div>
390
+ `;
@@ -0,0 +1,100 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Storyshots Clickable Button 1`] = `
4
+ .c0 {
5
+ cursor: pointer;
6
+ -webkit-appearance: none;
7
+ -moz-appearance: none;
8
+ appearance: none;
9
+ background: transparent;
10
+ padding: 0;
11
+ border-style: none;
12
+ outline: none;
13
+ color: inherit;
14
+ text-rendering: inherit;
15
+ -webkit-letter-spacing: inherit;
16
+ -moz-letter-spacing: inherit;
17
+ -ms-letter-spacing: inherit;
18
+ letter-spacing: inherit;
19
+ word-spacing: inherit;
20
+ font: inherit;
21
+ margin: 0;
22
+ overflow: visible;
23
+ text-transform: none;
24
+ }
25
+
26
+ .c0:disabled,
27
+ .c0[aria-disabled]:not([aria-disabled=false]) {
28
+ cursor: default;
29
+ }
30
+
31
+ .c0:focus {
32
+ outline: none;
33
+ }
34
+
35
+ .c0::-moz-focus-inner {
36
+ border-style: none;
37
+ padding: 0;
38
+ }
39
+
40
+ <div
41
+ data-dark={false}
42
+ >
43
+ <button
44
+ className="c0"
45
+ onClick={[Function]}
46
+ >
47
+ button
48
+ </button>
49
+ </div>
50
+ `;
51
+
52
+ exports[`Storyshots Clickable Link 1`] = `
53
+ .c0 {
54
+ cursor: pointer;
55
+ -webkit-appearance: none;
56
+ -moz-appearance: none;
57
+ appearance: none;
58
+ background: transparent;
59
+ padding: 0;
60
+ border-style: none;
61
+ outline: none;
62
+ color: inherit;
63
+ text-rendering: inherit;
64
+ -webkit-letter-spacing: inherit;
65
+ -moz-letter-spacing: inherit;
66
+ -ms-letter-spacing: inherit;
67
+ letter-spacing: inherit;
68
+ word-spacing: inherit;
69
+ font: inherit;
70
+ margin: 0;
71
+ overflow: visible;
72
+ text-transform: none;
73
+ }
74
+
75
+ .c0:disabled,
76
+ .c0[aria-disabled]:not([aria-disabled=false]) {
77
+ cursor: default;
78
+ }
79
+
80
+ .c0:focus {
81
+ outline: none;
82
+ }
83
+
84
+ .c0::-moz-focus-inner {
85
+ border-style: none;
86
+ padding: 0;
87
+ }
88
+
89
+ <div
90
+ data-dark={false}
91
+ >
92
+ <a
93
+ className="c0"
94
+ href="#"
95
+ onClick={[Function]}
96
+ >
97
+ link
98
+ </a>
99
+ </div>
100
+ `;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react'
2
- import styled, { css } from 'styled-components'
2
+ import styled from 'styled-components'
3
3
  import {
4
4
  LinkProps,
5
5
  useComponentAbstraction,
@@ -28,34 +28,33 @@ export type ClickableElement = HTMLButtonElement & HTMLAnchorElement
28
28
  const Clickable = React.forwardRef<ClickableElement, ClickableProps>(
29
29
  function Clickable(props, ref) {
30
30
  const { Link } = useComponentAbstraction()
31
- if ('to' in props) {
32
- const { onClick, disabled = false, ...rest } = props
33
- return (
34
- <A<typeof Link>
35
- {...rest}
36
- as={disabled ? undefined : Link}
37
- onClick={disabled ? undefined : onClick}
38
- aria-disabled={disabled}
39
- ref={ref}
40
- />
41
- )
42
- } else {
43
- return <Button {...props} ref={ref} />
31
+ const isLink = 'to' in props
32
+ const as = isLink ? Link : 'button'
33
+ const ariaDisabled = isLink && props.disabled === true ? true : undefined
34
+ let rest = props
35
+ if (isLink) {
36
+ const { disabled, ..._rest } = props
37
+ rest = _rest
44
38
  }
39
+ return (
40
+ <StyledClickableDiv
41
+ {...rest}
42
+ ref={ref}
43
+ as={as}
44
+ aria-disabled={ariaDisabled}
45
+ />
46
+ )
45
47
  }
46
48
  )
47
49
  export default Clickable
48
50
 
49
- const clickableCss = css`
50
- /* Clickable style */
51
+ const StyledClickableDiv = styled.div`
51
52
  cursor: pointer;
52
53
 
53
54
  ${disabledSelector} {
54
55
  cursor: default;
55
56
  }
56
- `
57
57
 
58
- const Button = styled.button`
59
58
  /* Reset button appearance */
60
59
  appearance: none;
61
60
  background: transparent;
@@ -88,21 +87,4 @@ const Button = styled.button`
88
87
  border-style: none;
89
88
  padding: 0;
90
89
  }
91
-
92
- ${clickableCss}
93
- `
94
-
95
- const A = styled.span`
96
- /* Reset a-tag appearance */
97
- color: inherit;
98
-
99
- &:focus {
100
- outline: none;
101
- }
102
-
103
- .text {
104
- top: calc(1em + 2em);
105
- }
106
-
107
- ${clickableCss}
108
90
  `
@@ -26,7 +26,6 @@ export function DropdownPopover({ children, ...props }: DropdownPopoverProps) {
26
26
  const selectedElement = document.querySelector(
27
27
  `[data-key="${props.value.toString()}"]`
28
28
  ) as HTMLElement | undefined
29
- selectedElement?.scrollIntoView({ block: 'center' })
30
29
  selectedElement?.focus()
31
30
  window.scrollTo(windowScrollX, windowScrollY)
32
31
  }