@customviews-js/customviews 1.7.0 → 1.7.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/custom-views.js +40 -15
- package/dist/custom-views.js.map +1 -1
- package/dist/custom-views.min.js +2 -2
- package/dist/custom-views.min.js.map +1 -1
- package/dist/types/src/lib/controller.svelte.d.ts.map +1 -1
- package/dist/types/src/lib/features/placeholder/stores/placeholder-value-store.svelte.d.ts +1 -0
- package/dist/types/src/lib/features/placeholder/stores/placeholder-value-store.svelte.d.ts.map +1 -1
- package/dist/types/src/lib/utils/scroll-utils.d.ts +4 -3
- package/dist/types/src/lib/utils/scroll-utils.d.ts.map +1 -1
- package/dist/types/tests/lib/utils/scroll-utils.test.d.ts +2 -0
- package/dist/types/tests/lib/utils/scroll-utils.test.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/custom-views.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @customviews-js/customviews v1.7.
|
|
2
|
+
* @customviews-js/customviews v1.7.1
|
|
3
3
|
* (c) 2026 Chan Ger Teck
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -9897,21 +9897,43 @@
|
|
|
9897
9897
|
|
|
9898
9898
|
this.persistence.setItem(STORAGE_KEY_BASE, JSON.stringify(this.values));
|
|
9899
9899
|
}
|
|
9900
|
+
|
|
9901
|
+
reset() {
|
|
9902
|
+
this.values = {};
|
|
9903
|
+
this.persistValue();
|
|
9904
|
+
}
|
|
9900
9905
|
}
|
|
9901
9906
|
|
|
9902
9907
|
const placeholderValueStore = new PlaceholderValueStore();
|
|
9903
9908
|
|
|
9904
9909
|
/**
|
|
9905
|
-
* Calculates the height of
|
|
9906
|
-
* This
|
|
9910
|
+
* Calculates the total height of fixed or sticky elements at the top of the viewport.
|
|
9911
|
+
* This includes the standard site header and any custom elements marked with [data-cv-scroll-offset].
|
|
9912
|
+
* Used to offset scroll positions so content isn't hidden behind these fixed elements.
|
|
9907
9913
|
*/
|
|
9908
|
-
function
|
|
9914
|
+
function getScrollTopOffset() {
|
|
9915
|
+
let headerHeight = 0;
|
|
9916
|
+
let customOffset = 0;
|
|
9917
|
+
// 1. Standard Site Header if applicable
|
|
9909
9918
|
const headerEl = document.querySelector('header');
|
|
9910
|
-
if (
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
9914
|
-
|
|
9919
|
+
if (headerEl) {
|
|
9920
|
+
const headerStyle = window.getComputedStyle(headerEl);
|
|
9921
|
+
const isHeaderFixedOrSticky = ['fixed', 'sticky'].includes(headerStyle.position);
|
|
9922
|
+
if (isHeaderFixedOrSticky) {
|
|
9923
|
+
headerHeight = headerEl.getBoundingClientRect().height;
|
|
9924
|
+
}
|
|
9925
|
+
}
|
|
9926
|
+
// 2. Custom Views Fixed Elements (e.g. Focus Banner)
|
|
9927
|
+
// Elements with [data-cv-scroll-offset] are considered fixed/sticky obstructions.
|
|
9928
|
+
// We use scrollHeight to get the full height even during animations (like slide transition).
|
|
9929
|
+
document.querySelectorAll('[data-cv-scroll-offset]').forEach((el) => {
|
|
9930
|
+
// We assume these elements overlap at the top (top: 0) unless a stacking context is managed.
|
|
9931
|
+
// Taking the MAX ensures we clear the tallest obstruction without over-counting.
|
|
9932
|
+
customOffset = Math.max(customOffset, el.scrollHeight);
|
|
9933
|
+
});
|
|
9934
|
+
// Custom elements overlay the standard header.
|
|
9935
|
+
// Avoid double-counting while ensuring visibility.
|
|
9936
|
+
return Math.max(headerHeight, customOffset);
|
|
9915
9937
|
}
|
|
9916
9938
|
/**
|
|
9917
9939
|
* Finds the highest element matching the selector that is currently in the viewport.
|
|
@@ -9919,7 +9941,7 @@
|
|
|
9919
9941
|
* @returns The HTMLElement of the highest visible element, or null if none are found.
|
|
9920
9942
|
*/
|
|
9921
9943
|
function findHighestVisibleElement(selector) {
|
|
9922
|
-
const headerOffset =
|
|
9944
|
+
const headerOffset = getScrollTopOffset();
|
|
9923
9945
|
const contentTop = headerOffset; // Viewport-relative position where content begins.
|
|
9924
9946
|
// 1. Find all matching elements, filtering out any inside the main header (if fixed/sticky).
|
|
9925
9947
|
const allElements = Array.from(document.querySelectorAll(selector));
|
|
@@ -9954,7 +9976,7 @@
|
|
|
9954
9976
|
* @param element The element to scroll to.
|
|
9955
9977
|
*/
|
|
9956
9978
|
function scrollToElement(element) {
|
|
9957
|
-
const headerOffset =
|
|
9979
|
+
const headerOffset = getScrollTopOffset();
|
|
9958
9980
|
const PADDING_BELOW_HEADER = 20;
|
|
9959
9981
|
const targetElementRect = element.getBoundingClientRect();
|
|
9960
9982
|
const scrollTargetY = targetElementRect.top + window.scrollY;
|
|
@@ -12117,11 +12139,11 @@
|
|
|
12117
12139
|
|
|
12118
12140
|
const focusStore = new FocusStore();
|
|
12119
12141
|
|
|
12120
|
-
var root_1$4 = from_html(`<div id="cv-exit-focus-banner" class="svelte-1yqpn7e"><span>You are viewing a focused selection.</span> <button class="svelte-1yqpn7e">Show Full Page</button></div>`);
|
|
12142
|
+
var root_1$4 = from_html(`<div class="cv-focus-banner-wrapper svelte-1yqpn7e"><div id="cv-exit-focus-banner" data-cv-scroll-offset="" class="svelte-1yqpn7e"><span>You are viewing a focused selection.</span> <button class="svelte-1yqpn7e">Show Full Page</button></div></div>`);
|
|
12121
12143
|
|
|
12122
12144
|
const $$css$a = {
|
|
12123
12145
|
hash: 'svelte-1yqpn7e',
|
|
12124
|
-
code: '
|
|
12146
|
+
code: '.cv-focus-banner-wrapper.svelte-1yqpn7e {position:fixed;top:0;left:0;right:0;z-index:9000;background-color:#0078d4;box-shadow:0 2px 8px rgba(0, 0, 0, 0.2);font-family:system-ui, sans-serif;}#cv-exit-focus-banner.svelte-1yqpn7e {color:white;padding:10px 20px;display:flex;align-items:center;justify-content:center;gap:16px;}button.svelte-1yqpn7e {background:white;color:#0078d4;border:none;padding:4px 12px;border-radius:4px;cursor:pointer;font-weight:600;}button.svelte-1yqpn7e:hover {background:#f0f0f0;}'
|
|
12125
12147
|
};
|
|
12126
12148
|
|
|
12127
12149
|
function FocusBanner($$anchor, $$props) {
|
|
@@ -12140,9 +12162,11 @@
|
|
|
12140
12162
|
{
|
|
12141
12163
|
var consequent = ($$anchor) => {
|
|
12142
12164
|
var div = root_1$4();
|
|
12143
|
-
var
|
|
12165
|
+
var div_1 = child(div);
|
|
12166
|
+
var button = sibling(child(div_1), 2);
|
|
12144
12167
|
|
|
12145
12168
|
button.__click = handleExit;
|
|
12169
|
+
reset(div_1);
|
|
12146
12170
|
reset(div);
|
|
12147
12171
|
transition(3, div, () => slide, () => ({ duration: 250 }));
|
|
12148
12172
|
append($$anchor, div);
|
|
@@ -12387,7 +12411,7 @@
|
|
|
12387
12411
|
|
|
12388
12412
|
const $$css$9 = {
|
|
12389
12413
|
hash: 'svelte-ylk7wm',
|
|
12390
|
-
code: '\n /* Root should allow clicks to pass through to the page unless hitting checking/interactive element */.cv-widget-root {position:fixed;top:0;left:0;width:0;height:0;z-index:9999;pointer-events:none; /* Crucial: Allow clicks to pass through */\n\n /* Light Theme Defaults */--cv-bg: white;--cv-text: rgba(0, 0, 0, 0.9);--cv-text-secondary: rgba(0, 0, 0, 0.6);--cv-border: rgba(0, 0, 0, 0.1);--cv-bg-hover: rgba(0, 0, 0, 0.05);--cv-primary: #3e84f4;--cv-primary-hover: #2563eb;--cv-danger: #dc2626;--cv-danger-bg: rgba(220, 38, 38, 0.1);--cv-shadow: rgba(0, 0, 0, 0.25);--cv-input-bg: white;--cv-input-border: rgba(0, 0, 0, 0.15);--cv-switch-bg: rgba(0, 0, 0, 0.1);--cv-switch-knob: white;--cv-modal-icon-bg: rgba(0, 0, 0, 0.08);--cv-icon-bg: rgba(255, 255, 255, 0.92);--cv-icon-color: rgba(0, 0, 0, 0.9);--cv-focus-ring: rgba(62, 132, 244, 0.2);--cv-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);font-family:inherit; /* Inherit font from host */}\n\n /* But interactive children need pointer-events back */.cv-widget-root > * {pointer-events:auto;}\n\n /* Exception: ShareOverlay manages its own pointer events */.cv-widget-root .cv-share-overlay {pointer-events:none; /* Overlay often passes clicks until specialized handles active */}.cv-widget-root[data-theme=\'dark\'] {\n /* Dark Theme Overrides */--cv-bg: #101722;--cv-text: #e2e8f0;--cv-text-secondary: rgba(255, 255, 255, 0.6);--cv-border: rgba(255, 255, 255, 0.1);--cv-bg-hover: rgba(255, 255, 255, 0.05);--cv-primary: #3e84f4;--cv-primary-hover: #60a5fa;--cv-danger: #f87171;--cv-danger-bg: rgba(248, 113, 113, 0.1);--cv-shadow: rgba(0, 0, 0, 0.5);--cv-input-bg: #1e293b;--cv-input-border: rgba(255, 255, 255, 0.1);--cv-switch-bg: rgba(255, 255, 255, 0.1);--cv-switch-knob: #e2e8f0;--cv-modal-icon-bg: rgba(255, 255, 255, 0.08);--cv-icon-bg: #1e293b;--cv-icon-color: #e2e8f0;--cv-focus-ring: rgba(62, 132, 244, 0.5);--cv-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);}
|
|
12414
|
+
code: '\n /* Root should allow clicks to pass through to the page unless hitting checking/interactive element */.cv-widget-root {position:fixed;top:0;left:0;width:0;height:0;z-index:9999;pointer-events:none; /* Crucial: Allow clicks to pass through */\n\n /* Light Theme Defaults */--cv-bg: white;--cv-text: rgba(0, 0, 0, 0.9);--cv-text-secondary: rgba(0, 0, 0, 0.6);--cv-border: rgba(0, 0, 0, 0.1);--cv-bg-hover: rgba(0, 0, 0, 0.05);--cv-primary: #3e84f4;--cv-primary-hover: #2563eb;--cv-danger: #dc2626;--cv-danger-bg: rgba(220, 38, 38, 0.1);--cv-shadow: rgba(0, 0, 0, 0.25);--cv-input-bg: white;--cv-input-border: rgba(0, 0, 0, 0.15);--cv-switch-bg: rgba(0, 0, 0, 0.1);--cv-switch-knob: white;--cv-modal-icon-bg: rgba(0, 0, 0, 0.08);--cv-icon-bg: rgba(255, 255, 255, 0.92);--cv-icon-color: rgba(0, 0, 0, 0.9);--cv-focus-ring: rgba(62, 132, 244, 0.2);--cv-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);font-family:inherit; /* Inherit font from host */}\n\n /* But interactive children need pointer-events back */.cv-widget-root > * {pointer-events:auto;}\n\n /* Exception: ShareOverlay manages its own pointer events */.cv-widget-root .cv-share-overlay {pointer-events:none; /* Overlay often passes clicks until specialized handles active */}.cv-widget-root[data-theme=\'dark\'] {\n /* Dark Theme Overrides */--cv-bg: #101722;--cv-text: #e2e8f0;--cv-text-secondary: rgba(255, 255, 255, 0.6);--cv-border: rgba(255, 255, 255, 0.1);--cv-bg-hover: rgba(255, 255, 255, 0.05);--cv-primary: #3e84f4;--cv-primary-hover: #60a5fa;--cv-danger: #f87171;--cv-danger-bg: rgba(248, 113, 113, 0.1);--cv-shadow: rgba(0, 0, 0, 0.5);--cv-input-bg: #1e293b;--cv-input-border: rgba(255, 255, 255, 0.1);--cv-switch-bg: rgba(255, 255, 255, 0.1);--cv-switch-knob: #e2e8f0;--cv-modal-icon-bg: rgba(255, 255, 255, 0.08);--cv-icon-bg: #1e293b;--cv-icon-color: #e2e8f0;--cv-focus-ring: rgba(62, 132, 244, 0.5);--cv-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);}.cv-hidden {display:none !important;}'
|
|
12391
12415
|
};
|
|
12392
12416
|
|
|
12393
12417
|
function UIRoot($$anchor, $$props) {
|
|
@@ -14411,6 +14435,7 @@
|
|
|
14411
14435
|
this.persistenceManager.clearAll();
|
|
14412
14436
|
this.store.reset();
|
|
14413
14437
|
this.store.isTabGroupNavHeadingVisible = true;
|
|
14438
|
+
placeholderValueStore.reset();
|
|
14414
14439
|
URLStateManager.clearURL();
|
|
14415
14440
|
}
|
|
14416
14441
|
|