@kjun-ui/native 0.7.0 → 0.8.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/index.cjs +82 -121
- package/dist/index.js +133 -172
- package/dist/index.web.cjs +82 -121
- package/dist/index.web.js +133 -172
- package/dist/styles.css +26 -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 +16 -0
- package/dist/types/shared/package-runtime/chart-skeleton.d.ts +16 -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,24 @@ 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
|
+
var chartDonutRatio = 0.8;
|
|
6495
|
+
function chartDonutHole(height, thickness) {
|
|
6496
|
+
return Math.max(0, height * chartDonutRatio - 2 * thickness);
|
|
6497
|
+
}
|
|
6498
|
+
function chartSkeletonKind(kind) {
|
|
6499
|
+
return kind === "donut" || kind === "matrix" ? kind : "frame";
|
|
6500
|
+
}
|
|
6501
|
+
|
|
6514
6502
|
// packages/native/src/market-skeleton.tsx
|
|
6515
6503
|
var import_tokens39 = require("@kjun-ui/tokens");
|
|
6516
6504
|
var import_react_native41 = require("react-native");
|
|
@@ -6668,26 +6656,23 @@ function KjunFormSkeleton({
|
|
|
6668
6656
|
}
|
|
6669
6657
|
);
|
|
6670
6658
|
}
|
|
6659
|
+
var chartPart = (name) => import_react_native42.Platform.OS === "web" ? { dataSet: { kjunChartPart: name } } : {};
|
|
6671
6660
|
function KjunChartSkeleton({
|
|
6661
|
+
kind: requestedKind = "frame",
|
|
6662
|
+
height = import_tokens40.tokens.extensions.chartSkeleton.height,
|
|
6672
6663
|
loadingText = "\uCC28\uD2B8\uB97C \uBD88\uB7EC\uC624\uB294 \uC911",
|
|
6673
|
-
|
|
6674
|
-
|
|
6664
|
+
skeleton = true,
|
|
6665
|
+
loadingDelay = 0,
|
|
6666
|
+
rows = 8,
|
|
6667
|
+
columns = 14
|
|
6675
6668
|
}) {
|
|
6676
|
-
const { colors } = useKjunStyles(), reduced = useReducedMotion(), opacity = (0, import_react57.useRef)(new import_react_native42.Animated.Value(1)).current;
|
|
6669
|
+
const kind = chartSkeletonKind(requestedKind), { 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
6670
|
(0, import_react57.useEffect)(() => {
|
|
6678
|
-
if (reduced) return;
|
|
6671
|
+
if (reduced || !skeleton) return;
|
|
6679
6672
|
const loop = import_react_native42.Animated.loop(
|
|
6680
6673
|
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
|
-
})
|
|
6674
|
+
import_react_native42.Animated.timing(opacity, { toValue: 0.55, duration: import_tokens40.tokens.motion.shimmer / 2, useNativeDriver: true }),
|
|
6675
|
+
import_react_native42.Animated.timing(opacity, { toValue: 1, duration: import_tokens40.tokens.motion.shimmer / 2, useNativeDriver: true })
|
|
6691
6676
|
])
|
|
6692
6677
|
);
|
|
6693
6678
|
loop.start();
|
|
@@ -6695,92 +6680,68 @@ function KjunChartSkeleton({
|
|
|
6695
6680
|
loop.stop();
|
|
6696
6681
|
opacity.setValue(1);
|
|
6697
6682
|
};
|
|
6698
|
-
}, [opacity, reduced]);
|
|
6699
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.
|
|
6683
|
+
}, [opacity, reduced, skeleton]);
|
|
6684
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
6700
6685
|
import_react_native42.Animated.View,
|
|
6701
6686
|
{
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
importantForAccessibility: "no-hide-descendants",
|
|
6712
|
-
children: [
|
|
6687
|
+
onLayout: typeof height === "number" ? void 0 : (event) => setMeasured(event.nativeEvent.layout.height),
|
|
6688
|
+
style: { height, alignItems: "center", justifyContent: "center", width: "100%", minWidth: 0, opacity: revealed ? opacity : 0 },
|
|
6689
|
+
"aria-hidden": revealed ? void 0 : true,
|
|
6690
|
+
importantForAccessibility: revealed ? void 0 : "no-hide-descendants",
|
|
6691
|
+
...import_react_native42.Platform.OS === "web" ? { dataSet: { kjunChartKind: kind, skeleton: skeleton ? void 0 : "false" } } : {},
|
|
6692
|
+
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: [
|
|
6693
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_react_native42.View, { ...hidden, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(KjunSpinner, { size: "md" }) }),
|
|
6694
|
+
!!loadingText && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(KText, { style: { ...typeStyle("body"), color: colors.textSecondary, textAlign: "center", maxWidth: "100%" }, children: loadingText })
|
|
6695
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
|
6713
6696
|
kind === "donut" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
6714
6697
|
import_react_native42.View,
|
|
6715
6698
|
{
|
|
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 })
|
|
6699
|
+
...chartPart("donut"),
|
|
6700
|
+
...hidden,
|
|
6701
|
+
style: { height: `${chartDonutRatio * 100}%`, aspectRatio: 1, borderWidth: thickness, borderColor: colors.skeleton, borderRadius: import_tokens40.tokens.radius.radius9999 }
|
|
6726
6702
|
}
|
|
6727
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime39.
|
|
6728
|
-
|
|
6703
|
+
) : 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)(
|
|
6704
|
+
import_react_native42.View,
|
|
6729
6705
|
{
|
|
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
|
-
|
|
6706
|
+
...chartPart("cell"),
|
|
6707
|
+
style: {
|
|
6708
|
+
flex: 1,
|
|
6709
|
+
borderRadius: import_tokens40.tokens.extensions.skeleton.lineRadius,
|
|
6710
|
+
backgroundColor: colors.skeleton,
|
|
6711
|
+
opacity: chartMatrixMuted(row, column) ? import_tokens40.tokens.states.opacity.pending : 1
|
|
6712
|
+
}
|
|
6713
|
+
},
|
|
6714
|
+
column
|
|
6715
|
+
)) }, 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" }) }) }),
|
|
6716
|
+
!!loadingText && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
6717
|
+
import_react_native42.View,
|
|
6718
|
+
{
|
|
6719
|
+
...chartPart("status"),
|
|
6720
|
+
role: status,
|
|
6721
|
+
accessibilityLiveRegion: status ? "polite" : void 0,
|
|
6722
|
+
pointerEvents: "none",
|
|
6723
|
+
style: { position: "absolute", inset: 0, alignItems: "center", justifyContent: "center" },
|
|
6724
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
6725
|
+
KText,
|
|
6726
|
+
{
|
|
6727
|
+
style: {
|
|
6728
|
+
...typeStyle("body"),
|
|
6729
|
+
paddingHorizontal: import_tokens40.tokens.dimension.value12,
|
|
6730
|
+
paddingVertical: import_tokens40.tokens.dimension.value4,
|
|
6731
|
+
borderRadius: import_tokens40.tokens.radius.radius6,
|
|
6732
|
+
borderWidth: kind === "donut" ? 0 : import_tokens40.tokens.border.defaultWidth,
|
|
6733
|
+
borderColor: colors.chartGrid,
|
|
6734
|
+
backgroundColor: colors.surface,
|
|
6735
|
+
color: colors.textSecondary,
|
|
6736
|
+
maxWidth: kind === "donut" && hole != null ? hole : "90%",
|
|
6737
|
+
textAlign: "center"
|
|
6755
6738
|
},
|
|
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
|
-
]
|
|
6739
|
+
children: loadingText
|
|
6740
|
+
}
|
|
6741
|
+
)
|
|
6780
6742
|
}
|
|
6781
|
-
)
|
|
6782
|
-
|
|
6783
|
-
]
|
|
6743
|
+
)
|
|
6744
|
+
] })
|
|
6784
6745
|
}
|
|
6785
6746
|
);
|
|
6786
6747
|
}
|