@cdx-ui/primitives 0.0.1-beta.132 → 0.0.1-beta.133
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/button/ButtonRoot.js +38 -2
- package/lib/commonjs/button/ButtonRoot.js.map +1 -1
- package/lib/module/button/ButtonRoot.js +38 -2
- package/lib/module/button/ButtonRoot.js.map +1 -1
- package/lib/typescript/button/ButtonRoot.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/button/ButtonRoot.tsx +43 -3
|
@@ -50,10 +50,46 @@ const ButtonRoot = exports.ButtonRoot = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
50
50
|
focusVisible: isFocusVisibleProp || isFocusVisible
|
|
51
51
|
};
|
|
52
52
|
}, [isHovered, isHoveredProp, isFocused, isFocusedProp, isActive, isActiveProp, isDisabled, isFocusVisible, isFocusVisibleProp]);
|
|
53
|
-
|
|
53
|
+
if (asChild) {
|
|
54
|
+
// Dedicated asChild path: composing Button onto a child (e.g. `<Link>`) must not
|
|
55
|
+
// force `role="button"` or leak ButtonRoot's internal usePress/useHover/useFocus
|
|
56
|
+
// handlers onto it — doing so overrides the child's own role and behavior (DEVEX-6442).
|
|
57
|
+
// The hooks above still run unconditionally (rules of hooks) so ButtonProvider can
|
|
58
|
+
// expose interaction state to sub-components, but their handler props are
|
|
59
|
+
// intentionally not spread onto the child here.
|
|
60
|
+
const {
|
|
61
|
+
onPress,
|
|
62
|
+
...restProps
|
|
63
|
+
} = props;
|
|
64
|
+
const slotProps = {
|
|
65
|
+
...restProps,
|
|
66
|
+
disabled: isDisabled
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// Only pass onPress when Button itself was given one — preserves the child's own
|
|
70
|
+
// handler (e.g. Link's navigation onPress) when Button has none of its own.
|
|
71
|
+
if (onPress) {
|
|
72
|
+
slotProps.onPress = onPress;
|
|
73
|
+
}
|
|
74
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_context.ButtonProvider, {
|
|
75
|
+
value: contextValue,
|
|
76
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_slot.Slot, {
|
|
77
|
+
ref: ref,
|
|
78
|
+
...slotProps,
|
|
79
|
+
...(0, _dataAttributes.mergeDataAttributes)(props, (0, _dataAttributes.dataAttributes)({
|
|
80
|
+
hover: isHoveredProp || isHovered,
|
|
81
|
+
focus: isFocusedProp || isFocused,
|
|
82
|
+
active: isActiveProp || isActive,
|
|
83
|
+
disabled: !!isDisabled,
|
|
84
|
+
focusVisible: isFocusVisibleProp || isFocusVisible
|
|
85
|
+
})),
|
|
86
|
+
children: typeof children === 'function' ? children(contextValue) : children
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
}
|
|
54
90
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_context.ButtonProvider, {
|
|
55
91
|
value: contextValue,
|
|
56
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
92
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
57
93
|
ref: ref,
|
|
58
94
|
role: props?.role || 'button',
|
|
59
95
|
disabled: isDisabled,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_utils","_focus","_interactions","_slot","_dataAttributes","_context","_jsxRuntime","ButtonRoot","exports","forwardRef","asChild","children","isDisabled","isHovered","isHoveredProp","isActive","isActiveProp","isFocused","isFocusedProp","isFocusVisible","isFocusVisibleProp","props","ref","focusProps","useFocus","focusRingProps","useFocusRing","pressProps","pressableProps","isPressed","usePress","hoverProps","useHover","contextValue","useMemo","hover","focus","active","disabled","focusVisible","
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_utils","_focus","_interactions","_slot","_dataAttributes","_context","_jsxRuntime","ButtonRoot","exports","forwardRef","asChild","children","isDisabled","isHovered","isHoveredProp","isActive","isActiveProp","isFocused","isFocusedProp","isFocusVisible","isFocusVisibleProp","props","ref","focusProps","useFocus","focusRingProps","useFocusRing","pressProps","pressableProps","isPressed","usePress","hoverProps","useHover","contextValue","useMemo","hover","focus","active","disabled","focusVisible","onPress","restProps","slotProps","jsx","ButtonProvider","value","Slot","mergeDataAttributes","dataAttributes","Pressable","role","onPressIn","composeEventHandlers","onPressOut","onHoverIn","onHoverOut","onFocus","onBlur","displayName"],"sourceRoot":"../../../src","sources":["button/ButtonRoot.tsx"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAEA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAA2C,IAAAQ,WAAA,GAAAR,OAAA;AAQpC,MAAMS,UAAU,GAAAC,OAAA,CAAAD,UAAA,gBAAG,IAAAE,iBAAU,EAClC,CACE;EACEC,OAAO;EACPC,QAAQ;EACRC,UAAU;EACVC,SAAS,EAAEC,aAAa;EACxBC,QAAQ,EAAEC,YAAY;EACtBC,SAAS,EAAEC,aAAa;EACxBC,cAAc,EAAEC,kBAAkB;EAClC,GAAGC;AACL,CAAC,EACDC,GAAG,KACA;EACH,MAAM;IAAEL,SAAS;IAAEM;EAAW,CAAC,GAAG,IAAAC,eAAQ,EAAC,CAAC;EAC5C,MAAM;IAAEL,cAAc;IAAEI,UAAU,EAAEE;EAAe,CAAC,GAAG,IAAAC,mBAAY,EAAC,CAGnE;EACD,MAAM;IAAEC,UAAU,EAAEC,cAAc;IAAEC,SAAS,EAAEd;EAAS,CAAC,GAAG,IAAAe,sBAAQ,EAAC;IACnElB;EACF,CAAC,CAAC;EACF,MAAM;IAAEC,SAAS;IAAEkB;EAAW,CAAC,GAAG,IAAAC,sBAAQ,EAAC,CAAC;EAE5C,MAAMC,YAAY,GAAG,I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oB,EAC1B,IAAAA,2BAAoB,EAClB/B,KAAK,EAAEoC,MAAM,EACblC,UAAU,CAACkC,MACb,CAAC,EACDhC,cAAc,CAACgC,MACjB,CAAE;MAAA9C,QAAA,EAED,OAAOA,QAAQ,KAAK,UAAU,GAC3BA,QAAQ,CAAC;QACPwB,KAAK,EAAErB,aAAa,IAAID,SAAS;QACjCuB,KAAK,EAAElB,aAAa,IAAID,SAAS;QACjCoB,MAAM,EAAErB,YAAY,IAAID,QAAQ;QAChCuB,QAAQ,EAAE,CAAC,CAAC1B,UAAU;QACtB2B,YAAY,EAAEnB,kBAAkB,IAAID;MACtC,CAAC,CAAC,GACFR;IAAQ,CACH;EAAC,CACE,CAAC;AAErB,CACF,CAAC;AAEDJ,UAAU,CAACmD,WAAW,GAAG,YAAY","ignoreList":[]}
|
|
@@ -46,10 +46,46 @@ export const ButtonRoot = /*#__PURE__*/forwardRef(({
|
|
|
46
46
|
focusVisible: isFocusVisibleProp || isFocusVisible
|
|
47
47
|
};
|
|
48
48
|
}, [isHovered, isHoveredProp, isFocused, isFocusedProp, isActive, isActiveProp, isDisabled, isFocusVisible, isFocusVisibleProp]);
|
|
49
|
-
|
|
49
|
+
if (asChild) {
|
|
50
|
+
// Dedicated asChild path: composing Button onto a child (e.g. `<Link>`) must not
|
|
51
|
+
// force `role="button"` or leak ButtonRoot's internal usePress/useHover/useFocus
|
|
52
|
+
// handlers onto it — doing so overrides the child's own role and behavior (DEVEX-6442).
|
|
53
|
+
// The hooks above still run unconditionally (rules of hooks) so ButtonProvider can
|
|
54
|
+
// expose interaction state to sub-components, but their handler props are
|
|
55
|
+
// intentionally not spread onto the child here.
|
|
56
|
+
const {
|
|
57
|
+
onPress,
|
|
58
|
+
...restProps
|
|
59
|
+
} = props;
|
|
60
|
+
const slotProps = {
|
|
61
|
+
...restProps,
|
|
62
|
+
disabled: isDisabled
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Only pass onPress when Button itself was given one — preserves the child's own
|
|
66
|
+
// handler (e.g. Link's navigation onPress) when Button has none of its own.
|
|
67
|
+
if (onPress) {
|
|
68
|
+
slotProps.onPress = onPress;
|
|
69
|
+
}
|
|
70
|
+
return /*#__PURE__*/_jsx(ButtonProvider, {
|
|
71
|
+
value: contextValue,
|
|
72
|
+
children: /*#__PURE__*/_jsx(Slot, {
|
|
73
|
+
ref: ref,
|
|
74
|
+
...slotProps,
|
|
75
|
+
...mergeDataAttributes(props, dataAttributes({
|
|
76
|
+
hover: isHoveredProp || isHovered,
|
|
77
|
+
focus: isFocusedProp || isFocused,
|
|
78
|
+
active: isActiveProp || isActive,
|
|
79
|
+
disabled: !!isDisabled,
|
|
80
|
+
focusVisible: isFocusVisibleProp || isFocusVisible
|
|
81
|
+
})),
|
|
82
|
+
children: typeof children === 'function' ? children(contextValue) : children
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
}
|
|
50
86
|
return /*#__PURE__*/_jsx(ButtonProvider, {
|
|
51
87
|
value: contextValue,
|
|
52
|
-
children: /*#__PURE__*/_jsx(
|
|
88
|
+
children: /*#__PURE__*/_jsx(Pressable, {
|
|
53
89
|
ref: ref,
|
|
54
90
|
role: props?.role || 'button',
|
|
55
91
|
disabled: isDisabled,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","useMemo","Pressable","composeEventHandlers","useFocus","useFocusRing","useHover","usePress","Slot","dataAttributes","mergeDataAttributes","ButtonProvider","jsx","_jsx","ButtonRoot","asChild","children","isDisabled","isHovered","isHoveredProp","isActive","isActiveProp","isFocused","isFocusedProp","isFocusVisible","isFocusVisibleProp","props","ref","focusProps","focusRingProps","pressProps","pressableProps","isPressed","hoverProps","contextValue","hover","focus","active","disabled","focusVisible","
|
|
1
|
+
{"version":3,"names":["forwardRef","useMemo","Pressable","composeEventHandlers","useFocus","useFocusRing","useHover","usePress","Slot","dataAttributes","mergeDataAttributes","ButtonProvider","jsx","_jsx","ButtonRoot","asChild","children","isDisabled","isHovered","isHoveredProp","isActive","isActiveProp","isFocused","isFocusedProp","isFocusVisible","isFocusVisibleProp","props","ref","focusProps","focusRingProps","pressProps","pressableProps","isPressed","hoverProps","contextValue","hover","focus","active","disabled","focusVisible","onPress","restProps","slotProps","value","role","onPressIn","onPressOut","onHoverIn","onHoverOut","onFocus","onBlur","displayName"],"sourceRoot":"../../../src","sources":["button/ButtonRoot.tsx"],"mappings":";;AACA,SAASA,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAC3C,SAASC,SAAS,QAA6B,cAAc;AAC7D,SAASC,oBAAoB,QAAQ,eAAe;AACpD,SAASC,QAAQ,EAAEC,YAAY,QAAQ,0BAA0B;AACjE,SAASC,QAAQ,EAAEC,QAAQ,QAAQ,iCAAiC;AAEpE,SAASC,IAAI,QAAQ,SAAS;AAC9B,SAASC,cAAc,EAAEC,mBAAmB,QAAQ,yBAAyB;AAC7E,SAASC,cAAc,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAQ3C,OAAO,MAAMC,UAAU,gBAAGd,UAAU,CAClC,CACE;EACEe,OAAO;EACPC,QAAQ;EACRC,UAAU;EACVC,SAAS,EAAEC,aAAa;EACxBC,QAAQ,EAAEC,YAAY;EACtBC,SAAS,EAAEC,aAAa;EACxBC,cAAc,EAAEC,kBAAkB;EAClC,GAAGC;AACL,CAAC,EACDC,GAAG,KACA;EACH,MAAM;IAAEL,SAAS;IAAEM;EAAW,CAAC,GAAGxB,QAAQ,CAAC,CAAC;EAC5C,MAAM;IAAEoB,cAAc;IAAEI,UAAU,EAAEC;EAAe,CAAC,GAAGxB,YAAY,CAAC,CAGnE;EACD,MAAM;IAAEyB,UAAU,EAAEC,cAAc;IAAEC,SAAS,EAAEZ;EAAS,CAAC,GAAGb,QAAQ,CAAC;IACnEU;EACF,CAAC,CAAC;EACF,MAAM;IAAEC,SAAS;IAAEe;EAAW,CAAC,GAAG3B,QAAQ,CAAC,CAAC;EAE5C,MAAM4B,YAAY,GAAGjC,OAAO,CAA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,IAAID,SAAS;QACjCe,MAAM,EAAEhB,YAAY,IAAID,QAAQ;QAChCkB,QAAQ,EAAE,CAAC,CAACrB,UAAU;QACtBsB,YAAY,EAAEd,kBAAkB,IAAID;MACtC,CAAC,CAAC,GACFR;IAAQ,CACH;EAAC,CACE,CAAC;AAErB,CACF,CAAC;AAEDF,UAAU,CAACqC,WAAW,GAAG,YAAY","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonRoot.d.ts","sourceRoot":"","sources":["../../../src/button/ButtonRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAIjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC;IACrE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;CAC7E;AAED,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"ButtonRoot.d.ts","sourceRoot":"","sources":["../../../src/button/ButtonRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAIjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC;IACrE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;CAC7E;AAED,eAAO,MAAM,UAAU,qGAuItB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdx-ui/primitives",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.133",
|
|
4
4
|
"main": "lib/commonjs/index.js",
|
|
5
5
|
"module": "lib/module/index.js",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@react-stately/checkbox": "3.7.4",
|
|
61
61
|
"@react-stately/radio": "3.12.0",
|
|
62
62
|
"@react-stately/toggle": "3.9.4",
|
|
63
|
-
"@cdx-ui/utils": "0.0.1-beta.
|
|
63
|
+
"@cdx-ui/utils": "0.0.1-beta.133"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/react": "19.1.17",
|
|
@@ -59,11 +59,51 @@ export const ButtonRoot = forwardRef<React.ComponentRef<typeof Pressable>, Butto
|
|
|
59
59
|
isFocusVisibleProp,
|
|
60
60
|
]);
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
if (asChild) {
|
|
63
|
+
// Dedicated asChild path: composing Button onto a child (e.g. `<Link>`) must not
|
|
64
|
+
// force `role="button"` or leak ButtonRoot's internal usePress/useHover/useFocus
|
|
65
|
+
// handlers onto it — doing so overrides the child's own role and behavior (DEVEX-6442).
|
|
66
|
+
// The hooks above still run unconditionally (rules of hooks) so ButtonProvider can
|
|
67
|
+
// expose interaction state to sub-components, but their handler props are
|
|
68
|
+
// intentionally not spread onto the child here.
|
|
69
|
+
const { onPress, ...restProps } = props;
|
|
70
|
+
|
|
71
|
+
const slotProps: Record<string, unknown> = {
|
|
72
|
+
...restProps,
|
|
73
|
+
disabled: isDisabled,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// Only pass onPress when Button itself was given one — preserves the child's own
|
|
77
|
+
// handler (e.g. Link's navigation onPress) when Button has none of its own.
|
|
78
|
+
if (onPress) {
|
|
79
|
+
slotProps.onPress = onPress;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<ButtonProvider value={contextValue}>
|
|
84
|
+
<Slot
|
|
85
|
+
ref={ref}
|
|
86
|
+
{...(slotProps as PressableProps)}
|
|
87
|
+
{...mergeDataAttributes(
|
|
88
|
+
props,
|
|
89
|
+
dataAttributes({
|
|
90
|
+
hover: isHoveredProp || isHovered,
|
|
91
|
+
focus: isFocusedProp || isFocused,
|
|
92
|
+
active: isActiveProp || isActive,
|
|
93
|
+
disabled: !!isDisabled,
|
|
94
|
+
focusVisible: isFocusVisibleProp || isFocusVisible,
|
|
95
|
+
}),
|
|
96
|
+
)}
|
|
97
|
+
>
|
|
98
|
+
{typeof children === 'function' ? children(contextValue) : children}
|
|
99
|
+
</Slot>
|
|
100
|
+
</ButtonProvider>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
63
103
|
|
|
64
104
|
return (
|
|
65
105
|
<ButtonProvider value={contextValue}>
|
|
66
|
-
<
|
|
106
|
+
<Pressable
|
|
67
107
|
ref={ref}
|
|
68
108
|
role={props?.role || 'button'}
|
|
69
109
|
disabled={isDisabled}
|
|
@@ -106,7 +146,7 @@ export const ButtonRoot = forwardRef<React.ComponentRef<typeof Pressable>, Butto
|
|
|
106
146
|
focusVisible: isFocusVisibleProp || isFocusVisible,
|
|
107
147
|
})
|
|
108
148
|
: children}
|
|
109
|
-
</
|
|
149
|
+
</Pressable>
|
|
110
150
|
</ButtonProvider>
|
|
111
151
|
);
|
|
112
152
|
},
|