@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 CHANGED
@@ -2322,36 +2322,6 @@ function KjunSkeleton({
2322
2322
  ))
2323
2323
  }
2324
2324
  ),
2325
- type === "chart" && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native16.View, { style: [frame, { height: height || import_tokens13.tokens.extensions.skeleton.chartHeight }], children: [
2326
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2327
- import_react_native16.View,
2328
- {
2329
- style: {
2330
- flex: 1,
2331
- flexDirection: "row",
2332
- alignItems: "flex-end",
2333
- justifyContent: "space-around",
2334
- gap: import_tokens13.tokens.extensions.skeleton.gap
2335
- // Bars stand on the axis line, like ChartSkeleton.
2336
- },
2337
- children: [40, 65, 50, 80, 60, 90, 75].map((h, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2338
- import_react_native16.Animated.View,
2339
- {
2340
- style: {
2341
- flex: 1,
2342
- maxWidth: import_tokens13.tokens.extensions.skeleton.chartBarMaxWidth,
2343
- height: `${h}%`,
2344
- backgroundColor: shimmer,
2345
- borderTopLeftRadius: import_tokens13.tokens.radius.radius4,
2346
- borderTopRightRadius: import_tokens13.tokens.radius.radius4
2347
- }
2348
- },
2349
- i
2350
- ))
2351
- }
2352
- ),
2353
- block("100%", import_tokens13.tokens.extensions.skeleton.chartAxisHeight, { backgroundColor: colors.border })
2354
- ] }),
2355
2325
  type === "stat" && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2356
2326
  import_react_native16.View,
2357
2327
  {
@@ -6256,6 +6226,20 @@ var import_react53 = require("react");
6256
6226
  var import_react_native42 = require("react-native");
6257
6227
  var import_react_native_svg5 = __toESM(require("react-native-svg"), 1);
6258
6228
 
6229
+ // shared/package-runtime/chart-skeleton.ts
6230
+ var chartFrameViewBox = "0 0 600 240";
6231
+ var chartFramePath = "M20 10V220H590 M20 65H590 M20 120H590 M20 175H590";
6232
+ var chartSkeletonMaxCount = 100;
6233
+ function chartSkeletonCount(value) {
6234
+ return Number.isFinite(value) ? Math.min(chartSkeletonMaxCount, Math.max(1, Math.floor(value))) : 1;
6235
+ }
6236
+ function chartMatrixMuted(row, column) {
6237
+ return (row + column + 2) % 3 === 0;
6238
+ }
6239
+ function chartDonutHole(height, thickness) {
6240
+ return Math.max(0, height * 0.8 - 2 * thickness);
6241
+ }
6242
+
6259
6243
  // packages/native/src/market-skeleton.tsx
6260
6244
  var import_tokens38 = require("@kjun-ui/tokens");
6261
6245
  var import_react_native41 = require("react-native");
@@ -6413,26 +6397,23 @@ function KjunFormSkeleton({
6413
6397
  }
6414
6398
  );
6415
6399
  }
