@charcoal-ui/react 2.7.0 → 2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@charcoal-ui/react",
3
- "version": "2.7.0",
3
+ "version": "2.9.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.js",
@@ -49,10 +49,10 @@
49
49
  "typescript": "^4.9.5"
50
50
  },
51
51
  "dependencies": {
52
- "@charcoal-ui/icons": "^2.7.0",
53
- "@charcoal-ui/styled": "^2.7.0",
54
- "@charcoal-ui/theme": "^2.7.0",
55
- "@charcoal-ui/utils": "^2.7.0",
52
+ "@charcoal-ui/icons": "^2.9.0",
53
+ "@charcoal-ui/styled": "^2.9.0",
54
+ "@charcoal-ui/theme": "^2.9.0",
55
+ "@charcoal-ui/utils": "^2.9.0",
56
56
  "@react-aria/button": "^3.7.0",
57
57
  "@react-aria/checkbox": "^3.8.0",
58
58
  "@react-aria/dialog": "^3.5.0",
@@ -88,5 +88,5 @@
88
88
  "url": "https://github.com/pixiv/charcoal.git",
89
89
  "directory": "packages/react"
90
90
  },
91
- "gitHead": "77e32148d5a981f988e8bbc0c88aec82b0936a1a"
91
+ "gitHead": "37a14b2a014a752fe20c358eb5d35e0e74063805"
92
92
  }
