@xaendar/core 0.6.18 → 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.
@@ -510,7 +510,7 @@ declare type RenderElementEvent = {
510
510
  /**
511
511
  * Event Parameters
512
512
  */
513
- parameters: NoArgsFunction<unknown>[];
513
+ parameters: Function_2<[Event], unknown>[];
514
514
  };
515
515
 
516
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)(...event.parameters.map((event) => event()));
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.18",
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.18",
20
- "@xaendar/types": "0.6.18"
19
+ "@xaendar/signals": "0.6.19",
20
+ "@xaendar/types": "0.6.19"
21
21
  }
22
22
  }