@xaendar/core 0.6.17 → 0.6.19

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.
@@ -10,6 +10,7 @@ import { NoArgsVoidFunction as NoArgsVoidFunction_2 } from '@xaendar/types';
10
10
  import { RequireOne } from '@xaendar/types';
11
11
  import { SignalOptions } from '@xaendar/signals';
12
12
  import { VoidFunction as VoidFunction_2 } from '@xaendar/types';
13
+ import { VoidFunction as VoidFunction_3 } from '@xaendar/types';
13
14
 
14
15
  /**
15
16
  * Base class for all web components in the framework.
@@ -153,7 +154,7 @@ export declare class Context {
153
154
  * @param handler - The name of the method on the root component to retrieve.
154
155
  * @returns The handler function, bound to the root component so `this` is correct.
155
156
  */
156
- getEventHandler(handler: string): VoidFunction;
157
+ getEventHandler(handler: string): VoidFunction_2;
157
158
  /**
158
159
  * Registers a child context as a nested scope of this context.
159
160
  *
@@ -391,7 +392,7 @@ export declare function _iterationVariables(items: unknown[], index: number, ite
391
392
  * @template Value - The type of the value to emit as the event detail. Defaults to `void`.
392
393
  */
393
394
  export declare type Output<Value = void> = {
394
- emit: VoidFunction_2<Value extends void ? ([EventOptions] | []) : ([Value, EventOptions] | [Value])>;
395
+ emit: VoidFunction_3<Value extends void ? ([EventOptions] | []) : ([Value, EventOptions] | [Value])>;
395
396
  };
396
397
 
397
398
  /**
@@ -506,6 +507,10 @@ declare type RenderElementEvent = {
506
507
  * The name of the handler method on the component class to invoke when the event fires.
507
508
  */
508
509
  handler: string;
510
+ /**
511
+ * Event Parameters
512
+ */
513
+ parameters: Function_2<[Event], unknown>[];
509
514
  };
510
515
 
511
516
  /**
@@ -771,6 +771,43 @@ function checkAndUpdateState(parentNode, parentContext, state, newState, conditi
771
771
  }
772
772
  }
773
773
  //#endregion
774
+ //#region ../packages/core/src/utils/render-element.util.ts
775
+ /**
776
+ * Creates a DOM element, applies attributes and event listeners, appends it
777
+ * to the parent, and registers cleanup functions in the current context.
778
+ *
779
+ * Static (literal) attribute values are set once via `setAttribute`. Dynamic
780
+ * attribute values are wrapped in a reactive `effect` so they update
781
+ * automatically whenever the underlying signal changes. Event listeners are
782
+ * attached with `addEventListener` and the corresponding `removeEventListener`
783
+ * is registered as a cleanup function.
784
+ *
785
+ * @param parentNode - The parent HTML element to append the new element to.
786
+ * @param context - The current template execution scope.
787
+ * @param tagName - The HTML tag name of the element to create.
788
+ * @param attributes - List of attribute descriptors to apply to the element.
789
+ * @param events - List of event listener descriptors to attach to the element.
790
+ * @returns The newly created HTML element.
791
+ */
792
+ function _renderElement(parentNode, context, tagName, attributes, events) {
793
+ const element = document.createElement(tagName);
794
+ parentNode.appendChild(element);
795
+ context.listen(() => {
796
+ context.removeNode(element);
797
+ parentNode.removeChild(element);
798
+ });
799
+ attributes.forEach(({ name, value, literal }) => {
800
+ literal ? element.setAttribute(name, String(value())) : context.listen(effect(() => element.setAttribute(name, String(value()))));
801
+ });
802
+ events.forEach((event) => {
803
+ const handler = ($event) => context.getEventHandler(event.handler)(...event.parameters.map((event) => event($event)));
804
+ const name = event.name;
805
+ element.addEventListener(name, handler);
806
+ context.listen(() => element.removeEventListener(name, handler));
807
+ });
808
+ return element;
809
+ }
810
+ //#endregion
774
811
  //#region ../packages/core/src/utils/render-text.util.ts
775
812
  /**
776
813
  * Creates a reactive text node bound to a named identifier in the current scope.
@@ -809,43 +846,6 @@ function _renderLiteralText(parentNode, context, text) {
809
846
  context.listen(() => parentNode.removeChild(node));
810
847
  }
811
848
  //#endregion
812
- //#region ../packages/core/src/utils/render-util.ts
813
- /**
814
- * Creates a DOM element, applies attributes and event listeners, appends it
815
- * to the parent, and registers cleanup functions in the current context.
816
- *
817
- * Static (literal) attribute values are set once via `setAttribute`. Dynamic
818
- * attribute values are wrapped in a reactive `effect` so they update
819
- * automatically whenever the underlying signal changes. Event listeners are
820
- * attached with `addEventListener` and the corresponding `removeEventListener`
821
- * is registered as a cleanup function.
822
- *
823
- * @param parentNode - The parent HTML element to append the new element to.
824
- * @param context - The current template execution scope.
825
- * @param tagName - The HTML tag name of the element to create.
826
- * @param attributes - List of attribute descriptors to apply to the element.
827
- * @param events - List of event listener descriptors to attach to the element.
828
- * @returns The newly created HTML element.
829
- */
830
- function _renderElement(parentNode, context, tagName, attributes, events) {
831
- const element = document.createElement(tagName);
832
- parentNode.appendChild(element);
833
- context.listen(() => {
834
- context.removeNode(element);
835
- parentNode.removeChild(element);
836
- });
837
- attributes.forEach(({ name, value, literal }) => {
838
- literal ? element.setAttribute(name, String(value())) : context.listen(effect(() => element.setAttribute(name, String(value()))));
839
- });
840
- events.forEach((event) => {
841
- const handler = ($event) => context.getEventHandler(event.handler)();
842
- const name = event.name;
843
- element.addEventListener(name, handler);
844
- context.listen(() => element.removeEventListener(name, handler));
845
- });
846
- return element;
847
- }
848
- //#endregion
849
849
  //#region ../packages/core/src/utils/switch.util.ts
850
850
  /**
851
851
  * Creates a reactive switch/case structure by converting it into an if/else-if chain
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaendar/core",
3
- "version": "0.6.17",
3
+ "version": "0.6.19",
4
4
  "description": "A library containing core utils such as webcomponent base classes and theming support",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -16,7 +16,7 @@
16
16
  }
17
17
  },
18
18
  "dependencies": {
19
- "@xaendar/signals": "0.6.17",
20
- "@xaendar/types": "0.6.17"
19
+ "@xaendar/signals": "0.6.19",
20
+ "@xaendar/types": "0.6.19"
21
21
  }
22
22
  }