@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.
@@ -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
- kind = "line",
6674
- height = import_tokens40.tokens.extensions.chartSkeleton.height
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
- toValue: 0.55,
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.jsxs)(
6679
+ }, [opacity, reduced, skeleton]);
6680
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
6700
6681
  import_react_native42.Animated.View,
6701
6682
  {
6702
- style: {
6703
- height,
6704
- alignItems: "center",
6705
- justifyContent: "center",
6706
- width: "100%",
6707
- minWidth: 0,
6708
- opacity
6709
- },
6710
- accessibilityElementsHidden: true,
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
- style: {
6717
- height: "80%",
6718
- aspectRatio: 1,
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.jsxs)(
6728
- import_react_native_svg5.default,
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
- viewBox: "0 0 600 240",
6731
- preserveAspectRatio: "none",
6732
- width: "100%",
6733
- height: "100%",
6734
- children: [
6735
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
6736
- import_react_native_svg5.Path,
6737
- {
6738
- d: "M20 10V220H590 M20 65H590 M20 120H590 M20 175H590",
6739
- fill: "none",
6740
- stroke: colors.border,
6741
- strokeWidth: 1
6742
- }
6743
- ),
6744
- kind === "line" && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_react_native_svg5.Path, { d: "M20 190 L100 160 L180 172 L260 120 L340 140 L420 96 L500 110 L590 64", fill: "none", stroke: colors.skeleton, strokeWidth: 4, strokeLinecap: "round", strokeLinejoin: "round" }),
6745
- kind === "matrix" ? Array.from({ length: 8 }, (_, row) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_react_native_svg5.G, { children: Array.from({ length: 14 }, (_2, col) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
6746
- import_react_native_svg5.Rect,
6747
- {
6748
- x: 24 + col * 40,
6749
- y: 12 + row * 26,
6750
- width: 36,
6751
- height: 22,
6752
- rx: 2,
6753
- fill: colors.skeleton,
6754
- opacity: (row + col + 2) % 3 === 0 ? 0.55 : 1
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
- col
6757
- )) }, row)) : (kind === "bar" || kind === "candle") && [60, 100, 85, 140, 110, 165, 180].map((h, i) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_react57.Fragment, { children: [
6758
- kind === "candle" && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
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
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_react_native42.View, { pointerEvents: "none", style: { position: "absolute", inset: 0, alignItems: "center", justifyContent: "center", gap: import_tokens40.tokens.dimension.value12 }, children: !!loadingText && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(KText, { style: { ...typeStyle("body"), paddingHorizontal: import_tokens40.tokens.dimension.value12, paddingVertical: import_tokens40.tokens.dimension.value4, borderRadius: import_tokens40.tokens.radius.radius6, backgroundColor: colors.surface, color: colors.textSecondary, maxWidth: "90%", textAlign: "center" }, children: loadingText }) })
6783
- ]
6738
+ )
6739
+ ] })
6784
6740
  }
6785
6741
  );
6786
6742
  }