@codbex/harmonia 1.11.0 → 1.11.1
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/harmonia.esm.js +76 -27
- package/dist/harmonia.esm.min.js +2 -2
- package/dist/harmonia.esm.min.js.map +3 -3
- package/dist/harmonia.js +76 -27
- package/dist/harmonia.min.js +2 -2
- package/dist/harmonia.min.js.map +3 -3
- package/package.json +1 -1
package/dist/harmonia.js
CHANGED
|
@@ -9295,8 +9295,13 @@
|
|
|
9295
9295
|
if (!storageKey) return;
|
|
9296
9296
|
if (saveTimer) clearTimeout(saveTimer);
|
|
9297
9297
|
saveTimer = setTimeout(() => {
|
|
9298
|
+
const usable = usableSize();
|
|
9299
|
+
if (usable <= 0) {
|
|
9300
|
+
saveTimer = null;
|
|
9301
|
+
return;
|
|
9302
|
+
}
|
|
9298
9303
|
const visible = panels.filter((p) => !p.hidden);
|
|
9299
|
-
const sizes = visible.map((p) => p.size /
|
|
9304
|
+
const sizes = visible.map((p) => p.size / usable);
|
|
9300
9305
|
localStorage.setItem(storageKey, JSON.stringify(sizes));
|
|
9301
9306
|
saveTimer = null;
|
|
9302
9307
|
}, SAVE_DELAY);
|
|
@@ -9331,26 +9336,44 @@
|
|
|
9331
9336
|
const total = usableSize();
|
|
9332
9337
|
if (!initialized) {
|
|
9333
9338
|
initialized = true;
|
|
9334
|
-
const
|
|
9335
|
-
|
|
9336
|
-
|
|
9337
|
-
|
|
9338
|
-
|
|
9339
|
-
|
|
9340
|
-
|
|
9341
|
-
|
|
9342
|
-
|
|
9343
|
-
|
|
9344
|
-
|
|
9345
|
-
|
|
9346
|
-
|
|
9347
|
-
if (p.explicit) {
|
|
9348
|
-
p.size = p.declaredSize;
|
|
9339
|
+
const anyRestore = visible.some((p) => p.restoreFraction != null);
|
|
9340
|
+
if (anyRestore) {
|
|
9341
|
+
const restoreFractionSum = visible.reduce((sum, p) => sum + (p.restoreFraction ?? 0), 0);
|
|
9342
|
+
const remainingSpace = total * (1 - restoreFractionSum);
|
|
9343
|
+
const nonRestorePanels = visible.filter((p) => p.restoreFraction == null);
|
|
9344
|
+
const nonRestoreDeclaredTotal = nonRestorePanels.reduce((s, p) => s + (p.declaredSize ?? 0), 0);
|
|
9345
|
+
visible.forEach((p) => {
|
|
9346
|
+
if (p.restoreFraction != null) {
|
|
9347
|
+
p.size = p.restoreFraction * total;
|
|
9348
|
+
p.explicit = true;
|
|
9349
|
+
p.restoreFraction = null;
|
|
9350
|
+
} else if (nonRestoreDeclaredTotal > 0) {
|
|
9351
|
+
p.size = (p.declaredSize ?? 0) / nonRestoreDeclaredTotal * remainingSpace;
|
|
9349
9352
|
} else {
|
|
9350
|
-
p.size =
|
|
9353
|
+
p.size = nonRestorePanels.length > 0 ? remainingSpace / nonRestorePanels.length : 0;
|
|
9351
9354
|
}
|
|
9352
|
-
p.size = Math.min(Math.max(p.size ?? share, p.min), p.max);
|
|
9353
9355
|
});
|
|
9356
|
+
} else {
|
|
9357
|
+
const stored = loadSizes();
|
|
9358
|
+
if (stored && stored.length === visible.length) {
|
|
9359
|
+
visible.forEach((p, i) => {
|
|
9360
|
+
p.size = stored[i] * usableSize();
|
|
9361
|
+
p.explicit = true;
|
|
9362
|
+
});
|
|
9363
|
+
} else {
|
|
9364
|
+
const explicitTotal = visible.filter((p) => p.explicit).reduce((sum, p) => sum + p.declaredSize, 0);
|
|
9365
|
+
const autoPanels = visible.filter((p) => !p.explicit);
|
|
9366
|
+
const remaining = total - explicitTotal;
|
|
9367
|
+
const share = autoPanels.length ? remaining / autoPanels.length : 0;
|
|
9368
|
+
visible.forEach((p) => {
|
|
9369
|
+
if (p.explicit) {
|
|
9370
|
+
p.size = p.declaredSize;
|
|
9371
|
+
} else {
|
|
9372
|
+
p.size = share;
|
|
9373
|
+
}
|
|
9374
|
+
p.size = Math.min(Math.max(p.size ?? share, p.min), p.max);
|
|
9375
|
+
});
|
|
9376
|
+
}
|
|
9354
9377
|
}
|
|
9355
9378
|
}
|
|
9356
9379
|
visible.forEach((p) => {
|
|
@@ -9363,6 +9386,10 @@
|
|
|
9363
9386
|
let delta = total - currentTotal;
|
|
9364
9387
|
if (Math.abs(delta) < DELTA_ABS) {
|
|
9365
9388
|
visible.forEach((p) => p.apply());
|
|
9389
|
+
if (total > 0)
|
|
9390
|
+
visible.forEach((p) => {
|
|
9391
|
+
p.savedFraction = p.size / total;
|
|
9392
|
+
});
|
|
9366
9393
|
return;
|
|
9367
9394
|
}
|
|
9368
9395
|
let flexible = visible.filter((p) => {
|
|
@@ -9396,6 +9423,10 @@
|
|
|
9396
9423
|
if (Math.abs(consumed) < DELTA_ABS) break;
|
|
9397
9424
|
}
|
|
9398
9425
|
visible.forEach((p) => p.apply());
|
|
9426
|
+
if (total > 0)
|
|
9427
|
+
visible.forEach((p) => {
|
|
9428
|
+
p.savedFraction = p.size / total;
|
|
9429
|
+
});
|
|
9399
9430
|
};
|
|
9400
9431
|
let layoutFrame = null;
|
|
9401
9432
|
const queueLayout = () => {
|
|
@@ -9430,7 +9461,6 @@
|
|
|
9430
9461
|
queueLayout();
|
|
9431
9462
|
},
|
|
9432
9463
|
panelHidden() {
|
|
9433
|
-
initialized = false;
|
|
9434
9464
|
refreshGutters();
|
|
9435
9465
|
queueLayout();
|
|
9436
9466
|
},
|
|
@@ -9441,6 +9471,9 @@
|
|
|
9441
9471
|
panelChange() {
|
|
9442
9472
|
queueLayout();
|
|
9443
9473
|
},
|
|
9474
|
+
resetInit() {
|
|
9475
|
+
initialized = false;
|
|
9476
|
+
},
|
|
9444
9477
|
normalize,
|
|
9445
9478
|
saveSizes
|
|
9446
9479
|
};
|
|
@@ -9604,6 +9637,9 @@
|
|
|
9604
9637
|
max: split._h_split.normalize(el.getAttribute("data-max")) ?? Infinity,
|
|
9605
9638
|
collapsed: false,
|
|
9606
9639
|
prevSize: null,
|
|
9640
|
+
prevHiddenFraction: null,
|
|
9641
|
+
savedFraction: null,
|
|
9642
|
+
restoreFraction: null,
|
|
9607
9643
|
apply() {
|
|
9608
9644
|
el.style.flexBasis = `${this.size.toFixed(2)}px`;
|
|
9609
9645
|
if (split._h_split.state.isBorder) {
|
|
@@ -9708,7 +9744,7 @@
|
|
|
9708
9744
|
gutter.addEventListener("pointerdown", drag);
|
|
9709
9745
|
const collapse = () => {
|
|
9710
9746
|
if (panel.collapsed) return;
|
|
9711
|
-
panel.prevSize = panel.size;
|
|
9747
|
+
panel.prevSize = panel.size > (panel.min ?? 0) ? panel.size : panel.declaredSize;
|
|
9712
9748
|
panel.size = panel.min ?? 0;
|
|
9713
9749
|
panel.collapsed = true;
|
|
9714
9750
|
panel.explicit = true;
|
|
@@ -9732,19 +9768,32 @@
|
|
|
9732
9768
|
panel.explicit = true;
|
|
9733
9769
|
split._h_split.panelChange();
|
|
9734
9770
|
};
|
|
9771
|
+
const setState = () => {
|
|
9772
|
+
if (panel.hidden) {
|
|
9773
|
+
el.classList.add("hidden");
|
|
9774
|
+
} else {
|
|
9775
|
+
el.classList.remove("hidden");
|
|
9776
|
+
}
|
|
9777
|
+
split._h_split.panelHidden();
|
|
9778
|
+
};
|
|
9779
|
+
setState();
|
|
9735
9780
|
const observer = new MutationObserver((mutations) => {
|
|
9736
9781
|
mutations.forEach((mutation) => {
|
|
9737
9782
|
if (mutation.attributeName === "data-gutterless") {
|
|
9738
9783
|
gutterless = el.getAttribute("data-gutterless") === "true";
|
|
9739
9784
|
split._h_split.gutterHidden();
|
|
9740
9785
|
} else if (mutation.attributeName === "data-hidden") {
|
|
9741
|
-
|
|
9742
|
-
if (panel.hidden) {
|
|
9743
|
-
|
|
9744
|
-
} else {
|
|
9745
|
-
|
|
9786
|
+
const newHidden = el.getAttribute("data-hidden") === "true";
|
|
9787
|
+
if (!panel.hidden && newHidden) {
|
|
9788
|
+
panel.prevHiddenFraction = panel.savedFraction;
|
|
9789
|
+
} else if (panel.hidden && !newHidden) {
|
|
9790
|
+
if (panel.prevHiddenFraction != null) {
|
|
9791
|
+
panel.restoreFraction = panel.prevHiddenFraction;
|
|
9792
|
+
}
|
|
9793
|
+
split._h_split.resetInit();
|
|
9746
9794
|
}
|
|
9747
|
-
|
|
9795
|
+
panel.hidden = newHidden;
|
|
9796
|
+
setState();
|
|
9748
9797
|
} else if (mutation.attributeName === "data-locked") {
|
|
9749
9798
|
panel.setLocked();
|
|
9750
9799
|
} else {
|
|
@@ -11717,7 +11766,7 @@
|
|
|
11717
11766
|
}
|
|
11718
11767
|
|
|
11719
11768
|
// package.json
|
|
11720
|
-
var version = "1.11.
|
|
11769
|
+
var version = "1.11.1";
|
|
11721
11770
|
|
|
11722
11771
|
// src/index.js
|
|
11723
11772
|
window.Harmonia = { getBreakpointListener, addColorSchemeListener, getColorScheme, removeColorSchemeListener, setColorScheme, getSystemColorScheme, version };
|