--[[
	Higher order component that lets the wrapped component consume the InputContext.
]]

local function withInputContext(component)
	return function(props)
		if props.inputContext then
			warn("Child component has a prop named `inputContext` and will be overriden by InputContext.")
		end

		return Roact.createElement(Context.Consumer, {
			render = function(inputContext)
				local mergedProps = Cryo.Dictionary.join({ inputContext = inputContext }, props)

				return Roact.createElement(component, mergedProps)
			end,
		})
	end
end

local InputContext = {
	Consumer = Context.Consumer,
	Provider = withConfiguration(InputContextProvider),
	withInputContext = withInputContext,
}

return InputContext