6400
+ var chartPart = (name) => import_react_native42.Platform.OS === "web" ? { dataSet: { kjunChartPart: name } } : {};
6416
6401
  function KjunChartSkeleton({
6402
+ kind = "frame",
6403
+ height = import_tokens39.tokens.extensions.chartSkeleton.height,
6417
6404
  loadingText = "\uCC28\uD2B8\uB97C \uBD88\uB7EC\uC624\uB294 \uC911",
6418
- kind = "line",
6419
- height = import_tokens39.tokens.extensions.chartSkeleton.height
6405
+ skeleton = true,
6406
+ loadingDelay = 0,
6407
+ rows = 8,
6408
+ columns = 14
6420
6409
  }) {
6421
- const { colors } = useKjunStyles(), reduced = useReducedMotion(), opacity = (0, import_react53.useRef)(new import_react_native42.Animated.Value(1)).current;
6410
+ const { colors } = useKjunStyles(), reduced = useReducedMotion(), opacity = (0, import_react53.useRef)(new import_react_native42.Animated.Value(1)).current, revealed = useLoadingReveal(true, loadingDelay), [measured, setMeasured] = (0, import_react53.useState)(0), thickness = import_tokens39.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" };
6422
6411
  (0, import_react53.useEffect)(() => {
6423
- if (reduced) return;
6412
+ if (reduced || !skeleton) return;
6424
6413
  const loop = import_react_native42.Animated.loop(
6425
6414
  import_react_native42.Animated.sequence([
6426
- import_react_native42.Animated.timing(opacity, {
6427
- toValue: 0.55,
6428
- duration: import_tokens39.tokens.motion.shimmer / 2,
6429
- useNativeDriver: true
6430
- }),
6431
- import_react_native42.Animated.timing(opacity, {
6432
- toValue: 1,
6433
- duration: import_tokens39.tokens.motion.shimmer / 2,
6434
- useNativeDriver: true
6435
- })
6415
+ import_react_native42.Animated.timing(opacity, { toValue: 0.55, duration: import_tokens39.tokens.motion.shimmer / 2, useNativeDriver: true }),
6416
+ import_react_native42.Animated.timing(opacity, { toValue: 1, duration: import_tokens39.tokens.motion.shimmer / 2, useNativeDriver: true })
6436
6417
  ])
6437
6418
  );
6438
6419
  loop.start();
@@ -6440,92 +6421,67 @@ function KjunChartSkeleton({
6440
6421
  loop.stop();
6441
6422
  opacity.setValue(1);
6442
6423
  };
6443
- }, [opacity, reduced]);
6444
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
6424
+ }, [opacity, reduced, skeleton]);
6425
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
6445
6426
  import_react_native42.Animated.View,
