@charcoal-ui/react 3.10.1 → 3.11.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 (91) hide show
  1. package/dist/components/Checkbox/index.d.ts.map +1 -1
  2. package/dist/components/DropdownSelector/Popover/index.d.ts +1 -2
  3. package/dist/components/DropdownSelector/Popover/index.d.ts.map +1 -1
  4. package/dist/components/Modal/index.d.ts +1 -1
  5. package/dist/components/Modal/index.d.ts.map +1 -1
  6. package/dist/components/Modal/useCustomModalOverlay.d.ts.map +1 -1
  7. package/dist/components/MultiSelect/index.d.ts.map +1 -1
  8. package/dist/components/Radio/index.d.ts +4 -4
  9. package/dist/components/Radio/index.d.ts.map +1 -1
  10. package/dist/components/TextArea/index.d.ts.map +1 -1
  11. package/dist/components/TextField/index.d.ts.map +1 -1
  12. package/dist/core/CharcoalProvider.d.ts +1 -1
  13. package/dist/core/CharcoalProvider.d.ts.map +1 -1
  14. package/dist/index.cjs.js +120 -348
  15. package/dist/index.cjs.js.map +1 -1
  16. package/dist/index.esm.js +82 -310
  17. package/dist/index.esm.js.map +1 -1
  18. package/package.json +13 -17
  19. package/src/components/Checkbox/__snapshots__/index.story.storyshot +560 -154
  20. package/src/components/Checkbox/index.story.tsx +46 -74
  21. package/src/components/Checkbox/index.tsx +1 -0
  22. package/src/components/DropdownSelector/Popover/index.tsx +1 -2
  23. package/src/components/IconButton/__snapshots__/index.story.storyshot +6 -8
  24. package/src/components/IconButton/index.story.tsx +14 -37
  25. package/src/components/LoadingSpinner/__snapshots__/index.story.storyshot +139 -1
  26. package/src/components/LoadingSpinner/index.story.tsx +18 -7
  27. package/src/components/Modal/index.tsx +1 -1
  28. package/src/components/Modal/useCustomModalOverlay.tsx +5 -4
  29. package/src/components/MultiSelect/__snapshots__/index.story.storyshot +32 -44
  30. package/src/components/MultiSelect/index.story.tsx +88 -192
  31. package/src/components/MultiSelect/index.tsx +2 -1
  32. package/src/components/Radio/__snapshots__/index.story.storyshot +1 -1
  33. package/src/components/Radio/index.story.tsx +20 -21
  34. package/src/components/Radio/index.tsx +14 -13
  35. package/src/components/Switch/__snapshots__/index.story.storyshot +8 -9
  36. package/src/components/Switch/index.story.tsx +10 -18
  37. package/src/components/TagItem/__snapshots__/index.story.storyshot +791 -665
  38. package/src/components/TagItem/index.story.tsx +44 -161
  39. package/src/components/TextArea/TextArea.story.tsx +62 -24
  40. package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +1858 -472
  41. package/src/components/TextArea/index.tsx +2 -0
  42. package/src/components/TextField/TextField.story.tsx +77 -67
  43. package/src/components/TextField/__snapshots__/TextField.story.storyshot +2004 -786
  44. package/src/components/TextField/index.tsx +2 -0
  45. package/src/components/a11y.test.tsx +1 -1
  46. package/src/core/CharcoalProvider.tsx +1 -1
  47. package/dist/components/Button/index.story.d.ts +0 -14
  48. package/dist/components/Button/index.story.d.ts.map +0 -1
  49. package/dist/components/Checkbox/index.story.d.ts +0 -8
  50. package/dist/components/Checkbox/index.story.d.ts.map +0 -1
  51. package/dist/components/Clickable/index.story.d.ts +0 -6
  52. package/dist/components/Clickable/index.story.d.ts.map +0 -1
  53. package/dist/components/DropdownSelector/ListItem/index.story.d.ts +0 -9
  54. package/dist/components/DropdownSelector/ListItem/index.story.d.ts.map +0 -1
  55. package/dist/components/DropdownSelector/MenuList/index.story.d.ts +0 -8
  56. package/dist/components/DropdownSelector/MenuList/index.story.d.ts.map +0 -1
  57. package/dist/components/DropdownSelector/Popover/index.story.d.ts +0 -5
  58. package/dist/components/DropdownSelector/Popover/index.story.d.ts.map +0 -1
  59. package/dist/components/DropdownSelector/index.story.d.ts +0 -19
  60. package/dist/components/DropdownSelector/index.story.d.ts.map +0 -1
  61. package/dist/components/Icon/index.story.d.ts +0 -6
  62. package/dist/components/Icon/index.story.d.ts.map +0 -1
  63. package/dist/components/IconButton/index.story.d.ts +0 -9
  64. package/dist/components/IconButton/index.story.d.ts.map +0 -1
  65. package/dist/components/LoadingSpinner/LoadingSpinnerIcon.story.d.ts +0 -8
  66. package/dist/components/LoadingSpinner/LoadingSpinnerIcon.story.d.ts.map +0 -1
  67. package/dist/components/LoadingSpinner/index.story.d.ts +0 -6
  68. package/dist/components/LoadingSpinner/index.story.d.ts.map +0 -1
  69. package/dist/components/Modal/index.story.d.ts +0 -21
  70. package/dist/components/Modal/index.story.d.ts.map +0 -1
  71. package/dist/components/MultiSelect/index.story.d.ts +0 -82
  72. package/dist/components/MultiSelect/index.story.d.ts.map +0 -1
  73. package/dist/components/MultiSelect/index.test.d.ts +0 -2
  74. package/dist/components/MultiSelect/index.test.d.ts.map +0 -1
  75. package/dist/components/Radio/index.story.d.ts +0 -26
  76. package/dist/components/Radio/index.story.d.ts.map +0 -1
  77. package/dist/components/Radio/index.test.d.ts +0 -2
  78. package/dist/components/Radio/index.test.d.ts.map +0 -1
  79. package/dist/components/SegmentedControl/index.story.d.ts +0 -7
  80. package/dist/components/SegmentedControl/index.story.d.ts.map +0 -1
  81. package/dist/components/Switch/index.story.d.ts +0 -9
  82. package/dist/components/Switch/index.story.d.ts.map +0 -1
  83. package/dist/components/TagItem/index.story.d.ts +0 -16
  84. package/dist/components/TagItem/index.story.d.ts.map +0 -1
  85. package/dist/components/TextArea/TextArea.story.d.ts +0 -9
  86. package/dist/components/TextArea/TextArea.story.d.ts.map +0 -1
  87. package/dist/components/TextField/TextField.story.d.ts +0 -22
  88. package/dist/components/TextField/TextField.story.d.ts.map +0 -1
  89. package/dist/components/a11y.test.d.ts +0 -2
  90. package/dist/components/a11y.test.d.ts.map +0 -1
  91. package/src/components/LoadingSpinner/LoadingSpinnerIcon.story.tsx +0 -13
