@mintjamsinc/ichigojs 0.1.13 → 0.1.15
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 +61 -106
- 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 +61 -106
- 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 +0 -8
- package/dist/types/ichigo/directives/VDirectiveManager.d.ts +0 -5
- package/package.json +1 -1
package/dist/ichigo.umd.js
CHANGED
@@ -6962,14 +6962,13 @@
|
|
6962
6962
|
*/
|
6963
6963
|
get domUpdater() {
|
6964
6964
|
const identifiers = this.#dependentIdentifiers ?? [];
|
6965
|
-
const render = () => this.#render();
|
6966
6965
|
// Create an updater that handles the attribute binding
|
6967
6966
|
const updater = {
|
6968
6967
|
get dependentIdentifiers() {
|
6969
6968
|
return identifiers;
|
6970
6969
|
},
|
6971
|
-
applyToDOM() {
|
6972
|
-
render();
|
6970
|
+
applyToDOM: () => {
|
6971
|
+
this.#render();
|
6973
6972
|
}
|
6974
6973
|
};
|
6975
6974
|
return updater;
|
@@ -7228,32 +7227,17 @@
|
|
7228
7227
|
* The virtual node to which this directive is applied.
|
7229
7228
|
*/
|
7230
7229
|
#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
7230
|
/**
|
7240
7231
|
* The component ID to render.
|
7241
7232
|
*/
|
7242
7233
|
#componentId;
|
7243
7234
|
/**
|
7244
|
-
* The
|
7235
|
+
* The application instance for the component.
|
7245
7236
|
*/
|
7246
|
-
#
|
7247
|
-
/**
|
7248
|
-
* Whether the component has been activated.
|
7249
|
-
*/
|
7250
|
-
#isActivated = false;
|
7237
|
+
#componentApp;
|
7251
7238
|
constructor(context) {
|
7252
7239
|
this.#vNode = context.vNode;
|
7253
|
-
this.#
|
7254
|
-
// Check for .static modifier
|
7255
|
-
const attrName = context.attribute.name;
|
7256
|
-
this.#isStatic = attrName.includes('.static');
|
7240
|
+
this.#componentId = context.attribute.value.trim();
|
7257
7241
|
// Remove the directive attribute from the element
|
7258
7242
|
this.#vNode.node.removeAttribute(context.attribute.name);
|
7259
7243
|
}
|
@@ -7273,7 +7257,7 @@
|
|
7273
7257
|
* @inheritdoc
|
7274
7258
|
*/
|
7275
7259
|
get needsAnchor() {
|
7276
|
-
return
|
7260
|
+
return true;
|
7277
7261
|
}
|
7278
7262
|
/**
|
7279
7263
|
* @inheritdoc
|
@@ -7291,9 +7275,7 @@
|
|
7291
7275
|
return [];
|
7292
7276
|
},
|
7293
7277
|
applyToDOM: () => {
|
7294
|
-
|
7295
|
-
this.renderComponent();
|
7296
|
-
}
|
7278
|
+
this.#render();
|
7297
7279
|
}
|
7298
7280
|
};
|
7299
7281
|
return updater;
|
@@ -7302,7 +7284,7 @@
|
|
7302
7284
|
* @inheritdoc
|
7303
7285
|
*/
|
7304
7286
|
get templatize() {
|
7305
|
-
return
|
7287
|
+
return true;
|
7306
7288
|
}
|
7307
7289
|
/**
|
7308
7290
|
* @inheritdoc
|
@@ -7338,7 +7320,7 @@
|
|
7338
7320
|
* @inheritdoc
|
7339
7321
|
*/
|
7340
7322
|
get onUnmount() {
|
7341
|
-
return
|
7323
|
+
return undefined;
|
7342
7324
|
}
|
7343
7325
|
/**
|
7344
7326
|
* @inheritdoc
|
@@ -7346,26 +7328,56 @@
|
|
7346
7328
|
get onUnmounted() {
|
7347
7329
|
return undefined;
|
7348
7330
|
}
|
7331
|
+
#cloneNode() {
|
7332
|
+
// Get component definition from the application's component registry
|
7333
|
+
const component = this.#vNode.vApplication.componentRegistry.get(this.#componentId);
|
7334
|
+
if (!component) {
|
7335
|
+
throw new Error(`Component '${this.#componentId}' not found in registry`);
|
7336
|
+
}
|
7337
|
+
// Get template element
|
7338
|
+
const finalTemplateID = component.templateID || component.id;
|
7339
|
+
const templateElement = document.querySelector(`#${finalTemplateID}`);
|
7340
|
+
if (!templateElement || !(templateElement instanceof HTMLTemplateElement)) {
|
7341
|
+
throw new Error(`Template element '#${finalTemplateID}' not found`);
|
7342
|
+
}
|
7343
|
+
// Clone template content
|
7344
|
+
const fragment = templateElement.content.cloneNode(true);
|
7345
|
+
const childNodes = Array.from(fragment.childNodes);
|
7346
|
+
// Find the first element node
|
7347
|
+
for (const node of childNodes) {
|
7348
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
7349
|
+
return node;
|
7350
|
+
}
|
7351
|
+
}
|
7352
|
+
throw new Error(`No element found in template '#${finalTemplateID}'`);
|
7353
|
+
}
|
7349
7354
|
/**
|
7350
7355
|
* @inheritdoc
|
7351
7356
|
*/
|
7352
7357
|
destroy() {
|
7353
|
-
this
|
7358
|
+
if (!this.#componentApp) {
|
7359
|
+
// Not rendered, no action needed
|
7360
|
+
return;
|
7361
|
+
}
|
7362
|
+
// Destroy component application first (calls @unmount hooks while DOM is still accessible)
|
7363
|
+
this.#componentApp.unmount();
|
7364
|
+
// Then remove from DOM
|
7365
|
+
const componentVNode = this.#componentApp.rootVNode;
|
7366
|
+
if (componentVNode?.node.parentNode) {
|
7367
|
+
componentVNode.node.parentNode.removeChild(componentVNode.node);
|
7368
|
+
}
|
7369
|
+
this.#componentApp = undefined;
|
7354
7370
|
}
|
7355
7371
|
/**
|
7356
7372
|
* Renders the component.
|
7357
7373
|
*/
|
7358
|
-
|
7359
|
-
|
7360
|
-
|
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`);
|
7374
|
+
#render() {
|
7375
|
+
if (this.#componentApp) {
|
7376
|
+
// Already rendered, no action needed
|
7367
7377
|
return;
|
7368
7378
|
}
|
7379
|
+
const clone = this.#cloneNode();
|
7380
|
+
this.#vNode.anchorNode?.parentNode?.insertBefore(clone, this.#vNode.anchorNode.nextSibling);
|
7369
7381
|
// Get properties from :options or :options.component directive
|
7370
7382
|
let properties = {};
|
7371
7383
|
const optionsDirective = this.#vNode.directiveManager?.optionsDirective('component');
|
@@ -7381,65 +7393,16 @@
|
|
7381
7393
|
properties = result;
|
7382
7394
|
}
|
7383
7395
|
}
|
7384
|
-
// Store component ID
|
7385
|
-
this.#componentId = componentId;
|
7386
7396
|
// 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);
|
7397
|
+
const component = this.#vNode.vApplication.componentRegistry.get(this.#componentId);
|
7393
7398
|
if (!component) {
|
7394
|
-
|
7395
|
-
return;
|
7396
|
-
}
|
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;
|
7399
|
+
throw new Error(`Component '${this.#componentId}' not found in registry`);
|
7424
7400
|
}
|
7425
|
-
parent.insertBefore(componentElement, element);
|
7426
|
-
parent.removeChild(element);
|
7427
7401
|
// Create component instance
|
7428
7402
|
const instance = component.createInstance(properties);
|
7429
7403
|
// Create and mount child application using the parent application's registries
|
7430
|
-
this.#
|
7431
|
-
this.#
|
7432
|
-
this.#isActivated = true;
|
7433
|
-
}
|
7434
|
-
/**
|
7435
|
-
* Cleans up the component.
|
7436
|
-
*/
|
7437
|
-
cleanupComponent() {
|
7438
|
-
if (this.#childApp) {
|
7439
|
-
this.#childApp.unmount();
|
7440
|
-
this.#childApp = undefined;
|
7441
|
-
}
|
7442
|
-
this.#isActivated = false;
|
7404
|
+
this.#componentApp = this.#vNode.vApplication.createChildApp(instance);
|
7405
|
+
this.#componentApp.mount(clone);
|
7443
7406
|
}
|
7444
7407
|
}
|
7445
7408
|
|
@@ -7831,13 +7794,6 @@
|
|
7831
7794
|
get keyDirective() {
|
7832
7795
|
return this.#keyDirective;
|
7833
7796
|
}
|
7834
|
-
/**
|
7835
|
-
* Gets a record of VBindDirectives for options specific to certain directives.
|
7836
|
-
* The keys are directive names (e.g., 'options', 'options.intersection').
|
7837
|
-
*/
|
7838
|
-
get optionsDirectives() {
|
7839
|
-
return this.#optionsDirectives;
|
7840
|
-
}
|
7841
7797
|
/**
|
7842
7798
|
* Gets the VBindDirective for options specific to the given directive name.
|
7843
7799
|
* Searches in order: `:options.{directive}` -> `:options`
|
@@ -8738,14 +8694,13 @@
|
|
8738
8694
|
*/
|
8739
8695
|
get domUpdater() {
|
8740
8696
|
const identifiers = this.#conditionalContext.allDependentIdentifiers;
|
8741
|
-
const render = () => this.#render();
|
8742
8697
|
// Create an updater that handles the conditional rendering
|
8743
8698
|
const updater = {
|
8744
8699
|
get dependentIdentifiers() {
|
8745
8700
|
return identifiers;
|
8746
8701
|
},
|
8747
|
-
applyToDOM() {
|
8748
|
-
render();
|
8702
|
+
applyToDOM: () => {
|
8703
|
+
this.#render();
|
8749
8704
|
}
|
8750
8705
|
};
|
8751
8706
|
return updater;
|
@@ -8880,6 +8835,7 @@
|
|
8880
8835
|
* Clones the template element and creates a new VNode for the cloned element.
|
8881
8836
|
*/
|
8882
8837
|
#cloneTemplate() {
|
8838
|
+
// Clone the original element
|
8883
8839
|
const element = this.#vNode.node;
|
8884
8840
|
const clone = element.cloneNode(true);
|
8885
8841
|
// Create a new VNode for the cloned element
|
@@ -9078,14 +9034,13 @@
|
|
9078
9034
|
*/
|
9079
9035
|
get domUpdater() {
|
9080
9036
|
const identifiers = this.#dependentIdentifiers ?? [];
|
9081
|
-
const render = () => this.#render();
|
9082
9037
|
// Create and return the DOM updater
|
9083
9038
|
const updater = {
|
9084
9039
|
get dependentIdentifiers() {
|
9085
9040
|
return identifiers;
|
9086
9041
|
},
|
9087
|
-
applyToDOM() {
|
9088
|
-
render();
|
9042
|
+
applyToDOM: () => {
|
9043
|
+
this.#render();
|
9089
9044
|
}
|
9090
9045
|
};
|
9091
9046
|
return updater;
|
@@ -9316,6 +9271,7 @@
|
|
9316
9271
|
* Clone template element for each iteration and create a new VNode
|
9317
9272
|
*/
|
9318
9273
|
#cloneTemplate(context) {
|
9274
|
+
// Clone the original element
|
9319
9275
|
const element = this.#vNode.node;
|
9320
9276
|
const clone = element.cloneNode(true);
|
9321
9277
|
// Prepare identifiers for the item
|
@@ -9713,14 +9669,13 @@
|
|
9713
9669
|
*/
|
9714
9670
|
get domUpdater() {
|
9715
9671
|
const identifiers = this.#dependentIdentifiers ?? [];
|
9716
|
-
const render = () => this.#render();
|
9717
9672
|
// Create and return the DOM updater
|
9718
9673
|
const updater = {
|
9719
9674
|
get dependentIdentifiers() {
|
9720
9675
|
return identifiers;
|
9721
9676
|
},
|
9722
|
-
applyToDOM() {
|
9723
|
-
render();
|
9677
|
+
applyToDOM: () => {
|
9678
|
+
this.#render();
|
9724
9679
|
}
|
9725
9680
|
};
|
9726
9681
|
return updater;
|