@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.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
|
-
|
|
6419
|
-
|
|
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
|
-
|
|
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.
|
|
6424
|
+
}, [opacity, reduced, skeleton]);
|
|
6425
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
6445
6426
|
import_react_native42.Animated.View,
|
|
6446
6427
|
{
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
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
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
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.
|
|
6473
|
-
|
|
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
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
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
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
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
|
-
|
|
6528
|
-
]
|
|
6483
|
+
)
|
|
6484
|
+
] })
|
|
6529
6485
|
}
|
|
6530
6486
|
);
|
|
6531
6487
|
}
|