@@ -1,103 +1,75 @@
1
1
  import { action } from '@storybook/addon-actions'
2
2
  import Checkbox from '.'
3
3
  import { Meta, StoryObj } from '@storybook/react'
4
+ import { useCallback, useState } from 'react'
5
+ import styled from 'styled-components'
4
6
 
5
7
  export default {
6
8
  title: 'Checkbox',
7
9
  component: Checkbox,
8
10
  } as Meta<typeof Checkbox>
9
11
 
10
- export const Labelled: StoryObj<typeof Checkbox> = {
11
- args: {
12
- checked: false,
13
- defaultChecked: false,
14
- disabled: false,
15
- readonly: false,
16
- invalid: false,
17
- },
18
- render: (props) => {
19
- return (
20
- <div>
21
- <div style={{ marginBottom: '1em' }}>
22
- <Checkbox
23
- {...props}
24
- name="labelled"
25
- label="label"
26
- onBlur={action('blur')}
27
- onClick={action('click')}
28
- onChange={action('change')}
29
- onFocus={action('focus')}
30
- >
31
- 同意する
32
- </Checkbox>
33
- </div>
34
-
35
- <div>
36
- <Checkbox
37
- {...props}
38
- name="labelled"
39
- label="label"
40
- onBlur={action('blur')}
41
- onClick={action('click')}
42
- onChange={action('change')}
43
- onFocus={action('focus')}
44
- >
45
- <span style={{ width: 200, display: 'block' }}>
46
- 同意する同意する同意する同意する同意する同意する同意する同意する同意する同意する同意する同意する同意する
47
- </span>
48
- </Checkbox>
49
- </div>
50
- </div>
51
- )
52
- },
53
- }
12
+ const InnerText = styled.span`
13
+ user-select: none;
14
+ `
54
15
 