@@ -47,6 +47,7 @@ export const Sections: Story<DropdownSelectorProps> = (props) => {
47
47
  <div>
48
48
  <DropdownSelector
49
49
  {...props}
50
+ label="sections"
50
51
  placeholder={'Drop Down menu'}
51
52
  onChange={action('change')}
52
53
  onOpenChange={action('open')}
@@ -68,6 +69,7 @@ export const Bottom: Story<DropdownSelectorProps> = (props) => {
68
69
  <div style={{ marginTop: '1000px' }}>
69
70
  <DropdownSelector
70
71
  {...props}
72
+ label="bottom"
71
73
  placeholder={'Drop Down menu'}
72
74
  onChange={action('change')}
73
75
  onOpenChange={action('open')}
@@ -86,6 +88,7 @@ export const Many: Story<DropdownSelectorProps> = (props) => {
86
88
  <div style={{ padding: '300px 100px' }}>
87
89
  <DropdownSelector
88
90
  {...props}
91
+ label="many"
89
92
  placeholder={'Drop Down menu'}
90
93
  onChange={(v) => {
91
94
  setValue(v.toString())
@@ -181,7 +184,7 @@ type InvalidProps = {
181
184
  }
182
185
  export const Invalid: Story<InvalidProps> = ({ disabled }) => {
183
186
  const props: Omit<DropdownSelectorProps, 'children'> = {
184
- label: '',
187
+ label: 'invalid',
185
188
  assertiveText: 'error message',
186
189
  invalid: true,
187
190
  }
@@ -19,6 +19,7 @@ const LoadingSpinnerRoot = styled.div.attrs({ role: 'progressbar' })<{
19
19
  padding: number
20
20
  transparent: boolean
21
21
  }>`
22
+ box-sizing: content-box;
22
23
  margin: auto;
23
24
  padding: ${(props) => props.padding}px;
24
25
  border-radius: 8px;
@@ -18,13 +18,16 @@ import { animated, useTransition, easings } from 'react-spring'
18
18
  import Button, { ButtonProps } from '../Button'
19
19
  import IconButton from '../IconButton'
20
20
 
21
+ type BottomSheet = boolean | 'full'
22
+ type Size = 'S' | 'M' | 'L'
23
+
21
24
  export type ModalProps = AriaModalOverlayProps &
22
25
  AriaDialogProps & {
23
26
  children: React.ReactNode
24
27
  zIndex?: number
25
28
  title: string
26
- size?: 'S' | 'M' | 'L'
27
- bottomSheet?: boolean | 'full'
29
+ size?: Size
30
+ bottomSheet?: BottomSheet
28
31
  isOpen: boolean
29
32
  onClose: () => void
30
33
 
@@ -133,28 +136,30 @@ export default function Modal({
133
136
  style={transitionEnabled ? { backgroundColor } : {}}
134
137
  >
135
138
  <FocusScope contain restoreFocus autoFocus>
136
- <ModalDialog
137
- ref={ref}
138
- {...overlayProps}
139
- {...modalProps}
140
- {...dialogProps}
141
- style={transitionEnabled ? { transform } : {}}
142
- size={size}
143
- bottomSheet={bottomSheet}
144
- >
145
- <ModalContext.Provider
146
- value={{ titleProps, title, close: onClose, showDismiss }}
139
+ <DialogContainer bottomSheet={bottomSheet} size={size}>
140
+ <ModalDialog
141
+ ref={ref}
142
+ {...overlayProps}
143
+ {...modalProps}
144
+ {...dialogProps}
145
+ style={transitionEnabled ? { transform } : {}}
146
+ size={size}
147
+ bottomSheet={bottomSheet}
147
148
  >
148
- {children}
149
- {isDismissable === true && (
150
- <ModalCrossButton
151
- size="S"
152
- icon="24/Close"
153
- onClick={onClose}
154
- />
155
- )}
156
- </ModalContext.Provider>
157
- </ModalDialog>
149
+ <ModalContext.Provider
150
+ value={{ titleProps, title, close: onClose, showDismiss }}
151
+ >
152
+ {children}
153
+ {isDismissable === true && (
154
+ <ModalCrossButton
155
+ size="S"
156
+ icon="24/Close"
157
+ onClick={onClose}
158
+ />
159
+ )}
160
+ </ModalContext.Provider>
161
+ </ModalDialog>
162
+ </DialogContainer>
158
163
  </FocusScope>
159
164
  </ModalBackground>
160
165
  </Overlay>
@@ -176,6 +181,8 @@ const ModalContext = React.createContext<{
176
181
 
177
182
  const ModalBackground = animated(styled.div<{ zIndex: number }>`
178
183
  z-index: ${({ zIndex }) => zIndex};
184
+ overflow: scroll;
185
+ display: flex;
179
186
  position: fixed;
180
187
  top: 0;
181
188
  left: 0;
@@ -185,50 +192,61 @@ const ModalBackground = animated(styled.div<{ zIndex: number }>`
185
192
  ${theme((o) => [o.bg.surface4])}
186
193
  `)
187
194
 
195
+ const DialogContainer = styled.div<{ bottomSheet: BottomSheet; size: Size }>`
196
+ position: relative;
197
+ margin: auto;
198
+ padding: 24px 0;
199
+ width: ${(p) => {
200
+ switch (p.size) {
201
+ case 'S': {
202
+ return columnSystem(3, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2
203
+ }
204
+ case 'M': {
205
+ return columnSystem(4, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2
206
+ }
207
+ case 'L': {
208
+ return columnSystem(6, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2
209
+ }
210
+ default: {
211
+ return unreachable(p.size)
212
+ }
213
+ }
214
+ }}px;
215
+
216
+ @media ${({ theme }) => maxWidth(theme.breakpoint.screen1)} {
217
+ width: calc(100% - 48px);
218
+ ${(p) =>
219
+ p.bottomSheet !== false &&
220
+ css`
221
+ margin: 0;
222
+ padding: 0;
223
+ bottom: 0;
224
+ position: absolute;
225
+ width: 100%;
226
+ ${p.bottomSheet === 'full' ? 'height: 100%' : ''};
227
+ `}
228
+ }
229
+ `
230
+
188
231
  const ModalDialog = animated(styled.div<{
189
- size: 'S' | 'M' | 'L'
190
- bottomSheet: boolean | 'full'
232
+ size: Size
233
+ bottomSheet: BottomSheet
191
234
  }>`
192
- position: absolute;
193
- top: 50%;
194
- left: 50%;
195
- transform: translate(-50%, -50%);
196
- width: ${(p) =>
197
- p.size === 'S'
198
- ? columnSystem(3, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2
199
- : p.size === 'M'
200
- ? columnSystem(4, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2
201
- : // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
202
- p.size === 'L'
203
- ? columnSystem(6, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2
204
- : unreachable(p.size)}px;
235
+ position: relative;
236
+ margin: auto;
237
+ padding: 24px 0;
205
238
 
206
239
  ${theme((o) => [o.bg.background1, o.borderRadius(24)])}
207
-
208
240
  @media ${({ theme }) => maxWidth(theme.breakpoint.screen1)} {
209
241
  ${(p) =>
210
- p.bottomSheet === 'full'
211
- ? css`
212
- top: auto;
213
- bottom: 0;
214
- left: 0;
215
- transform: none;
216
- border-radius: 0;
217
- width: 100%;
218
- height: 100%;
219
- `
220
- : p.bottomSheet
221
- ? css`
222
- top: auto;
223
- bottom: 0;
224
- left: 0;
225
- transform: none;
226
- border-radius: 0;
227
- width: 100%;
228
- `
229
- : css`
230
- width: calc(100% - 48px);
231
- `}
242
+ p.bottomSheet !== false &&
243
+ css`
244
+ border-radius: 0;
245
+ ${p.bottomSheet === 'full' &&
246
+ css`
247
+ height: 100%;
248
+ `}
249
+ `}
232
250
  }
233
251
  `)
234
252
 
@@ -82,6 +82,8 @@ export const RadioInput = styled.input.attrs({ type: 'radio' })<{
82
82
  width: 20px;
83
83
  height: 20px;
84
84
 
85
+ cursor: pointer;
86
+
85
87
  ${({ hasError = false }) =>
86
88
  theme((o) => [
87
89
  o.borderRadius('oval'),
@@ -13,6 +13,7 @@ export const StringSegments: Story<SegmentedControlProps> = (props) => {
13
13
  }
14
14
 
15
15
  StringSegments.args = {
16
+ name: 'test',
16
17
  data: ['option1', 'option2', 'option3'],
17
18
  disabled: false,
18
19
  readonly: false,
@@ -24,6 +25,7 @@ export const ObjectSegments: Story<SegmentedControlProps> = (props) => {
24
25
  }
25
26
 
26
27
  ObjectSegments.args = {
28
+ name: 'test',
27
29
  data: [
28
30
  { label: '選択肢1', value: 'option1' },
29
31
  { label: '選択肢2', value: 'option2' },
@@ -41,6 +41,7 @@ const SegmentedControl = forwardRef<HTMLDivElement, SegmentedControlProps>(
41
41
  isDisabled: props.disabled,
42
42
  isReadOnly: props.readonly,
43
43
  isRequired: props.required,
44
+ 'aria-label': props.name,
44
45
  }),
45
46
  [props]
46
47
  )
@@ -349,6 +349,7 @@ const PrefixContainer = styled.span`
349
349
  top: 50%;
350
350
  left: 8px;
351
351
  transform: translateY(-50%);
352
+ z-index: 1;
352
353
  `
353
354
 
354
355
  const SuffixContainer = styled.span`
package/src/index.ts CHANGED
@@ -52,11 +52,12 @@ export {
52
52
  } from './components/LoadingSpinner'
53
53
  export {
54
54
  default as DropdownSelector,
55
+ type DropdownSelectorProps,
55
56
  DropdownSelectorItem,
56
57
  } from './components/DropdownSelector'
57
58
  export {
58
59
  default as SegmentedControl,
59
60
  type SegmentedControlProps,
60
61
  } from './components/SegmentedControl'
61
- export { default as Checkbox } from './components/Checkbox'
62
+ export { default as Checkbox, type CheckboxProps } from './components/Checkbox'
62
63
  export { default as TagItem, type TagItemProps } from './components/TagItem'