@mintjamsinc/ichigojs 0.1.13 → 0.1.14
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.
- package/dist/ichigo.esm.js +64 -77
- package/dist/ichigo.esm.js.map +1 -1
- package/dist/ichigo.esm.min.js +1 -1
- package/dist/ichigo.esm.min.js.map +1 -1
- package/dist/ichigo.umd.js +64 -77
- package/dist/ichigo.umd.js.map +1 -1
- package/dist/ichigo.umd.min.js +1 -1
- package/dist/ichigo.umd.min.js.map +1 -1
- package/dist/types/ichigo/directives/VComponentDirective.d.ts +1 -8
- package/dist/types/ichigo/directives/VDirectiveManager.d.ts +4 -3
- package/package.json +1 -1
package/dist/ichigo.umd.js
CHANGED
@@ -7228,14 +7228,6 @@
|
|
7228
7228
|
* The virtual node to which this directive is applied.
|
7229
7229
|
*/
|
7230
7230
|
#vNode;
|
7231
|
-
/**
|
7232
|
-
* The component ID expression.
|
7233
|
-
*/
|
7234
|
-
#expression;
|
7235
|
-
/**
|
7236
|
-
* Whether the component ID is static (not reactive).
|
7237
|
-
*/
|
7238
|
-
#isStatic = false;
|
7239
7231
|
/**
|
7240
7232
|
* The component ID to render.
|
7241
7233
|
*/
|
@@ -7250,10 +7242,7 @@
|
|
7250
7242
|
#isActivated = false;
|
7251
7243
|
constructor(context) {
|
7252
7244
|
this.#vNode = context.vNode;
|
7253
|
-
this.#
|
7254
|
-
// Check for .static modifier
|
7255
|
-
const attrName = context.attribute.name;
|
7256
|
-
this.#isStatic = attrName.includes('.static');
|
7245
|
+
this.#componentId = context.attribute.value.trim();
|
7257
7246
|
// Remove the directive attribute from the element
|
7258
7247
|
this.#vNode.node.removeAttribute(context.attribute.name);
|
7259
7248
|
}
|
@@ -7292,7 +7281,7 @@
|
|
7292
7281
|
},
|
7293
7282
|
applyToDOM: () => {
|
7294
7283
|
if (!this.#isActivated) {
|
7295
|
-
this
|
7284
|
+
this.#renderComponent();
|
7296
7285
|
}
|
7297
7286
|
}
|
7298
7287
|
};
|
@@ -7338,7 +7327,7 @@
|
|
7338
7327
|
* @inheritdoc
|
7339
7328
|
*/
|
7340
7329
|
get onUnmount() {
|
7341
|
-
return () => this
|
7330
|
+
return () => this.#cleanupComponent();
|
7342
7331
|
}
|
7343
7332
|
/**
|
7344
7333
|
* @inheritdoc
|
@@ -7346,26 +7335,39 @@
|
|
7346
7335
|
get onUnmounted() {
|
7347
7336
|
return undefined;
|
7348
7337
|
}
|
7338
|
+
cloneNode() {
|
7339
|
+
// Get component definition from the application's component registry
|
7340
|
+
const component = this.#vNode.vApplication.componentRegistry.get(this.#componentId);
|
7341
|
+
if (!component) {
|
7342
|
+
throw new Error(`Component '${this.#componentId}' not found in registry`);
|
7343
|
+
}
|
7344
|
+
// Get template element
|
7345
|
+
const finalTemplateID = component.templateID || component.id;
|
7346
|
+
const templateElement = document.querySelector(`#${finalTemplateID}`);
|
7347
|
+
if (!templateElement || !(templateElement instanceof HTMLTemplateElement)) {
|
7348
|
+
throw new Error(`Template element '#${finalTemplateID}' not found`);
|
7349
|
+
}
|
7350
|
+
// Clone template content
|
7351
|
+
const fragment = templateElement.content.cloneNode(true);
|
7352
|
+
const childNodes = Array.from(fragment.childNodes);
|
7353
|
+
// Find the first element node
|
7354
|
+
for (const node of childNodes) {
|
7355
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
7356
|
+
return node;
|
7357
|
+
}
|
7358
|
+
}
|
7359
|
+
throw new Error(`No element found in template '#${finalTemplateID}'`);
|
7360
|
+
}
|
7349
7361
|
/**
|
7350
7362
|
* @inheritdoc
|
7351
7363
|
*/
|
7352
7364
|
destroy() {
|
7353
|
-
this
|
7365
|
+
this.#cleanupComponent();
|
7354
7366
|
}
|
7355
7367
|
/**
|
7356
7368
|
* Renders the component.
|
7357
7369
|
*/
|
7358
|
-
renderComponent() {
|
7359
|
-
const element = this.#vNode.node;
|
7360
|
-
if (!element) {
|
7361
|
-
return;
|
7362
|
-
}
|
7363
|
-
// For now, only support static component IDs
|
7364
|
-
const componentId = this.#expression.trim();
|
7365
|
-
if (!componentId) {
|
7366
|
-
console.warn(`Component ID is empty for v-component directive`);
|
7367
|
-
return;
|
7368
|
-
}
|
7370
|
+
#renderComponent() {
|
7369
7371
|
// Get properties from :options or :options.component directive
|
7370
7372
|
let properties = {};
|
7371
7373
|
const optionsDirective = this.#vNode.directiveManager?.optionsDirective('component');
|
@@ -7381,60 +7383,22 @@
|
|
7381
7383
|
properties = result;
|
7382
7384
|
}
|
7383
7385
|
}
|
7384
|
-
// Store component ID
|
7385
|
-
this.#componentId = componentId;
|
7386
7386
|
// Get component definition from the application's component registry
|
7387
|
-
const
|
7388
|
-
if (!vApplication) {
|
7389
|
-
console.error('VApplication not found on VNode');
|
7390
|
-
return;
|
7391
|
-
}
|
7392
|
-
const component = vApplication.componentRegistry.get(componentId);
|
7387
|
+
const component = this.#vNode.vApplication.componentRegistry.get(this.#componentId);
|
7393
7388
|
if (!component) {
|
7394
|
-
|
7395
|
-
return;
|
7389
|
+
throw new Error(`Component '${this.#componentId}' not found in registry`);
|
7396
7390
|
}
|
7397
|
-
// Get template element
|
7398
|
-
const finalTemplateID = component.templateID;
|
7399
|
-
const templateElement = document.querySelector(`#${finalTemplateID}`);
|
7400
|
-
if (!templateElement || !(templateElement instanceof HTMLTemplateElement)) {
|
7401
|
-
console.error(`Template element '#${finalTemplateID}' not found`);
|
7402
|
-
return;
|
7403
|
-
}
|
7404
|
-
// Clone template content
|
7405
|
-
const fragment = templateElement.content.cloneNode(true);
|
7406
|
-
const childNodes = Array.from(fragment.childNodes);
|
7407
|
-
// Find the first element node
|
7408
|
-
let componentElement;
|
7409
|
-
for (const node of childNodes) {
|
7410
|
-
if (node.nodeType === Node.ELEMENT_NODE) {
|
7411
|
-
componentElement = node;
|
7412
|
-
break;
|
7413
|
-
}
|
7414
|
-
}
|
7415
|
-
if (!componentElement) {
|
7416
|
-
console.error(`No element found in template '#${finalTemplateID}'`);
|
7417
|
-
return;
|
7418
|
-
}
|
7419
|
-
// Replace element with component element
|
7420
|
-
const parent = element.parentNode;
|
7421
|
-
if (!parent) {
|
7422
|
-
console.error(`Element has no parent node. Component '${componentId}' cannot be mounted.`);
|
7423
|
-
return;
|
7424
|
-
}
|
7425
|
-
parent.insertBefore(componentElement, element);
|
7426
|
-
parent.removeChild(element);
|
7427
7391
|
// Create component instance
|
7428
7392
|
const instance = component.createInstance(properties);
|
7429
7393
|
// Create and mount child application using the parent application's registries
|
7430
|
-
this.#childApp = vApplication.createChildApp(instance);
|
7431
|
-
this.#childApp.mount(
|
7394
|
+
this.#childApp = this.#vNode.vApplication.createChildApp(instance);
|
7395
|
+
this.#childApp.mount(this.#vNode.node);
|
7432
7396
|
this.#isActivated = true;
|
7433
7397
|
}
|
7434
7398
|
/**
|
7435
7399
|
* Cleans up the component.
|
7436
7400
|
*/
|
7437
|
-
cleanupComponent() {
|
7401
|
+
#cleanupComponent() {
|
7438
7402
|
if (this.#childApp) {
|
7439
7403
|
this.#childApp.unmount();
|
7440
7404
|
this.#childApp = undefined;
|
@@ -7774,6 +7738,11 @@
|
|
7774
7738
|
* The keys are directive names (e.g., 'options', 'options.intersection').
|
7775
7739
|
*/
|
7776
7740
|
#optionsDirectives = {};
|
7741
|
+
/**
|
7742
|
+
* The v-component directive associated with this node, if any.
|
7743
|
+
* This may be undefined if there is no v-component directive.
|
7744
|
+
*/
|
7745
|
+
#componentDirective;
|
7777
7746
|
constructor(vNode) {
|
7778
7747
|
// Directives can only be associated with element nodes
|
7779
7748
|
if (vNode.nodeType !== Node.ELEMENT_NODE) {
|
@@ -7832,11 +7801,11 @@
|
|
7832
7801
|
return this.#keyDirective;
|
7833
7802
|
}
|
7834
7803
|
/**
|
7835
|
-
* Gets
|
7836
|
-
*
|
7804
|
+
* Gets the v-component directive associated with this node, if any.
|
7805
|
+
* This may be undefined if there is no v-component directive.
|
7837
7806
|
*/
|
7838
|
-
get
|
7839
|
-
return this.#
|
7807
|
+
get componentDirective() {
|
7808
|
+
return this.#componentDirective;
|
7840
7809
|
}
|
7841
7810
|
/**
|
7842
7811
|
* Gets the VBindDirective for options specific to the given directive name.
|
@@ -7927,6 +7896,10 @@
|
|
7927
7896
|
this.#optionsDirectives[attrName] = bindDirective;
|
7928
7897
|
}
|
7929
7898
|
}
|
7899
|
+
// If this is a v-component directive, store it separately
|
7900
|
+
if (directive.name === StandardDirectiveName.V_COMPONENT) {
|
7901
|
+
this.#componentDirective = directive;
|
7902
|
+
}
|
7930
7903
|
}
|
7931
7904
|
}
|
7932
7905
|
// Sort directives by priority: v-for > v-if > v-else-if > v-else > v-show > others
|
@@ -8880,8 +8853,15 @@
|
|
8880
8853
|
* Clones the template element and creates a new VNode for the cloned element.
|
8881
8854
|
*/
|
8882
8855
|
#cloneTemplate() {
|
8883
|
-
|
8884
|
-
|
8856
|
+
// Clone the original element
|
8857
|
+
let clone;
|
8858
|
+
if (this.vNode.directiveManager?.componentDirective) {
|
8859
|
+
clone = this.vNode.directiveManager.componentDirective.cloneNode();
|
8860
|
+
}
|
8861
|
+
else {
|
8862
|
+
const element = this.#vNode.node;
|
8863
|
+
clone = element.cloneNode(true);
|
8864
|
+
}
|
8885
8865
|
// Create a new VNode for the cloned element
|
8886
8866
|
const vNode = new VNode({
|
8887
8867
|
node: clone,
|
@@ -9316,8 +9296,15 @@
|
|
9316
9296
|
* Clone template element for each iteration and create a new VNode
|
9317
9297
|
*/
|
9318
9298
|
#cloneTemplate(context) {
|
9319
|
-
|
9320
|
-
|
9299
|
+
// Clone the original element
|
9300
|
+
let clone;
|
9301
|
+
if (this.vNode.directiveManager?.componentDirective) {
|
9302
|
+
clone = this.vNode.directiveManager.componentDirective.cloneNode();
|
9303
|
+
}
|
9304
|
+
else {
|
9305
|
+
const element = this.#vNode.node;
|
9306
|
+
clone = element.cloneNode(true);
|
9307
|
+
}
|
9321
9308
|
// Prepare identifiers for the item
|
9322
9309
|
this.#itemName;
|
9323
9310
|
this.#indexName;
|