@mintjamsinc/ichigojs 0.1.53 → 0.1.55

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.
@@ -11,6 +11,7 @@ export declare class VDOM {
11
11
  /**
12
12
  * Gets the component registry.
13
13
  * @return {VComponentRegistry} The component registry.
14
+ * @deprecated This method is deprecated and will be removed in a future release. Please use the new component registration system instead.
14
15
  */
15
16
  static get componentRegistry(): VComponentRegistry;
16
17
  /**
@@ -0,0 +1,19 @@
1
+ import { VApplicationOptions } from '../VApplicationOptions';
2
+ /**
3
+ * Options for defining a Web Component backed by ichigo.js reactivity.
4
+ * Extends VApplicationOptions with component-specific settings.
5
+ */
6
+ export interface IchigoComponentOptions extends VApplicationOptions {
7
+ /**
8
+ * List of property names to receive from the parent via attribute/property binding.
9
+ * Each name in this list will be exposed as a property setter on the custom element.
10
+ * When the parent updates a bound value (e.g., :items="items"), the component's
11
+ * reactive bindings are updated automatically.
12
+ */
13
+ props?: string[];
14
+ /**
15
+ * CSS selector for the <template> element that defines this component's markup.
16
+ * Example: '#my-card' targets <template id="my-card">.
17
+ */
18
+ template: string;
19
+ }
@@ -0,0 +1,43 @@
1
+ import { VApplicationOptions } from '../VApplicationOptions';
2
+ /**
3
+ * Base class for ichigo.js-backed Web Components (Light DOM, no Shadow DOM).
4
+ *
5
+ * Mount timing:
6
+ * - If the component declares no props, the VApplication is mounted synchronously
7
+ * at the end of connectedCallback (the template is known, no props to wait for).
8
+ * - If the component declares props, the VApplication is mounted the first time
9
+ * _setProp() is called after connectedCallback has prepared the DOM. This
10
+ * guarantees that the parent framework (e.g. ichigo.js VBindDirective) has
11
+ * already delivered at least one prop value before data() is evaluated.
12
+ *
13
+ * Subclasses must set the static fields _template, _props and _buildOptions before
14
+ * calling customElements.define(). defineComponent() handles this automatically.
15
+ */
16
+ export declare class IchigoElement extends HTMLElement {
17
+ #private;
18
+ connectedCallback(): void;
19
+ disconnectedCallback(): void;
20
+ /**
21
+ * Called by the property setters generated by defineComponent().
22
+ * Before mount: stores the value and schedules a mount microtask.
23
+ * After mount: pushes the value directly into the reactive bindings.
24
+ */
25
+ _setProp(name: string, value: any): void;
26
+ /**
27
+ * Called by the property getters generated by defineComponent().
28
+ */
29
+ _getProp(name: string): any;
30
+ /**
31
+ * CSS selector for the component's <template> element (e.g. '#my-card').
32
+ */
33
+ static _template: string;
34
+ /**
35
+ * List of declared prop names. Used to decide whether to defer mounting.
36
+ */
37
+ static _props: string[];
38
+ /**
39
+ * Factory that builds VApplicationOptions from the current prop values.
40
+ * Implemented by defineComponent() as a closure that captures the user's options.
41
+ */
42
+ static _buildOptions: (propValues: Record<string, any>) => VApplicationOptions;
43
+ }
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * Represents a reusable component definition.
3
+ * @deprecated This class is deprecated and will be removed in a future release. Please use the new component registration system instead.
3
4
  */
4
5
  export declare class VComponent {
5
6
  /**
@@ -1,6 +1,7 @@
1
1
  import { VComponent } from './VComponent';
2
2
  /**
3
3
  * A registry for managing component definitions.
4
+ * @deprecated This class is deprecated and will be removed in a future release. Please use the new component registration system instead.
4
5
  */
5
6
  export declare class VComponentRegistry {
6
7
  #private;
@@ -0,0 +1,34 @@
1
+ import { IchigoComponentOptions } from './IchigoComponentOptions';
2
+ /**
3
+ * Defines and registers a custom element backed by ichigo.js reactivity.
4
+ *
5
+ * Usage:
6
+ * ```html
7
+ * <template id="my-list">
8
+ * <div>
9
+ * <ul v-if="items.length > 0">
10
+ * <li v-for="item of items">{{item.name}}</li>
11
+ * </ul>
12
+ * <slot></slot>
13
+ * </div>
14
+ * </template>
15
+ * ```
16
+ * ```typescript
17
+ * defineComponent('my-list', {
18
+ * template: '#my-list',
19
+ * props: ['items'],
20
+ * data() {
21
+ * return { items: this.items ?? [] };
22
+ * },
23
+ * });
24
+ * ```
25
+ * ```html
26
+ * <my-list :items="searchResults">
27
+ * <span slot="empty">No results.</span>
28
+ * </my-list>
29
+ * ```
30
+ *
31
+ * @param tagName Custom element tag name (must contain a hyphen, e.g. 'my-card').
32
+ * @param options Component options including template selector and optional props.
33
+ */
34
+ export declare function defineComponent(tagName: string, options: IchigoComponentOptions): void;
@@ -3,3 +3,6 @@ export { VComponent } from './ichigo/components/VComponent';
3
3
  export { VComponentRegistry } from './ichigo/components/VComponentRegistry';
4
4
  export { ReactiveProxy } from './ichigo/util/ReactiveProxy';
5
5
  export { ExpressionUtils } from './ichigo/util/ExpressionUtils';
6
+ export { defineComponent } from './ichigo/components/defineComponent';
7
+ export type { IchigoComponentOptions } from './ichigo/components/IchigoComponentOptions';
8
+ export { IchigoElement } from './ichigo/components/IchigoElement';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintjamsinc/ichigojs",
3
- "version": "0.1.53",
3
+ "version": "0.1.55",
4
4
  "description": "ichigo.js - Simple and intuitive reactive framework. Lightweight, fast, and user-friendly virtual DOM library",
5
5
  "main": "./dist/ichigo.cjs",
6
6
  "module": "./dist/ichigo.esm.js",