Repository navigation
Expand file tree
/
Copy pathCheckbox.macos.tsx
More file actions
53 lines (49 loc) · 1.65 KB
/
Copy pathCheckbox.macos.tsx
File metadata and controls
53 lines (49 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
* @format
*/
/** @jsxImportSource @fluentui-react-native/framework-base */
import type { CheckboxTokens, CheckboxProps, CheckboxState } from '@fluentui-react-native/checkbox';
import { checkboxName } from '@fluentui-react-native/checkbox';
import type { UseSlots } from '@fluentui-react-native/framework';
import { compose, buildProps } from '@fluentui-react-native/framework';
import { mergeProps } from '@fluentui-react-native/framework-base';
import NativeCheckboxView from './MacOSCheckboxNativeComponent';
import type { NativeProps } from './MacOSCheckboxNativeComponent';
interface CheckboxSlotPropsMacOS {
root: React.PropsWithRef<NativeProps>;
}
interface CheckboxTypeMacOS {
props: CheckboxProps;
tokens: CheckboxTokens;
slotProps: CheckboxSlotPropsMacOS;
state: CheckboxState;
}
export const Checkbox = compose<CheckboxTypeMacOS>({
displayName: checkboxName,
tokens: [checkboxName],
slots: { root: NativeCheckboxView },
slotProps: {
root: buildProps<CheckboxProps, CheckboxTokens>(() => ({
style: {
minHeight: 20,
minWidth: '100%',
},
})),
},
useRender: (props: CheckboxProps, useSlots: UseSlots<CheckboxTypeMacOS>) => {
const { onChange, ...restOfUserProps } = props;
const onPress = (e: any) => {
if (onChange != null) {
onChange(e, e.nativeEvent.isChecked);
}
};
const rootProps = { ...restOfUserProps };
const Root = useSlots(props).root;
return (rest: CheckboxProps) => {
return <Root {...mergeProps(rootProps, rest)} onPress={onPress} />;
};
},
});
export default Checkbox;