@khipu/design-system 0.3.5-alpha.4 → 0.3.5-alpha.40
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/beercss/khipu-beercss.css +1599 -199
- package/dist/beercss/khipu-beercss.js +59 -52
- package/dist/beercss/khipu-beercss.min.css +1 -1
- package/dist/beercss/khipu-beercss.min.js +1 -1
- package/dist/beercss/khipu-beercss.scoped.css +1598 -198
- package/dist/beercss/khipu-beercss.scoped.min.css +1 -1
- package/dist/beercss/metadata.json +5 -5
- package/dist/index.d.mts +426 -12
- package/dist/index.d.ts +426 -12
- package/dist/index.js +1153 -428
- package/dist/index.mjs +1140 -427
- package/package.json +2 -2
|
@@ -849,6 +849,7 @@ const ui = _context.ui;
|
|
|
849
849
|
* - Sticky invoice card (collapse on scroll)
|
|
850
850
|
* - Brand inner (logo inside sticky card on mobile)
|
|
851
851
|
* - Secure footer (moved inside last card per screen)
|
|
852
|
+
* - Read-to-accept contracts (checkbox enabled after scrolling to the end)
|
|
852
853
|
*/
|
|
853
854
|
|
|
854
855
|
(function() {
|
|
@@ -895,71 +896,77 @@ const ui = _context.ui;
|
|
|
895
896
|
initHideOnScroll();
|
|
896
897
|
initBankModal();
|
|
897
898
|
initMerchantLogoBackdrop();
|
|
898
|
-
|
|
899
|
+
initContract();
|
|
899
900
|
|
|
900
901
|
console.log('Material Design initialization complete!');
|
|
901
902
|
}
|
|
902
903
|
|
|
903
904
|
/**
|
|
904
|
-
* Initialize
|
|
905
|
-
*
|
|
906
|
-
*
|
|
907
|
-
*
|
|
908
|
-
*
|
|
909
|
-
*
|
|
910
|
-
* el valor declarado cambia, que no es el caso). Por eso se mide y se anima acá.
|
|
905
|
+
* Initialize read-to-accept contracts (KTUF-398)
|
|
906
|
+
* In each [data-kds-contract] the acceptance checkbox (.kds-contract-accept) stays
|
|
907
|
+
* disabled until .kds-contract-content is scrolled to the end, or right away if the
|
|
908
|
+
* content fits without scrolling. Then the hint (.kds-contract-hint) is hidden, the
|
|
909
|
+
* container gets .kds-contract--read and fires `kds:contract-read` once.
|
|
910
|
+
* Vanilla mirror of KdsContract for server-side views (payment).
|
|
911
911
|
* @param {Element} root - Root element to scope the query (default: document)
|
|
912
912
|
*/
|
|
913
|
-
function
|
|
913
|
+
function initContract(root) {
|
|
914
914
|
root = root || document;
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
return;
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
915
|
+
root.querySelectorAll('[data-kds-contract]').forEach(function(contract) {
|
|
916
|
+
if (contract.hasAttribute('data-kds-contract-ready')) return;
|
|
917
|
+
contract.setAttribute('data-kds-contract-ready', '');
|
|
918
|
+
|
|
919
|
+
var content = contract.querySelector('.kds-contract-content');
|
|
920
|
+
var checkbox = contract.querySelector('.kds-contract-accept input[type="checkbox"]');
|
|
921
|
+
var hint = contract.querySelector('.kds-contract-hint');
|
|
922
|
+
if (!content || !checkbox) return;
|
|
923
|
+
|
|
924
|
+
// The markup ships the checkbox enabled so the page still works without this
|
|
925
|
+
// script; here it is locked until the content has been read.
|
|
926
|
+
checkbox.disabled = true;
|
|
927
|
+
|
|
928
|
+
function markRead() {
|
|
929
|
+
if (contract.classList.contains('kds-contract--read')) return;
|
|
930
|
+
contract.classList.add('kds-contract--read');
|
|
931
|
+
checkbox.disabled = false;
|
|
932
|
+
if (hint) {
|
|
933
|
+
hint.hidden = true;
|
|
934
|
+
// The hidden hint no longer describes the checkbox (as in KdsContract).
|
|
935
|
+
if (hint.id) {
|
|
936
|
+
var describedBy = (checkbox.getAttribute('aria-describedby') || '')
|
|
937
|
+
.split(/\s+/)
|
|
938
|
+
.filter(function(id) { return id && id !== hint.id; });
|
|
939
|
+
if (describedBy.length) checkbox.setAttribute('aria-describedby', describedBy.join(' '));
|
|
940
|
+
else checkbox.removeAttribute('aria-describedby');
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
contract.dispatchEvent(new CustomEvent('kds:contract-read', { bubbles: true }));
|
|
929
944
|
}
|
|
930
|
-
card.setAttribute('data-kds-height-transition', 'on');
|
|
931
|
-
|
|
932
|
-
var previous = card.offsetHeight;
|
|
933
|
-
var animating = false;
|
|
934
945
|
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
if (Math.abs(next - previous) < MIN_DELTA_PX) {
|
|
943
|
-
previous = next;
|
|
944
|
-
return;
|
|
946
|
+
// A few px of tolerance: zoom and sub-pixel rounding rarely land exactly on 0.
|
|
947
|
+
// clientHeight 0 means not laid out yet (hidden step or tab): wait for the
|
|
948
|
+
// ResizeObserver instead of reading 0 >= -8 as "reached the end".
|
|
949
|
+
function check() {
|
|
950
|
+
if (content.clientHeight === 0) return;
|
|
951
|
+
if (content.scrollTop + content.clientHeight >= content.scrollHeight - 8) {
|
|
952
|
+
markRead();
|
|
945
953
|
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
);
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
animating = false;
|
|
954
|
-
previous = card.offsetHeight;
|
|
955
|
-
}).catch(function() {
|
|
956
|
-
animating = false;
|
|
957
|
-
});
|
|
958
|
-
});
|
|
959
|
-
observer.observe(card);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
content.addEventListener('scroll', check, { passive: true });
|
|
957
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
958
|
+
new ResizeObserver(check).observe(content);
|
|
959
|
+
}
|
|
960
|
+
check();
|
|
960
961
|
});
|
|
961
962
|
}
|
|
962
963
|
|
|
964
|
+
// El alto de la body card cambia de golpe entre pantallas, sin animar. Hubo una
|
|
965
|
+
// transición acá (KTUF-239) y se quitó en KTUF-314: ver el comentario en
|
|
966
|
+
// KdsThemeProvider.tsx — animar el alto obliga a fijar `height` en píxeles, y con el
|
|
967
|
+
// alto fijado no hay forma de medir el alto natural del contenido para saber cuándo
|
|
968
|
+
// soltarlo, así que la card quedaba con espacio muerto abajo.
|
|
969
|
+
|
|
963
970
|
/**
|
|
964
971
|
* Initialize merchant logo backdrop (KTUF-204)
|
|
965
972
|
* Los logos de comercio van sobre el fondo neutro, no sobre el color de marca (los PNG
|
|
@@ -1798,7 +1805,7 @@ const ui = _context.ui;
|
|
|
1798
1805
|
window.Khipu.initBankModal = initBankModal;
|
|
1799
1806
|
window.Khipu.initStickyInvoice = initStickyInvoice;
|
|
1800
1807
|
window.Khipu.initHideOnScroll = initHideOnScroll;
|
|
1801
|
-
window.Khipu.
|
|
1808
|
+
window.Khipu.initContract = initContract;
|
|
1802
1809
|
|
|
1803
1810
|
// Also export showSnackbar to global scope for backward compatibility
|
|
1804
1811
|
window.showSnackbar = showSnackbar;
|