@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.esm.js
CHANGED
@@ -6956,14 +6956,13 @@ class VBindDirective {
|
|
6956
6956
|
*/
|
6957
6957
|
get domUpdater() {
|
6958
6958
|
const identifiers = this.#dependentIdentifiers ?? [];
|
6959
|
-
const render = () => this.#render();
|
6960
6959
|
// Create an updater that handles the attribute binding
|
6961
6960
|
const updater = {
|
6962
6961
|
get dependentIdentifiers() {
|
6963
6962
|
return identifiers;
|
6964
6963
|
},
|
6965
|
-
applyToDOM() {
|
6966
|
-
render();
|
6964
|
+
applyToDOM: () => {
|
6965
|
+
this.#render();
|
6967
6966
|
}
|
6968
6967
|
};
|
6969
6968
|
return updater;
|
@@ -7222,32 +7221,17 @@ class VComponentDirective {
|
|
7222
7221
|
* The virtual node to which this directive is applied.
|
7223
7222
|
*/
|
7224
7223
|
#vNode;
|
7225
|
-
/**
|
7226
|
-
* The component ID expression.
|
7227
|
-
*/
|
7228
|
-
#expression;
|
7229
|
-
/**
|
7230
|
-
* Whether the component ID is static (not reactive).
|
7231
|
-
*/
|
7232
|
-
#isStatic = false;
|
7233
7224
|
/**
|
7234
7225
|
* The component ID to render.
|
7235
7226
|
*/
|
7236
7227
|
#componentId;
|
7237
7228
|
/**
|
7238
|
-
* The
|
7229
|
+
* The application instance for the component.
|
7239
7230
|
*/
|
7240
|
-
#
|
7241
|
-
/**
|
7242
|
-
* Whether the component has been activated.
|
7243
|
-
*/
|
7244
|
-
#isActivated = false;
|
7231
|
+
#componentApp;
|
7245
7232
|
constructor(context) {
|
7246
7233
|
this.#vNode = context.vNode;
|
7247
|
-
this.#
|
7248
|
-
// Check for .static modifier
|
7249
|
-
const attrName = context.attribute.name;
|
7250
|
-
this.#isStatic = attrName.includes('.static');
|
7234
|
+
this.#componentId = context.attribute.value.trim();
|
7251
7235
|
// Remove the directive attribute from the element
|
7252
7236
|
this.#vNode.node.removeAttribute(context.attribute.name);
|
7253
7237
|
}
|
@@ -7267,7 +7251,7 @@ class VComponentDirective {
|
|
7267
7251
|
* @inheritdoc
|
7268
7252
|
*/
|
7269
7253
|
get needsAnchor() {
|
7270
|
-
return
|
7254
|
+
return true;
|
7271
7255
|
}
|
7272
7256
|
/**
|
7273
7257
|
* @inheritdoc
|
@@ -7285,9 +7269,7 @@ class VComponentDirective {
|
|
7285
7269
|
return [];
|
7286
7270
|
},
|
7287
7271
|
applyToDOM: () => {
|
7288
|
-
|
7289
|
-
this.renderComponent();
|
7290
|
-
}
|
7272
|
+
this.#render();
|
7291
7273
|
}
|
7292
7274
|
};
|
7293
7275
|
return updater;
|
@@ -7296,7 +7278,7 @@ class VComponentDirective {
|
|
7296
7278
|
* @inheritdoc
|
7297
7279
|
*/
|
7298
7280
|
get templatize() {
|
7299
|
-
return
|
7281
|
+
return true;
|
7300
7282
|
}
|
7301
7283
|
/**
|
7302
7284
|
* @inheritdoc
|
@@ -7332,7 +7314,7 @@ class VComponentDirective {
|
|
7332
7314
|
* @inheritdoc
|
7333
7315
|
*/
|
7334
7316
|
get onUnmount() {
|
7335
|
-
return
|
7317
|
+
return undefined;
|
7336
7318
|
}
|
7337
7319
|
/**
|
7338
7320
|
* @inheritdoc
|
@@ -7340,26 +7322,56 @@ class VComponentDirective {
|
|
7340
7322
|
get onUnmounted() {
|
7341
7323
|
return undefined;
|
7342
7324
|
}
|
7325
|
+
#cloneNode() {
|
7326
|
+
// Get component definition from the application's component registry
|
7327
|
+
const component = this.#vNode.vApplication.componentRegistry.get(this.#componentId);
|
7328
|
+
if (!component) {
|
7329
|
+
throw new Error(`Component '${this.#componentId}' not found in registry`);
|
7330
|
+
}
|
7331
|
+
// Get template element
|
7332
|
+
const finalTemplateID = component.templateID || component.id;
|
7333
|
+
const templateElement = document.querySelector(`#${finalTemplateID}`);
|
7334
|
+
if (!templateElement || !(templateElement instanceof HTMLTemplateElement)) {
|
7335
|
+
throw new Error(`Template element '#${finalTemplateID}' not found`);
|
7336
|
+
}
|
7337
|
+
// Clone template content
|
7338
|
+
const fragment = templateElement.content.cloneNode(true);
|
7339
|
+
const childNodes = Array.from(fragment.childNodes);
|
7340
|
+
// Find the first element node
|
7341
|
+
for (const node of childNodes) {
|
7342
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
7343
|
+
return node;
|
7344
|
+
}
|
7345
|
+
}
|
7346
|
+
throw new Error(`No element found in template '#${finalTemplateID}'`);
|
7347
|
+
}
|
7343
7348
|
/**
|
7344
7349
|
* @inheritdoc
|
7345
7350
|
*/
|
7346
7351
|
destroy() {
|
7347
|
-
this
|
7352
|
+
if (!this.#componentApp) {
|
7353
|
+
// Not rendered, no action needed
|
7354
|
+
return;
|
7355
|
+
}
|
7356
|
+
// Destroy component application first (calls @unmount hooks while DOM is still accessible)
|
7357
|
+
this.#componentApp.unmount();
|
7358
|
+
// Then remove from DOM
|
7359
|
+
const componentVNode = this.#componentApp.rootVNode;
|
7360
|
+
if (componentVNode?.node.parentNode) {
|
7361
|
+
componentVNode.node.parentNode.removeChild(componentVNode.node);
|
7362
|
+
}
|
7363
|
+
this.#componentApp = undefined;
|
7348
7364
|
}
|
7349
7365
|
/**
|
7350
7366
|
* Renders the component.
|
7351
7367
|
*/
|
7352
|
-
|
7353
|
-
|
7354
|
-
|
7355
|
-
return;
|
7356
|
-
}
|
7357
|
-
// For now, only support static component IDs
|
7358
|
-
const componentId = this.#expression.trim();
|
7359
|
-
if (!componentId) {
|
7360
|
-
console.warn(`Component ID is empty for v-component directive`);
|
7368
|
+
#render() {
|
7369
|
+
if (this.#componentApp) {
|
7370
|
+
// Already rendered, no action needed
|
7361
7371
|
return;
|
7362
7372
|
}
|
7373
|
+
const clone = this.#cloneNode();
|
7374
|
+
this.#vNode.anchorNode?.parentNode?.insertBefore(clone, this.#vNode.anchorNode.nextSibling);
|
7363
7375
|
// Get properties from :options or :options.component directive
|
7364
7376
|
let properties = {};
|
7365
7377
|
const optionsDirective = this.#vNode.directiveManager?.optionsDirective('component');
|
@@ -7375,65 +7387,16 @@ class VComponentDirective {
|
|
7375
7387
|
properties = result;
|
7376
7388
|
}
|
7377
7389
|
}
|
7378
|
-
// Store component ID
|
7379
|
-
this.#componentId = componentId;
|
7380
7390
|
// Get component definition from the application's component registry
|
7381
|
-
const
|
7382
|
-
if (!vApplication) {
|
7383
|
-
console.error('VApplication not found on VNode');
|
7384
|
-
return;
|
7385
|
-
}
|
7386
|
-
const component = vApplication.componentRegistry.get(componentId);
|
7391
|
+
const component = this.#vNode.vApplication.componentRegistry.get(this.#componentId);
|
7387
7392
|
if (!component) {
|
7388
|
-
|
7389
|
-
return;
|
7390
|
-
}
|
7391
|
-
// Get template element
|
7392
|
-
const finalTemplateID = component.templateID;
|
7393
|
-
const templateElement = document.querySelector(`#${finalTemplateID}`);
|
7394
|
-
if (!templateElement || !(templateElement instanceof HTMLTemplateElement)) {
|
7395
|
-
console.error(`Template element '#${finalTemplateID}' not found`);
|
7396
|
-
return;
|
7397
|
-
}
|
7398
|
-
// Clone template content
|
7399
|
-
const fragment = templateElement.content.cloneNode(true);
|
7400
|
-
const childNodes = Array.from(fragment.childNodes);
|
7401
|
-
// Find the first element node
|
7402
|
-
let componentElement;
|
7403
|
-
for (const node of childNodes) {
|
7404
|
-
if (node.nodeType === Node.ELEMENT_NODE) {
|
7405
|
-
componentElement = node;
|
7406
|
-
break;
|
7407
|
-
}
|
7408
|
-
}
|
7409
|
-
if (!componentElement) {
|
7410
|
-
console.error(`No element found in template '#${finalTemplateID}'`);
|
7411
|
-
return;
|
7412
|
-
}
|
7413
|
-
// Replace element with component element
|
7414
|
-
const parent = element.parentNode;
|
7415
|
-
if (!parent) {
|
7416
|
-
console.error(`Element has no parent node. Component '${componentId}' cannot be mounted.`);
|
7417
|
-
return;
|
7393
|
+
throw new Error(`Component '${this.#componentId}' not found in registry`);
|
7418
7394
|
}
|
7419
|
-
parent.insertBefore(componentElement, element);
|
7420
|
-
parent.removeChild(element);
|
7421
7395
|
// Create component instance
|
7422
7396
|
const instance = component.createInstance(properties);
|
7423
7397
|
// Create and mount child application using the parent application's registries
|
7424
|
-
this.#
|
7425
|
-
this.#
|
7426
|
-
this.#isActivated = true;
|
7427
|
-
}
|
7428
|
-
/**
|
7429
|
-
* Cleans up the component.
|
7430
|
-
*/
|
7431
|
-
cleanupComponent() {
|
7432
|
-
if (this.#childApp) {
|
7433
|
-
this.#childApp.unmount();
|
7434
|
-
this.#childApp = undefined;
|
7435
|
-
}
|
7436
|
-
this.#isActivated = false;
|
7398
|
+
this.#componentApp = this.#vNode.vApplication.createChildApp(instance);
|
7399
|
+
this.#componentApp.mount(clone);
|
7437
7400
|
}
|
7438
7401
|
}
|
7439
7402
|
|
@@ -7825,13 +7788,6 @@ class VDirectiveManager {
|
|
7825
7788
|
get keyDirective() {
|
7826
7789
|
return this.#keyDirective;
|
7827
7790
|
}
|
7828
|
-
/**
|
7829
|
-
* Gets a record of VBindDirectives for options specific to certain directives.
|
7830
|
-
* The keys are directive names (e.g., 'options', 'options.intersection').
|
7831
|
-
*/
|
7832
|
-
get optionsDirectives() {
|
7833
|
-
return this.#optionsDirectives;
|
7834
|
-
}
|
7835
7791
|
/**
|
7836
7792
|
* Gets the VBindDirective for options specific to the given directive name.
|
7837
7793
|
* Searches in order: `:options.{directive}` -> `:options`
|
@@ -8732,14 +8688,13 @@ class VConditionalDirective {
|
|
8732
8688
|
*/
|
8733
8689
|
get domUpdater() {
|
8734
8690
|
const identifiers = this.#conditionalContext.allDependentIdentifiers;
|
8735
|
-
const render = () => this.#render();
|
8736
8691
|
// Create an updater that handles the conditional rendering
|
8737
8692
|
const updater = {
|
8738
8693
|
get dependentIdentifiers() {
|
8739
8694
|
return identifiers;
|
8740
8695
|
},
|
8741
|
-
applyToDOM() {
|
8742
|
-
render();
|
8696
|
+
applyToDOM: () => {
|
8697
|
+
this.#render();
|
8743
8698
|
}
|
8744
8699
|
};
|
8745
8700
|
return updater;
|
@@ -8874,6 +8829,7 @@ class VConditionalDirective {
|
|
8874
8829
|
* Clones the template element and creates a new VNode for the cloned element.
|
8875
8830
|
*/
|
8876
8831
|
#cloneTemplate() {
|
8832
|
+
// Clone the original element
|
8877
8833
|
const element = this.#vNode.node;
|
8878
8834
|
const clone = element.cloneNode(true);
|
8879
8835
|
// Create a new VNode for the cloned element
|
@@ -9072,14 +9028,13 @@ class VForDirective {
|
|
9072
9028
|
*/
|
9073
9029
|
get domUpdater() {
|
9074
9030
|
const identifiers = this.#dependentIdentifiers ?? [];
|
9075
|
-
const render = () => this.#render();
|
9076
9031
|
// Create and return the DOM updater
|
9077
9032
|
const updater = {
|
9078
9033
|
get dependentIdentifiers() {
|
9079
9034
|
return identifiers;
|
9080
9035
|
},
|
9081
|
-
applyToDOM() {
|
9082
|
-
render();
|
9036
|
+
applyToDOM: () => {
|
9037
|
+
this.#render();
|
9083
9038
|
}
|
9084
9039
|
};
|
9085
9040
|
return updater;
|
@@ -9310,6 +9265,7 @@ class VForDirective {
|
|
9310
9265
|
* Clone template element for each iteration and create a new VNode
|
9311
9266
|
*/
|
9312
9267
|
#cloneTemplate(context) {
|
9268
|
+
// Clone the original element
|
9313
9269
|
const element = this.#vNode.node;
|
9314
9270
|
const clone = element.cloneNode(true);
|
9315
9271
|
// Prepare identifiers for the item
|
@@ -9707,14 +9663,13 @@ class VModelDirective {
|
|
9707
9663
|
*/
|
9708
9664
|
get domUpdater() {
|
9709
9665
|
const identifiers = this.#dependentIdentifiers ?? [];
|
9710
|
-
const render = () => this.#render();
|
9711
9666
|
// Create and return the DOM updater
|
9712
9667
|
const updater = {
|
9713
9668
|
get dependentIdentifiers() {
|
9714
9669
|
return identifiers;
|
9715
9670
|
},
|
9716
|
-
applyToDOM() {
|
9717
|
-
render();
|
9671
|
+
applyToDOM: () => {
|
9672
|
+
this.#render();
|
9718
9673
|
}
|
9719
9674
|
};
|
9720
9675
|
return updater;
|