55
- export const Invalid: StoryObj<typeof Checkbox> = {
56
- args: {
57
- checked: false,
58
- defaultChecked: false,
59
- disabled: false,
60
- readonly: false,
61
- },
16
+ export const Default: StoryObj<typeof Checkbox> = {
62
17
  render: (props) => {
18
+ const [checked, setChecked] = useState(props.checked)
19
+ const handleChange = useCallback((isSelected: boolean) => {
20
+ setChecked(isSelected)
21
+ action('change')(isSelected)
22
+ }, [])
23
+
63
24
  return (
64
25
  <Checkbox
65
26
  {...props}
27
+ checked={checked ?? props.checked}
66
28
  name="labelled"
67
29
  label="label"
68
- invalid
69
30
  onBlur={action('blur')}
70
31
  onClick={action('click')}
71
- onChange={action('change')}
32
+ onChange={handleChange}
72
33
  onFocus={action('focus')}
73
- >
74
- 同意する
34
+ />
35
+ )
36
+ },
37
+ }
38
+
39
+ export const Label: StoryObj<typeof Checkbox> = {
40
+ render: () => {
41
+ return (
42
+ <Checkbox name="labelled">
43
+ <InnerText>同意する</InnerText>
75
44
  </Checkbox>
76
45
  )
77
46
  },
78
47
  }
79
48
 
80
- export const Unlabelled: StoryObj<typeof Checkbox> = {
81
- args: {
82
- checked: false,
83
- defaultChecked: false,
84
- disabled: false,
85
- readonly: false,
86
- invalid: false,
49
+ export const Checked: StoryObj<typeof Checkbox> = {
50
+ render: () => {
51
+ return <Checkbox name="labelled" label="同意する" checked />
87
52
  },
88
- render: (props) => {
53
+ }
54
+
55
+ export const Disabled: StoryObj<typeof Checkbox> = {
56
+ render: () => {
57
+ return <Checkbox name="labelled" label="同意する" disabled />
58
+ },
59
+ }
60
+
61
+ export const ReadOnly: StoryObj<typeof Checkbox> = {
62
+ render: () => {
63
+ return <Checkbox name="labelled" label="同意する" readonly />
64
+ },
65
+ }
66
+
67
+ export const Invalid: StoryObj<typeof Checkbox> = {
68
+ render: () => {
89
69
  return (
90
- <div>
91
- <Checkbox
92
- {...props}
93
- name="unlabelled"
94
- label="label"
95
- onBlur={action('blur')}
96
- onClick={action('click')}
97
- onChange={action('change')}
98
- onFocus={action('focus')}
99
- />
100
- </div>
70
+ <Checkbox name="labelled" invalid>
71
+ 同意する
72
+ </Checkbox>
101
73
  )
102
74
  },
103
75
  }
@@ -46,6 +46,7 @@ const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
46
46
  // children がいない場合は aria-label をつけないといけない
47
47
  'aria-label': 'children' in props ? undefined : props.label,
48
48
  isDisabled: props.disabled,
49
+ isReadOnly: props.readonly,
49
50
  }),
50
51
  [invalid, props]
51
52
  )
@@ -1,5 +1,4 @@
1
- import { RefObject, useContext, useRef } from 'react'
2
- import { ReactNode } from 'react'
1
+ import { RefObject, useContext, useRef, ReactNode } from 'react'
3
2
  import { DismissButton, Overlay, usePopover } from '@react-aria/overlays'
4
3
  import styled from 'styled-components'
5
4
  import { ModalBackgroundContext } from '../../Modal/ModalBackgroundContext'
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Storybook Tests IconButton DefaultM 1`] = `
3
+ exports[`Storybook Tests IconButton Default 1`] = `
4
4
  .c0 {
5
5
  cursor: pointer;
6
6
  -webkit-appearance: none;
@@ -103,10 +103,10 @@ exports[`Storybook Tests IconButton DefaultM 1`] = `
103
103
  >
104
104
  <button
105
105
  className="c0 c1"
106
- title="close"
106
+ title="add"
107
107
  >
108
108
  <pixiv-icon
109
- name="24/Close"
109
+ name="16/Add"
110
110
  />
111
111
  </button>
112
112
  </div>
@@ -209,16 +209,15 @@ exports[`Storybook Tests IconButton IsActive 1`] = `
209
209
  >
210
210
  <button
211
211
  className="c0 c1"
212
- title="close"
213
212
  >
214
213
  <pixiv-icon
215
- name="24/Close"
214
+ name="16/Add"
216
215
  />
217
216
  </button>
218
217
  </div>
219
218
  `;
220
219
 
221
- exports[`Storybook Tests IconButton OverlayM 1`] = `
220
+ exports[`Storybook Tests IconButton Overlay 1`] = `
222
221
  .c0 {
223
222
  cursor: pointer;
224
223
  -webkit-appearance: none;
@@ -321,10 +320,9 @@ exports[`Storybook Tests IconButton OverlayM 1`] = `
321
320
  >
322
321
  <button
323
322
  className="c0 c1"
324
- title="close"
325
323
  >
326
324
  <pixiv-icon
327
- name="24/Close"
325
+ name="16/Add"
328
326
  />
329
327
  </button>
330
328
  </div>
@@ -1,57 +1,34 @@
1
1
  import '@charcoal-ui/icons'
2
2
  import IconButton from '.'
3
- import type { KnownIconType } from '@charcoal-ui/icons'
4
3
  import { Meta, StoryObj } from '@storybook/react'
5
4
 
6
5
  export default {
7
6
  title: 'IconButton',
8
7
  component: IconButton,
9
- argTypes: {
10
- variant: {
11
- control: {
12
- type: 'inline-radio',
13
- options: ['Default', 'Overlay'],
14
- },
15
- },
16
- size: {
17
- control: {
18
- type: 'inline-radio',
19
- options: ['M', 'S', 'XS'],
20
- },
21
- },
22
- isActive: {
23
- control: {
24
- type: 'boolean',
25
- },
26
- },
27
- },
28
- render: (props) => {
29
- const { size } = props
30
- const icon: keyof KnownIconType = {
31
- XS: '16/Remove' as const,
32
- S: '24/Close' as const,
33
- M: '24/Close' as const,
34
- }[size ?? 'M']
35
- return <IconButton title="close" {...props} icon={icon} />
8
+ parameters: {
9
+ layout: 'centered',
36
10
  },
37
11
  } as Meta<typeof IconButton>
38
12
 
39
- export const DefaultM: StoryObj<typeof IconButton> = {
13
+ export const Default: StoryObj<typeof IconButton> = {
40
14
  args: {
41
- variant: 'Default',
42
- size: 'M',
15
+ icon: '16/Add',
16
+ },
17
+ render: (props) => {
18
+ const title = props.icon.split('/').at(1)?.toLocaleLowerCase()
19
+
20
+ return <IconButton title={title} {...props} />
43
21
  },
44
22
  }
45
23
 
46
24
  export const IsActive: StoryObj<typeof IconButton> = {
47
- args: {
48
- isActive: true,
25
+ render: () => {
26
+ return <IconButton icon="16/Add" isActive />
49
27
  },
50
28
  }
51
29
 
52
- export const OverlayM: StoryObj<typeof IconButton> = {
53
- args: {
54
- variant: 'Overlay',
55
- size: 'M',
30
+ export const Overlay: StoryObj<typeof IconButton> = {
31
+ render: () => {
32
+ return <IconButton icon="16/Add" variant="Overlay" />
56
33
  },
57
34
  }
@@ -34,7 +34,145 @@ exports[`Storybook Tests LoadingSpinner Default 1`] = `
34
34
  data-dark={false}
35
35
  >
36
36
  <div
37
- className="c0 basic"
37
+ className="c0"
38
+ role="progressbar"
39
+ size={48}
40
+ >
41
+ <div
42
+ className="c1"
43
+ role="presentation"
44
+ />
45
+ </div>
46
+ </div>
47
+ `;
48
+
49
+ exports[`Storybook Tests LoadingSpinner Padding 1`] = `
50
+ .c0 {
51
+ box-sizing: content-box;
52
+ margin: auto;
53
+ padding: 24px;
54
+ border-radius: 8px;
55
+ font-size: 48px;
56
+ width: 48px;
57
+ height: 48px;
58
+ opacity: 0.84;
59
+ color: var(--charcoal-text4);
60
+ background-color: var(--charcoal-background1);
61
+ }
62
+
63
+ .c1 {
64
+ width: 1em;
65
+ height: 1em;
66
+ border-radius: 1em;
67
+ background-color: currentColor;
68
+ -webkit-animation: cNZOgq 1s both ease-out;
69
+ animation: cNZOgq 1s both ease-out;
70
+ -webkit-animation-iteration-count: infinite;
71
+ animation-iteration-count: infinite;
72
+ }
73
+
74
+ .c1[data-reset-animation] {
75
+ -webkit-animation: none;
76
+ animation: none;
77
+ }
78
+
79
+ <div
80
+ data-dark={false}
81
+ >
82
+ <div
83
+ className="c0"
84
+ role="progressbar"
85
+ size={48}
86
+ >
87
+ <div
88
+ className="c1"
89
+ role="presentation"
90
+ />
91
+ </div>
92
+ </div>
93
+ `;
94
+
95
+ exports[`Storybook Tests LoadingSpinner Size 1`] = `
96
+ .c0 {
97
+ box-sizing: content-box;
98
+ margin: auto;
99
+ padding: 16px;
100
+ border-radius: 8px;
101
+ font-size: 128px;
102
+ width: 128px;
103
+ height: 128px;
104
+ opacity: 0.84;
105
+ color: var(--charcoal-text4);
106
+ background-color: var(--charcoal-background1);
107
+ }
108
+
109
+ .c1 {
110
+ width: 1em;
111
+ height: 1em;
112
+ border-radius: 1em;
113
+ background-color: currentColor;
114
+ -webkit-animation: cNZOgq 1s both ease-out;
115
+ animation: cNZOgq 1s both ease-out;
116
+ -webkit-animation-iteration-count: infinite;
117
+ animation-iteration-count: infinite;
118
+ }
119
+
120
+ .c1[data-reset-animation] {
121
+ -webkit-animation: none;
122
+ animation: none;
123
+ }
124
+
125
+ <div
126
+ data-dark={false}
127
+ >
128
+ <div
129
+ className="c0"
130
+ role="progressbar"
131
+ size={128}
132
+ >
133
+ <div
134
+ className="c1"
135
+ role="presentation"
136
+ />
137
+ </div>
138
+ </div>
139
+ `;
140
+
141
+ exports[`Storybook Tests LoadingSpinner Transparent 1`] = `
142
+ .c0 {
143
+ box-sizing: content-box;
144
+ margin: auto;
145
+ padding: 16px;
146
+ border-radius: 8px;
147
+ font-size: 48px;
148
+ width: 48px;
149
+ height: 48px;
150
+ opacity: 0.84;
151
+ color: var(--charcoal-text4);
152
+ background-color: var(--charcoal-transparent);
153
+ }
154
+
155
+ .c1 {
156
+ width: 1em;
157
+ height: 1em;
158
+ border-radius: 1em;
159
+ background-color: currentColor;
160
+ -webkit-animation: cNZOgq 1s both ease-out;
161
+ animation: cNZOgq 1s both ease-out;
162
+ -webkit-animation-iteration-count: infinite;
163
+ animation-iteration-count: infinite;
164
+ }
165
+
166
+ .c1[data-reset-animation] {
167
+ -webkit-animation: none;
168
+ animation: none;
169
+ }
170
+
171
+ <div
172
+ data-dark={false}
173
+ >
174
+ <div
175
+ className="c0"
38
176
  role="progressbar"
39
177
  size={48}
40
178
  >
@@ -4,13 +4,24 @@ import LoadingSpinner from '.'
4
4
  export default {
5
5
  title: 'LoadingSpinner',
6
6
  component: LoadingSpinner,
7
- args: {
8
- size: 48,
9
- padding: 16,
10
- transparent: false,
11
- className: 'basic',
12
- },
13
7
  tags: ['skip-test'],
8
+ parameters: {
9
+ layout: 'centered',
10
+ },
14
11
  } as Meta<typeof LoadingSpinner>
15
12
 
16
- export const Default: StoryObj<typeof LoadingSpinner> = {}
13
+ export const Default: StoryObj<typeof LoadingSpinner> = {
14
+ render: (props) => <LoadingSpinner {...props} />,
15
+ }
16
+
17
+ export const Transparent: StoryObj<typeof LoadingSpinner> = {
18
+ render: () => <LoadingSpinner transparent />,
19
+ }
20
+
21
+ export const Size: StoryObj<typeof LoadingSpinner> = {
22
+ render: () => <LoadingSpinner size={128} />,
23
+ }
24
+
25
+ export const Padding: StoryObj<typeof LoadingSpinner> = {
26
+ render: () => <LoadingSpinner padding={24} />,
27
+ }
@@ -2,7 +2,7 @@ import { useContext, forwardRef, memo } from 'react'
2
2
  import * as React from 'react'
3
3
  import { AriaModalOverlayProps, Overlay } from '@react-aria/overlays'
4
4
  import styled, { css, useTheme } from 'styled-components'
5
- import { AriaDialogProps } from '@react-types/dialog'
5
+ import type { AriaDialogProps } from '@react-types/dialog'
6
6
  import { maxWidth } from '@charcoal-ui/utils'
7
7
  import { useMedia } from '@charcoal-ui/styled'
8
8
  import { animated, useTransition, easings } from 'react-spring'
@@ -5,8 +5,8 @@ import {
5
5
  ariaHideOutside,
6
6
  useOverlay,
7
7
  useOverlayFocusContain,
8
- usePreventScroll,
9
8
  } from '@react-aria/overlays'
9
+ import { usePreventScroll } from '../DropdownSelector/Popover/usePreventScroll'
10
10
 
11
11
  /**
12
12
  * We want to enable scrolling on the modal background,
@@ -28,9 +28,10 @@ export function useCharcoalModalOverlay(
28
28
  ref
29
29
  )
30
30
 
31
- usePreventScroll({
32
- isDisabled: !state.isOpen,
33
- })
31
+ usePreventScroll(
32
+ typeof document !== 'undefined' ? document.body : null,
33
+ state.isOpen
34
+ )
34
35
 
35
36
  useOverlayFocusContain()
36
37