@charcoal-ui/react 2.0.0-alpha.9 → 2.0.0-rc.1
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/README.md +16 -0
- package/dist/components/Checkbox/index.d.ts +21 -0
- package/dist/components/Checkbox/index.d.ts.map +1 -0
- package/dist/components/Checkbox/index.story.d.ts +16 -0
- package/dist/components/Checkbox/index.story.d.ts.map +1 -0
- package/dist/components/DropdownSelector/Listbox.d.ts +10 -0
- package/dist/components/DropdownSelector/Listbox.d.ts.map +1 -0
- package/dist/components/DropdownSelector/Popover.d.ts +10 -0
- package/dist/components/DropdownSelector/Popover.d.ts.map +1 -0
- package/dist/components/DropdownSelector/index.d.ts +32 -0
- package/dist/components/DropdownSelector/index.d.ts.map +1 -0
- package/dist/components/DropdownSelector/index.story.d.ts +22 -0
- package/dist/components/DropdownSelector/index.story.d.ts.map +1 -0
- package/dist/components/Icon/index.story.d.ts +1 -1
- package/dist/components/LoadingSpinner/index.d.ts +15 -0
- package/dist/components/LoadingSpinner/index.d.ts.map +1 -0
- package/dist/components/LoadingSpinner/index.story.d.ts +10 -0
- package/dist/components/LoadingSpinner/index.story.d.ts.map +1 -0
- package/dist/components/Modal/ModalPlumbing.d.ts +5 -0
- package/dist/components/Modal/ModalPlumbing.d.ts.map +1 -0
- package/dist/components/Modal/index.d.ts +16 -0
- package/dist/components/Modal/index.d.ts.map +1 -0
- package/dist/components/Modal/index.story.d.ts +33 -0
- package/dist/components/Modal/index.story.d.ts.map +1 -0
- package/dist/components/{Select → MultiSelect}/context.d.ts +2 -2
- package/dist/components/MultiSelect/context.d.ts.map +1 -0
- package/dist/components/MultiSelect/index.d.ts +24 -0
- package/dist/components/MultiSelect/index.d.ts.map +1 -0
- package/dist/components/{Select → MultiSelect}/index.story.d.ts +2 -2
- package/dist/components/MultiSelect/index.story.d.ts.map +1 -0
- package/dist/components/{Select → MultiSelect}/index.test.d.ts +0 -0
- package/dist/components/MultiSelect/index.test.d.ts.map +1 -0
- package/dist/components/SegmentedControl/RadioGroupContext.d.ts +9 -0
- package/dist/components/SegmentedControl/RadioGroupContext.d.ts.map +1 -0
- package/dist/components/SegmentedControl/index.d.ts +20 -0
- package/dist/components/SegmentedControl/index.d.ts.map +1 -0
- package/dist/components/SegmentedControl/index.story.d.ts +11 -0
- package/dist/components/SegmentedControl/index.story.d.ts.map +1 -0
- package/dist/components/TextField/index.d.ts +6 -3
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/components/TextField/index.story.d.ts +1 -0
- package/dist/components/TextField/index.story.d.ts.map +1 -1
- package/dist/core/SSRProvider.d.ts +2 -0
- package/dist/core/SSRProvider.d.ts.map +1 -0
- package/dist/index.cjs +22686 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.modern.js +21612 -45
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +22641 -1
- package/dist/index.module.js.map +1 -1
- package/package.json +15 -8
- package/src/components/Checkbox/index.story.tsx +64 -0
- package/src/components/Checkbox/index.tsx +122 -0
- package/src/components/DropdownSelector/Listbox.tsx +127 -0
- package/src/components/DropdownSelector/Popover.tsx +46 -0
- package/src/components/DropdownSelector/index.story.tsx +134 -0
- package/src/components/DropdownSelector/index.tsx +214 -0
- package/src/components/FieldLabel/index.tsx +1 -1
- package/src/components/LoadingSpinner/index.story.tsx +52 -0
- package/src/components/LoadingSpinner/index.tsx +87 -0
- package/src/components/Modal/ModalPlumbing.tsx +47 -0
- package/src/components/Modal/index.story.tsx +195 -0
- package/src/components/Modal/index.tsx +226 -0
- package/src/components/{Select → MultiSelect}/context.ts +3 -3
- package/src/components/{Select → MultiSelect}/index.story.tsx +16 -12
- package/src/components/{Select → MultiSelect}/index.test.tsx +13 -13
- package/src/components/{Select → MultiSelect}/index.tsx +24 -21
- package/src/components/SegmentedControl/RadioGroupContext.tsx +22 -0
- package/src/components/SegmentedControl/index.story.tsx +36 -0
- package/src/components/SegmentedControl/index.tsx +157 -0
- package/src/components/TextField/index.story.tsx +31 -16
- package/src/components/TextField/index.tsx +53 -34
- package/src/components/a11y.test.tsx +11 -0
- package/src/core/SSRProvider.tsx +1 -0
- package/src/index.ts +22 -5
- package/src/styled.ts +1 -1
- package/dist/components/Select/context.d.ts.map +0 -1
- package/dist/components/Select/index.d.ts +0 -24
- package/dist/components/Select/index.d.ts.map +0 -1
- package/dist/components/Select/index.story.d.ts.map +0 -1
- package/dist/components/Select/index.test.d.ts.map +0 -1
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import React, { forwardRef, memo, useMemo, useRef } from 'react'
|
|
2
|
+
import { useRadioGroupState } from 'react-stately'
|
|
3
|
+
import {
|
|
4
|
+
AriaRadioGroupProps,
|
|
5
|
+
AriaRadioProps,
|
|
6
|
+
useRadio,
|
|
7
|
+
useRadioGroup,
|
|
8
|
+
} from '@react-aria/radio'
|
|
9
|
+
import styled from 'styled-components'
|
|
10
|
+
import { disabledSelector } from '@charcoal-ui/utils'
|
|
11
|
+
|
|
12
|
+
import { RadioProvider, useRadioContext } from './RadioGroupContext'
|
|
13
|
+
import { theme } from '../../styled'
|
|
14
|
+
|
|
15
|
+
type SegmentedControlItem = {
|
|
16
|
+
label: React.ReactNode
|
|
17
|
+
value: string
|
|
18
|
+
disabled?: boolean
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type SegmentedControlProps = {
|
|
22
|
+
readonly id?: string
|
|
23
|
+
readonly name?: string
|
|
24
|
+
readonly disabled?: boolean
|
|
25
|
+
readonly readonly?: boolean
|
|
26
|
+
readonly required?: boolean
|
|
27
|
+
|
|
28
|
+
readonly value?: string
|
|
29
|
+
readonly defaultValue?: string
|
|
30
|
+
|
|
31
|
+
readonly data: string[] | SegmentedControlItem[]
|
|
32
|
+
|
|
33
|
+
readonly onChange?: (value: string) => void
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const SegmentedControl = forwardRef<HTMLDivElement, SegmentedControlProps>(
|
|
37
|
+
function SegmentedControlInner(props, ref) {
|
|
38
|
+
const ariaRadioGroupProps = useMemo<AriaRadioGroupProps>(
|
|
39
|
+
() => ({
|
|
40
|
+
...props,
|
|
41
|
+
isDisabled: props.disabled,
|
|
42
|
+
isReadOnly: props.readonly,
|
|
43
|
+
isRequired: props.required,
|
|
44
|
+
}),
|
|
45
|
+
[props]
|
|
46
|
+
)
|
|
47
|
+
const state = useRadioGroupState(ariaRadioGroupProps)
|
|
48
|
+
const { radioGroupProps } = useRadioGroup(ariaRadioGroupProps, state)
|
|
49
|
+
const segmentedControlItems = useMemo<SegmentedControlItem[]>(() => {
|
|
50
|
+
return props.data.map((d) =>
|
|
51
|
+
typeof d === 'string' ? { value: d, label: d } : d
|
|
52
|
+
)
|
|
53
|
+
}, [props.data])
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<SegmentedControlRoot ref={ref} {...radioGroupProps}>
|
|
57
|
+
<RadioProvider value={state}>
|
|
58
|
+
{segmentedControlItems.map((item) => (
|
|
59
|
+
<Segmented
|
|
60
|
+
key={item.value}
|
|
61
|
+
value={item.value}
|
|
62
|
+
disabled={item.disabled}
|
|
63
|
+
>
|
|
64
|
+
{item.label}
|
|
65
|
+
</Segmented>
|
|
66
|
+
))}
|
|
67
|
+
</RadioProvider>
|
|
68
|
+
</SegmentedControlRoot>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
export default memo(SegmentedControl)
|
|
74
|
+
|
|
75
|
+
type RadioProps = {
|
|
76
|
+
value: string
|
|
77
|
+
disabled?: boolean
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const Segmented: React.FC<RadioProps> = ({ children, ...props }) => {
|
|
81
|
+
const state = useRadioContext()
|
|
82
|
+
const ref = useRef<HTMLInputElement>(null)
|
|
83
|
+
const ariaRadioProps = useMemo<AriaRadioProps>(
|
|
84
|
+
() => ({ ...props, isDisabled: props.disabled }),
|
|
85
|
+
[props]
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
const { inputProps, isDisabled, isSelected } = useRadio(
|
|
89
|
+
ariaRadioProps,
|
|
90
|
+
state,
|
|
91
|
+
ref
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<SegmentedRoot
|
|
96
|
+
aria-disabled={isDisabled || state.isReadOnly}
|
|
97
|
+
checked={isSelected}
|
|
98
|
+
>
|
|
99
|
+
<SegmentedInput {...inputProps} ref={ref} />
|
|
100
|
+
<RadioLabel>
|
|
101
|
+
<SegmentedLabelInner>{children}</SegmentedLabelInner>
|
|
102
|
+
</RadioLabel>
|
|
103
|
+
</SegmentedRoot>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const SegmentedControlRoot = styled.div`
|
|
108
|
+
display: inline-flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
|
|
111
|
+
${theme((o) => [o.bg.surface3, o.borderRadius(16)])}
|
|
112
|
+
`
|
|
113
|
+
|
|
114
|
+
const SegmentedRoot = styled.label<{ checked?: boolean }>`
|
|
115
|
+
position: relative;
|
|
116
|
+
display: flex;
|
|
117
|
+
align-items: center;
|
|
118
|
+
cursor: pointer;
|
|
119
|
+
height: 32px;
|
|
120
|
+
|
|
121
|
+
${disabledSelector} {
|
|
122
|
+
cursor: default;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
${({ checked }) =>
|
|
126
|
+
theme((o) => [
|
|
127
|
+
o.padding.horizontal(16),
|
|
128
|
+
o.borderRadius(16),
|
|
129
|
+
o.disabled,
|
|
130
|
+
checked === true && o.bg.brand,
|
|
131
|
+
checked === true ? o.font.text5 : o.font.text2,
|
|
132
|
+
])}
|
|
133
|
+
`
|
|
134
|
+
const SegmentedInput = styled.input`
|
|
135
|
+
position: absolute;
|
|
136
|
+
|
|
137
|
+
height: 0px;
|
|
138
|
+
width: 0px;
|
|
139
|
+
padding: 0;
|
|
140
|
+
margin: 0;
|
|
141
|
+
|
|
142
|
+
appearance: none;
|
|
143
|
+
box-sizing: border-box;
|
|
144
|
+
overflow: hidden;
|
|
145
|
+
white-space: nowrap;
|
|
146
|
+
opacity: 0;
|
|
147
|
+
`
|
|
148
|
+
|
|
149
|
+
const RadioLabel = styled.div`
|
|
150
|
+
background: transparent;
|
|
151
|
+
display: flex;
|
|
152
|
+
align-items: center;
|
|
153
|
+
height: 22px;
|
|
154
|
+
`
|
|
155
|
+
const SegmentedLabelInner = styled.div`
|
|
156
|
+
${theme((o) => [o.typography(14)])}
|
|
157
|
+
`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { action } from '@storybook/addon-actions'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import
|
|
3
|
+
import styled from 'styled-components'
|
|
4
4
|
import { Story } from '../../_lib/compat'
|
|
5
5
|
import Clickable from '../Clickable'
|
|
6
6
|
import TextField, {
|
|
@@ -9,6 +9,7 @@ import TextField, {
|
|
|
9
9
|
TextFieldProps,
|
|
10
10
|
} from '.'
|
|
11
11
|
import { px } from '@charcoal-ui/utils'
|
|
12
|
+
import IconButton from '../IconButton'
|
|
12
13
|
|
|
13
14
|
export default {
|
|
14
15
|
title: 'TextField',
|
|
@@ -24,23 +25,20 @@ export default {
|
|
|
24
25
|
},
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
const Container = styled.div`
|
|
29
|
+
display: grid;
|
|
30
|
+
gap: ${({ theme }) => px(theme.spacing[24])};
|
|
31
|
+
`
|
|
32
|
+
|
|
27
33
|
const Template: Story<Partial<TextFieldProps>> = (args) => (
|
|
28
|
-
<
|
|
29
|
-
css={css`
|
|
30
|
-
display: grid;
|
|
31
|
-
gap: ${({ theme }) => px(theme.spacing[24])};
|
|
32
|
-
`}
|
|
33
|
-
>
|
|
34
|
+
<Container>
|
|
34
35
|
<TextField
|
|
35
36
|
label="Label"
|
|
36
37
|
requiredText="*必須"
|
|
37
38
|
subLabel={
|
|
38
|
-
<Clickable
|
|
39
|
-
Text Link
|
|
40
|
-
</Clickable>
|
|
39
|
+
<Clickable onClick={action('label-click')}>Text Link</Clickable>
|
|
41
40
|
}
|
|
42
41
|
placeholder="Single Line"
|
|
43
|
-
onChange={action('change')}
|
|
44
42
|
{...(args as Partial<SingleLineTextFieldProps>)}
|
|
45
43
|
multiline={false}
|
|
46
44
|
/>
|
|
@@ -48,16 +46,13 @@ const Template: Story<Partial<TextFieldProps>> = (args) => (
|
|
|
48
46
|
label="Label"
|
|
49
47
|
requiredText="*必須"
|
|
50
48
|
subLabel={
|
|
51
|
-
<Clickable
|
|
52
|
-
Text Link
|
|
53
|
-
</Clickable>
|
|
49
|
+
<Clickable onClick={action('label-click')}>Text Link</Clickable>
|
|
54
50
|
}
|
|
55
51
|
placeholder="Multi Line"
|
|
56
|
-
onChange={action('change')}
|
|
57
52
|
{...(args as Partial<MultiLineTextFieldProps>)}
|
|
58
53
|
multiline
|
|
59
54
|
/>
|
|
60
|
-
</
|
|
55
|
+
</Container>
|
|
61
56
|
)
|
|
62
57
|
|
|
63
58
|
export const Default = Template.bind({})
|
|
@@ -91,3 +86,23 @@ export const AutoHeight: Story<Partial<MultiLineTextFieldProps>> = (args) => (
|
|
|
91
86
|
AutoHeight.args = {
|
|
92
87
|
autoHeight: true,
|
|
93
88
|
}
|
|
89
|
+
|
|
90
|
+
export const PrefixIcon: Story<Partial<SingleLineTextFieldProps>> = (args) => (
|
|
91
|
+
<TextField
|
|
92
|
+
label="Label"
|
|
93
|
+
placeholder="Icon prefix"
|
|
94
|
+
prefix={
|
|
95
|
+
<PrefixIconWrap>
|
|
96
|
+
<pixiv-icon name="16/Search" />
|
|
97
|
+
</PrefixIconWrap>
|
|
98
|
+
}
|
|
99
|
+
suffix={<IconButton variant="Overlay" icon={'16/Remove'} size="XS" />}
|
|
100
|
+
{...args}
|
|
101
|
+
/>
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
const PrefixIconWrap = styled.div`
|
|
105
|
+
color: ${({ theme }) => theme.color.text4};
|
|
106
|
+
margin-top: 2px;
|
|
107
|
+
margin-right: 4px;
|
|
108
|
+
`
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { useTextField } from '@react-aria/textfield'
|
|
2
2
|
import { useVisuallyHidden } from '@react-aria/visually-hidden'
|
|
3
|
-
import React, {
|
|
3
|
+
import React, {
|
|
4
|
+
ReactNode,
|
|
5
|
+
useCallback,
|
|
6
|
+
useEffect,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
} from 'react'
|
|
4
10
|
import styled, { css } from 'styled-components'
|
|
5
11
|
import FieldLabel, { FieldLabelProps } from '../FieldLabel'
|
|
6
|
-
import createTheme from '@charcoal-ui/styled'
|
|
12
|
+
import { createTheme } from '@charcoal-ui/styled'
|
|
7
13
|
|
|
8
14
|
const theme = createTheme(styled)
|
|
9
15
|
|
|
@@ -13,6 +19,9 @@ interface TextFieldBaseProps
|
|
|
13
19
|
readonly defaultValue?: string
|
|
14
20
|
readonly value?: string
|
|
15
21
|
readonly onChange?: (value: string) => void
|
|
22
|
+
readonly onKeyDown?: (event: React.KeyboardEvent<Element>) => void
|
|
23
|
+
readonly onFocus?: (event: React.FocusEvent<Element>) => void
|
|
24
|
+
readonly onBlur?: (event: React.FocusEvent<Element>) => void
|
|
16
25
|
readonly showCount?: boolean
|
|
17
26
|
readonly showLabel?: boolean
|
|
18
27
|
readonly placeholder?: string
|
|
@@ -32,8 +41,8 @@ export interface SingleLineTextFieldProps extends TextFieldBaseProps {
|
|
|
32
41
|
readonly multiline?: false
|
|
33
42
|
readonly rows?: never
|
|
34
43
|
readonly type?: string
|
|
35
|
-
readonly prefix?:
|
|
36
|
-
readonly suffix?:
|
|
44
|
+
readonly prefix?: ReactNode
|
|
45
|
+
readonly suffix?: ReactNode
|
|
37
46
|
}
|
|
38
47
|
|
|
39
48
|
export interface MultiLineTextFieldProps extends TextFieldBaseProps {
|
|
@@ -94,8 +103,8 @@ const SingleLineTextField = React.forwardRef<
|
|
|
94
103
|
invalid = false,
|
|
95
104
|
assistiveText,
|
|
96
105
|
maxLength,
|
|
97
|
-
prefix =
|
|
98
|
-
suffix =
|
|
106
|
+
prefix = null,
|
|
107
|
+
suffix = null,
|
|
99
108
|
} = props
|
|
100
109
|
|
|
101
110
|
const { visuallyHiddenProps } = useVisuallyHidden()
|
|
@@ -184,9 +193,9 @@ const SingleLineTextField = React.forwardRef<
|
|
|
184
193
|
/>
|
|
185
194
|
<SuffixContainer ref={suffixRef}>
|
|
186
195
|
<Affix>{suffix}</Affix>
|
|
187
|
-
{showCount &&
|
|
196
|
+
{showCount && (
|
|
188
197
|
<SingleLineCounter>
|
|
189
|
-
{count}
|
|
198
|
+
{maxLength !== undefined ? `${count}/${maxLength}` : count}
|
|
190
199
|
</SingleLineCounter>
|
|
191
200
|
)}
|
|
192
201
|
</SuffixContainer>
|
|
@@ -231,10 +240,8 @@ const MultiLineTextField = React.forwardRef<
|
|
|
231
240
|
|
|
232
241
|
const syncHeight = useCallback(
|
|
233
242
|
(textarea: HTMLTextAreaElement) => {
|
|
234
|
-
const rows = `${textarea.value}\n`.match(/\n/gu)?.length ?? 1
|
|
235
|
-
|
|
236
|
-
setRows(rows)
|
|
237
|
-
}
|
|
243
|
+
const rows = (`${textarea.value}\n`.match(/\n/gu)?.length ?? 0) || 1
|
|
244
|
+
setRows(initialRows <= rows ? rows : initialRows)
|
|
238
245
|
},
|
|
239
246
|
[initialRows]
|
|
240
247
|
)
|
|
@@ -290,16 +297,23 @@ const MultiLineTextField = React.forwardRef<
|
|
|
290
297
|
required={required}
|
|
291
298
|
subLabel={subLabel}
|
|
292
299
|
{...labelProps}
|
|
293
|
-
{...(showLabel ? visuallyHiddenProps : {})}
|
|
300
|
+
{...(!showLabel ? visuallyHiddenProps : {})}
|
|
294
301
|
/>
|
|
295
|
-
<StyledTextareaContainer
|
|
302
|
+
<StyledTextareaContainer
|
|
303
|
+
invalid={invalid}
|
|
304
|
+
rows={showCount ? rows + 1 : rows}
|
|
305
|
+
>
|
|
296
306
|
<StyledTextarea
|
|
297
307
|
ref={mergeRefs(textareaRef, forwardRef, ariaRef)}
|
|
298
|
-
invalid={invalid}
|
|
299
308
|
rows={rows}
|
|
309
|
+
noBottomPadding={showCount}
|
|
300
310
|
{...inputProps}
|
|
301
311
|
/>
|
|
302
|
-
{showCount &&
|
|
312
|
+
{showCount && (
|
|
313
|
+
<MultiLineCounter>
|
|
314
|
+
{maxLength !== undefined ? `${count}/${maxLength}` : count}
|
|
315
|
+
</MultiLineCounter>
|
|
316
|
+
)}
|
|
303
317
|
</StyledTextareaContainer>
|
|
304
318
|
{assistiveText != null && assistiveText.length !== 0 && (
|
|
305
319
|
<AssistiveText
|
|
@@ -370,8 +384,6 @@ const StyledInput = styled.input<{
|
|
|
370
384
|
height: calc(100% / 0.875);
|
|
371
385
|
font-size: calc(14px / 0.875);
|
|
372
386
|
line-height: calc(22px / 0.875);
|
|
373
|
-
padding-top: calc(9px / 0.875);
|
|
374
|
-
padding-bottom: calc(9px / 0.875);
|
|
375
387
|
padding-left: calc((8px + ${(p) => p.extraLeftPadding}px) / 0.875);
|
|
376
388
|
padding-right: calc((8px + ${(p) => p.extraRightPadding}px) / 0.875);
|
|
377
389
|
border-radius: calc(4px / 0.875);
|
|
@@ -392,21 +404,35 @@ const StyledInput = styled.input<{
|
|
|
392
404
|
}
|
|
393
405
|
`
|
|
394
406
|
|
|
395
|
-
const StyledTextareaContainer = styled.div<{ rows: number }>`
|
|
396
|
-
display: grid;
|
|
407
|
+
const StyledTextareaContainer = styled.div<{ rows: number; invalid: boolean }>`
|
|
397
408
|
position: relative;
|
|
409
|
+
overflow: hidden;
|
|
410
|
+
padding: 0 8px;
|
|
411
|
+
|
|
412
|
+
${(p) =>
|
|
413
|
+
theme((o) => [
|
|
414
|
+
o.bg.surface3.hover,
|
|
415
|
+
p.invalid && o.outline.assertive,
|
|
416
|
+
o.font.text2,
|
|
417
|
+
o.borderRadius(4),
|
|
418
|
+
])}
|
|
419
|
+
|
|
420
|
+
&:focus-within {
|
|
421
|
+
${(p) =>
|
|
422
|
+
theme((o) => (p.invalid ? o.outline.assertive : o.outline.default))}
|
|
423
|
+
}
|
|
398
424
|
|
|
399
425
|
${({ rows }) => css`
|
|
400
|
-
|
|
426
|
+
height: calc(22px * ${rows} + 18px);
|
|
401
427
|
`};
|
|
402
428
|
`
|
|
403
429
|
|
|
404
|
-
const StyledTextarea = styled.textarea<{
|
|
430
|
+
const StyledTextarea = styled.textarea<{ noBottomPadding: boolean }>`
|
|
405
431
|
border: none;
|
|
406
|
-
box-sizing: border-box;
|
|
407
432
|
outline: none;
|
|
408
433
|
resize: none;
|
|
409
434
|
font-family: inherit;
|
|
435
|
+
color: inherit;
|
|
410
436
|
|
|
411
437
|
/* Prevent zooming for iOS Safari */
|
|
412
438
|
transform-origin: top left;
|
|
@@ -414,23 +440,16 @@ const StyledTextarea = styled.textarea<{ invalid: boolean }>`
|
|
|
414
440
|
width: calc(100% / 0.875);
|
|
415
441
|
font-size: calc(14px / 0.875);
|
|
416
442
|
line-height: calc(22px / 0.875);
|
|
417
|
-
padding: calc(9px / 0.875)
|
|
418
|
-
border-radius: calc(4px / 0.875);
|
|
443
|
+
padding: calc(9px / 0.875) 0 ${(p) => (p.noBottomPadding ? 0 : '')};
|
|
419
444
|
|
|
420
|
-
${({ rows }) => css`
|
|
421
|
-
height: calc(22px / 0.875 * ${rows}
|
|
445
|
+
${({ rows = 1 }) => css`
|
|
446
|
+
height: calc(22px / 0.875 * ${rows});
|
|
422
447
|
`};
|
|
423
448
|
|
|
424
449
|
/* Display box-shadow for iOS Safari */
|
|
425
450
|
appearance: none;
|
|
426
451
|
|
|
427
|
-
|
|
428
|
-
theme((o) => [
|
|
429
|
-
o.bg.surface3.hover,
|
|
430
|
-
o.outline.default.focus,
|
|
431
|
-
p.invalid && o.outline.assertive,
|
|
432
|
-
o.font.text2,
|
|
433
|
-
])}
|
|
452
|
+
background: none;
|
|
434
453
|
|
|
435
454
|
&::placeholder {
|
|
436
455
|
${theme((o) => o.font.text3)}
|
|
@@ -63,6 +63,17 @@ beforeEach(() => {
|
|
|
63
63
|
return null
|
|
64
64
|
},
|
|
65
65
|
}))
|
|
66
|
+
|
|
67
|
+
global.matchMedia = jest.fn().mockImplementation(() => ({
|
|
68
|
+
matches: true,
|
|
69
|
+
media: '(max-width: 600px)',
|
|
70
|
+
addEventListener() {
|
|
71
|
+
// Do Nothing
|
|
72
|
+
},
|
|
73
|
+
removeEventListener() {
|
|
74
|
+
// Do Nothing
|
|
75
|
+
},
|
|
76
|
+
}))
|
|
66
77
|
})
|
|
67
78
|
|
|
68
79
|
describe.each(themes)('using %s theme', (_name, theme) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SSRProvider } from '@react-aria/ssr'
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ export {
|
|
|
3
3
|
useComponentAbstraction,
|
|
4
4
|
type LinkProps,
|
|
5
5
|
} from './core/ComponentAbstraction'
|
|
6
|
+
export { SSRProvider } from './core/SSRProvider'
|
|
6
7
|
export { default as Button, type ButtonProps } from './components/Button'
|
|
7
8
|
export {
|
|
8
9
|
default as Clickable,
|
|
@@ -20,14 +21,30 @@ export {
|
|
|
20
21
|
type RadioGroupProps,
|
|
21
22
|
} from './components/Radio'
|
|
22
23
|
export {
|
|
23
|
-
default as
|
|
24
|
-
type
|
|
25
|
-
|
|
26
|
-
type
|
|
27
|
-
} from './components/
|
|
24
|
+
default as MultiSelect,
|
|
25
|
+
type MultiSelectProps,
|
|
26
|
+
MultiSelectGroup,
|
|
27
|
+
type MultiSelectGroupProps,
|
|
28
|
+
} from './components/MultiSelect'
|
|
28
29
|
export { default as Switch, type SwitchProps } from './components/Switch'
|
|
29
30
|
export {
|
|
30
31
|
default as TextField,
|
|
31
32
|
type TextFieldProps,
|
|
33
|
+
type SingleLineTextFieldProps,
|
|
34
|
+
type MultiLineTextFieldProps,
|
|
32
35
|
} from './components/TextField'
|
|
33
36
|
export { default as Icon, type IconProps } from './components/Icon'
|
|
37
|
+
export { default as Modal, type ModalProps } from './components/Modal'
|
|
38
|
+
export {
|
|
39
|
+
default as LoadingSpinner,
|
|
40
|
+
LoadingSpinnerIcon,
|
|
41
|
+
} from './components/LoadingSpinner'
|
|
42
|
+
export {
|
|
43
|
+
default as DropdownSelector,
|
|
44
|
+
DropdownSelectorItem,
|
|
45
|
+
} from './components/DropdownSelector'
|
|
46
|
+
export {
|
|
47
|
+
default as SegmentedControl,
|
|
48
|
+
type SegmentedControlProps,
|
|
49
|
+
} from './components/SegmentedControl'
|
|
50
|
+
export { default as Checkbox } from './components/Checkbox'
|
package/src/styled.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/Select/context.ts"],"names":[],"mappings":"AAEA,aAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAA;CAC9E,CAAA;AAED,eAAO,MAAM,kBAAkB,6CAW7B,CAAA"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export declare type SelectProps = React.PropsWithChildren<{
|
|
3
|
-
value: string;
|
|
4
|
-
forceChecked?: boolean;
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
variant?: 'default' | 'overlay';
|
|
7
|
-
onChange?: (payload: {
|
|
8
|
-
value: string;
|
|
9
|
-
selected: boolean;
|
|
10
|
-
}) => void;
|
|
11
|
-
}>;
|
|
12
|
-
export default function Select({ value, forceChecked, disabled, onChange, variant, children, }: SelectProps): JSX.Element;
|
|
13
|
-
export declare type SelectGroupProps = React.PropsWithChildren<{
|
|
14
|
-
className?: string;
|
|
15
|
-
name: string;
|
|
16
|
-
ariaLabel: string;
|
|
17
|
-
selected: string[];
|
|
18
|
-
onChange: (selected: string[]) => void;
|
|
19
|
-
disabled?: boolean;
|
|
20
|
-
readonly?: boolean;
|
|
21
|
-
hasError?: boolean;
|
|
22
|
-
}>;
|
|
23
|
-
export declare function SelectGroup({ className, name, ariaLabel, selected, onChange, disabled, readonly, hasError, children, }: SelectGroupProps): JSX.Element;
|
|
24
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Select/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAA;AAQnE,oBAAY,WAAW,GAAG,KAAK,CAAC,iBAAiB,CAAC;IAChD,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;IAC/B,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAA;CACnE,CAAC,CAAA;AAEF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAC7B,KAAK,EACL,YAAoB,EACpB,QAAgB,EAChB,QAAQ,EACR,OAAmB,EACnB,QAAQ,GACT,EAAE,WAAW,eAsDb;AAyED,oBAAY,gBAAgB,GAAG,KAAK,CAAC,iBAAiB,CAAC;IACrD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAC,CAAA;AAEF,wBAAgB,WAAW,CAAC,EAC1B,SAAS,EACT,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,QAAgB,EAChB,QAAgB,EAChB,QAAgB,EAChB,QAAQ,GACT,EAAE,gBAAgB,eAsClB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/components/Select/index.story.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzC,OAAO,EAAe,OAAO,IAAI,MAAM,EAAE,MAAM,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElD,wBA8CC;AAED,aAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,OAAO,CAAA;IACjB,uBAAuB,EAAE,OAAO,CAAA;IAChC,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;CAChC,CAAA;AA8CD,eAAO,MAAM,OAAO;;CAAoB,CAAA;AAcxC,aAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;CAChC,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,eAAe,CAY7C,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/components/Select/index.test.tsx"],"names":[],"mappings":""}
|