@kud/ink-ui 0.20.0 → 0.20.2
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/index.js +20 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -655,14 +655,23 @@ var ScrollView = ({
|
|
|
655
655
|
] });
|
|
656
656
|
};
|
|
657
657
|
var GAP = 2;
|
|
658
|
-
var SLIDE_STEPS =
|
|
659
|
-
var SLIDE_MS =
|
|
658
|
+
var SLIDE_STEPS = 12;
|
|
659
|
+
var SLIDE_MS = 28;
|
|
660
660
|
var between = (from, to, t) => {
|
|
661
|
-
const ease = 1 - Math.pow(
|
|
661
|
+
const ease = t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
|
|
662
662
|
const lerp = (a, b) => Math.round(a + (b - a) * ease);
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
663
|
+
return {
|
|
664
|
+
start: lerp(from.start, to.start),
|
|
665
|
+
width: Math.max(1, lerp(from.width, to.width))
|
|
666
|
+
};
|
|
667
|
+
};
|
|
668
|
+
var nearestTo = (rules, rule, fallback) => {
|
|
669
|
+
const centre = (r) => r.start + r.width / 2;
|
|
670
|
+
if (rules.length === 0) return fallback;
|
|
671
|
+
return rules.reduce(
|
|
672
|
+
(best, r, i) => Math.abs(centre(r) - centre(rule)) < Math.abs(centre(rules[best]) - centre(rule)) ? i : best,
|
|
673
|
+
Math.min(fallback, rules.length - 1)
|
|
674
|
+
);
|
|
666
675
|
};
|
|
667
676
|
var useSlide = (rules, active) => {
|
|
668
677
|
const target = rules[active] ?? null;
|
|
@@ -706,15 +715,16 @@ var Tabs = ({ active, items }) => {
|
|
|
706
715
|
}
|
|
707
716
|
const activeIndex = cells.findIndex((c) => c.isActive);
|
|
708
717
|
const rule = useSlide(rules, activeIndex) ?? { start: 0, width: 0 };
|
|
718
|
+
const litIndex = nearestTo(rules, rule, Math.max(0, activeIndex));
|
|
709
719
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
710
|
-
/* @__PURE__ */ jsx(Box, { gap: GAP, children: cells.map((cell) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
720
|
+
/* @__PURE__ */ jsx(Box, { gap: GAP, children: cells.map((cell, i) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
711
721
|
cell.marker ? /* @__PURE__ */ jsx(Text, { color: cell.markerColor, children: cell.marker }) : null,
|
|
712
722
|
/* @__PURE__ */ jsx(
|
|
713
723
|
Text,
|
|
714
724
|
{
|
|
715
|
-
bold:
|
|
716
|
-
color:
|
|
717
|
-
dimColor:
|
|
725
|
+
bold: i === litIndex,
|
|
726
|
+
color: i === litIndex ? colors.accent : void 0,
|
|
727
|
+
dimColor: i !== litIndex,
|
|
718
728
|
children: cell.text
|
|
719
729
|
}
|
|
720
730
|
)
|