@audira/carbon-react-native 1.0.0-beta.13 → 1.0.0-beta.15
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/lib/commonjs/components/checkbox/Checkbox.js +4 -4
- package/lib/commonjs/components/checkbox/Checkbox.js.map +1 -1
- package/lib/commonjs/components/checkbox/index.js.map +1 -1
- package/lib/commonjs/components/checkbox-group/index.js.map +1 -1
- package/lib/commonjs/components/checkbox-input/CheckboxInput.js +20 -20
- package/lib/commonjs/components/checkbox-input/CheckboxInput.js.map +1 -1
- package/lib/commonjs/components/checkbox-input/CheckboxInputState.js +2 -0
- package/lib/commonjs/components/checkbox-input/{CheckboxInputValue.js.map → CheckboxInputState.js.map} +1 -1
- package/lib/commonjs/components/checkbox-input/index.js +4 -4
- package/lib/commonjs/components/checkbox-input/index.js.map +1 -1
- package/lib/commonjs/components/notification/_variants/actionable/ActionableVariant.js +0 -1
- package/lib/commonjs/components/notification/_variants/actionable/ActionableVariant.js.map +1 -1
- package/lib/commonjs/components/notification/_variants/callout/CalloutVariant.js +0 -1
- package/lib/commonjs/components/notification/_variants/callout/CalloutVariant.js.map +1 -1
- package/lib/module/components/checkbox/Checkbox.js +4 -4
- package/lib/module/components/checkbox/Checkbox.js.map +1 -1
- package/lib/module/components/checkbox/index.js.map +1 -1
- package/lib/module/components/checkbox-group/index.js.map +1 -1
- package/lib/module/components/checkbox-input/CheckboxInput.js +20 -20
- package/lib/module/components/checkbox-input/CheckboxInput.js.map +1 -1
- package/lib/module/components/checkbox-input/CheckboxInputState.js +2 -0
- package/lib/module/components/checkbox-input/{CheckboxInputValue.js.map → CheckboxInputState.js.map} +1 -1
- package/lib/module/components/checkbox-input/index.js +1 -1
- package/lib/module/components/checkbox-input/index.js.map +1 -1
- package/lib/module/components/notification/_variants/actionable/ActionableVariant.js +0 -1
- package/lib/module/components/notification/_variants/actionable/ActionableVariant.js.map +1 -1
- package/lib/module/components/notification/_variants/callout/CalloutVariant.js +0 -1
- package/lib/module/components/notification/_variants/callout/CalloutVariant.js.map +1 -1
- package/lib/typescript/commonjs/components/checkbox/CheckboxProps.d.ts +3 -3
- package/lib/typescript/commonjs/components/checkbox/CheckboxProps.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/checkbox/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/checkbox-group/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/checkbox-input/CheckboxInputProps.d.ts +5 -5
- package/lib/typescript/commonjs/components/checkbox-input/CheckboxInputProps.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/checkbox-input/CheckboxInputState.d.ts +5 -0
- package/lib/typescript/commonjs/components/checkbox-input/CheckboxInputState.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/checkbox-input/_RefBase.d.ts +3 -3
- package/lib/typescript/commonjs/components/checkbox-input/index.d.ts +1 -1
- package/lib/typescript/commonjs/components/checkbox-input/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/notification/_variants/actionable/ActionableVariant.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/notification/_variants/callout/CalloutVariant.d.ts.map +1 -1
- package/lib/typescript/module/components/checkbox/CheckboxProps.d.ts +3 -3
- package/lib/typescript/module/components/checkbox/CheckboxProps.d.ts.map +1 -1
- package/lib/typescript/module/components/checkbox/index.d.ts.map +1 -1
- package/lib/typescript/module/components/checkbox-group/index.d.ts.map +1 -1
- package/lib/typescript/module/components/checkbox-input/CheckboxInputProps.d.ts +5 -5
- package/lib/typescript/module/components/checkbox-input/CheckboxInputProps.d.ts.map +1 -1
- package/lib/typescript/module/components/checkbox-input/CheckboxInputState.d.ts +5 -0
- package/lib/typescript/module/components/checkbox-input/CheckboxInputState.d.ts.map +1 -0
- package/lib/typescript/module/components/checkbox-input/_RefBase.d.ts +3 -3
- package/lib/typescript/module/components/checkbox-input/index.d.ts +1 -1
- package/lib/typescript/module/components/checkbox-input/index.d.ts.map +1 -1
- package/lib/typescript/module/components/notification/_variants/actionable/ActionableVariant.d.ts.map +1 -1
- package/lib/typescript/module/components/notification/_variants/callout/CalloutVariant.d.ts.map +1 -1
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/checkbox/Checkbox.tsx +4 -4
- package/src/components/checkbox/CheckboxProps.ts +4 -5
- package/src/components/checkbox-input/CheckboxInput.tsx +27 -27
- package/src/components/checkbox-input/CheckboxInputProps.ts +7 -5
- package/src/components/checkbox-input/{CheckboxInputValue.ts → CheckboxInputState.ts} +1 -1
- package/src/components/checkbox-input/_RefBase.ts +4 -4
- package/src/components/checkbox-input/{index.tsx → index.ts} +1 -1
- package/src/components/notification/_variants/actionable/ActionableVariant.tsx +0 -1
- package/src/components/notification/_variants/callout/CalloutVariant.tsx +0 -1
- package/lib/commonjs/components/checkbox-input/CheckboxInputValue.js +0 -2
- package/lib/module/components/checkbox-input/CheckboxInputValue.js +0 -2
- package/lib/typescript/commonjs/components/checkbox-input/CheckboxInputValue.d.ts +0 -5
- package/lib/typescript/commonjs/components/checkbox-input/CheckboxInputValue.d.ts.map +0 -1
- package/lib/typescript/module/components/checkbox-input/CheckboxInputValue.d.ts +0 -5
- package/lib/typescript/module/components/checkbox-input/CheckboxInputValue.d.ts.map +0 -1
- /package/src/components/checkbox/{index.tsx → index.ts} +0 -0
- /package/src/components/checkbox-group/{index.tsx → index.ts} +0 -0
package/package.json
CHANGED
|
@@ -61,8 +61,8 @@ import type {
|
|
|
61
61
|
export const Checkbox = forwardRef<CheckboxRef, CheckboxProps>(
|
|
62
62
|
function Checkbox(
|
|
63
63
|
{
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
defaultChecked,
|
|
65
|
+
checked,
|
|
66
66
|
interactiveState = "normal",
|
|
67
67
|
label,
|
|
68
68
|
role = "checkbox",
|
|
@@ -150,8 +150,8 @@ export const Checkbox = forwardRef<CheckboxRef, CheckboxProps>(
|
|
|
150
150
|
<CheckboxInput
|
|
151
151
|
{ ...checkboxInputProps }
|
|
152
152
|
role="none"
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
defaultChecked={ defaultChecked }
|
|
154
|
+
checked={ checked }
|
|
155
155
|
interactiveState={ interactiveState }
|
|
156
156
|
onChange={ onChange }
|
|
157
157
|
onPress={ onPress }
|
|
@@ -12,17 +12,16 @@ import type {
|
|
|
12
12
|
} from "../form-label"
|
|
13
13
|
|
|
14
14
|
export interface CheckboxProps extends Omit<ViewProps, "children"> {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
defaultChecked?: CheckboxInputProps["defaultChecked"],
|
|
16
|
+
checked?: CheckboxInputProps["checked"],
|
|
17
17
|
interactiveState?: CheckboxInputProps["interactiveState"],
|
|
18
18
|
label: string,
|
|
19
19
|
onChange?: CheckboxInputProps["onChange"],
|
|
20
20
|
onPress?: CheckboxInputProps["onPress"],
|
|
21
21
|
checkboxInputProps?: Omit<
|
|
22
22
|
CheckboxInputProps,
|
|
23
|
-
| "
|
|
24
|
-
| "
|
|
25
|
-
| "indeterminate"
|
|
23
|
+
| "defaultChecked"
|
|
24
|
+
| "checked"
|
|
26
25
|
| "interactiveState"
|
|
27
26
|
| "role"
|
|
28
27
|
| "onChange"
|
|
@@ -49,8 +49,8 @@ import type {
|
|
|
49
49
|
} from "./CheckboxInputRef"
|
|
50
50
|
|
|
51
51
|
import type {
|
|
52
|
-
|
|
53
|
-
} from "./
|
|
52
|
+
CheckboxInputState,
|
|
53
|
+
} from "./CheckboxInputState"
|
|
54
54
|
|
|
55
55
|
import type {
|
|
56
56
|
RefBase,
|
|
@@ -59,8 +59,8 @@ import type {
|
|
|
59
59
|
export const CheckboxInput = forwardRef<CheckboxInputRef, CheckboxInputProps>(
|
|
60
60
|
function CheckboxInput(
|
|
61
61
|
{
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
defaultChecked,
|
|
63
|
+
checked: checkedProp,
|
|
64
64
|
interactiveState = "normal",
|
|
65
65
|
style,
|
|
66
66
|
role = "checkbox",
|
|
@@ -83,32 +83,32 @@ export const CheckboxInput = forwardRef<CheckboxInputRef, CheckboxInputProps>(
|
|
|
83
83
|
ref =
|
|
84
84
|
useRef({
|
|
85
85
|
onChangeEffect: false,
|
|
86
|
-
value: typeof
|
|
87
|
-
?
|
|
88
|
-
: typeof
|
|
89
|
-
?
|
|
86
|
+
value: typeof checkedProp == "boolean" || typeof checkedProp == "object"
|
|
87
|
+
? checkedProp
|
|
88
|
+
: typeof defaultChecked == "boolean" || typeof defaultChecked == "object"
|
|
89
|
+
? defaultChecked
|
|
90
90
|
: false,
|
|
91
91
|
}),
|
|
92
92
|
|
|
93
93
|
[isFocused, setIsFocused] =
|
|
94
94
|
useState(false),
|
|
95
95
|
|
|
96
|
-
[
|
|
96
|
+
[checkedSelf, setCheckedSelf] =
|
|
97
97
|
useState(() => {
|
|
98
|
-
if(typeof
|
|
99
|
-
return
|
|
98
|
+
if(typeof defaultChecked == "boolean" || typeof defaultChecked == "object") {
|
|
99
|
+
return defaultChecked
|
|
100
100
|
}
|
|
101
101
|
return false
|
|
102
102
|
}),
|
|
103
103
|
|
|
104
104
|
controlled =
|
|
105
|
-
typeof
|
|
105
|
+
typeof checkedProp !== "undefined",
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
controlled ?
|
|
107
|
+
checked =
|
|
108
|
+
controlled ? checkedProp : checkedSelf,
|
|
109
109
|
|
|
110
110
|
indeterminate =
|
|
111
|
-
|
|
111
|
+
checked === null,
|
|
112
112
|
|
|
113
113
|
blurHandler: NonNullable<PressableProps["onBlur"]> =
|
|
114
114
|
useCallback(event => {
|
|
@@ -132,7 +132,7 @@ export const CheckboxInput = forwardRef<CheckboxInputRef, CheckboxInputProps>(
|
|
|
132
132
|
if(interactiveState !== "read_only") {
|
|
133
133
|
if(!controlled) {
|
|
134
134
|
ref.current.onChangeEffect = true
|
|
135
|
-
|
|
135
|
+
setCheckedSelf(self => self === null ? true : !self)
|
|
136
136
|
} else {
|
|
137
137
|
onChange?.(ref.current.value === null ? true : !ref.current.value)
|
|
138
138
|
}
|
|
@@ -148,13 +148,13 @@ export const CheckboxInput = forwardRef<CheckboxInputRef, CheckboxInputProps>(
|
|
|
148
148
|
mapIconColor[interactiveState][themeContext.colorScheme]
|
|
149
149
|
|
|
150
150
|
useEffect(() => {
|
|
151
|
-
ref.current.value =
|
|
151
|
+
ref.current.value = checked
|
|
152
152
|
if(ref.current.onChangeEffect) {
|
|
153
153
|
ref.current.onChangeEffect = false
|
|
154
|
-
onChange?.(
|
|
154
|
+
onChange?.(checked)
|
|
155
155
|
}
|
|
156
156
|
}, [
|
|
157
|
-
|
|
157
|
+
checked,
|
|
158
158
|
onChange,
|
|
159
159
|
])
|
|
160
160
|
|
|
@@ -163,12 +163,12 @@ export const CheckboxInput = forwardRef<CheckboxInputRef, CheckboxInputProps>(
|
|
|
163
163
|
viewRef.current as View,
|
|
164
164
|
{
|
|
165
165
|
get value() {
|
|
166
|
-
return
|
|
166
|
+
return checked
|
|
167
167
|
},
|
|
168
168
|
setValue(value_) {
|
|
169
169
|
if(!controlled && interactiveState !== "read_only") {
|
|
170
170
|
ref.current.onChangeEffect = true
|
|
171
|
-
|
|
171
|
+
setCheckedSelf(self => {
|
|
172
172
|
if(typeof value_ === "function") {
|
|
173
173
|
ref.current.value = value_(self)
|
|
174
174
|
} else {
|
|
@@ -181,7 +181,7 @@ export const CheckboxInput = forwardRef<CheckboxInputRef, CheckboxInputProps>(
|
|
|
181
181
|
},
|
|
182
182
|
)
|
|
183
183
|
}, [
|
|
184
|
-
|
|
184
|
+
checked,
|
|
185
185
|
controlled,
|
|
186
186
|
interactiveState,
|
|
187
187
|
])
|
|
@@ -199,7 +199,7 @@ export const CheckboxInput = forwardRef<CheckboxInputRef, CheckboxInputProps>(
|
|
|
199
199
|
FlexStyleSheet.justify_center,
|
|
200
200
|
CommonStyleSheet.relative,
|
|
201
201
|
baseStyle.checkbox,
|
|
202
|
-
getInteractiveStateStyle(interactiveState,
|
|
202
|
+
getInteractiveStateStyle(interactiveState, checked),
|
|
203
203
|
style,
|
|
204
204
|
] }
|
|
205
205
|
ref={ viewRef }
|
|
@@ -215,7 +215,7 @@ export const CheckboxInput = forwardRef<CheckboxInputRef, CheckboxInputProps>(
|
|
|
215
215
|
] }
|
|
216
216
|
/>
|
|
217
217
|
|
|
218
|
-
{
|
|
218
|
+
{ indeterminate ? (
|
|
219
219
|
<IconSubtract
|
|
220
220
|
width={ iconSize }
|
|
221
221
|
height={ iconSize }
|
|
@@ -226,7 +226,7 @@ export const CheckboxInput = forwardRef<CheckboxInputRef, CheckboxInputProps>(
|
|
|
226
226
|
width={ iconSize }
|
|
227
227
|
height={ iconSize }
|
|
228
228
|
fill={ iconColor }
|
|
229
|
-
style={ !
|
|
229
|
+
style={ !checked ? baseStyle.checkmarkHidden : null }
|
|
230
230
|
/>
|
|
231
231
|
) }
|
|
232
232
|
</Pressable>
|
|
@@ -334,7 +334,7 @@ const
|
|
|
334
334
|
|
|
335
335
|
function getInteractiveStateStyle(
|
|
336
336
|
interactiveState: CheckboxInputInteractiveState,
|
|
337
|
-
value:
|
|
337
|
+
value: CheckboxInputState,
|
|
338
338
|
) {
|
|
339
|
-
return interactiveStyle[`${interactiveState}_${
|
|
339
|
+
return interactiveStyle[`${interactiveState}_${typeof value == "object" ? true : value}`]
|
|
340
340
|
}
|
|
@@ -8,18 +8,20 @@ import type {
|
|
|
8
8
|
} from "./CheckboxInputInteractiveState"
|
|
9
9
|
|
|
10
10
|
import type {
|
|
11
|
-
|
|
12
|
-
} from "./
|
|
11
|
+
CheckboxInputState,
|
|
12
|
+
} from "./CheckboxInputState"
|
|
13
13
|
|
|
14
14
|
export interface CheckboxInputProps extends Omit<
|
|
15
15
|
PressableProps,
|
|
16
|
+
| "defaultValue"
|
|
17
|
+
| "value"
|
|
16
18
|
| "children"
|
|
17
19
|
| "disabled"
|
|
18
20
|
| "style"
|
|
19
21
|
> {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
defaultChecked?: CheckboxInputState,
|
|
23
|
+
checked?: CheckboxInputState,
|
|
22
24
|
interactiveState?: CheckboxInputInteractiveState,
|
|
23
|
-
onChange?: (value:
|
|
25
|
+
onChange?: (value: CheckboxInputState) => void,
|
|
24
26
|
style?: ViewProps["style"],
|
|
25
27
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
} from "./
|
|
2
|
+
CheckboxInputState,
|
|
3
|
+
} from "./CheckboxInputState"
|
|
4
4
|
|
|
5
5
|
export interface RefBase {
|
|
6
|
-
readonly value:
|
|
6
|
+
readonly value: CheckboxInputState,
|
|
7
7
|
/**
|
|
8
8
|
* This method does nothing when `controlled` prop is true
|
|
9
9
|
*/
|
|
10
|
-
setValue: (value:
|
|
10
|
+
setValue: (value: CheckboxInputState | ((value: CheckboxInputState) => CheckboxInputState)) => void,
|
|
11
11
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxInputValue.d.ts","sourceRoot":"","sources":["../../../../../src/components/checkbox-input/CheckboxInputValue.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC3B,OAAO,GACP,IAAI,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxInputValue.d.ts","sourceRoot":"","sources":["../../../../../src/components/checkbox-input/CheckboxInputValue.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC3B,OAAO,GACP,IAAI,CAAA"}
|
|
File without changes
|
|
File without changes
|