gyosjs 0.2.2 → 0.2.4
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/README.md +131 -131
- package/dist/core/directive.d.ts.map +1 -1
- package/dist/core/reactive.d.ts.map +1 -1
- package/dist/core/reveal.d.ts +3 -0
- package/dist/core/reveal.d.ts.map +1 -0
- package/dist/core/router/router.d.ts.map +1 -1
- package/dist/form/form-validation.d.ts.map +1 -1
- package/dist/gyos.auto.esm.js +328 -37
- package/dist/gyos.auto.esm.js.map +1 -1
- package/dist/gyos.auto.js +328 -37
- package/dist/gyos.auto.js.map +1 -1
- package/dist/gyos.auto.min.js +2 -2
- package/dist/gyos.esm.js +328 -37
- package/dist/gyos.esm.js.map +1 -1
- package/dist/gyos.js +328 -37
- package/dist/gyos.js.map +1 -1
- package/dist/gyos.min.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/template/bindings.d.ts.map +1 -1
- package/dist/template/directives.d.ts.map +1 -1
- package/dist/template/events.d.ts.map +1 -1
- package/dist/template/model.d.ts.map +1 -1
- package/dist/template/scope-chain.d.ts +3 -0
- package/dist/template/scope-chain.d.ts.map +1 -0
- package/dist/template/structurals/structural.d.ts.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +46 -46
package/dist/gyos.auto.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* GyosJS v0.2.
|
|
2
|
+
* GyosJS v0.2.4
|
|
3
3
|
* (c) 2026
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -1584,6 +1584,162 @@
|
|
|
1584
1584
|
});
|
|
1585
1585
|
}
|
|
1586
1586
|
|
|
1587
|
+
const DEFAULT_OPTIONS = {
|
|
1588
|
+
classNames: ['is-revealed'],
|
|
1589
|
+
rootMargin: '0px',
|
|
1590
|
+
threshold: 0.1
|
|
1591
|
+
};
|
|
1592
|
+
const pools = new Map();
|
|
1593
|
+
const mountedRecords = new WeakMap();
|
|
1594
|
+
function clampThreshold(value) {
|
|
1595
|
+
const number = Number(value);
|
|
1596
|
+
if (!Number.isFinite(number))
|
|
1597
|
+
return DEFAULT_OPTIONS.threshold;
|
|
1598
|
+
return Math.min(1, Math.max(0, number));
|
|
1599
|
+
}
|
|
1600
|
+
function normalizeThreshold(value) {
|
|
1601
|
+
if (!Array.isArray(value))
|
|
1602
|
+
return clampThreshold(value);
|
|
1603
|
+
const values = Array.from(new Set(value.map(clampThreshold))).sort((a, b) => a - b);
|
|
1604
|
+
return values.length ? values : DEFAULT_OPTIONS.threshold;
|
|
1605
|
+
}
|
|
1606
|
+
function normalizeOptions(binding) {
|
|
1607
|
+
const value = binding.value && typeof binding.value === 'object' && !Array.isArray(binding.value)
|
|
1608
|
+
? binding.value
|
|
1609
|
+
: {};
|
|
1610
|
+
const args = new Set(binding.arg || []);
|
|
1611
|
+
const classNames = typeof value.className === 'string'
|
|
1612
|
+
? value.className.split(/\s+/).filter(Boolean)
|
|
1613
|
+
: DEFAULT_OPTIONS.classNames;
|
|
1614
|
+
return {
|
|
1615
|
+
classNames,
|
|
1616
|
+
once: typeof value.once === 'boolean' ? value.once : !args.has('repeat'),
|
|
1617
|
+
rootMargin: typeof value.rootMargin === 'string' ? value.rootMargin : DEFAULT_OPTIONS.rootMargin,
|
|
1618
|
+
target: value.target === 'parent' || args.has('parent') ? 'parent' : 'self',
|
|
1619
|
+
threshold: normalizeThreshold(value.threshold ?? DEFAULT_OPTIONS.threshold)
|
|
1620
|
+
};
|
|
1621
|
+
}
|
|
1622
|
+
function poolKey(options) {
|
|
1623
|
+
return JSON.stringify([options.rootMargin, options.threshold]);
|
|
1624
|
+
}
|
|
1625
|
+
function setRevealed(record, revealed) {
|
|
1626
|
+
const { element, options } = record;
|
|
1627
|
+
if (revealed) {
|
|
1628
|
+
element.setAttribute('data-gyos-revealed', '');
|
|
1629
|
+
for (const className of options.classNames)
|
|
1630
|
+
element.classList.add(className);
|
|
1631
|
+
}
|
|
1632
|
+
else {
|
|
1633
|
+
element.removeAttribute('data-gyos-revealed');
|
|
1634
|
+
for (const className of options.classNames)
|
|
1635
|
+
element.classList.remove(className);
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
function removeRecord(record) {
|
|
1639
|
+
if (mountedRecords.get(record.element) !== record)
|
|
1640
|
+
return;
|
|
1641
|
+
mountedRecords.delete(record.element);
|
|
1642
|
+
const records = record.pool.records.get(record.observedTarget);
|
|
1643
|
+
if (records) {
|
|
1644
|
+
records.delete(record);
|
|
1645
|
+
if (records.size === 0) {
|
|
1646
|
+
record.pool.records.delete(record.observedTarget);
|
|
1647
|
+
record.pool.observer.unobserve(record.observedTarget);
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
if (record.pool.records.size === 0) {
|
|
1651
|
+
record.pool.observer.disconnect();
|
|
1652
|
+
pools.delete(record.pool.key);
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
function createPool(options) {
|
|
1656
|
+
const key = poolKey(options);
|
|
1657
|
+
const existing = pools.get(key);
|
|
1658
|
+
if (existing)
|
|
1659
|
+
return existing;
|
|
1660
|
+
let pool;
|
|
1661
|
+
try {
|
|
1662
|
+
const records = new Map();
|
|
1663
|
+
const observer = new IntersectionObserver(entries => {
|
|
1664
|
+
for (const entry of entries) {
|
|
1665
|
+
const current = Array.from(records.get(entry.target) || []);
|
|
1666
|
+
for (const record of current) {
|
|
1667
|
+
if (entry.isIntersecting) {
|
|
1668
|
+
setRevealed(record, true);
|
|
1669
|
+
if (record.options.once)
|
|
1670
|
+
removeRecord(record);
|
|
1671
|
+
}
|
|
1672
|
+
else if (!record.options.once) {
|
|
1673
|
+
setRevealed(record, false);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
}, { rootMargin: options.rootMargin, threshold: options.threshold });
|
|
1678
|
+
pool = { key, observer, records };
|
|
1679
|
+
}
|
|
1680
|
+
catch {
|
|
1681
|
+
return null;
|
|
1682
|
+
}
|
|
1683
|
+
pools.set(key, pool);
|
|
1684
|
+
return pool;
|
|
1685
|
+
}
|
|
1686
|
+
function prefersReducedMotion() {
|
|
1687
|
+
return typeof window.matchMedia === 'function'
|
|
1688
|
+
&& window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
1689
|
+
}
|
|
1690
|
+
function mountReveal(element, binding) {
|
|
1691
|
+
unmountReveal(element);
|
|
1692
|
+
document.documentElement.classList.add('gyos-reveal-ready');
|
|
1693
|
+
const options = normalizeOptions(binding);
|
|
1694
|
+
if (options.once && element.hasAttribute('data-gyos-revealed')) {
|
|
1695
|
+
for (const className of options.classNames)
|
|
1696
|
+
element.classList.add(className);
|
|
1697
|
+
return;
|
|
1698
|
+
}
|
|
1699
|
+
if (prefersReducedMotion() || typeof window.IntersectionObserver !== 'function') {
|
|
1700
|
+
const fallback = { element, options };
|
|
1701
|
+
setRevealed(fallback, true);
|
|
1702
|
+
return;
|
|
1703
|
+
}
|
|
1704
|
+
const pool = createPool(options);
|
|
1705
|
+
if (!pool) {
|
|
1706
|
+
const fallback = { element, options };
|
|
1707
|
+
setRevealed(fallback, true);
|
|
1708
|
+
return;
|
|
1709
|
+
}
|
|
1710
|
+
const observedTarget = options.target === 'parent' ? element.parentElement || element : element;
|
|
1711
|
+
const record = { element, observedTarget, options, pool };
|
|
1712
|
+
let records = pool.records.get(observedTarget);
|
|
1713
|
+
if (!records) {
|
|
1714
|
+
records = new Set();
|
|
1715
|
+
pool.records.set(observedTarget, records);
|
|
1716
|
+
pool.observer.observe(observedTarget);
|
|
1717
|
+
}
|
|
1718
|
+
records.add(record);
|
|
1719
|
+
mountedRecords.set(element, record);
|
|
1720
|
+
}
|
|
1721
|
+
function unmountReveal(element) {
|
|
1722
|
+
const record = mountedRecords.get(element);
|
|
1723
|
+
if (!record)
|
|
1724
|
+
return;
|
|
1725
|
+
removeRecord(record);
|
|
1726
|
+
if (!record.options.once)
|
|
1727
|
+
setRevealed(record, false);
|
|
1728
|
+
}
|
|
1729
|
+
const revealDirective = {
|
|
1730
|
+
mounted: mountReveal,
|
|
1731
|
+
updated(element, binding) {
|
|
1732
|
+
const previous = normalizeOptions({ ...binding, value: binding.oldValue });
|
|
1733
|
+
const next = normalizeOptions(binding);
|
|
1734
|
+
for (const className of previous.classNames) {
|
|
1735
|
+
if (!next.classNames.includes(className))
|
|
1736
|
+
element.classList.remove(className);
|
|
1737
|
+
}
|
|
1738
|
+
mountReveal(element, binding);
|
|
1739
|
+
},
|
|
1740
|
+
unmounted: unmountReveal
|
|
1741
|
+
};
|
|
1742
|
+
|
|
1587
1743
|
const directives = new Map();
|
|
1588
1744
|
/**
|
|
1589
1745
|
* Register a custom directive
|
|
@@ -1758,6 +1914,7 @@
|
|
|
1758
1914
|
el.innerHTML = html;
|
|
1759
1915
|
},
|
|
1760
1916
|
});
|
|
1917
|
+
directive('reveal', revealDirective);
|
|
1761
1918
|
|
|
1762
1919
|
/**
|
|
1763
1920
|
* Transitions System - Smooth animations for enter/leave
|
|
@@ -2307,11 +2464,14 @@
|
|
|
2307
2464
|
if (directive) {
|
|
2308
2465
|
// g-on needs the handler itself. The general evaluator intentionally
|
|
2309
2466
|
// invokes bare functions to support function-style computed values.
|
|
2310
|
-
const
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2467
|
+
const evaluateValue = () => {
|
|
2468
|
+
if (attr.value.trim() === '')
|
|
2469
|
+
return undefined;
|
|
2470
|
+
return directiveName === 'on' && typeof scope[attr.value] === 'function'
|
|
2471
|
+
? scope[attr.value]
|
|
2472
|
+
: evaluateExpression(attr.value, scope, false);
|
|
2473
|
+
};
|
|
2474
|
+
const value = evaluateValue();
|
|
2315
2475
|
let oldValue = directive.mounted ? value : undefined;
|
|
2316
2476
|
let initialized = !directive.mounted;
|
|
2317
2477
|
// Call mounted hook
|
|
@@ -2337,7 +2497,7 @@
|
|
|
2337
2497
|
// Setup reactive update if has updated hook
|
|
2338
2498
|
if (directive.updated) {
|
|
2339
2499
|
queueReactiveEffect(element, () => {
|
|
2340
|
-
const newValue =
|
|
2500
|
+
const newValue = evaluateValue();
|
|
2341
2501
|
if (!initialized) {
|
|
2342
2502
|
initialized = true;
|
|
2343
2503
|
oldValue = newValue;
|
|
@@ -2392,28 +2552,108 @@
|
|
|
2392
2552
|
/**
|
|
2393
2553
|
* Reactive attribute bindings (:class, :style, :aria-*, :data-*, and custom attributes).
|
|
2394
2554
|
*/
|
|
2395
|
-
function
|
|
2555
|
+
function createClassBindingState(el) {
|
|
2556
|
+
return {
|
|
2557
|
+
staticClasses: new Set(el.classList),
|
|
2558
|
+
dynamicClasses: new Set()
|
|
2559
|
+
};
|
|
2560
|
+
}
|
|
2561
|
+
function classNamesFromBinding(value) {
|
|
2396
2562
|
if (typeof value === 'string') {
|
|
2397
|
-
|
|
2563
|
+
return new Set(value.split(/\s+/).filter(Boolean));
|
|
2398
2564
|
}
|
|
2399
|
-
|
|
2400
|
-
Object.entries(value)
|
|
2401
|
-
|
|
2565
|
+
if (value && typeof value === 'object') {
|
|
2566
|
+
return new Set(Object.entries(value)
|
|
2567
|
+
.filter(([, condition]) => Boolean(condition))
|
|
2568
|
+
.flatMap(([className]) => className.split(/\s+/).filter(Boolean)));
|
|
2569
|
+
}
|
|
2570
|
+
return new Set();
|
|
2571
|
+
}
|
|
2572
|
+
function handleClassBinding(el, value, state) {
|
|
2573
|
+
const nextClasses = classNamesFromBinding(value);
|
|
2574
|
+
if (value && typeof value === 'object') {
|
|
2575
|
+
for (const [className, condition] of Object.entries(value)) {
|
|
2576
|
+
if (!condition) {
|
|
2577
|
+
for (const token of className.split(/\s+/).filter(Boolean))
|
|
2578
|
+
el.classList.remove(token);
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
for (const className of state.dynamicClasses) {
|
|
2583
|
+
if (!nextClasses.has(className) && !state.staticClasses.has(className)) {
|
|
2584
|
+
el.classList.remove(className);
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
for (const className of nextClasses) {
|
|
2588
|
+
el.classList.add(className);
|
|
2589
|
+
}
|
|
2590
|
+
state.dynamicClasses = nextClasses;
|
|
2591
|
+
}
|
|
2592
|
+
function readStyleValues(style) {
|
|
2593
|
+
const values = new Map();
|
|
2594
|
+
for (let index = 0; index < style.length; index++) {
|
|
2595
|
+
const property = style.item(index);
|
|
2596
|
+
values.set(property, {
|
|
2597
|
+
priority: style.getPropertyPriority(property),
|
|
2598
|
+
value: style.getPropertyValue(property)
|
|
2402
2599
|
});
|
|
2403
2600
|
}
|
|
2601
|
+
return values;
|
|
2602
|
+
}
|
|
2603
|
+
function normalizeStyleProperty(property) {
|
|
2604
|
+
if (property.startsWith('--') || property.includes('-'))
|
|
2605
|
+
return property.toLowerCase();
|
|
2606
|
+
return property.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`);
|
|
2404
2607
|
}
|
|
2405
|
-
function
|
|
2608
|
+
function styleValuesFromBinding(value) {
|
|
2609
|
+
const scratch = document.createElement('div').style;
|
|
2610
|
+
const mentioned = new Set();
|
|
2406
2611
|
if (typeof value === 'string') {
|
|
2407
|
-
|
|
2612
|
+
scratch.cssText = value;
|
|
2613
|
+
for (const property of readStyleValues(scratch).keys())
|
|
2614
|
+
mentioned.add(property);
|
|
2408
2615
|
}
|
|
2409
2616
|
else if (value && typeof value === 'object') {
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2617
|
+
for (const [property, propertyValue] of Object.entries(value)) {
|
|
2618
|
+
const normalized = normalizeStyleProperty(property);
|
|
2619
|
+
mentioned.add(normalized);
|
|
2620
|
+
if (propertyValue == null || propertyValue === false)
|
|
2621
|
+
continue;
|
|
2622
|
+
if (property.startsWith('--'))
|
|
2623
|
+
scratch.setProperty(property, String(propertyValue));
|
|
2624
|
+
else
|
|
2625
|
+
scratch[property] = propertyValue;
|
|
2626
|
+
}
|
|
2413
2627
|
}
|
|
2414
|
-
|
|
2415
|
-
|
|
2628
|
+
return { mentioned, values: readStyleValues(scratch) };
|
|
2629
|
+
}
|
|
2630
|
+
function createStyleBindingState(el) {
|
|
2631
|
+
return {
|
|
2632
|
+
staticStyles: readStyleValues(el.style),
|
|
2633
|
+
dynamicProperties: new Set()
|
|
2634
|
+
};
|
|
2635
|
+
}
|
|
2636
|
+
function restoreStaticStyle(el, property, state) {
|
|
2637
|
+
const original = state.staticStyles.get(property);
|
|
2638
|
+
if (original)
|
|
2639
|
+
el.style.setProperty(property, original.value, original.priority);
|
|
2640
|
+
else
|
|
2641
|
+
el.style.removeProperty(property);
|
|
2642
|
+
}
|
|
2643
|
+
function handleStyleBinding(el, value, state) {
|
|
2644
|
+
const next = styleValuesFromBinding(value);
|
|
2645
|
+
for (const property of state.dynamicProperties) {
|
|
2646
|
+
if (!next.mentioned.has(property))
|
|
2647
|
+
restoreStaticStyle(el, property, state);
|
|
2648
|
+
}
|
|
2649
|
+
for (const property of next.mentioned) {
|
|
2650
|
+
const styleValue = next.values.get(property);
|
|
2651
|
+
if (styleValue)
|
|
2652
|
+
el.style.setProperty(property, styleValue.value, styleValue.priority);
|
|
2653
|
+
else
|
|
2654
|
+
el.style.removeProperty(property);
|
|
2416
2655
|
}
|
|
2656
|
+
state.dynamicProperties = next.mentioned;
|
|
2417
2657
|
}
|
|
2418
2658
|
const booleanAttributes = new Set([
|
|
2419
2659
|
'allowfullscreen', 'async', 'autofocus', 'autoplay', 'checked', 'controls',
|
|
@@ -2508,13 +2748,15 @@
|
|
|
2508
2748
|
for (const attribute of boundAttributes(element)) {
|
|
2509
2749
|
const attrName = attribute.name.slice(1);
|
|
2510
2750
|
const expression = attribute.value;
|
|
2751
|
+
const classState = attrName === 'class' ? createClassBindingState(element) : undefined;
|
|
2752
|
+
const styleState = attrName === 'style' ? createStyleBindingState(element) : undefined;
|
|
2511
2753
|
queueReactiveEffect(element, () => {
|
|
2512
2754
|
const currentScope = getScopeFromElement(element) || scope;
|
|
2513
2755
|
const value = evaluateExpression(expression, currentScope);
|
|
2514
2756
|
if (attrName === 'class')
|
|
2515
|
-
handleClassBinding(element, value);
|
|
2757
|
+
handleClassBinding(element, value, classState);
|
|
2516
2758
|
else if (attrName === 'style')
|
|
2517
|
-
handleStyleBinding(element, value);
|
|
2759
|
+
handleStyleBinding(element, value, styleState);
|
|
2518
2760
|
else
|
|
2519
2761
|
applyAttributeBinding(element, attrName, value);
|
|
2520
2762
|
});
|
|
@@ -2529,9 +2771,9 @@
|
|
|
2529
2771
|
const attrName = attribute.name.slice(1);
|
|
2530
2772
|
const value = evaluateExpression(attribute.value, scope);
|
|
2531
2773
|
if (attrName === 'class')
|
|
2532
|
-
handleClassBinding(element, value);
|
|
2774
|
+
handleClassBinding(element, value, createClassBindingState(element));
|
|
2533
2775
|
else if (attrName === 'style')
|
|
2534
|
-
handleStyleBinding(element, value);
|
|
2776
|
+
handleStyleBinding(element, value, createStyleBindingState(element));
|
|
2535
2777
|
else
|
|
2536
2778
|
applyAttributeBinding(element, attrName, value);
|
|
2537
2779
|
}
|
|
@@ -3026,8 +3268,8 @@
|
|
|
3026
3268
|
|
|
3027
3269
|
const managedForms = new WeakSet();
|
|
3028
3270
|
const approvedSubmissions = new WeakSet();
|
|
3029
|
-
// Coordinates the
|
|
3030
|
-
//
|
|
3271
|
+
// Coordinates the form capture validator with the Router's document listener
|
|
3272
|
+
// without exposing state on application elements.
|
|
3031
3273
|
function registerValidatedForm(form) {
|
|
3032
3274
|
managedForms.add(form);
|
|
3033
3275
|
}
|
|
@@ -3177,7 +3419,6 @@
|
|
|
3177
3419
|
const submitListener = async (e) => {
|
|
3178
3420
|
if (replayingSubmission) {
|
|
3179
3421
|
replayingSubmission = false;
|
|
3180
|
-
cancelApprovedFormSubmission(form);
|
|
3181
3422
|
return;
|
|
3182
3423
|
}
|
|
3183
3424
|
e.preventDefault();
|
|
@@ -3208,11 +3449,11 @@
|
|
|
3208
3449
|
}
|
|
3209
3450
|
finally {
|
|
3210
3451
|
// requestSubmit dispatches synchronously. If native validation or
|
|
3211
|
-
// another
|
|
3452
|
+
// another listener stopped it, do not leak approval state.
|
|
3212
3453
|
if (replayingSubmission) {
|
|
3213
3454
|
replayingSubmission = false;
|
|
3214
|
-
cancelApprovedFormSubmission(form);
|
|
3215
3455
|
}
|
|
3456
|
+
cancelApprovedFormSubmission(form);
|
|
3216
3457
|
}
|
|
3217
3458
|
}, 0);
|
|
3218
3459
|
return;
|
|
@@ -3542,12 +3783,12 @@
|
|
|
3542
3783
|
// e.stopPropagation(); // Optional: prevent other click handlers
|
|
3543
3784
|
const target = e.target;
|
|
3544
3785
|
// Check if click is outside element AND element is still in DOM
|
|
3545
|
-
if (!document.body.contains(element)
|
|
3546
|
-
(target instanceof Element && target.hasAttribute('g-ignore-outside-click'))) {
|
|
3547
|
-
// Element removed, cleanup
|
|
3786
|
+
if (!document.body.contains(element)) {
|
|
3548
3787
|
cleanup();
|
|
3549
3788
|
return;
|
|
3550
3789
|
}
|
|
3790
|
+
if (target instanceof Element && target.closest('[g-ignore-outside-click]'))
|
|
3791
|
+
return;
|
|
3551
3792
|
if (element !== target && !element.contains(target)) {
|
|
3552
3793
|
const currentScope = getScopeFromElement(element) || scope;
|
|
3553
3794
|
if (modifiers.includes('once'))
|
|
@@ -3673,6 +3914,39 @@
|
|
|
3673
3914
|
});
|
|
3674
3915
|
}
|
|
3675
3916
|
|
|
3917
|
+
const PARENT_SCOPE = Symbol('gyos.parent-scope');
|
|
3918
|
+
function attachParentScope(childScope, parentScope) {
|
|
3919
|
+
Object.defineProperty(childScope, PARENT_SCOPE, {
|
|
3920
|
+
value: parentScope,
|
|
3921
|
+
configurable: false,
|
|
3922
|
+
enumerable: false,
|
|
3923
|
+
writable: false
|
|
3924
|
+
});
|
|
3925
|
+
}
|
|
3926
|
+
function parentOf(scope) {
|
|
3927
|
+
return scope?.[PARENT_SCOPE];
|
|
3928
|
+
}
|
|
3929
|
+
function ensureModelPropertyOwner(scope, property) {
|
|
3930
|
+
if (!parentOf(scope) || property in scope)
|
|
3931
|
+
return;
|
|
3932
|
+
let owner = scope;
|
|
3933
|
+
let parent = parentOf(owner);
|
|
3934
|
+
while (parent) {
|
|
3935
|
+
owner = parent;
|
|
3936
|
+
parent = parentOf(owner);
|
|
3937
|
+
}
|
|
3938
|
+
if (!(property in owner))
|
|
3939
|
+
owner[property] = undefined;
|
|
3940
|
+
Object.defineProperty(scope, property, {
|
|
3941
|
+
get: () => owner[property],
|
|
3942
|
+
set: value => {
|
|
3943
|
+
owner[property] = value;
|
|
3944
|
+
},
|
|
3945
|
+
configurable: true,
|
|
3946
|
+
enumerable: true
|
|
3947
|
+
});
|
|
3948
|
+
}
|
|
3949
|
+
|
|
3676
3950
|
/**
|
|
3677
3951
|
* Two-Way Binding (g-model)
|
|
3678
3952
|
* Handles form input binding with optional modifiers (debounce, number, trim, etc.)
|
|
@@ -3782,6 +4056,9 @@
|
|
|
3782
4056
|
DEBUG() && console.log('[g-model] Expression:', expr, 'Modifiers:', modifiers, 'Debounce:', debounceMs);
|
|
3783
4057
|
// Get current scope from element
|
|
3784
4058
|
const currentScope = getScopeFromElement(element) || scope;
|
|
4059
|
+
const modelParts = parsePath(expr);
|
|
4060
|
+
if (typeof modelParts[0] === 'string')
|
|
4061
|
+
ensureModelPropertyOwner(currentScope, modelParts[0]);
|
|
3785
4062
|
// Set initial value (no pipes in v-model)
|
|
3786
4063
|
const initialValue = evaluateExpression(expr, currentScope, false);
|
|
3787
4064
|
if (inputElement.type === 'checkbox') {
|
|
@@ -4038,8 +4315,15 @@
|
|
|
4038
4315
|
proxy = new Proxy(raw, {
|
|
4039
4316
|
get(target, key, receiver) {
|
|
4040
4317
|
const value = Reflect.get(target, key, receiver);
|
|
4041
|
-
//
|
|
4318
|
+
// Missing own fields can become reactive later; prototype APIs stay untouched.
|
|
4042
4319
|
if (!Object.prototype.hasOwnProperty.call(target, key)) {
|
|
4320
|
+
if (typeof key !== 'symbol' && !isReservedKey(key) && !(key in target)) {
|
|
4321
|
+
const existingSig = fieldSignals.get(target)?.get(key);
|
|
4322
|
+
if (hasCurrentEffect())
|
|
4323
|
+
return (existingSig || getFieldSignal(target, key, undefined)).value;
|
|
4324
|
+
if (existingSig)
|
|
4325
|
+
return existingSig.peek;
|
|
4326
|
+
}
|
|
4043
4327
|
return value;
|
|
4044
4328
|
}
|
|
4045
4329
|
// symbol / key internal bỏ qua reactive
|
|
@@ -4130,6 +4414,7 @@
|
|
|
4130
4414
|
return true;
|
|
4131
4415
|
},
|
|
4132
4416
|
ownKeys(target) {
|
|
4417
|
+
ensureVersion(target).value;
|
|
4133
4418
|
return Reflect.ownKeys(target).filter(key => !isReservedKey(key));
|
|
4134
4419
|
},
|
|
4135
4420
|
getOwnPropertyDescriptor(target, key) {
|
|
@@ -4240,6 +4525,7 @@
|
|
|
4240
4525
|
*/
|
|
4241
4526
|
function createChildScope(parentScope, itemVar, list, index) {
|
|
4242
4527
|
const childScope = {};
|
|
4528
|
+
attachParentScope(childScope, parentScope);
|
|
4243
4529
|
const state = signal({ list, index });
|
|
4244
4530
|
Object.defineProperty(childScope, FOR_SCOPE_STATE, { value: state });
|
|
4245
4531
|
// handle itemVar include index (e.g., "item, idx in items")
|
|
@@ -4278,6 +4564,9 @@
|
|
|
4278
4564
|
if (!(key in childScope)) {
|
|
4279
4565
|
Object.defineProperty(childScope, key, {
|
|
4280
4566
|
get: () => parentScope[key],
|
|
4567
|
+
set: (value) => {
|
|
4568
|
+
parentScope[key] = value;
|
|
4569
|
+
},
|
|
4281
4570
|
enumerable: true,
|
|
4282
4571
|
configurable: true,
|
|
4283
4572
|
});
|
|
@@ -7154,8 +7443,8 @@
|
|
|
7154
7443
|
if (progressBarEnabled) {
|
|
7155
7444
|
progressBar = new ProgressBar(progressBarEnabled);
|
|
7156
7445
|
}
|
|
7157
|
-
document.addEventListener('click',
|
|
7158
|
-
document.addEventListener('submit',
|
|
7446
|
+
document.addEventListener('click', onClick);
|
|
7447
|
+
document.addEventListener('submit', onSubmit);
|
|
7159
7448
|
document.addEventListener('mouseover', onMouseOverCapture, true);
|
|
7160
7449
|
window.addEventListener('popstate', onPopState);
|
|
7161
7450
|
if ('scrollRestoration' in history) {
|
|
@@ -7826,7 +8115,7 @@
|
|
|
7826
8115
|
return; // this case not link (tag a) or form so do nothing
|
|
7827
8116
|
}
|
|
7828
8117
|
}
|
|
7829
|
-
function
|
|
8118
|
+
function onClick(event) {
|
|
7830
8119
|
if (event.defaultPrevented)
|
|
7831
8120
|
return;
|
|
7832
8121
|
if (event.button !== 0)
|
|
@@ -7883,7 +8172,9 @@
|
|
|
7883
8172
|
return;
|
|
7884
8173
|
preload(url.toString());
|
|
7885
8174
|
}
|
|
7886
|
-
function
|
|
8175
|
+
function onSubmit(event) {
|
|
8176
|
+
if (event.defaultPrevented)
|
|
8177
|
+
return;
|
|
7887
8178
|
const form = event.target;
|
|
7888
8179
|
if (!form || form.tagName.toLowerCase() !== 'form')
|
|
7889
8180
|
return;
|
|
@@ -8009,7 +8300,7 @@
|
|
|
8009
8300
|
onAfterNavigate,
|
|
8010
8301
|
portalCreate,
|
|
8011
8302
|
portalDestroy,
|
|
8012
|
-
version: '0.2.
|
|
8303
|
+
version: '0.2.4'
|
|
8013
8304
|
};
|
|
8014
8305
|
|
|
8015
8306
|
var _a, _b, _c;
|