@khipu/design-system 0.3.5-alpha.2 → 0.3.5-alpha.21
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 +197 -26
- package/dist/beercss/khipu-beercss.js +5 -61
- 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 +196 -26
- package/dist/beercss/khipu-beercss.scoped.min.css +1 -1
- package/dist/beercss/metadata.json +5 -5
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +162 -214
- package/dist/index.mjs +31 -84
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// src/theme/KdsThemeProvider.tsx
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
|
|
4
1
|
// src/components/core/utils.ts
|
|
5
2
|
import { clsx } from "clsx";
|
|
6
3
|
function hexToRgb(hex) {
|
|
@@ -72,79 +69,28 @@ function formatTime(iso) {
|
|
|
72
69
|
return `${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
73
70
|
}
|
|
74
71
|
|
|
72
|
+
// src/version.ts
|
|
73
|
+
var KDS_VERSION = "0.3.5-alpha.21";
|
|
74
|
+
|
|
75
75
|
// src/theme/KdsThemeProvider.tsx
|
|
76
76
|
import { jsx } from "react/jsx-runtime";
|
|
77
|
-
var CARD_MIN_DELTA_PX = 8;
|
|
78
|
-
var CARD_TRANSITION_MS = 280;
|
|
79
|
-
var BODY_CARD_SELECTOR = ".kds-screen > .kds-card-elevated";
|
|
80
|
-
var CARD_MARK_ATTRIBUTE = "data-kds-height-transition";
|
|
81
|
-
function useCardHeightTransition() {
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
if (typeof window === "undefined" || typeof ResizeObserver === "undefined") {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (typeof Element.prototype.animate !== "function") {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if (window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const observers = [];
|
|
93
|
-
const observe = (card) => {
|
|
94
|
-
if (card.getAttribute(CARD_MARK_ATTRIBUTE) === "on") {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
card.setAttribute(CARD_MARK_ATTRIBUTE, "on");
|
|
98
|
-
let previous = card.offsetHeight;
|
|
99
|
-
let animating = false;
|
|
100
|
-
const observer = new ResizeObserver(() => {
|
|
101
|
-
if (animating) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const next = card.offsetHeight;
|
|
105
|
-
if (Math.abs(next - previous) < CARD_MIN_DELTA_PX) {
|
|
106
|
-
previous = next;
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
animating = true;
|
|
110
|
-
const animation = card.animate(
|
|
111
|
-
[{ height: `${previous}px` }, { height: `${next}px` }],
|
|
112
|
-
{ duration: CARD_TRANSITION_MS, easing: "ease-out" }
|
|
113
|
-
);
|
|
114
|
-
previous = next;
|
|
115
|
-
animation.finished.then(() => {
|
|
116
|
-
animating = false;
|
|
117
|
-
previous = card.offsetHeight;
|
|
118
|
-
}).catch(() => {
|
|
119
|
-
animating = false;
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
observer.observe(card);
|
|
123
|
-
observers.push(observer);
|
|
124
|
-
};
|
|
125
|
-
document.querySelectorAll(BODY_CARD_SELECTOR).forEach(observe);
|
|
126
|
-
const tree = new MutationObserver(() => {
|
|
127
|
-
document.querySelectorAll(BODY_CARD_SELECTOR).forEach(observe);
|
|
128
|
-
});
|
|
129
|
-
tree.observe(document.body, { childList: true, subtree: true });
|
|
130
|
-
return () => {
|
|
131
|
-
tree.disconnect();
|
|
132
|
-
observers.forEach((observer) => observer.disconnect());
|
|
133
|
-
document.querySelectorAll(BODY_CARD_SELECTOR).forEach((card) => {
|
|
134
|
-
card.removeAttribute(CARD_MARK_ATTRIBUTE);
|
|
135
|
-
});
|
|
136
|
-
};
|
|
137
|
-
}, []);
|
|
138
|
-
}
|
|
139
77
|
function KdsThemeProvider({ primaryColor, mode = "light", children }) {
|
|
140
|
-
useCardHeightTransition();
|
|
141
78
|
const style = primaryColor ? {
|
|
142
79
|
"--primary": primaryColor,
|
|
143
80
|
"--on-primary": getContrastColor(primaryColor),
|
|
144
81
|
"--primary-container": lighten(primaryColor, 0.85),
|
|
145
82
|
"--on-primary-container": primaryColor
|
|
146
83
|
} : void 0;
|
|
147
|
-
return /* @__PURE__ */ jsx(
|
|
84
|
+
return /* @__PURE__ */ jsx(
|
|
85
|
+
"div",
|
|
86
|
+
{
|
|
87
|
+
className: `kds-theme-root ${mode}`,
|
|
88
|
+
"data-theme": mode,
|
|
89
|
+
"data-kds-version": KDS_VERSION,
|
|
90
|
+
style,
|
|
91
|
+
children
|
|
92
|
+
}
|
|
93
|
+
);
|
|
148
94
|
}
|
|
149
95
|
|
|
150
96
|
// src/tokens/index.ts
|
|
@@ -1520,7 +1466,7 @@ var KdsTypography = forwardRef11(
|
|
|
1520
1466
|
KdsTypography.displayName = "KdsTypography";
|
|
1521
1467
|
|
|
1522
1468
|
// src/components/core/KdsTabs/KdsTabs.tsx
|
|
1523
|
-
import
|
|
1469
|
+
import React12, { forwardRef as forwardRef12, Children, useMemo } from "react";
|
|
1524
1470
|
|
|
1525
1471
|
// src/components/core/hooks/useTabsKeyboard.ts
|
|
1526
1472
|
import { useCallback as useCallback2 } from "react";
|
|
@@ -1568,8 +1514,8 @@ var KdsTabs = forwardRef12(
|
|
|
1568
1514
|
onKeyDown,
|
|
1569
1515
|
...props,
|
|
1570
1516
|
children: Children.map(children, (child, i) => {
|
|
1571
|
-
if (!
|
|
1572
|
-
return
|
|
1517
|
+
if (!React12.isValidElement(child)) return child;
|
|
1518
|
+
return React12.cloneElement(child, {
|
|
1573
1519
|
_active: i === activeIndex,
|
|
1574
1520
|
_onClick: () => onChange(i)
|
|
1575
1521
|
});
|
|
@@ -1730,12 +1676,12 @@ KdsChip.displayName = "KdsChip";
|
|
|
1730
1676
|
import { forwardRef as forwardRef16 } from "react";
|
|
1731
1677
|
|
|
1732
1678
|
// src/components/core/hooks/useAutoHide.ts
|
|
1733
|
-
import { useState as useState3, useEffect
|
|
1679
|
+
import { useState as useState3, useEffect, useRef } from "react";
|
|
1734
1680
|
function useAutoHide(durationMs, onHide) {
|
|
1735
1681
|
const [visible, setVisible] = useState3(true);
|
|
1736
1682
|
const onHideRef = useRef(onHide);
|
|
1737
1683
|
onHideRef.current = onHide;
|
|
1738
|
-
|
|
1684
|
+
useEffect(() => {
|
|
1739
1685
|
if (durationMs <= 0) return;
|
|
1740
1686
|
const timer = setTimeout(() => {
|
|
1741
1687
|
setVisible(false);
|
|
@@ -2179,10 +2125,10 @@ var KdsExpandPanel = forwardRef24(
|
|
|
2179
2125
|
KdsExpandPanel.displayName = "KdsExpandPanel";
|
|
2180
2126
|
|
|
2181
2127
|
// src/components/core/KdsCountdown/KdsCountdown.tsx
|
|
2182
|
-
import { forwardRef as forwardRef25, useEffect as
|
|
2128
|
+
import { forwardRef as forwardRef25, useEffect as useEffect3, useRef as useRef3 } from "react";
|
|
2183
2129
|
|
|
2184
2130
|
// src/components/core/hooks/useCountdown.ts
|
|
2185
|
-
import { useState as useState6, useEffect as
|
|
2131
|
+
import { useState as useState6, useEffect as useEffect2 } from "react";
|
|
2186
2132
|
function calcRemaining(deadline) {
|
|
2187
2133
|
const diff = Math.max(0, new Date(deadline).getTime() - Date.now());
|
|
2188
2134
|
const totalSeconds = Math.floor(diff / 1e3);
|
|
@@ -2196,7 +2142,7 @@ function calcRemaining(deadline) {
|
|
|
2196
2142
|
}
|
|
2197
2143
|
function useCountdown(deadline) {
|
|
2198
2144
|
const [state, setState] = useState6(() => calcRemaining(deadline));
|
|
2199
|
-
|
|
2145
|
+
useEffect2(() => {
|
|
2200
2146
|
const tick = () => setState(calcRemaining(deadline));
|
|
2201
2147
|
const id = setInterval(tick, 1e3);
|
|
2202
2148
|
return () => clearInterval(id);
|
|
@@ -2211,7 +2157,7 @@ var KdsCountdown = forwardRef25(
|
|
|
2211
2157
|
const { hours, minutes, seconds, expired, urgent } = useCountdown(deadline);
|
|
2212
2158
|
const onExpireRef = useRef3(onExpire);
|
|
2213
2159
|
onExpireRef.current = onExpire;
|
|
2214
|
-
|
|
2160
|
+
useEffect3(() => {
|
|
2215
2161
|
if (expired) {
|
|
2216
2162
|
onExpireRef.current?.();
|
|
2217
2163
|
}
|
|
@@ -2590,7 +2536,7 @@ KdsMerchantTile.displayName = "KdsMerchantTile";
|
|
|
2590
2536
|
import { forwardRef as forwardRef42, useState as useState9 } from "react";
|
|
2591
2537
|
|
|
2592
2538
|
// src/components/domain/KdsInvoiceMerchant/useLogoBackdrop.ts
|
|
2593
|
-
import { useEffect as
|
|
2539
|
+
import { useEffect as useEffect4, useState as useState8 } from "react";
|
|
2594
2540
|
|
|
2595
2541
|
// src/components/domain/KdsInvoiceMerchant/logoLuminance.ts
|
|
2596
2542
|
var LIGHT_LOGO_LUMINANCE_THRESHOLD = 0.72;
|
|
@@ -2640,7 +2586,7 @@ function pickLogoBackdrop(luminance) {
|
|
|
2640
2586
|
// src/components/domain/KdsInvoiceMerchant/useLogoBackdrop.ts
|
|
2641
2587
|
function useLogoBackdrop(logoUrl) {
|
|
2642
2588
|
const [backdrop, setBackdrop] = useState8("light");
|
|
2643
|
-
|
|
2589
|
+
useEffect4(() => {
|
|
2644
2590
|
let cancelled = false;
|
|
2645
2591
|
setBackdrop("light");
|
|
2646
2592
|
if (!logoUrl) {
|
|
@@ -2882,12 +2828,12 @@ var guideToFirstInvalidFieldOnBlur = (form) => {
|
|
|
2882
2828
|
};
|
|
2883
2829
|
|
|
2884
2830
|
// src/components/core/hooks/useStickyInvoiceCollapse.ts
|
|
2885
|
-
import { useEffect as
|
|
2831
|
+
import { useEffect as useEffect5, useRef as useRef4 } from "react";
|
|
2886
2832
|
function useStickyInvoiceCollapse(options = {}) {
|
|
2887
2833
|
const { onCollapseStart, collapseEnd = 20, mobileBreakpoint = 768 } = options;
|
|
2888
2834
|
const onCollapseStartRef = useRef4(onCollapseStart);
|
|
2889
2835
|
onCollapseStartRef.current = onCollapseStart;
|
|
2890
|
-
|
|
2836
|
+
useEffect5(() => {
|
|
2891
2837
|
let viewportOffset = 0;
|
|
2892
2838
|
let ticking = false;
|
|
2893
2839
|
let wasCollapsing = false;
|
|
@@ -3009,11 +2955,11 @@ function useExpandToggle(options = {}) {
|
|
|
3009
2955
|
}
|
|
3010
2956
|
|
|
3011
2957
|
// src/components/core/hooks/useHideOnScroll.ts
|
|
3012
|
-
import { useEffect as
|
|
2958
|
+
import { useEffect as useEffect6, useState as useState11 } from "react";
|
|
3013
2959
|
function useHideOnScroll(options = {}) {
|
|
3014
2960
|
const { threshold = 8, topOffset = 0 } = options;
|
|
3015
2961
|
const [hidden, setHidden] = useState11(false);
|
|
3016
|
-
|
|
2962
|
+
useEffect6(() => {
|
|
3017
2963
|
let viewportOffset = 0;
|
|
3018
2964
|
let lastY = 0;
|
|
3019
2965
|
let ticking = false;
|
|
@@ -3056,12 +3002,12 @@ function useHideOnScroll(options = {}) {
|
|
|
3056
3002
|
}
|
|
3057
3003
|
|
|
3058
3004
|
// src/components/core/hooks/useMediaQuery.ts
|
|
3059
|
-
import { useEffect as
|
|
3005
|
+
import { useEffect as useEffect7, useState as useState12 } from "react";
|
|
3060
3006
|
function useMediaQuery(query) {
|
|
3061
3007
|
const [matches, setMatches] = useState12(
|
|
3062
3008
|
() => typeof window !== "undefined" ? window.matchMedia(query).matches : false
|
|
3063
3009
|
);
|
|
3064
|
-
|
|
3010
|
+
useEffect7(() => {
|
|
3065
3011
|
if (typeof window === "undefined") return;
|
|
3066
3012
|
const mql = window.matchMedia(query);
|
|
3067
3013
|
setMatches(mql.matches);
|
|
@@ -3072,6 +3018,7 @@ function useMediaQuery(query) {
|
|
|
3072
3018
|
return matches;
|
|
3073
3019
|
}
|
|
3074
3020
|
export {
|
|
3021
|
+
KDS_VERSION,
|
|
3075
3022
|
KdsAccordion,
|
|
3076
3023
|
KdsAccordionDetails,
|
|
3077
3024
|
KdsAccordionSummary,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khipu/design-system",
|
|
3
|
-
"version": "0.3.5-alpha.
|
|
3
|
+
"version": "0.3.5-alpha.21",
|
|
4
4
|
"description": "Khipu Design System - UI components and design tokens for the Khipu payment platform",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "npm run build:web && npm run tokens:export && node scripts/generate-css-variables.js && npm run beercss:build",
|
|
52
|
-
"build:web": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
52
|
+
"build:web": "node scripts/generate-version.js && tsup src/index.ts --format cjs,esm --dts --clean",
|
|
53
53
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
54
54
|
"demo": "vite --config demo/vite.config.ts",
|
|
55
55
|
"typecheck": "tsc --noEmit",
|