6446
6427
  {
6447
- style: {
6448
- height,
6449
- alignItems: "center",
6450
- justifyContent: "center",
6451
- width: "100%",
6452
- minWidth: 0,
6453
- opacity
6454
- },
6455
- accessibilityElementsHidden: true,
6456
- importantForAccessibility: "no-hide-descendants",
6457
- children: [
6428
+ onLayout: typeof height === "number" ? void 0 : (event) => setMeasured(event.nativeEvent.layout.height),
6429
+ style: { height, alignItems: "center", justifyContent: "center", width: "100%", minWidth: 0, opacity: revealed ? opacity : 0 },
6430
+ "aria-hidden": revealed ? void 0 : true,
6431
+ importantForAccessibility: revealed ? void 0 : "no-hide-descendants",
6432
+ ...import_react_native42.Platform.OS === "web" ? { dataSet: { kjunChartKind: kind, skeleton: skeleton ? void 0 : "false" } } : {},
6433
+ children: !skeleton ? /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_react_native42.View, { ...chartPart("loading"), role: status, style: { alignItems: "center", gap: import_tokens39.tokens.dimension.value12 }, children: [
6434
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_react_native42.View, { ...hidden, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(KjunSpinner, { size: "md" }) }),
6435
+ !!loadingText && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(KText, { style: { ...typeStyle("body"), color: colors.textSecondary, textAlign: "center", maxWidth: "100%" }, children: loadingText })
6436
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
6458
6437
  kind === "donut" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
6459
6438
  import_react_native42.View,
6460
6439
  {
6461
- style: {
6462
- height: "80%",
6463
- aspectRatio: 1,
6464
- borderWidth: import_tokens39.tokens.extensions.chartSkeleton.donutThickness,
6465
- borderColor: colors.skeleton,
6466
- borderRadius: import_tokens39.tokens.radius.radius9999,
6467
- alignItems: "center",
6468
- justifyContent: "center"
6469
- },
6470
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(KjunSkeleton, { type: "block", width: import_tokens39.tokens.extensions.chartSkeleton.donutLabelWidth, height: import_tokens39.tokens.extensions.chartSkeleton.donutLabelHeight })
6440
+ ...chartPart("donut"),
6441
+ ...hidden,
6442
+ style: { height: "80%", aspectRatio: 1, borderWidth: thickness, borderColor: colors.skeleton, borderRadius: import_tokens39.tokens.radius.radius9999 }
6471
6443
  }
6472
- ) : /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
6473
- import_react_native_svg5.default,
6444
+ ) : kind === "matrix" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_react_native42.View, { ...chartPart("matrix"), ...hidden, style: { alignSelf: "stretch", flex: 1, gap: import_tokens39.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_tokens39.tokens.dimension.value4 }, children: Array.from({ length: columnCount }, (_2, column) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
6445
+ import_react_native42.View,
6474
6446
  {
6475
- viewBox: "0 0 600 240",
6476
- preserveAspectRatio: "none",
6477
- width: "100%",
6478
- height: "100%",
6479
- children: [
6480
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
6481
- import_react_native_svg5.Path,
6482
- {
6483
- d: "M20 10V220H590 M20 65H590 M20 120H590 M20 175H590",
6484
- fill: "none",
6485
- stroke: colors.border,
6486
- strokeWidth: 1
6487
- }
6488
- ),
6489
- 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" }),
6490
- 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)(
6491
- import_react_native_svg5.Rect,
6492
- {
6493
- x: 24 + col * 40,
6494
- y: 12 + row * 26,
6495
- width: 36,
6496
- height: 22,
6497
- rx: 2,
6498
- fill: colors.skeleton,
6499
- opacity: (row + col + 2) % 3 === 0 ? 0.55 : 1
6447
+ ...chartPart("cell"),
6448
+ style: {
6449
+ flex: 1,
6450
+ borderRadius: import_tokens39.tokens.extensions.skeleton.lineRadius,
6451
+ backgroundColor: colors.skeleton,
6452
+ opacity: chartMatrixMuted(row, column) ? import_tokens39.tokens.states.opacity.pending : 1
6453
+ }
6454
+ },
6455
+ column
6456
+ )) }, 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_tokens39.tokens.border.defaultWidth, vectorEffect: "non-scaling-stroke" }) }) }),
6457
+ !!loadingText && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
6458
+ import_react_native42.View,
6459
+ {
6460
+ ...chartPart("status"),
6461
+ role: status,
6462
+ pointerEvents: "none",
6463
+ style: { position: "absolute", inset: 0, alignItems: "center", justifyContent: "center" },
6464
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
6465
+ KText,
6466
+ {
6467
+ style: {
6468
+ ...typeStyle("body"),
6469
+ paddingHorizontal: import_tokens39.tokens.dimension.value12,
6470
+ paddingVertical: import_tokens39.tokens.dimension.value4,
6471
+ borderRadius: import_tokens39.tokens.radius.radius6,
6472
+ borderWidth: kind === "donut" ? 0 : import_tokens39.tokens.border.defaultWidth,
6473
+ borderColor: colors.chartGrid,
6474
+ backgroundColor: colors.surface,
6475
+ color: colors.textSecondary,
6476
+ maxWidth: kind === "donut" && hole != null ? hole : "90%",
6477
+ textAlign: "center"
6500
6478
  },
6501
- col
6502
- )) }, row)) : (kind === "bar" || kind === "candle") && [60, 100, 85, 140, 110, 165, 180].map((h, i) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_react53.Fragment, { children: [
6503
- kind === "candle" && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
6504
- import_react_native_svg5.Path,
6505
- {
6506
- d: `M${55 + i * 75} ${195 - h}V${225 - h / 2}`,
6507
- fill: "none",
6508
- stroke: colors.skeleton,
6509
- strokeWidth: 4
6510
- }
6511
- ),
6512
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
6513
- import_react_native_svg5.Rect,
6514
- {
6515
- x: 35 + i * 75,
6516
- y: kind === "candle" ? 210 - h : 220 - h,
6517
- width: kind === "candle" ? 28 : 42,
6518
- height: kind === "candle" ? h / 2 : h,
6519
- rx: 3,
6520
- fill: colors.skeleton
6521
- }
6522
- )
6523
- ] }, i))
6524
- ]
6479
+ children: loadingText
6480
+ }
6481
+ )
6525
6482
  }
6526
- ),
6527
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_react_native42.View, { pointerEvents: "none", style: { position: "absolute", inset: 0, alignItems: "center", justifyContent: "center", gap: import_tokens39.tokens.dimension.value12 }, children: !!loadingText && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(KText, { style: { ...typeStyle("body"), paddingHorizontal: import_tokens39.tokens.dimension.value12, paddingVertical: import_tokens39.tokens.dimension.value4, borderRadius: import_tokens39.tokens.radius.radius6, backgroundColor: colors.surface, color: colors.textSecondary, maxWidth: "90%", textAlign: "center" }, children: loadingText }) })
6528
- ]
6483
+ )
6484
+ ] })
6529
6485
  }
6530
6486
  );
6531
6487
  }