@kjun-ui/native 0.7.0 → 0.8.0
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.cjs +77 -121
- package/dist/index.js +128 -172
- package/dist/index.web.cjs +77 -121
- package/dist/index.web.js +128 -172
- package/dist/styles.css +24 -42
- package/dist/types/packages/native/src/skeleton-base.d.cts +1 -1
- package/dist/types/packages/native/src/skeleton-base.d.ts +1 -1
- package/dist/types/packages/native/src/skeletons.d.cts +8 -3
- package/dist/types/packages/native/src/skeletons.d.ts +8 -3
- package/dist/types/shared/package-runtime/chart-skeleton.d.cts +12 -0
- package/dist/types/shared/package-runtime/chart-skeleton.d.ts +12 -0
- package/package.json +3 -3
package/dist/index.web.cjs
CHANGED
|
@@ -2417,36 +2417,6 @@ function KjunSkeleton({
|
|
|
2417
2417
|
))
|
|
2418
2418
|
}
|
|
2419
2419
|
),
|
|
2420
|
-
type === "chart" && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native16.View, { style: [frame, { height: height || import_tokens13.tokens.extensions.skeleton.chartHeight }], children: [
|
|
2421
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2422
|
-
import_react_native16.View,
|
|
2423
|
-
{
|
|
2424
|
-
style: {
|
|
2425
|
-
flex: 1,
|
|
2426
|
-
flexDirection: "row",
|
|
2427
|
-
alignItems: "flex-end",
|
|
2428
|
-
justifyContent: "space-around",
|
|
2429
|
-
gap: import_tokens13.tokens.extensions.skeleton.gap
|
|
2430
|
-
// Bars stand on the axis line, like ChartSkeleton.
|
|
2431
|
-
},
|
|
2432
|
-
children: [40, 65, 50, 80, 60, 90, 75].map((h, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2433
|
-
import_react_native16.Animated.View,
|
|
2434
|
-
{
|
|
2435
|
-
style: {
|
|
2436
|
-
flex: 1,
|
|
2437
|
-
maxWidth: import_tokens13.tokens.extensions.skeleton.chartBarMaxWidth,
|
|
2438
|
-
height: `${h}%`,
|
|
2439
|
-
backgroundColor: shimmer,
|
|
2440
|
-
borderTopLeftRadius: import_tokens13.tokens.radius.radius4,
|
|
2441
|
-
borderTopRightRadius: import_tokens13.tokens.radius.radius4
|
|
2442
|
-
}
|
|
2443
|
-
},
|
|
2444
|
-
i
|
|
2445
|
-
))
|
|
2446
|
-
}
|
|
2447
|
-
),
|
|
2448
|
-
block("100%", import_tokens13.tokens.extensions.skeleton.chartAxisHeight, { backgroundColor: colors.border })
|
|
2449
|
-
] }),
|
|
2450
2420
|
type === "stat" && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2451
2421
|
import_react_native16.View,
|
|
2452
2422
|
{
|
|
@@ -6511,6 +6481,20 @@ var import_react57 = require("react");
|
|
|
6511
6481
|
var import_react_native42 = require("react-native");
|
|
6512
6482
|
var import_react_native_svg5 = __toESM(require("react-native-svg"), 1);
|
|
6513
6483
|
|
|
6484
|
+
// shared/package-runtime/chart-skeleton.ts
|
|
6485
|
+
var chartFrameViewBox = "0 0 600 240";
|
|
6486
|
+
var chartFramePath = "M20 10V220H590 M20 65H590 M20 120H590 M20 175H590";
|
|
6487
|
+
var chartSkeletonMaxCount = 100;
|
|
6488
|
+
function chartSkeletonCount(value) {
|
|
6489
|
+
return Number.isFinite(value) ? Math.min(chartSkeletonMaxCount, Math.max(1, Math.floor(value))) : 1;
|
|
6490
|
+
}
|
|
6491
|
+
function chartMatrixMuted(row, column) {
|
|
6492
|
+
return (row + column + 2) % 3 === 0;
|
|
6493
|
+
}
|
|
6494
|
+
function chartDonutHole(height, thickness) {
|
|
6495
|
+
return Math.max(0, height * 0.8 - 2 * thickness);
|
|
6496
|
+
}
|
|
6497
|
+
|
|
6514
6498
|
// packages/native/src/market-skeleton.tsx
|
|
6515
6499
|
var import_tokens39 = require("@kjun-ui/tokens");
|
|
6516
6500
|
var import_react_native41 = require("react-native");
|
|
@@ -6668,26 +6652,23 @@ function KjunFormSkeleton({
|
|
|
6668
6652
|
}
|
|
6669
6653
|
);
|
|
6670
6654
|
}
|
|
6655
|
+
var chartPart = (name) => import_react_native42.Platform.OS === "web" ? { dataSet: { kjunChartPart: name } } : {};
|
|
6671
6656
|
function KjunChartSkeleton({
|
|
6657
|
+
kind = "frame",
|
|
6658
|
+
height = import_tokens40.tokens.extensions.chartSkeleton.height,
|
|
6672
6659
|
loadingText = "\uCC28\uD2B8\uB97C \uBD88\uB7EC\uC624\uB294 \uC911",
|
|
6673
|
-
|
|
6674
|
-
|
|
6660
|
+
skeleton = true,
|
|
6661
|
+
loadingDelay = 0,
|
|
6662
|
+
rows = 8,
|
|
6663
|
+
columns = 14
|
|
6675
6664
|
}) {
|
|
6676
|
-
const { colors } = useKjunStyles(), reduced = useReducedMotion(), opacity = (0, import_react57.useRef)(new import_react_native42.Animated.Value(1)).current;
|
|
6665
|
+
const { colors } = useKjunStyles(), reduced = useReducedMotion(), opacity = (0, import_react57.useRef)(new import_react_native42.Animated.Value(1)).current, revealed = useLoadingReveal(true, loadingDelay), [measured, setMeasured] = (0, import_react57.useState)(0), thickness = import_tokens40.tokens.extensions.chartSkeleton.donutThickness, boxHeight = typeof height === "number" ? height : measured, hole = boxHeight > 0 ? chartDonutHole(boxHeight, thickness) : void 0, rowCount = chartSkeletonCount(rows), columnCount = chartSkeletonCount(columns), status = revealed && loadingText ? "status" : void 0, hidden = { "aria-hidden": true, importantForAccessibility: "no-hide-descendants" };
|
|
6677
6666
|
(0, import_react57.useEffect)(() => {
|
|
6678
|
-
if (reduced) return;
|
|
6667
|
+
if (reduced || !skeleton) return;
|
|
6679
6668
|
const loop = import_react_native42.Animated.loop(
|
|
6680
6669
|
import_react_native42.Animated.sequence([
|
|
6681
|
-
import_react_native42.Animated.timing(opacity, {
|
|
6682
|
-
|
|
6683
|
-
duration: import_tokens40.tokens.motion.shimmer / 2,
|
|
6684
|
-
useNativeDriver: true
|
|
6685
|
-
}),
|
|
6686
|
-
import_react_native42.Animated.timing(opacity, {
|
|
6687
|
-
toValue: 1,
|
|
6688
|
-
duration: import_tokens40.tokens.motion.shimmer / 2,
|
|
6689
|
-
useNativeDriver: true
|
|
6690
|
-
})
|
|
6670
|
+
import_react_native42.Animated.timing(opacity, { toValue: 0.55, duration: import_tokens40.tokens.motion.shimmer / 2, useNativeDriver: true }),
|
|
6671
|
+
import_react_native42.Animated.timing(opacity, { toValue: 1, duration: import_tokens40.tokens.motion.shimmer / 2, useNativeDriver: true })
|
|
6691
6672
|
])
|
|
6692
6673
|
);
|
|
6693
6674
|
loop.start();
|
|
@@ -6695,92 +6676,67 @@ function KjunChartSkeleton({
|
|
|
6695
6676
|
loop.stop();
|
|
6696
6677
|
opacity.setValue(1);
|
|
6697
6678
|
};
|
|
6698
|
-
}, [opacity, reduced]);
|
|
6699
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.
|
|
6679
|
+
}, [opacity, reduced, skeleton]);
|
|
6680
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
6700
6681
|
import_react_native42.Animated.View,
|
|
6701
6682
|
{
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
importantForAccessibility: "no-hide-descendants",
|
|
6712
|
-
children: [
|
|
6683
|
+
onLayout: typeof height === "number" ? void 0 : (event) => setMeasured(event.nativeEvent.layout.height),
|
|
6684
|
+
style: { height, alignItems: "center", justifyContent: "center", width: "100%", minWidth: 0, opacity: revealed ? opacity : 0 },
|
|
6685
|
+
"aria-hidden": revealed ? void 0 : true,
|
|
6686
|
+
importantForAccessibility: revealed ? void 0 : "no-hide-descendants",
|
|
6687
|
+
...import_react_native42.Platform.OS === "web" ? { dataSet: { kjunChartKind: kind, skeleton: skeleton ? void 0 : "false" } } : {},
|
|
6688
|
+
children: !skeleton ? /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_react_native42.View, { ...chartPart("loading"), role: status, style: { alignItems: "center", gap: import_tokens40.tokens.dimension.value12 }, children: [
|
|
6689
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_react_native42.View, { ...hidden, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(KjunSpinner, { size: "md" }) }),
|
|
6690
|
+
!!loadingText && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(KText, { style: { ...typeStyle("body"), color: colors.textSecondary, textAlign: "center", maxWidth: "100%" }, children: loadingText })
|
|
6691
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
|
6713
6692
|
kind === "donut" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
6714
6693
|
import_react_native42.View,
|
|
6715
6694
|
{
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
borderWidth: import_tokens40.tokens.extensions.chartSkeleton.donutThickness,
|
|
6720
|
-
borderColor: colors.skeleton,
|
|
6721
|
-
borderRadius: import_tokens40.tokens.radius.radius9999,
|
|
6722
|
-
alignItems: "center",
|
|
6723
|
-
justifyContent: "center"
|
|
6724
|
-
},
|
|
6725
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(KjunSkeleton, { type: "block", width: import_tokens40.tokens.extensions.chartSkeleton.donutLabelWidth, height: import_tokens40.tokens.extensions.chartSkeleton.donutLabelHeight })
|
|
6695
|
+
...chartPart("donut"),
|
|
6696
|
+
...hidden,
|
|
6697
|
+
style: { height: "80%", aspectRatio: 1, borderWidth: thickness, borderColor: colors.skeleton, borderRadius: import_tokens40.tokens.radius.radius9999 }
|
|
6726
6698
|
}
|
|
6727
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime39.
|
|
6728
|
-
|
|
6699
|
+
) : kind === "matrix" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_react_native42.View, { ...chartPart("matrix"), ...hidden, style: { alignSelf: "stretch", flex: 1, gap: import_tokens40.tokens.dimension.value4 }, children: Array.from({ length: rowCount }, (_, row) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_react_native42.View, { style: { flex: 1, flexDirection: "row", gap: import_tokens40.tokens.dimension.value4 }, children: Array.from({ length: columnCount }, (_2, column) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
6700
|
+
import_react_native42.View,
|
|
6729
6701
|
{
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6702
|
+
...chartPart("cell"),
|
|
6703
|
+
style: {
|
|
6704
|
+
flex: 1,
|
|
6705
|
+
borderRadius: import_tokens40.tokens.extensions.skeleton.lineRadius,
|
|
6706
|
+
backgroundColor: colors.skeleton,
|
|
6707
|
+
opacity: chartMatrixMuted(row, column) ? import_tokens40.tokens.states.opacity.pending : 1
|
|
6708
|
+
}
|
|
6709
|
+
},
|
|
6710
|
+
column
|
|
6711
|
+
)) }, row)) }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_react_native42.View, { ...chartPart("plot"), ...hidden, style: { alignSelf: "stretch", flex: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_react_native_svg5.default, { viewBox: chartFrameViewBox, preserveAspectRatio: "none", width: "100%", height: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_react_native_svg5.Path, { d: chartFramePath, fill: "none", stroke: colors.chartGrid, strokeWidth: import_tokens40.tokens.border.defaultWidth, vectorEffect: "non-scaling-stroke" }) }) }),
|
|
6712
|
+
!!loadingText && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
6713
|
+
import_react_native42.View,
|
|
6714
|
+
{
|
|
6715
|
+
...chartPart("status"),
|
|
6716
|
+
role: status,
|
|
6717
|
+
pointerEvents: "none",
|
|
6718
|
+
style: { position: "absolute", inset: 0, alignItems: "center", justifyContent: "center" },
|
|
6719
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
6720
|
+
KText,
|
|
6721
|
+
{
|
|
6722
|
+
style: {
|
|
6723
|
+
...typeStyle("body"),
|
|
6724
|
+
paddingHorizontal: import_tokens40.tokens.dimension.value12,
|
|
6725
|
+
paddingVertical: import_tokens40.tokens.dimension.value4,
|
|
6726
|
+
borderRadius: import_tokens40.tokens.radius.radius6,
|
|
6727
|
+
borderWidth: kind === "donut" ? 0 : import_tokens40.tokens.border.defaultWidth,
|
|
6728
|
+
borderColor: colors.chartGrid,
|
|
6729
|
+
backgroundColor: colors.surface,
|
|
6730
|
+
color: colors.textSecondary,
|
|
6731
|
+
maxWidth: kind === "donut" && hole != null ? hole : "90%",
|
|
6732
|
+
textAlign: "center"
|
|
6755
6733
|
},
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
import_react_native_svg5.Path,
|
|
6760
|
-
{
|
|
6761
|
-
d: `M${55 + i * 75} ${195 - h}V${225 - h / 2}`,
|
|
6762
|
-
fill: "none",
|
|
6763
|
-
stroke: colors.skeleton,
|
|
6764
|
-
strokeWidth: 4
|
|
6765
|
-
}
|
|
6766
|
-
),
|
|
6767
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
6768
|
-
import_react_native_svg5.Rect,
|
|
6769
|
-
{
|
|
6770
|
-
x: 35 + i * 75,
|
|
6771
|
-
y: kind === "candle" ? 210 - h : 220 - h,
|
|
6772
|
-
width: kind === "candle" ? 28 : 42,
|
|
6773
|
-
height: kind === "candle" ? h / 2 : h,
|
|
6774
|
-
rx: 3,
|
|
6775
|
-
fill: colors.skeleton
|
|
6776
|
-
}
|
|
6777
|
-
)
|
|
6778
|
-
] }, i))
|
|
6779
|
-
]
|
|
6734
|
+
children: loadingText
|
|
6735
|
+
}
|
|
6736
|
+
)
|
|
6780
6737
|
}
|
|
6781
|
-
)
|
|
6782
|
-
|
|
6783
|
-
]
|
|
6738
|
+
)
|
|
6739
|
+
] })
|
|
6784
6740
|
}
|
|
6785
6741
|
);
|
|
6786
6742
|
}
|