Using elementSelect for third-party elements I'm writing plugin to extend Craft Commerce and I want to present a good way to select products in CP. 

I know I could use dropdown select for this, but using Craft's elementSelect would make the UI much nicer. Is there a way to use elementSelect dialog / fieldtype not just for entries or assets, but for custom data set (in my case, Commerce Products)?
If you are referring to a custom field to select products, one already exists:



If you are building a general attribute field for a plugin, taking a look at the B BaseElementFieldType.php within the craft/app filder (that the product field above extends) will give you clues on how to recreate the UI to select products (or any other element).

The key file being craft/app/templates/_includes/forms/elementSelect.html which will show you how to instantiate the Craft.BaseElementSelectInput js class.

Hope that points you in the right direction. I am not sure if there is a full guide out there on how to useCraft.BaseElementSelectInput js, but hopefully the above will get you most of the way there by looking at the code.