@instructure/ui-radio-input 11.6.0 → 11.6.1-snapshot-129
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/CHANGELOG.md +45 -299
- package/es/RadioInput/{index.js → v1/index.js} +1 -1
- package/es/RadioInput/v2/index.js +189 -0
- package/{src/index.ts → es/RadioInput/v2/props.js} +2 -4
- package/es/RadioInput/v2/styles.js +268 -0
- package/es/RadioInputGroup/{index.js → v1/index.js} +3 -3
- package/es/RadioInputGroup/v2/index.js +146 -0
- package/es/RadioInputGroup/v2/props.js +26 -0
- package/es/{index.js → exports/a.js} +2 -2
- package/es/exports/b.js +25 -0
- package/lib/RadioInput/{index.js → v1/index.js} +1 -1
- package/lib/RadioInput/v2/index.js +195 -0
- package/lib/RadioInput/v2/props.js +31 -0
- package/lib/RadioInput/v2/styles.js +274 -0
- package/lib/RadioInputGroup/{index.js → v1/index.js} +6 -6
- package/lib/RadioInputGroup/v2/index.js +154 -0
- package/lib/RadioInputGroup/v2/props.js +31 -0
- package/lib/{index.js → exports/a.js} +4 -4
- package/lib/exports/b.js +19 -0
- package/package.json +40 -18
- package/src/RadioInput/{index.tsx → v1/index.tsx} +1 -1
- package/src/RadioInput/v2/README.md +110 -0
- package/src/RadioInput/v2/index.tsx +223 -0
- package/src/RadioInput/v2/props.ts +126 -0
- package/src/RadioInput/v2/styles.ts +304 -0
- package/src/RadioInputGroup/{index.tsx → v1/index.tsx} +4 -4
- package/src/RadioInputGroup/{props.ts → v1/props.ts} +1 -1
- package/src/RadioInputGroup/{styles.ts → v1/styles.ts} +3 -1
- package/src/RadioInputGroup/v2/README.md +241 -0
- package/src/RadioInputGroup/v2/index.tsx +178 -0
- package/src/RadioInputGroup/v2/props.ts +122 -0
- package/src/exports/a.ts +28 -0
- package/src/exports/b.ts +28 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/RadioInput/v1/index.d.ts.map +1 -0
- package/types/RadioInput/v1/props.d.ts.map +1 -0
- package/types/RadioInput/v1/styles.d.ts.map +1 -0
- package/types/RadioInput/v1/theme.d.ts.map +1 -0
- package/types/RadioInput/v2/index.d.ts +64 -0
- package/types/RadioInput/v2/index.d.ts.map +1 -0
- package/types/RadioInput/v2/props.d.ts +77 -0
- package/types/RadioInput/v2/props.d.ts.map +1 -0
- package/types/RadioInput/v2/styles.d.ts +24 -0
- package/types/RadioInput/v2/styles.d.ts.map +1 -0
- package/types/RadioInputGroup/{index.d.ts → v1/index.d.ts} +3 -3
- package/types/RadioInputGroup/v1/index.d.ts.map +1 -0
- package/types/RadioInputGroup/{props.d.ts → v1/props.d.ts} +1 -1
- package/types/RadioInputGroup/v1/props.d.ts.map +1 -0
- package/types/RadioInputGroup/v1/styles.d.ts.map +1 -0
- package/types/RadioInputGroup/v1/theme.d.ts.map +1 -0
- package/types/RadioInputGroup/v2/index.d.ts +47 -0
- package/types/RadioInputGroup/v2/index.d.ts.map +1 -0
- package/types/RadioInputGroup/v2/props.d.ts +63 -0
- package/types/RadioInputGroup/v2/props.d.ts.map +1 -0
- package/types/exports/a.d.ts +5 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +5 -0
- package/types/exports/b.d.ts.map +1 -0
- package/types/RadioInput/index.d.ts.map +0 -1
- package/types/RadioInput/props.d.ts.map +0 -1
- package/types/RadioInput/styles.d.ts.map +0 -1
- package/types/RadioInput/theme.d.ts.map +0 -1
- package/types/RadioInputGroup/index.d.ts.map +0 -1
- package/types/RadioInputGroup/props.d.ts.map +0 -1
- package/types/RadioInputGroup/styles.d.ts.map +0 -1
- package/types/RadioInputGroup/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -5
- package/types/index.d.ts.map +0 -1
- /package/es/RadioInput/{props.js → v1/props.js} +0 -0
- /package/es/RadioInput/{styles.js → v1/styles.js} +0 -0
- /package/es/RadioInput/{theme.js → v1/theme.js} +0 -0
- /package/es/RadioInputGroup/{props.js → v1/props.js} +0 -0
- /package/es/RadioInputGroup/{styles.js → v1/styles.js} +0 -0
- /package/es/RadioInputGroup/{theme.js → v1/theme.js} +0 -0
- /package/lib/RadioInput/{props.js → v1/props.js} +0 -0
- /package/lib/RadioInput/{styles.js → v1/styles.js} +0 -0
- /package/lib/RadioInput/{theme.js → v1/theme.js} +0 -0
- /package/lib/RadioInputGroup/{props.js → v1/props.js} +0 -0
- /package/lib/RadioInputGroup/{styles.js → v1/styles.js} +0 -0
- /package/lib/RadioInputGroup/{theme.js → v1/theme.js} +0 -0
- /package/src/RadioInput/{README.md → v1/README.md} +0 -0
- /package/src/RadioInput/{props.ts → v1/props.ts} +0 -0
- /package/src/RadioInput/{styles.ts → v1/styles.ts} +0 -0
- /package/src/RadioInput/{theme.ts → v1/theme.ts} +0 -0
- /package/src/RadioInputGroup/{README.md → v1/README.md} +0 -0
- /package/src/RadioInputGroup/{theme.ts → v1/theme.ts} +0 -0
- /package/types/RadioInput/{index.d.ts → v1/index.d.ts} +0 -0
- /package/types/RadioInput/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/RadioInput/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/RadioInput/{theme.d.ts → v1/theme.d.ts} +0 -0
- /package/types/RadioInputGroup/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/RadioInputGroup/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import React from 'react'
|
|
26
|
+
import type { InputHTMLAttributes } from 'react'
|
|
27
|
+
import type { OtherHTMLAttributes } from '@instructure/shared-types'
|
|
28
|
+
import type { ComponentStyle, ThemeOverrideValue } from '@instructure/emotion'
|
|
29
|
+
import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
|
|
30
|
+
|
|
31
|
+
type RadioInputOwnProps = {
|
|
32
|
+
/**
|
|
33
|
+
* The label displayed next to the checkbox
|
|
34
|
+
*/
|
|
35
|
+
label: React.ReactNode
|
|
36
|
+
/**
|
|
37
|
+
* This maps to the low level HTML attribute
|
|
38
|
+
* [with the same name](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio#value)
|
|
39
|
+
*/
|
|
40
|
+
value?: string | number
|
|
41
|
+
/**
|
|
42
|
+
* The id of the input element. If not provided, a unique id will be generated.
|
|
43
|
+
*/
|
|
44
|
+
id?: string
|
|
45
|
+
/**
|
|
46
|
+
* The [name](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio#defining_a_radio_group)
|
|
47
|
+
* defines which group it belongs to, it's managed by the `RadioInputGroup`
|
|
48
|
+
* this component belongs to.
|
|
49
|
+
*
|
|
50
|
+
* Do not set it manually.
|
|
51
|
+
*/
|
|
52
|
+
name?: string
|
|
53
|
+
/**
|
|
54
|
+
* Sets the `checked` prop of the underlying input element. If left undefined,
|
|
55
|
+
* the component will control its own state.
|
|
56
|
+
*/
|
|
57
|
+
checked?: boolean
|
|
58
|
+
/**
|
|
59
|
+
* Whether to disable the input
|
|
60
|
+
*/
|
|
61
|
+
disabled?: boolean
|
|
62
|
+
/**
|
|
63
|
+
* Works just like disabled but keeps the same styles as if it were active
|
|
64
|
+
*/
|
|
65
|
+
readOnly?: boolean
|
|
66
|
+
/**
|
|
67
|
+
* The visual style of the radio button
|
|
68
|
+
*/
|
|
69
|
+
variant?: 'simple' | 'toggle'
|
|
70
|
+
size?: 'small' | 'medium' | 'large'
|
|
71
|
+
/**
|
|
72
|
+
* Sets the background color of the radio button when `variant="toggle"`
|
|
73
|
+
*/
|
|
74
|
+
context?: 'success' | 'warning' | 'danger' | 'off'
|
|
75
|
+
/**
|
|
76
|
+
* Sets the `display:inline-flex` in CSS
|
|
77
|
+
*/
|
|
78
|
+
inline?: boolean
|
|
79
|
+
onClick?: (event: React.MouseEvent<HTMLInputElement>) => void
|
|
80
|
+
/**
|
|
81
|
+
* Callback fired when the input fires a change event.
|
|
82
|
+
* event.target.value will contain the new value. It will always be a string.
|
|
83
|
+
*/
|
|
84
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void
|
|
85
|
+
/**
|
|
86
|
+
* A function that provides a reference to the actual underlying input element
|
|
87
|
+
*/
|
|
88
|
+
inputRef?: (inputElement: HTMLInputElement | null) => void
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
type PropKeys = keyof RadioInputOwnProps
|
|
92
|
+
|
|
93
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
94
|
+
|
|
95
|
+
type RadioInputProps = RadioInputOwnProps & {
|
|
96
|
+
themeOverride?: ThemeOverrideValue
|
|
97
|
+
} & OtherHTMLAttributes<
|
|
98
|
+
RadioInputOwnProps,
|
|
99
|
+
InputHTMLAttributes<RadioInputOwnProps & Element>
|
|
100
|
+
> &
|
|
101
|
+
WithDeterministicIdProps
|
|
102
|
+
|
|
103
|
+
type RadioInputStyle = ComponentStyle<'radioInput' | 'input' | 'label'>
|
|
104
|
+
|
|
105
|
+
type RadioInputState = {
|
|
106
|
+
checked?: boolean
|
|
107
|
+
}
|
|
108
|
+
const allowedProps: AllowedPropKeys = [
|
|
109
|
+
'label',
|
|
110
|
+
'value',
|
|
111
|
+
'id',
|
|
112
|
+
'name',
|
|
113
|
+
'checked',
|
|
114
|
+
'disabled',
|
|
115
|
+
'readOnly',
|
|
116
|
+
'variant',
|
|
117
|
+
'size',
|
|
118
|
+
'context',
|
|
119
|
+
'inline',
|
|
120
|
+
'onClick',
|
|
121
|
+
'onChange',
|
|
122
|
+
'inputRef'
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
export type { RadioInputProps, RadioInputState, RadioInputStyle }
|
|
126
|
+
export { allowedProps }
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import type { RadioInputProps, RadioInputStyle } from './props'
|
|
26
|
+
import type { NewComponentTypes, SharedTokens } from '@instructure/ui-themes'
|
|
27
|
+
import { boxShadowObjectsToCSSString } from '@instructure/ui-themes'
|
|
28
|
+
import { calcFocusOutlineStyles } from '@instructure/emotion'
|
|
29
|
+
|
|
30
|
+
type StyleParams = {
|
|
31
|
+
disabled: RadioInputProps['disabled']
|
|
32
|
+
context: RadioInputProps['context']
|
|
33
|
+
inline: RadioInputProps['inline']
|
|
34
|
+
hovered: boolean
|
|
35
|
+
readOnly: RadioInputProps['readOnly']
|
|
36
|
+
size: RadioInputProps['size']
|
|
37
|
+
variant: RadioInputProps['variant']
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* ---
|
|
42
|
+
* private: true
|
|
43
|
+
* ---
|
|
44
|
+
* Generates the style object from the theme and provided additional information
|
|
45
|
+
* @param componentTheme The theme variable object.
|
|
46
|
+
* @param params Additional parameters to customize the style.
|
|
47
|
+
* @param sharedTokens Shared token object that stores common values for the theme.
|
|
48
|
+
* @return The final style object, which will be used in the component
|
|
49
|
+
*/
|
|
50
|
+
const generateStyle = (
|
|
51
|
+
componentTheme: NewComponentTypes['RadioInput'],
|
|
52
|
+
params: StyleParams,
|
|
53
|
+
sharedTokens: SharedTokens
|
|
54
|
+
): RadioInputStyle => {
|
|
55
|
+
const { disabled, inline, hovered, size, readOnly, variant, context } = params
|
|
56
|
+
|
|
57
|
+
// 4*2 states: base, hover, disabled, readonly X none/selected
|
|
58
|
+
const insetSizes = {
|
|
59
|
+
small: componentTheme.checkedInsetSm,
|
|
60
|
+
medium: componentTheme.checkedInsetMd,
|
|
61
|
+
large: componentTheme.checkedInsetLg
|
|
62
|
+
}
|
|
63
|
+
const labelColors = {
|
|
64
|
+
// the states here are mutually exclusive
|
|
65
|
+
color: componentTheme.labelBaseColor,
|
|
66
|
+
...(hovered && {
|
|
67
|
+
color: componentTheme.labelHoverColor
|
|
68
|
+
}),
|
|
69
|
+
...(readOnly && {
|
|
70
|
+
color: componentTheme.labelReadonlyColor
|
|
71
|
+
}),
|
|
72
|
+
...(disabled && {
|
|
73
|
+
color: componentTheme.labelDisabledColor
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const getInputColors = () => {
|
|
78
|
+
if (disabled) {
|
|
79
|
+
return {
|
|
80
|
+
background: componentTheme.backgroundDisabledColor,
|
|
81
|
+
borderColor: componentTheme.borderDisabledColor,
|
|
82
|
+
checkedBoxShadow: `inset 0 0 0 ${insetSizes[size!]} ${
|
|
83
|
+
componentTheme.borderDisabledColor
|
|
84
|
+
}`
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (readOnly) {
|
|
88
|
+
return {
|
|
89
|
+
background: componentTheme.backgroundReadonlyColor,
|
|
90
|
+
borderColor: componentTheme.borderReadonlyColor,
|
|
91
|
+
checkedBoxShadow: `inset 0 0 0 ${insetSizes[size!]} ${
|
|
92
|
+
componentTheme.borderSelectedColor
|
|
93
|
+
}`
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (hovered) {
|
|
97
|
+
return {
|
|
98
|
+
background: componentTheme.backgroundHoverColor,
|
|
99
|
+
borderColor: componentTheme.borderHoverColor,
|
|
100
|
+
checkedBoxShadow: `inset 0 0 0 ${insetSizes[size!]} ${
|
|
101
|
+
componentTheme.borderSelectedColor
|
|
102
|
+
}`
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
background: componentTheme.backgroundColor,
|
|
107
|
+
borderColor: componentTheme.borderColor,
|
|
108
|
+
checkedBoxShadow: `inset 0 0 0 ${insetSizes[size!]} ${
|
|
109
|
+
componentTheme.borderSelectedColor
|
|
110
|
+
}`
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const inputColors = getInputColors()
|
|
115
|
+
|
|
116
|
+
const toggleContextBackgrounds: Record<
|
|
117
|
+
NonNullable<RadioInputProps['context']>,
|
|
118
|
+
string
|
|
119
|
+
> = {
|
|
120
|
+
success: componentTheme.toggleBackgroundSuccess,
|
|
121
|
+
warning: componentTheme.toggleBackgroundWarning,
|
|
122
|
+
danger: componentTheme.toggleBackgroundDanger,
|
|
123
|
+
off: componentTheme.toggleBackgroundOff
|
|
124
|
+
}
|
|
125
|
+
const toggleBackground =
|
|
126
|
+
toggleContextBackgrounds[context ?? 'success'] ??
|
|
127
|
+
toggleContextBackgrounds['success']
|
|
128
|
+
|
|
129
|
+
const focusOutline = calcFocusOutlineStyles(sharedTokens.focusOutline)
|
|
130
|
+
focusOutline.transition += ', box-shadow 0.2s'
|
|
131
|
+
|
|
132
|
+
const inputVariants = {
|
|
133
|
+
simple: {
|
|
134
|
+
base: {
|
|
135
|
+
all: 'initial',
|
|
136
|
+
boxSizing: 'border-box',
|
|
137
|
+
appearance: 'none',
|
|
138
|
+
display: 'block',
|
|
139
|
+
position: 'relative',
|
|
140
|
+
marginInlineEnd: componentTheme.gap,
|
|
141
|
+
marginInlineStart: '0',
|
|
142
|
+
flexShrink: 0,
|
|
143
|
+
minWidth: '1rem',
|
|
144
|
+
borderRadius: '100%',
|
|
145
|
+
borderWidth: componentTheme.borderWidth,
|
|
146
|
+
borderStyle: 'solid',
|
|
147
|
+
background: inputColors.background,
|
|
148
|
+
borderColor: inputColors.borderColor,
|
|
149
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
150
|
+
'&:checked': {
|
|
151
|
+
borderColor: disabled
|
|
152
|
+
? componentTheme.borderDisabledColor
|
|
153
|
+
: componentTheme.borderSelectedColor,
|
|
154
|
+
boxShadow: inputColors.checkedBoxShadow
|
|
155
|
+
},
|
|
156
|
+
marginTop: componentTheme.controlVerticalMargin,
|
|
157
|
+
marginBottom: componentTheme.controlVerticalMargin,
|
|
158
|
+
...focusOutline
|
|
159
|
+
},
|
|
160
|
+
small: {
|
|
161
|
+
width: componentTheme.controlSizeSm,
|
|
162
|
+
height: componentTheme.controlSizeSm
|
|
163
|
+
},
|
|
164
|
+
medium: {
|
|
165
|
+
width: componentTheme.controlSizeMd,
|
|
166
|
+
height: componentTheme.controlSizeMd
|
|
167
|
+
},
|
|
168
|
+
large: {
|
|
169
|
+
width: componentTheme.controlSizeLg,
|
|
170
|
+
height: componentTheme.controlSizeLg
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
toggle: {
|
|
174
|
+
base: {
|
|
175
|
+
all: 'initial',
|
|
176
|
+
boxSizing: 'border-box',
|
|
177
|
+
// Visually hidden but accessible (screen reader, focus, keyboard)
|
|
178
|
+
position: 'absolute',
|
|
179
|
+
opacity: 0.0001 /* selenium cannot find fully transparent elements */,
|
|
180
|
+
width: '1px',
|
|
181
|
+
height: '1px',
|
|
182
|
+
overflow: 'hidden',
|
|
183
|
+
margin: 0,
|
|
184
|
+
padding: 0
|
|
185
|
+
},
|
|
186
|
+
small: {},
|
|
187
|
+
medium: {},
|
|
188
|
+
large: {}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const labelVariants = {
|
|
193
|
+
simple: {
|
|
194
|
+
base: {},
|
|
195
|
+
small: {
|
|
196
|
+
fontSize: componentTheme.fontSizeSm,
|
|
197
|
+
lineHeight: componentTheme.lineHeightSm
|
|
198
|
+
},
|
|
199
|
+
medium: {
|
|
200
|
+
fontSize: componentTheme.fontSizeMd,
|
|
201
|
+
lineHeight: componentTheme.lineHeightMd
|
|
202
|
+
},
|
|
203
|
+
large: {
|
|
204
|
+
fontSize: componentTheme.fontSizeLg,
|
|
205
|
+
lineHeight: componentTheme.lineHeightLg
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
toggle: {
|
|
209
|
+
base: {
|
|
210
|
+
flex: '0 0 auto',
|
|
211
|
+
position: 'relative',
|
|
212
|
+
zIndex: 1,
|
|
213
|
+
textTransform: 'uppercase',
|
|
214
|
+
overflow: 'hidden',
|
|
215
|
+
whiteSpace: 'nowrap',
|
|
216
|
+
textOverflow: 'ellipsis',
|
|
217
|
+
lineHeight: 1,
|
|
218
|
+
display: 'flex',
|
|
219
|
+
alignItems: 'center',
|
|
220
|
+
justifyContent: 'center',
|
|
221
|
+
minWidth: '0.0625rem',
|
|
222
|
+
borderRadius: componentTheme.toggleBorderRadius,
|
|
223
|
+
color: disabled
|
|
224
|
+
? componentTheme.labelDisabledColor
|
|
225
|
+
: componentTheme.labelBaseColor,
|
|
226
|
+
background: 'transparent',
|
|
227
|
+
'input:checked + &': {
|
|
228
|
+
color: componentTheme.toggleHandleText,
|
|
229
|
+
background: toggleBackground,
|
|
230
|
+
boxShadow: disabled
|
|
231
|
+
? 'none'
|
|
232
|
+
: boxShadowObjectsToCSSString(componentTheme.toggleShadow)
|
|
233
|
+
},
|
|
234
|
+
...calcFocusOutlineStyles(sharedTokens.focusOutline, {
|
|
235
|
+
customCSSSelector: 'input:focus + &&'
|
|
236
|
+
}),
|
|
237
|
+
'input:focus + &': {
|
|
238
|
+
textDecoration: 'underline'
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
small: {
|
|
242
|
+
fontSize: componentTheme.toggleSmallFontSize,
|
|
243
|
+
height: componentTheme.toggleSmallHeight,
|
|
244
|
+
padding: '0 0.5rem',
|
|
245
|
+
svg: {
|
|
246
|
+
fontSize: `calc(${componentTheme.toggleSmallFontSize} + 0.375rem)`
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
medium: {
|
|
250
|
+
fontSize: componentTheme.toggleMediumFontSize,
|
|
251
|
+
height: componentTheme.toggleMediumHeight,
|
|
252
|
+
padding: '0 0.875rem',
|
|
253
|
+
svg: {
|
|
254
|
+
fontSize: `calc(${componentTheme.toggleMediumFontSize} + 0.375rem)`
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
large: {
|
|
258
|
+
fontSize: componentTheme.toggleLargeFontSize,
|
|
259
|
+
height: componentTheme.toggleLargeHeight,
|
|
260
|
+
padding: '0 1rem',
|
|
261
|
+
svg: {
|
|
262
|
+
fontSize: `calc(${componentTheme.toggleLargeFontSize} + 0.375rem)`
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return {
|
|
269
|
+
radioInput: {
|
|
270
|
+
label: 'radioInput',
|
|
271
|
+
position: 'relative',
|
|
272
|
+
display: 'flex',
|
|
273
|
+
alignItems: 'flex-start',
|
|
274
|
+
width: inline ? 'auto' : '100%',
|
|
275
|
+
...(inline && {
|
|
276
|
+
display: 'inline-flex',
|
|
277
|
+
verticalAlign: 'middle'
|
|
278
|
+
}),
|
|
279
|
+
|
|
280
|
+
'&:hover': {
|
|
281
|
+
cursor: 'default',
|
|
282
|
+
...(disabled && { cursor: 'not-allowed' })
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
input: {
|
|
286
|
+
label: 'radioInput__input',
|
|
287
|
+
...inputVariants[variant!].base,
|
|
288
|
+
...inputVariants[variant!][size!]
|
|
289
|
+
},
|
|
290
|
+
label: {
|
|
291
|
+
label: 'radioInput__label',
|
|
292
|
+
flex: '1 1 auto',
|
|
293
|
+
alignSelf: 'center',
|
|
294
|
+
...labelColors,
|
|
295
|
+
fontFamily: componentTheme.fontFamily,
|
|
296
|
+
fontWeight: componentTheme.fontWeight,
|
|
297
|
+
...labelVariants[variant!].base,
|
|
298
|
+
...labelVariants[variant!][size!],
|
|
299
|
+
cursor: disabled ? 'not-allowed' : 'pointer'
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export default generateStyle
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
import { ComponentElement, Fragment, Children, Component } from 'react'
|
|
26
26
|
|
|
27
|
-
import { FormFieldGroup } from '@instructure/ui-form-field'
|
|
27
|
+
import { FormFieldGroup } from '@instructure/ui-form-field/v11_6'
|
|
28
28
|
import {
|
|
29
29
|
matchComponentTypes,
|
|
30
30
|
safeCloneElement,
|
|
@@ -34,10 +34,10 @@ import {
|
|
|
34
34
|
} from '@instructure/ui-react-utils'
|
|
35
35
|
import { hasVisibleChildren } from '@instructure/ui-a11y-utils'
|
|
36
36
|
|
|
37
|
-
import { RadioInput } from '
|
|
38
|
-
import type { RadioInputProps } from '
|
|
37
|
+
import { RadioInput } from '../../RadioInput/v1'
|
|
38
|
+
import type { RadioInputProps } from '../../RadioInput/v1/props'
|
|
39
39
|
|
|
40
|
-
import { withStyle } from '@instructure/emotion'
|
|
40
|
+
import { withStyleLegacy as withStyle } from '@instructure/emotion'
|
|
41
41
|
|
|
42
42
|
import generateStyle from './styles'
|
|
43
43
|
import generateComponentTheme from './theme'
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
import React from 'react'
|
|
26
26
|
|
|
27
27
|
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
28
|
-
import type { FormMessage } from '@instructure/ui-form-field'
|
|
28
|
+
import type { FormMessage } from '@instructure/ui-form-field/v11_6'
|
|
29
29
|
import type {
|
|
30
30
|
OtherHTMLAttributes,
|
|
31
31
|
RadioInputGroupTheme
|
|
@@ -33,7 +33,9 @@ import type { RadioInputGroupStyle } from './props'
|
|
|
33
33
|
* @param {Object} componentTheme The theme variable object.
|
|
34
34
|
* @return {Object} The final style object, which will be used in the component
|
|
35
35
|
*/
|
|
36
|
-
const generateStyle = (
|
|
36
|
+
const generateStyle = (
|
|
37
|
+
componentTheme: RadioInputGroupTheme
|
|
38
|
+
): RadioInputGroupStyle => {
|
|
37
39
|
const { invalidAsteriskColor } = componentTheme
|
|
38
40
|
|
|
39
41
|
return {
|