@ffsm/compositor
Version:
A collection of declarative React utility components for simplified component composition, conditional rendering, and prop management - making React UI development more maintainable and expressive.
56 lines (55 loc) • 1.92 kB
JavaScript
var CompositorEvent = /** @class */ (function () {
function CompositorEvent(name, value, bubbles, cancelable) {
if (bubbles === void 0) { bubbles = true; }
if (cancelable === void 0) { cancelable = true; }
this.name = name;
this.value = value;
this.bubbles = bubbles;
this.cancelable = cancelable;
this._isDefaultPrevented = false;
this._isPropagationStopped = false;
this.target = {
name: name,
value: value,
};
this.currentTarget = {
name: name,
value: value,
};
}
CompositorEvent.prototype.preventDefault = function () {
this._isDefaultPrevented = true;
};
CompositorEvent.prototype.stopPropagation = function () {
this._isPropagationStopped = true;
};
CompositorEvent.prototype.isDefaultPrevented = function () {
return this._isDefaultPrevented;
};
CompositorEvent.prototype.isPropagationStopped = function () {
return this._isPropagationStopped;
};
return CompositorEvent;
}());
/**
* Creates a new Compositor event with specified name and value.
*
* @template Ev - The type to cast the returned event to
* @param {string | undefined} name - The name of the event, can be undefined
* @param {unknown} value - The value associated with the event
* @returns {Ev} A new CompositorEvent instance cast to the specified type Ev
*
* @example
* // Create a simple event
* const clickEvent = createEvent<ClickEvent>('click', { x: 100, y: 200 });
*
* @example
* // Create an event with a specific type
* interface FormSubmitEvent extends CompositorEvent {
* formData: Record<string, unknown>;
* }
* const submitEvent = createEvent<FormSubmitEvent>('submit', { formData: { name: 'John' } });
*/
export function createEvent(name, value) {
return new CompositorEvent(name, value);
}