UNPKG

element-vir

Version:

Heroic. Reactive. Declarative. Type safe. Web components without compromise.

28 lines (27 loc) 921 B
import { getObjectTypedKeys } from '@augment-vir/common'; /** * This is used to create the parameters passed to the `render`, `init`, and `cleanup` element * definition methods whenever they are called. * * @category Internal */ export function createRenderParams({ element, eventsMap, cssVars, slotNamesMap, testIdsMap, }) { function updateState(newStatePartial) { getObjectTypedKeys(newStatePartial).forEach((stateKey) => { const newValue = newStatePartial[stateKey]; element.instanceState[stateKey] = newValue; }); } const renderParams = { cssVars, slotNames: slotNamesMap, testIds: testIdsMap, dispatch: (event) => element.dispatchEvent(event), events: eventsMap, host: element, inputs: element.instanceInputs, state: element.instanceState, updateState, }; return renderParams; }