@cdx-ui/primitives 0.0.1-alpha.2 → 0.0.1-alpha.21
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/avatar/context.js +11 -0
- package/lib/commonjs/avatar/context.js.map +1 -0
- package/lib/commonjs/avatar/createAvatarBadge.js +20 -0
- package/lib/commonjs/avatar/createAvatarBadge.js.map +1 -0
- package/lib/commonjs/avatar/createAvatarIcon.js +30 -0
- package/lib/commonjs/avatar/createAvatarIcon.js.map +1 -0
- package/lib/commonjs/avatar/createAvatarImage.js +51 -0
- package/lib/commonjs/avatar/createAvatarImage.js.map +1 -0
- package/lib/commonjs/avatar/createAvatarRoot.js +34 -0
- package/lib/commonjs/avatar/createAvatarRoot.js.map +1 -0
- package/lib/commonjs/avatar/createAvatarText.js +42 -0
- package/lib/commonjs/avatar/createAvatarText.js.map +1 -0
- package/lib/commonjs/avatar/index.js +30 -0
- package/lib/commonjs/avatar/index.js.map +1 -0
- package/lib/commonjs/avatar/types.js +6 -0
- package/lib/commonjs/avatar/types.js.map +1 -0
- package/lib/commonjs/button/createButtonRoot.js +3 -3
- package/lib/commonjs/button/createButtonRoot.js.map +1 -1
- package/lib/commonjs/button/index.js +18 -19
- package/lib/commonjs/button/index.js.map +1 -1
- package/lib/commonjs/checkbox/context.js +14 -0
- package/lib/commonjs/checkbox/context.js.map +1 -0
- package/lib/commonjs/checkbox/createCheckboxGroup.js +44 -0
- package/lib/commonjs/checkbox/createCheckboxGroup.js.map +1 -0
- package/lib/commonjs/checkbox/createCheckboxIcon.js +29 -0
- package/lib/commonjs/checkbox/createCheckboxIcon.js.map +1 -0
- package/lib/commonjs/checkbox/createCheckboxIndicator.js +47 -0
- package/lib/commonjs/checkbox/createCheckboxIndicator.js.map +1 -0
- package/lib/commonjs/checkbox/createCheckboxLabel.js +46 -0
- package/lib/commonjs/checkbox/createCheckboxLabel.js.map +1 -0
- package/lib/commonjs/checkbox/createCheckboxRoot.js +99 -0
- package/lib/commonjs/checkbox/createCheckboxRoot.js.map +1 -0
- package/lib/commonjs/checkbox/createCheckboxRoot.web.js +90 -0
- package/lib/commonjs/checkbox/createCheckboxRoot.web.js.map +1 -0
- package/lib/commonjs/checkbox/index.js +30 -0
- package/lib/commonjs/checkbox/index.js.map +1 -0
- package/lib/commonjs/checkbox/types.js +6 -0
- package/lib/commonjs/checkbox/types.js.map +1 -0
- package/lib/commonjs/checkbox/useCheckboxRoot.js +82 -0
- package/lib/commonjs/checkbox/useCheckboxRoot.js.map +1 -0
- package/lib/commonjs/index.js +49 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/input/index.js +13 -19
- package/lib/commonjs/input/index.js.map +1 -1
- package/lib/commonjs/link/LinkProvider.js +28 -0
- package/lib/commonjs/link/LinkProvider.js.map +1 -0
- package/lib/commonjs/link/createLink.js +74 -0
- package/lib/commonjs/link/createLink.js.map +1 -0
- package/lib/commonjs/link/index.js +27 -0
- package/lib/commonjs/link/index.js.map +1 -0
- package/lib/commonjs/link/types.js +6 -0
- package/lib/commonjs/link/types.js.map +1 -0
- package/lib/commonjs/link/useLink.js +56 -0
- package/lib/commonjs/link/useLink.js.map +1 -0
- package/lib/commonjs/overlay/OverlayContainer.js +6 -4
- package/lib/commonjs/overlay/OverlayContainer.js.map +1 -1
- package/lib/commonjs/select/context.js +8 -43
- package/lib/commonjs/select/context.js.map +1 -1
- package/lib/commonjs/select/createSelectItem.js +1 -1
- package/lib/commonjs/select/createSelectItem.js.map +1 -1
- package/lib/commonjs/select/createSelectRoot.js +1 -1
- package/lib/commonjs/select/createSelectRoot.js.map +1 -1
- package/lib/commonjs/select/createSelectTrigger.js +2 -8
- package/lib/commonjs/select/createSelectTrigger.js.map +1 -1
- package/lib/commonjs/switch/createSwitchRoot.js +73 -0
- package/lib/commonjs/switch/createSwitchRoot.js.map +1 -0
- package/lib/commonjs/switch/index.js +15 -0
- package/lib/commonjs/switch/index.js.map +1 -0
- package/lib/commonjs/switch/types.js +6 -0
- package/lib/commonjs/switch/types.js.map +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/utils/dataAttributes.web.js +1 -4
- package/lib/commonjs/utils/dataAttributes.web.js.map +1 -1
- package/lib/module/avatar/context.js +5 -0
- package/lib/module/avatar/context.js.map +1 -0
- package/lib/module/{input/createInputIcon.js → avatar/createAvatarBadge.js} +3 -3
- package/lib/module/avatar/createAvatarBadge.js.map +1 -0
- package/lib/module/avatar/createAvatarIcon.js +25 -0
- package/lib/module/avatar/createAvatarIcon.js.map +1 -0
- package/lib/module/avatar/createAvatarImage.js +46 -0
- package/lib/module/avatar/createAvatarImage.js.map +1 -0
- package/lib/module/avatar/createAvatarRoot.js +29 -0
- package/lib/module/avatar/createAvatarRoot.js.map +1 -0
- package/lib/module/avatar/createAvatarText.js +37 -0
- package/lib/module/avatar/createAvatarText.js.map +1 -0
- package/lib/module/avatar/index.js +26 -0
- package/lib/module/avatar/index.js.map +1 -0
- package/lib/module/avatar/types.js +4 -0
- package/lib/module/avatar/types.js.map +1 -0
- package/lib/module/button/createButtonRoot.js +3 -3
- package/lib/module/button/createButtonRoot.js.map +1 -1
- package/lib/module/button/index.js +18 -19
- package/lib/module/button/index.js.map +1 -1
- package/lib/module/checkbox/context.js +7 -0
- package/lib/module/checkbox/context.js.map +1 -0
- package/lib/module/checkbox/createCheckboxGroup.js +39 -0
- package/lib/module/checkbox/createCheckboxGroup.js.map +1 -0
- package/lib/module/checkbox/createCheckboxIcon.js +24 -0
- package/lib/module/checkbox/createCheckboxIcon.js.map +1 -0
- package/lib/module/checkbox/createCheckboxIndicator.js +42 -0
- package/lib/module/checkbox/createCheckboxIndicator.js.map +1 -0
- package/lib/module/checkbox/createCheckboxLabel.js +41 -0
- package/lib/module/checkbox/createCheckboxLabel.js.map +1 -0
- package/lib/module/checkbox/createCheckboxRoot.js +94 -0
- package/lib/module/checkbox/createCheckboxRoot.js.map +1 -0
- package/lib/module/checkbox/createCheckboxRoot.web.js +85 -0
- package/lib/module/checkbox/createCheckboxRoot.web.js.map +1 -0
- package/lib/module/checkbox/index.js +26 -0
- package/lib/module/checkbox/index.js.map +1 -0
- package/lib/module/checkbox/types.js +4 -0
- package/lib/module/checkbox/types.js.map +1 -0
- package/lib/module/checkbox/useCheckboxRoot.js +78 -0
- package/lib/module/checkbox/useCheckboxRoot.js.map +1 -0
- package/lib/module/index.js +5 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/input/index.js +12 -17
- package/lib/module/input/index.js.map +1 -1
- package/lib/module/link/LinkProvider.js +23 -0
- package/lib/module/link/LinkProvider.js.map +1 -0
- package/lib/module/link/createLink.js +68 -0
- package/lib/module/link/createLink.js.map +1 -0
- package/lib/module/link/index.js +6 -0
- package/lib/module/link/index.js.map +1 -0
- package/lib/module/link/types.js +4 -0
- package/lib/module/link/types.js.map +1 -0
- package/lib/module/link/useLink.js +52 -0
- package/lib/module/link/useLink.js.map +1 -0
- package/lib/module/overlay/OverlayContainer.js +7 -5
- package/lib/module/overlay/OverlayContainer.js.map +1 -1
- package/lib/module/select/context.js +4 -42
- package/lib/module/select/context.js.map +1 -1
- package/lib/module/select/createSelectItem.js +2 -2
- package/lib/module/select/createSelectItem.js.map +1 -1
- package/lib/module/select/createSelectRoot.js +2 -2
- package/lib/module/select/createSelectRoot.js.map +1 -1
- package/lib/module/select/createSelectTrigger.js +3 -9
- package/lib/module/select/createSelectTrigger.js.map +1 -1
- package/lib/module/switch/createSwitchRoot.js +67 -0
- package/lib/module/switch/createSwitchRoot.js.map +1 -0
- package/lib/module/switch/index.js +11 -0
- package/lib/module/switch/index.js.map +1 -0
- package/lib/module/switch/types.js +4 -0
- package/lib/module/switch/types.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils/dataAttributes.web.js +1 -4
- package/lib/module/utils/dataAttributes.web.js.map +1 -1
- package/lib/typescript/avatar/context.d.ts +6 -0
- package/lib/typescript/avatar/context.d.ts.map +1 -0
- package/lib/typescript/avatar/createAvatarBadge.d.ts +4 -0
- package/lib/typescript/avatar/createAvatarBadge.d.ts.map +1 -0
- package/lib/typescript/avatar/createAvatarIcon.d.ts +4 -0
- package/lib/typescript/avatar/createAvatarIcon.d.ts.map +1 -0
- package/lib/typescript/avatar/createAvatarImage.d.ts +4 -0
- package/lib/typescript/avatar/createAvatarImage.d.ts.map +1 -0
- package/lib/typescript/avatar/createAvatarRoot.d.ts +4 -0
- package/lib/typescript/avatar/createAvatarRoot.d.ts.map +1 -0
- package/lib/typescript/avatar/createAvatarText.d.ts +4 -0
- package/lib/typescript/avatar/createAvatarText.d.ts.map +1 -0
- package/lib/typescript/avatar/index.d.ts +11 -0
- package/lib/typescript/avatar/index.d.ts.map +1 -0
- package/lib/typescript/avatar/types.d.ts +33 -0
- package/lib/typescript/avatar/types.d.ts.map +1 -0
- package/lib/typescript/button/context.d.ts +1 -1
- package/lib/typescript/button/context.d.ts.map +1 -1
- package/lib/typescript/button/createButtonRoot.d.ts +1 -1
- package/lib/typescript/button/createButtonRoot.d.ts.map +1 -1
- package/lib/typescript/button/index.d.ts +1 -1
- package/lib/typescript/button/index.d.ts.map +1 -1
- package/lib/typescript/button/types.d.ts +0 -7
- package/lib/typescript/button/types.d.ts.map +1 -1
- package/lib/typescript/checkbox/context.d.ts +18 -0
- package/lib/typescript/checkbox/context.d.ts.map +1 -0
- package/lib/typescript/checkbox/createCheckboxGroup.d.ts +3 -0
- package/lib/typescript/checkbox/createCheckboxGroup.d.ts.map +1 -0
- package/lib/typescript/checkbox/createCheckboxIcon.d.ts +3 -0
- package/lib/typescript/checkbox/createCheckboxIcon.d.ts.map +1 -0
- package/lib/typescript/checkbox/createCheckboxIndicator.d.ts +5 -0
- package/lib/typescript/checkbox/createCheckboxIndicator.d.ts.map +1 -0
- package/lib/typescript/checkbox/createCheckboxLabel.d.ts +5 -0
- package/lib/typescript/checkbox/createCheckboxLabel.d.ts.map +1 -0
- package/lib/typescript/checkbox/createCheckboxRoot.d.ts +2 -0
- package/lib/typescript/checkbox/createCheckboxRoot.d.ts.map +1 -0
- package/lib/typescript/checkbox/createCheckboxRoot.web.d.ts +2 -0
- package/lib/typescript/checkbox/createCheckboxRoot.web.d.ts.map +1 -0
- package/lib/typescript/checkbox/index.d.ts +11 -0
- package/lib/typescript/checkbox/index.d.ts.map +1 -0
- package/lib/typescript/checkbox/types.d.ts +57 -0
- package/lib/typescript/checkbox/types.d.ts.map +1 -0
- package/lib/typescript/checkbox/useCheckboxRoot.d.ts +147 -0
- package/lib/typescript/checkbox/useCheckboxRoot.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +6 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/input/index.d.ts +3 -3
- package/lib/typescript/input/index.d.ts.map +1 -1
- package/lib/typescript/input/types.d.ts +1 -2
- package/lib/typescript/input/types.d.ts.map +1 -1
- package/lib/typescript/link/LinkProvider.d.ts +36 -0
- package/lib/typescript/link/LinkProvider.d.ts.map +1 -0
- package/lib/typescript/link/createLink.d.ts +6 -0
- package/lib/typescript/link/createLink.d.ts.map +1 -0
- package/lib/typescript/link/index.d.ts +6 -0
- package/lib/typescript/link/index.d.ts.map +1 -0
- package/lib/typescript/link/types.d.ts +45 -0
- package/lib/typescript/link/types.d.ts.map +1 -0
- package/lib/typescript/link/useLink.d.ts +9 -0
- package/lib/typescript/link/useLink.d.ts.map +1 -0
- package/lib/typescript/overlay/OverlayContainer.d.ts +5 -1
- package/lib/typescript/overlay/OverlayContainer.d.ts.map +1 -1
- package/lib/typescript/select/context.d.ts +14 -7
- package/lib/typescript/select/context.d.ts.map +1 -1
- package/lib/typescript/select/createSelectTrigger.d.ts +2 -7
- package/lib/typescript/select/createSelectTrigger.d.ts.map +1 -1
- package/lib/typescript/select/types.d.ts +1 -7
- package/lib/typescript/select/types.d.ts.map +1 -1
- package/lib/typescript/switch/createSwitchRoot.d.ts +3 -0
- package/lib/typescript/switch/createSwitchRoot.d.ts.map +1 -0
- package/lib/typescript/switch/index.d.ts +7 -0
- package/lib/typescript/switch/index.d.ts.map +1 -0
- package/lib/typescript/switch/types.d.ts +38 -0
- package/lib/typescript/switch/types.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +8 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/lib/typescript/utils/dataAttributes.web.d.ts.map +1 -1
- package/package.json +12 -8
- package/src/avatar/context.tsx +5 -0
- package/src/avatar/createAvatarBadge.tsx +12 -0
- package/src/avatar/createAvatarIcon.tsx +16 -0
- package/src/avatar/createAvatarImage.tsx +40 -0
- package/src/avatar/createAvatarRoot.tsx +23 -0
- package/src/avatar/createAvatarText.tsx +30 -0
- package/src/avatar/index.ts +43 -0
- package/src/avatar/types.ts +77 -0
- package/src/button/context.tsx +1 -1
- package/src/button/createButtonRoot.tsx +5 -4
- package/src/button/index.tsx +18 -19
- package/src/button/types.ts +0 -8
- package/src/checkbox/context.tsx +18 -0
- package/src/checkbox/createCheckboxGroup.tsx +32 -0
- package/src/checkbox/createCheckboxIcon.tsx +18 -0
- package/src/checkbox/createCheckboxIndicator.tsx +43 -0
- package/src/checkbox/createCheckboxLabel.tsx +42 -0
- package/src/checkbox/createCheckboxRoot.tsx +100 -0
- package/src/checkbox/createCheckboxRoot.web.tsx +79 -0
- package/src/checkbox/index.ts +43 -0
- package/src/checkbox/types.ts +74 -0
- package/src/checkbox/useCheckboxRoot.ts +85 -0
- package/src/index.ts +6 -1
- package/src/input/index.tsx +15 -28
- package/src/input/types.ts +0 -4
- package/src/link/LinkProvider.tsx +50 -0
- package/src/link/createLink.tsx +71 -0
- package/src/link/index.tsx +5 -0
- package/src/link/types.ts +47 -0
- package/src/link/useLink.ts +54 -0
- package/src/overlay/OverlayContainer.tsx +7 -8
- package/src/select/context.tsx +9 -44
- package/src/select/createSelectItem.tsx +3 -3
- package/src/select/createSelectRoot.tsx +3 -3
- package/src/select/createSelectTrigger.tsx +6 -31
- package/src/select/types.ts +1 -10
- package/src/switch/createSwitchRoot.tsx +72 -0
- package/src/switch/index.ts +16 -0
- package/src/switch/types.ts +42 -0
- package/src/types.ts +7 -0
- package/src/utils/dataAttributes.web.ts +2 -4
- package/lib/commonjs/input/createInputIcon.js +0 -20
- package/lib/commonjs/input/createInputIcon.js.map +0 -1
- package/lib/module/input/createInputIcon.js.map +0 -1
- package/lib/typescript/input/createInputIcon.d.ts +0 -4
- package/lib/typescript/input/createInputIcon.d.ts.map +0 -1
- package/src/input/createInputIcon.tsx +0 -12
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import type { IAvatarBadgeProps } from './types';
|
|
4
|
+
|
|
5
|
+
export const createAvatarBadge = <T,>(BaseBadge: React.ComponentType<T>) =>
|
|
6
|
+
forwardRef<unknown, IAvatarBadgeProps>(({ children, ...props }, ref) => {
|
|
7
|
+
return (
|
|
8
|
+
<BaseBadge ref={ref} {...(props as T)}>
|
|
9
|
+
{children}
|
|
10
|
+
</BaseBadge>
|
|
11
|
+
);
|
|
12
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { useAvatarContext } from './context';
|
|
4
|
+
import type { IAvatarIconProps } from './types';
|
|
5
|
+
|
|
6
|
+
export const createAvatarIcon = <T,>(BaseIcon: React.ComponentType<T>) =>
|
|
7
|
+
forwardRef<unknown, IAvatarIconProps>(({ children, style, ...props }, ref) => {
|
|
8
|
+
const { imageLoaded, imageError } = useAvatarContext();
|
|
9
|
+
const visible = !imageLoaded || imageError;
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<BaseIcon ref={ref} style={[style, !visible && { opacity: 0 }]} {...(props as T)}>
|
|
13
|
+
{children}
|
|
14
|
+
</BaseIcon>
|
|
15
|
+
);
|
|
16
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef, useEffect, useMemo } from 'react';
|
|
3
|
+
import { useAvatarContext } from './context';
|
|
4
|
+
import type { IAvatarImageProps } from './types';
|
|
5
|
+
|
|
6
|
+
export const createAvatarImage = <T,>(BaseImage: React.ComponentType<T>) =>
|
|
7
|
+
forwardRef<unknown, IAvatarImageProps>(({ src, source, onLoad, onError, ...props }, ref) => {
|
|
8
|
+
const { imageError, setImageLoaded, setImageError } = useAvatarContext();
|
|
9
|
+
|
|
10
|
+
const resolvedSource = useMemo(() => (src ? { uri: src } : source), [src, source]);
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!resolvedSource) {
|
|
14
|
+
setImageError(true);
|
|
15
|
+
} else {
|
|
16
|
+
setImageError(false);
|
|
17
|
+
setImageLoaded(false);
|
|
18
|
+
}
|
|
19
|
+
}, [resolvedSource, setImageError, setImageLoaded]);
|
|
20
|
+
|
|
21
|
+
if (!resolvedSource || imageError) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<BaseImage
|
|
27
|
+
ref={ref}
|
|
28
|
+
source={resolvedSource}
|
|
29
|
+
onLoad={(e: unknown) => {
|
|
30
|
+
setImageLoaded(true);
|
|
31
|
+
(onLoad as (e: unknown) => void)?.(e);
|
|
32
|
+
}}
|
|
33
|
+
onError={(e: unknown) => {
|
|
34
|
+
setImageError(true);
|
|
35
|
+
(onError as (e: unknown) => void)?.(e);
|
|
36
|
+
}}
|
|
37
|
+
{...(props as T)}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef, useMemo, useState } from 'react';
|
|
3
|
+
import { AvatarProvider } from './context';
|
|
4
|
+
import type { IAvatarProps } from './types';
|
|
5
|
+
|
|
6
|
+
export const createAvatarRoot = <T,>(BaseAvatar: React.ComponentType<T>) =>
|
|
7
|
+
forwardRef<unknown, IAvatarProps>(({ children, ...props }, ref) => {
|
|
8
|
+
const [imageLoaded, setImageLoaded] = useState(false);
|
|
9
|
+
const [imageError, setImageError] = useState(false);
|
|
10
|
+
|
|
11
|
+
const contextValue = useMemo(
|
|
12
|
+
() => ({ imageLoaded, imageError, setImageLoaded, setImageError }),
|
|
13
|
+
[imageLoaded, imageError],
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<AvatarProvider value={contextValue}>
|
|
18
|
+
<BaseAvatar ref={ref} role="img" accessibilityRole="image" {...(props as T)}>
|
|
19
|
+
{children}
|
|
20
|
+
</BaseAvatar>
|
|
21
|
+
</AvatarProvider>
|
|
22
|
+
);
|
|
23
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { useAvatarContext } from './context';
|
|
4
|
+
import type { IAvatarTextProps } from './types';
|
|
5
|
+
|
|
6
|
+
function getInitials(name: string): string {
|
|
7
|
+
const words = name.trim().split(/\s+/);
|
|
8
|
+
let result = '';
|
|
9
|
+
for (const word of words) {
|
|
10
|
+
if (word.length > 0) {
|
|
11
|
+
result += word.charAt(0);
|
|
12
|
+
}
|
|
13
|
+
if (result.length >= 2) break;
|
|
14
|
+
}
|
|
15
|
+
return result.toUpperCase();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const createAvatarText = <T,>(BaseText: React.ComponentType<T>) =>
|
|
19
|
+
forwardRef<unknown, IAvatarTextProps>(({ children, style, ...props }, ref) => {
|
|
20
|
+
const { imageLoaded, imageError } = useAvatarContext();
|
|
21
|
+
const visible = !imageLoaded || imageError;
|
|
22
|
+
|
|
23
|
+
const text = typeof children === 'string' ? getInitials(children) : children;
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<BaseText ref={ref} style={[style, !visible && { opacity: 0 }]} {...(props as T)}>
|
|
27
|
+
{text}
|
|
28
|
+
</BaseText>
|
|
29
|
+
);
|
|
30
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { createAvatarBadge } from './createAvatarBadge';
|
|
3
|
+
import { createAvatarIcon } from './createAvatarIcon';
|
|
4
|
+
import { createAvatarText } from './createAvatarText';
|
|
5
|
+
import { createAvatarImage } from './createAvatarImage';
|
|
6
|
+
import { createAvatarRoot } from './createAvatarRoot';
|
|
7
|
+
import type { IAvatarComponentType } from './types';
|
|
8
|
+
|
|
9
|
+
export type {
|
|
10
|
+
IAvatarBadgeProps,
|
|
11
|
+
IAvatarComponentType,
|
|
12
|
+
IAvatarIconProps,
|
|
13
|
+
IAvatarTextProps,
|
|
14
|
+
IAvatarImageProps,
|
|
15
|
+
IAvatarProps,
|
|
16
|
+
} from './types';
|
|
17
|
+
|
|
18
|
+
export function createAvatar<Root, Image, Text, Icon, Badge>(BaseComponents: {
|
|
19
|
+
Root: React.ComponentType<Root>;
|
|
20
|
+
Image: React.ComponentType<Image>;
|
|
21
|
+
Text: React.ComponentType<Text>;
|
|
22
|
+
Icon: React.ComponentType<Icon>;
|
|
23
|
+
Badge: React.ComponentType<Badge>;
|
|
24
|
+
}) {
|
|
25
|
+
const Avatar = createAvatarRoot(BaseComponents.Root);
|
|
26
|
+
const AvatarImage = createAvatarImage(BaseComponents.Image);
|
|
27
|
+
const Text = createAvatarText(BaseComponents.Text);
|
|
28
|
+
const AvatarIcon = createAvatarIcon(BaseComponents.Icon);
|
|
29
|
+
const Badge = createAvatarBadge(BaseComponents.Badge);
|
|
30
|
+
|
|
31
|
+
Avatar.displayName = 'AvatarPrimitive';
|
|
32
|
+
AvatarImage.displayName = 'AvatarPrimitive.Image';
|
|
33
|
+
Text.displayName = 'AvatarPrimitive.Text';
|
|
34
|
+
AvatarIcon.displayName = 'AvatarPrimitive.Icon';
|
|
35
|
+
Badge.displayName = 'AvatarPrimitive.Badge';
|
|
36
|
+
|
|
37
|
+
return Object.assign(Avatar, {
|
|
38
|
+
Image: AvatarImage,
|
|
39
|
+
Text,
|
|
40
|
+
Icon: AvatarIcon,
|
|
41
|
+
Badge,
|
|
42
|
+
}) as unknown as IAvatarComponentType<Root, Image, Text, Icon, Badge>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { ImageProps, TextProps, ViewProps } from 'react-native';
|
|
2
|
+
|
|
3
|
+
// =============================================================================
|
|
4
|
+
// AVATAR ROOT
|
|
5
|
+
// =============================================================================
|
|
6
|
+
|
|
7
|
+
export interface IAvatarProps extends ViewProps {
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// =============================================================================
|
|
12
|
+
// AVATAR IMAGE
|
|
13
|
+
// =============================================================================
|
|
14
|
+
|
|
15
|
+
export interface IAvatarImageProps extends Omit<ImageProps, 'source'> {
|
|
16
|
+
/** Image source — URI string or RN ImageSourcePropType */
|
|
17
|
+
src?: string;
|
|
18
|
+
source?: ImageProps['source'];
|
|
19
|
+
alt?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// =============================================================================
|
|
23
|
+
// AVATAR FALLBACK TEXT
|
|
24
|
+
// =============================================================================
|
|
25
|
+
|
|
26
|
+
export interface IAvatarTextProps extends TextProps {
|
|
27
|
+
/** Full name — initials will be derived automatically */
|
|
28
|
+
children?: React.ReactNode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// =============================================================================
|
|
32
|
+
// AVATAR ICON (fallback icon — hidden when image loads)
|
|
33
|
+
// =============================================================================
|
|
34
|
+
|
|
35
|
+
export interface IAvatarIconProps extends ViewProps {
|
|
36
|
+
children?: React.ReactNode;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// =============================================================================
|
|
40
|
+
// AVATAR BADGE
|
|
41
|
+
// =============================================================================
|
|
42
|
+
|
|
43
|
+
export interface IAvatarBadgeProps extends ViewProps {
|
|
44
|
+
children?: React.ReactNode;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// =============================================================================
|
|
48
|
+
// CONTEXT
|
|
49
|
+
// =============================================================================
|
|
50
|
+
|
|
51
|
+
export interface IAvatarContextValue {
|
|
52
|
+
imageLoaded: boolean;
|
|
53
|
+
imageError: boolean;
|
|
54
|
+
setImageLoaded: (loaded: boolean) => void;
|
|
55
|
+
setImageError: (error: boolean) => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// =============================================================================
|
|
59
|
+
// COMPOUND COMPONENT TYPE
|
|
60
|
+
// =============================================================================
|
|
61
|
+
|
|
62
|
+
export type IAvatarComponentType<Root, Image, Text, Icon, Badge> = React.ForwardRefExoticComponent<
|
|
63
|
+
React.RefAttributes<Root> & React.PropsWithoutRef<Root> & IAvatarProps
|
|
64
|
+
> & {
|
|
65
|
+
Image: React.ForwardRefExoticComponent<
|
|
66
|
+
React.RefAttributes<Image> & React.PropsWithoutRef<Image> & IAvatarImageProps
|
|
67
|
+
>;
|
|
68
|
+
Text: React.ForwardRefExoticComponent<
|
|
69
|
+
React.RefAttributes<Text> & React.PropsWithoutRef<Text> & IAvatarTextProps
|
|
70
|
+
>;
|
|
71
|
+
Icon: React.ForwardRefExoticComponent<
|
|
72
|
+
React.RefAttributes<Icon> & React.PropsWithoutRef<Icon> & IAvatarIconProps
|
|
73
|
+
>;
|
|
74
|
+
Badge: React.ForwardRefExoticComponent<
|
|
75
|
+
React.RefAttributes<Badge> & React.PropsWithoutRef<Badge> & IAvatarBadgeProps
|
|
76
|
+
>;
|
|
77
|
+
};
|
package/src/button/context.tsx
CHANGED
|
@@ -3,9 +3,10 @@ import { forwardRef, useMemo } from 'react';
|
|
|
3
3
|
import { composeEventHandlers } from '@cdx-ui/utils';
|
|
4
4
|
import { useFocus, useFocusRing } from '@react-native-aria/focus';
|
|
5
5
|
import { useHover, usePress } from '@react-native-aria/interactions';
|
|
6
|
+
import type { InteractionState } from '../types';
|
|
6
7
|
import { dataAttributes } from '../utils/dataAttributes';
|
|
7
8
|
import { ButtonProvider } from './context';
|
|
8
|
-
import type { IButtonProps
|
|
9
|
+
import type { IButtonProps } from './types';
|
|
9
10
|
|
|
10
11
|
export const createButtonRoot = <T,>(BaseButton: React.ComponentType<T>) =>
|
|
11
12
|
forwardRef(
|
|
@@ -37,7 +38,7 @@ export const createButtonRoot = <T,>(BaseButton: React.ComponentType<T>) =>
|
|
|
37
38
|
hover: isHoveredProp || isHovered,
|
|
38
39
|
focus: isFocusedProp || isFocused,
|
|
39
40
|
active: isActiveProp || isActive,
|
|
40
|
-
disabled: isDisabled,
|
|
41
|
+
disabled: !!isDisabled,
|
|
41
42
|
focusVisible: isFocusVisibleProp || isFocusVisible,
|
|
42
43
|
};
|
|
43
44
|
}, [
|
|
@@ -61,7 +62,7 @@ export const createButtonRoot = <T,>(BaseButton: React.ComponentType<T>) =>
|
|
|
61
62
|
hover: isHoveredProp || isHovered,
|
|
62
63
|
focus: isFocusedProp || isFocused,
|
|
63
64
|
active: isActiveProp || isActive,
|
|
64
|
-
disabled: isDisabled,
|
|
65
|
+
disabled: !!isDisabled,
|
|
65
66
|
focusVisible: isFocusVisibleProp || isFocusVisible,
|
|
66
67
|
})}
|
|
67
68
|
disabled={isDisabled}
|
|
@@ -90,7 +91,7 @@ export const createButtonRoot = <T,>(BaseButton: React.ComponentType<T>) =>
|
|
|
90
91
|
hover: isHoveredProp || isHovered,
|
|
91
92
|
focus: isFocusedProp || isFocused,
|
|
92
93
|
active: isActiveProp || isActive,
|
|
93
|
-
disabled: isDisabled,
|
|
94
|
+
disabled: !!isDisabled,
|
|
94
95
|
focusVisible: isFocusVisibleProp || isFocusVisible,
|
|
95
96
|
})
|
|
96
97
|
: children}
|
package/src/button/index.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import { createButtonRoot } from './createButtonRoot';
|
|
3
2
|
import { createButtonGroup } from './createButtonGroup';
|
|
4
3
|
import { createButtonIcon } from './createButtonIcon';
|
|
4
|
+
import { createButtonRoot } from './createButtonRoot';
|
|
5
5
|
import { createButtonSpinner } from './createButtonSpinner';
|
|
6
6
|
import { createButtonText } from './createButtonText';
|
|
7
7
|
import type { IButtonComponentType } from './types';
|
|
@@ -16,32 +16,31 @@ export function createButton<
|
|
|
16
16
|
IconProps,
|
|
17
17
|
ButtonRef = unknown,
|
|
18
18
|
TextRef = unknown,
|
|
19
|
-
>({
|
|
20
|
-
Root,
|
|
21
|
-
Text,
|
|
22
|
-
Group,
|
|
23
|
-
Spinner,
|
|
24
|
-
Icon,
|
|
25
|
-
}: {
|
|
19
|
+
>(BaseComponents: {
|
|
26
20
|
Root: React.ComponentType<ButtonProps>;
|
|
27
21
|
Text: React.ComponentType<TextProps>;
|
|
28
22
|
Group: React.ComponentType<GroupProps>;
|
|
29
23
|
Spinner: React.ComponentType<SpinnerProps>;
|
|
30
24
|
Icon: React.ComponentType<IconProps>;
|
|
31
25
|
}) {
|
|
32
|
-
const Button = createButtonRoot(Root)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
const Button = createButtonRoot(BaseComponents.Root);
|
|
27
|
+
const Text = createButtonText(BaseComponents.Text);
|
|
28
|
+
const Group = createButtonGroup(BaseComponents.Group);
|
|
29
|
+
const Spinner = createButtonSpinner(BaseComponents.Spinner);
|
|
30
|
+
const Icon = createButtonIcon(BaseComponents.Icon);
|
|
37
31
|
|
|
38
|
-
Button.displayName = '
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
Button.displayName = 'ButtonPrimitive';
|
|
33
|
+
Text.displayName = 'ButtonPrimitive.Text';
|
|
34
|
+
Group.displayName = 'ButtonPrimitive.Group';
|
|
35
|
+
Spinner.displayName = 'ButtonPrimitive.Spinner';
|
|
36
|
+
Icon.displayName = 'ButtonPrimitive.Icon';
|
|
43
37
|
|
|
44
|
-
return Button
|
|
38
|
+
return Object.assign(Button, {
|
|
39
|
+
Text,
|
|
40
|
+
Group,
|
|
41
|
+
Spinner,
|
|
42
|
+
Icon,
|
|
43
|
+
}) as IButtonComponentType<
|
|
45
44
|
ButtonProps,
|
|
46
45
|
GroupProps,
|
|
47
46
|
SpinnerProps,
|
package/src/button/types.ts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import type { PropsWithoutRef, ReactElement, ReactNode, RefAttributes } from 'react';
|
|
2
2
|
import type { PressableProps, ViewProps } from 'react-native';
|
|
3
3
|
|
|
4
|
-
export interface InteractionState {
|
|
5
|
-
hover: boolean;
|
|
6
|
-
focus: boolean;
|
|
7
|
-
active: boolean;
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
focusVisible: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
4
|
export interface InterfaceButtonProps extends PressableProps {
|
|
13
5
|
/**
|
|
14
6
|
* If true, the button will be in hovered state.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createContext } from '@cdx-ui/utils';
|
|
3
|
+
import type { ICheckboxContextValue } from './types';
|
|
4
|
+
|
|
5
|
+
export const [CheckboxProvider, useCheckboxContext] =
|
|
6
|
+
createContext<ICheckboxContextValue>('CheckboxContext');
|
|
7
|
+
|
|
8
|
+
interface ICheckboxGroupState {
|
|
9
|
+
isReadOnly: boolean;
|
|
10
|
+
isDisabled: boolean;
|
|
11
|
+
isSelected: (value: string) => boolean;
|
|
12
|
+
addValue: (value: string) => void;
|
|
13
|
+
removeValue: (value: string) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const CheckboxGroupContext = React.createContext<{
|
|
17
|
+
state: ICheckboxGroupState;
|
|
18
|
+
} | null>(null);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { useFormControlContext } from '@cdx-ui/utils';
|
|
3
|
+
import { useCheckboxGroup } from '@react-native-aria/checkbox';
|
|
4
|
+
import { useCheckboxGroupState } from '@react-stately/checkbox';
|
|
5
|
+
import { CheckboxGroupContext } from './context';
|
|
6
|
+
import type { ICheckboxGroupProps } from './types';
|
|
7
|
+
|
|
8
|
+
export const createCheckboxGroup = <T,>(BaseCheckboxGroup: React.ComponentType<T>) =>
|
|
9
|
+
forwardRef(({ children, ...props }: ICheckboxGroupProps, ref?: React.Ref<T>) => {
|
|
10
|
+
const state = useCheckboxGroupState({
|
|
11
|
+
...props,
|
|
12
|
+
validationState: props.isInvalid ? 'invalid' : 'valid',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const { groupProps } = useCheckboxGroup(
|
|
16
|
+
{
|
|
17
|
+
...props,
|
|
18
|
+
'aria-label': props['aria-label'],
|
|
19
|
+
},
|
|
20
|
+
state,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const formControlContext = useFormControlContext();
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<CheckboxGroupContext.Provider value={{ state: { ...formControlContext, ...state } }}>
|
|
27
|
+
<BaseCheckboxGroup {...groupProps} {...props} ref={ref}>
|
|
28
|
+
{children}
|
|
29
|
+
</BaseCheckboxGroup>
|
|
30
|
+
</CheckboxGroupContext.Provider>
|
|
31
|
+
);
|
|
32
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { useCheckboxContext } from './context';
|
|
3
|
+
import type { ICheckboxIconProps } from './types';
|
|
4
|
+
|
|
5
|
+
export const createCheckboxIcon = <T,>(BaseCheckboxIcon: React.ComponentType<T>) =>
|
|
6
|
+
forwardRef<unknown, ICheckboxIconProps>(({ children, forceMount = false, ...props }, ref) => {
|
|
7
|
+
const { isChecked, isIndeterminate } = useCheckboxContext();
|
|
8
|
+
|
|
9
|
+
if (forceMount || isChecked || isIndeterminate) {
|
|
10
|
+
return (
|
|
11
|
+
<BaseCheckboxIcon {...(props as T)} ref={ref}>
|
|
12
|
+
{children}
|
|
13
|
+
</BaseCheckboxIcon>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return null;
|
|
18
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
3
|
+
import { useCheckboxContext } from './context';
|
|
4
|
+
import type { ICheckboxIndicatorProps } from './types';
|
|
5
|
+
|
|
6
|
+
export const createCheckboxIndicator = <T,>(BaseCheckboxIndicator: React.ComponentType<T>) =>
|
|
7
|
+
forwardRef<unknown, ICheckboxIndicatorProps & { className?: string }>(
|
|
8
|
+
({ children, className, ...props }, ref) => {
|
|
9
|
+
const {
|
|
10
|
+
isChecked,
|
|
11
|
+
isDisabled,
|
|
12
|
+
isHovered,
|
|
13
|
+
isInvalid,
|
|
14
|
+
isReadOnly,
|
|
15
|
+
isPressed,
|
|
16
|
+
isFocused,
|
|
17
|
+
isIndeterminate,
|
|
18
|
+
isFocusVisible,
|
|
19
|
+
} = useCheckboxContext();
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<BaseCheckboxIndicator
|
|
23
|
+
className={className}
|
|
24
|
+
{...dataAttributes({
|
|
25
|
+
hover: isHovered,
|
|
26
|
+
checked: isChecked,
|
|
27
|
+
disabled: isDisabled,
|
|
28
|
+
focusVisible: isFocusVisible,
|
|
29
|
+
invalid: isInvalid,
|
|
30
|
+
readOnly: isReadOnly,
|
|
31
|
+
active: isPressed,
|
|
32
|
+
focused: isFocused,
|
|
33
|
+
indeterminate: isIndeterminate,
|
|
34
|
+
slot: 'checkbox-indicator',
|
|
35
|
+
})}
|
|
36
|
+
{...(props as T)}
|
|
37
|
+
ref={ref}
|
|
38
|
+
>
|
|
39
|
+
{children}
|
|
40
|
+
</BaseCheckboxIndicator>
|
|
41
|
+
);
|
|
42
|
+
},
|
|
43
|
+
);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
3
|
+
import { useCheckboxContext } from './context';
|
|
4
|
+
import type { ICheckboxLabelProps } from './types';
|
|
5
|
+
|
|
6
|
+
export const createCheckboxLabel = <T,>(BaseCheckboxLabel: React.ComponentType<T>) =>
|
|
7
|
+
forwardRef<unknown, ICheckboxLabelProps & { className?: string }>(
|
|
8
|
+
({ children, className, ...props }, ref) => {
|
|
9
|
+
const {
|
|
10
|
+
isChecked,
|
|
11
|
+
isDisabled,
|
|
12
|
+
isHovered,
|
|
13
|
+
isInvalid,
|
|
14
|
+
isReadOnly,
|
|
15
|
+
isPressed,
|
|
16
|
+
isFocused,
|
|
17
|
+
isIndeterminate,
|
|
18
|
+
isFocusVisible,
|
|
19
|
+
} = useCheckboxContext();
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<BaseCheckboxLabel
|
|
23
|
+
className={className}
|
|
24
|
+
{...dataAttributes({
|
|
25
|
+
hover: isHovered,
|
|
26
|
+
checked: isChecked,
|
|
27
|
+
disabled: isDisabled,
|
|
28
|
+
focusVisible: isFocusVisible,
|
|
29
|
+
invalid: isInvalid,
|
|
30
|
+
readOnly: isReadOnly,
|
|
31
|
+
pressed: isPressed,
|
|
32
|
+
focused: isFocused,
|
|
33
|
+
indeterminate: isIndeterminate,
|
|
34
|
+
})}
|
|
35
|
+
{...(props as T)}
|
|
36
|
+
ref={ref}
|
|
37
|
+
>
|
|
38
|
+
{children}
|
|
39
|
+
</BaseCheckboxLabel>
|
|
40
|
+
);
|
|
41
|
+
},
|
|
42
|
+
);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { composeEventHandlers } from '@cdx-ui/utils';
|
|
3
|
+
import { useFocus } from '@react-native-aria/focus';
|
|
4
|
+
import { usePress } from '@react-native-aria/interactions';
|
|
5
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
6
|
+
import { CheckboxProvider } from './context';
|
|
7
|
+
import type { ICheckboxProps } from './types';
|
|
8
|
+
import { useCheckboxRoot } from './useCheckboxRoot';
|
|
9
|
+
|
|
10
|
+
export const createCheckboxRoot = <T,>(BaseCheckbox: React.ComponentType<T>) =>
|
|
11
|
+
forwardRef(
|
|
12
|
+
(
|
|
13
|
+
{
|
|
14
|
+
onPressIn,
|
|
15
|
+
onPressOut,
|
|
16
|
+
onHoverIn,
|
|
17
|
+
onHoverOut,
|
|
18
|
+
onFocus,
|
|
19
|
+
onBlur,
|
|
20
|
+
children,
|
|
21
|
+
...props
|
|
22
|
+
}: ICheckboxProps,
|
|
23
|
+
ref?: React.Ref<T>,
|
|
24
|
+
) => {
|
|
25
|
+
const {
|
|
26
|
+
isHovered: isHoveredProp,
|
|
27
|
+
isChecked: isCheckedProp,
|
|
28
|
+
isDisabled: isDisabledProp,
|
|
29
|
+
isInvalid: isInvalidProp,
|
|
30
|
+
isReadOnly: isReadOnlyProp,
|
|
31
|
+
isPressed: isPressedProp,
|
|
32
|
+
isFocused: isFocusedProp,
|
|
33
|
+
isIndeterminate: isIndeterminateProp,
|
|
34
|
+
isFocusVisible,
|
|
35
|
+
} = props;
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
combinedProps,
|
|
39
|
+
isInvalid,
|
|
40
|
+
isReadOnly,
|
|
41
|
+
isIndeterminate,
|
|
42
|
+
groupItemInputProps,
|
|
43
|
+
isChecked,
|
|
44
|
+
isDisabled,
|
|
45
|
+
isHovered,
|
|
46
|
+
hoverProps,
|
|
47
|
+
mergedRef,
|
|
48
|
+
} = useCheckboxRoot(props, ref);
|
|
49
|
+
|
|
50
|
+
const { focusProps, isFocused } = useFocus();
|
|
51
|
+
|
|
52
|
+
const { pressProps, isPressed } = usePress({
|
|
53
|
+
isDisabled: isDisabled || isDisabledProp,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<BaseCheckbox
|
|
58
|
+
disabled={isDisabled || isDisabledProp}
|
|
59
|
+
{...pressProps}
|
|
60
|
+
{...(combinedProps as T)}
|
|
61
|
+
{...groupItemInputProps}
|
|
62
|
+
ref={mergedRef}
|
|
63
|
+
role="checkbox"
|
|
64
|
+
onPressIn={composeEventHandlers(onPressIn, pressProps.onPressIn)}
|
|
65
|
+
onPressOut={composeEventHandlers(onPressOut, pressProps.onPressOut)}
|
|
66
|
+
onHoverIn={composeEventHandlers(onHoverIn, hoverProps.onHoverIn)}
|
|
67
|
+
onHoverOut={composeEventHandlers(onHoverOut, hoverProps.onHoverOut)}
|
|
68
|
+
onFocus={composeEventHandlers(composeEventHandlers(onFocus, focusProps.onFocus))}
|
|
69
|
+
onBlur={composeEventHandlers(composeEventHandlers(onBlur, focusProps.onBlur))}
|
|
70
|
+
{...dataAttributes({
|
|
71
|
+
checked: isChecked || isCheckedProp,
|
|
72
|
+
disabled: isDisabled || isDisabledProp,
|
|
73
|
+
hover: isHovered || isHoveredProp,
|
|
74
|
+
invalid: isInvalid || isInvalidProp,
|
|
75
|
+
readonly: isReadOnly || isReadOnlyProp,
|
|
76
|
+
active: isPressed,
|
|
77
|
+
focus: isFocused,
|
|
78
|
+
indeterminate: isIndeterminate || isIndeterminateProp,
|
|
79
|
+
focusVisible: isFocusVisible,
|
|
80
|
+
})}
|
|
81
|
+
>
|
|
82
|
+
<CheckboxProvider
|
|
83
|
+
value={{
|
|
84
|
+
isChecked: isChecked || isCheckedProp,
|
|
85
|
+
isDisabled: isDisabled || isDisabledProp,
|
|
86
|
+
isHovered: isHovered || isHoveredProp,
|
|
87
|
+
isInvalid: isInvalid || isInvalidProp,
|
|
88
|
+
isReadOnly: isReadOnly || isReadOnlyProp,
|
|
89
|
+
isPressed: isPressed || isPressedProp,
|
|
90
|
+
isFocused: isFocused || isFocusedProp,
|
|
91
|
+
isIndeterminate: isIndeterminate || isIndeterminateProp,
|
|
92
|
+
isFocusVisible,
|
|
93
|
+
}}
|
|
94
|
+
>
|
|
95
|
+
{children}
|
|
96
|
+
</CheckboxProvider>
|
|
97
|
+
</BaseCheckbox>
|
|
98
|
+
);
|
|
99
|
+
},
|
|
100
|
+
);
|