expo-checkbox
Advanced tools
Comparing version 2.7.0 to 3.0.0
@@ -1,3 +0,3 @@ | ||
import { SyntheticEvent } from 'react'; | ||
import { ColorValue, NativeSyntheticEvent, ViewProps } from 'react-native'; | ||
import type { SyntheticEvent } from 'react'; | ||
import type { ColorValue, NativeSyntheticEvent, ViewProps } from 'react-native'; | ||
export type CheckboxEvent = { | ||
@@ -4,0 +4,0 @@ /** |
@@ -1,7 +0,3 @@ | ||
import React from 'react'; | ||
import { CheckboxProps } from './Checkbox.types'; | ||
export default class ExpoCheckbox extends React.PureComponent<CheckboxProps> { | ||
private handleChange; | ||
render(): JSX.Element; | ||
} | ||
import type { CheckboxProps } from './Checkbox.types'; | ||
export default function ExpoCheckbox({ color, disabled, onChange, onValueChange, style, value, ...other }: CheckboxProps): JSX.Element; | ||
//# sourceMappingURL=ExpoCheckbox.d.ts.map |
@@ -0,25 +1,23 @@ | ||
// Copyright © 2024 650 Industries. | ||
import React from 'react'; | ||
import { StyleSheet, Image, Pressable, Platform } from 'react-native'; | ||
const checkmarkBase64 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAYAAACAvzbMAAAACXBIWXMAFxGDABcRgwEFErJzAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAADY1JREFUeJzt3TuOrOtZhuGnFyKxnSMYgGWJKeBgyxFj2EhIZgxMAuQpIO0IOwXJ2hEQMAUSJEIExJDin4D12+vUq+vwvf93uq6wg9KjDvrWW9VVlQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAso7j+P3eGwCYzHEcPz2O49+O4/jj3lsAmMT7ePz38f/+U0QAeNMn8ThEBIA3vRIPEQHgdW/EQ0QA+NyN8RARAH7nzniICAAPx0NEAHb2ZDxEBGBH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React.PureComponent { | ||
handleChange = () => { | ||
this.props.onValueChange?.(!this.props.value); | ||
export default function ExpoCheckbox({ color, disabled, onChange, onValueChange, style, value, ...other }) { | ||
const handleChange = () => { | ||
onValueChange?.(!value); | ||
}; | ||
render() { | ||
const { color, disabled, onChange, onValueChange, style, value, ...other } = this.props; | ||
return (<Pressable {...other} disabled={disabled} | ||
// Announces "checked" status and "checkbox" as the focused element | ||
accessibilityRole="checkbox" accessibilityState={{ disabled, checked: value }} style={[ | ||
styles.root, | ||
style, | ||
value && styles.checked, | ||
!!color && { backgroundColor: value ? color : undefined, borderColor: color }, | ||
disabled && styles.disabled, | ||
value && disabled && styles.checkedAndDisabled, | ||
]} onPress={this.handleChange}> | ||
{value && (<Image source={{ | ||
uri: checkmarkBase64, | ||
}} style={StyleSheet.absoluteFill}/>)} | ||
</Pressable>); | ||
} | ||
return (<Pressable {...other} disabled={disabled} | ||
// Announces "checked" status and "checkbox" as the focused element | ||
accessibilityRole="checkbox" accessibilityState={{ disabled, checked: value }} style={[ | ||
styles.root, | ||
style, | ||
value && styles.checked, | ||
!!color && { backgroundColor: value ? color : undefined, borderColor: color }, | ||
disabled && styles.disabled, | ||
value && disabled && styles.checkedAndDisabled, | ||
]} onPress={handleChange}> | ||
{value && (<Image source={{ | ||
uri: checkmarkBase64, | ||
}} style={StyleSheet.absoluteFill}/>)} | ||
</Pressable>); | ||
} | ||
@@ -26,0 +24,0 @@ const defaultEnabledColor = Platform.select({ |
/** | ||
* Copyright © 2024 650 Industries. | ||
* Copyright (c) Nicolas Gallagher. | ||
@@ -11,8 +12,12 @@ * Copyright (c) Facebook, Inc. and its affiliates. | ||
import React from 'react'; | ||
import { CheckboxProps } from './Checkbox.types'; | ||
export default class ExpoCheckbox extends React.PureComponent<CheckboxProps> { | ||
private handleChange; | ||
render(): JSX.Element; | ||
} | ||
import type { CheckboxEvent } from './Checkbox.types'; | ||
declare const ExpoCheckbox: React.ForwardRefExoticComponent<import("react-native").ViewProps & { | ||
value?: boolean | undefined; | ||
disabled?: boolean | undefined; | ||
color?: import("react-native").ColorValue | undefined; | ||
onChange?: ((event: import("react-native").NativeSyntheticEvent<CheckboxEvent> | React.SyntheticEvent<HTMLInputElement, CheckboxEvent>) => void) | undefined; | ||
onValueChange?: ((value: boolean) => void) | undefined; | ||
} & React.RefAttributes<unknown>>; | ||
export default ExpoCheckbox; | ||
export declare const name = "ExpoCheckbox"; | ||
//# sourceMappingURL=ExpoCheckbox.web.d.ts.map |
/** | ||
* Copyright © 2024 650 Industries. | ||
* Copyright (c) Nicolas Gallagher. | ||
@@ -11,36 +12,33 @@ * Copyright (c) Facebook, Inc. and its affiliates. | ||
import React from 'react'; | ||
// @ts-ignore | ||
import { StyleSheet, View, unstable_createElement as createElement } from 'react-native'; | ||
export default class ExpoCheckbox extends React.PureComponent { | ||
handleChange = (event) => { | ||
import { StyleSheet, View, unstable_createElement as createElement } from 'react-native-web'; | ||
const ExpoCheckbox = React.forwardRef(({ color, disabled, onChange, onValueChange, style, value, ...other }, ref) => { | ||
const handleChange = (event) => { | ||
const value = event.nativeEvent.target.checked; | ||
event.nativeEvent.value = value; | ||
this.props.onChange?.(event); | ||
this.props.onValueChange?.(value); | ||
onChange?.(event); | ||
onValueChange?.(value); | ||
}; | ||
render() { | ||
const { color, disabled, onChange, onValueChange, style, value, ...other } = this.props; | ||
const fakeControl = (<View style={[ | ||
styles.fakeControl, | ||
value && styles.fakeControlChecked, | ||
// custom color | ||
!!color && { backgroundColor: value ? color : undefined, borderColor: color }, | ||
disabled && styles.fakeControlDisabled, | ||
value && disabled && styles.fakeControlCheckedAndDisabled, | ||
]}/>); | ||
const nativeControl = createElement('input', { | ||
accessibilityChecked: value, | ||
accessibilityDisabled: disabled, | ||
checked: value, | ||
disabled, | ||
onChange: this.handleChange, | ||
style: [styles.nativeControl, styles.cursorInherit], | ||
type: 'checkbox', | ||
}); | ||
return (<View {...other} style={[styles.root, style, disabled && styles.cursorDefault]}> | ||
const fakeControl = (<View style={[ | ||
styles.fakeControl, | ||
value && styles.fakeControlChecked, | ||
// custom color | ||
!!color && { backgroundColor: value ? color : undefined, borderColor: color }, | ||
disabled && styles.fakeControlDisabled, | ||
value && disabled && styles.fakeControlCheckedAndDisabled, | ||
]}/>); | ||
const nativeControl = createElement('input', { | ||
'aria-checked': value, | ||
'aria-disabled': disabled, | ||
checked: value, | ||
disabled, | ||
onChange: handleChange, | ||
style: [styles.nativeControl, styles.cursorInherit], | ||
type: 'checkbox', | ||
}); | ||
return (<View ref={ref} {...other} style={[styles.root, style, disabled && styles.cursorDefault]}> | ||
{nativeControl} | ||
{fakeControl} | ||
</View>); | ||
} | ||
} | ||
}); | ||
export default ExpoCheckbox; | ||
const styles = StyleSheet.create({ | ||
@@ -47,0 +45,0 @@ root: { |
@@ -13,2 +13,12 @@ # Changelog | ||
## 3.0.0 — 2024-04-18 | ||
### 🎉 New features | ||
- Mark React client components with "use client" directives. ([#27300](https://github.com/expo/expo/pull/27300) by [@EvanBacon](https://github.com/EvanBacon)) | ||
### 💡 Others | ||
- Convert to function components and remove "use client" directives. ([#27438](https://github.com/expo/expo/pull/27438) by [@EvanBacon](https://github.com/EvanBacon)) | ||
## 2.7.0 — 2023-11-14 | ||
@@ -15,0 +25,0 @@ |
{ | ||
"name": "expo-checkbox", | ||
"version": "2.7.0", | ||
"version": "3.0.0", | ||
"description": "Basic checkbox for iOS, Android, and web", | ||
@@ -41,3 +41,3 @@ "main": "build/Checkbox.js", | ||
}, | ||
"gitHead": "3142a086578deffd8704a8f1b6f0f661527d836c" | ||
"gitHead": "4165b8d72e1b9a1889c2767534cc619e21468110" | ||
} |
@@ -1,3 +0,3 @@ | ||
import { SyntheticEvent } from 'react'; | ||
import { ColorValue, NativeSyntheticEvent, ViewProps } from 'react-native'; | ||
import type { SyntheticEvent } from 'react'; | ||
import type { ColorValue, NativeSyntheticEvent, ViewProps } from 'react-native'; | ||
@@ -4,0 +4,0 @@ export type CheckboxEvent = { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48012
497