@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.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,24 @@ 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
|
+
var chartDonutRatio = 0.8;
|
|
6240
|
+
function chartDonutHole(height, thickness) {
|
|
6241
|
+
return Math.max(0, height * chartDonutRatio - 2 * thickness);
|
|
6242
|
+
}
|
|
6243
|
+
function chartSkeletonKind(kind) {
|
|
6244
|
+
return kind === "donut" || kind === "matrix" ? kind : "frame";
|
|
6245
|
+
}
|
|
6246
|
+
|
|
6259
6247
|
// packages/native/src/market-skeleton.tsx
|
|
6260
6248
|
var import_tokens38 = require("@kjun-ui/tokens");
|
|
6261
6249
|
var import_react_native41 = require("react-native");
|
|
@@ -6413,26 +6401,23 @@ function KjunFormSkeleton({
|
|
|
6413
6401
|
}
|
|
6414
6402
|
);
|
|
6415
6403
|
}
|
|
6404
|
+
var chartPart = (name) => import_react_native42.Platform.OS === "web" ? { dataSet: { kjunChartPart: name } } : {};
|
|
6416
6405
|
function KjunChartSkeleton({
|
|
6406
|
+
kind: requestedKind = "frame",
|
|
6407
|
+
height = import_tokens39.tokens.extensions.chartSkeleton.height,
|
|
6417
6408
|
loadingText = "\uCC28\uD2B8\uB97C \uBD88\uB7EC\uC624\uB294 \uC911",
|
|
6418
|
-
|
|
6419
|
-
|
|
6409
|
+
skeleton = true,
|
|
6410
|
+
loadingDelay = 0,
|
|
6411
|
+
rows = 8,
|
|
6412
|
+
columns = 14
|
|
6420
6413
|
}) {
|
|
6421
|
-
const { colors } = useKjunStyles(), reduced = useReducedMotion(), opacity = (0, import_react53.useRef)(new import_react_native42.Animated.Value(1)).current;
|
|
6414
|
+
const kind = chartSkeletonKind(requestedKind), { 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
6415
|
(0, import_react53.useEffect)(() => {
|
|
6423
|
-
if (reduced) return;
|
|
6416
|
+
if (reduced || !skeleton) return;
|
|
6424
6417
|
const loop = import_react_native42.Animated.loop(
|
|
6425
6418
|
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
|
-
})
|
|
6419
|
+
import_react_native42.Animated.timing(opacity, { toValue: 0.55, duration: import_tokens39.tokens.motion.shimmer / 2, useNativeDriver: true }),
|
|
6420
|
+
import_react_native42.Animated.timing(opacity, { toValue: 1, duration: import_tokens39.tokens.motion.shimmer / 2, useNativeDriver: true })
|
|
6436
6421
|
])
|
|
6437
6422
|
);
|
|
6438
6423
|
loop.start();
|
|
@@ -6440,92 +6425,68 @@ function KjunChartSkeleton({
|
|
|
6440
6425
|
loop.stop();
|
|
6441
6426
|
opacity.setValue(1);
|
|
6442
6427
|
};
|
|
6443
|
-
}, [opacity, reduced]);
|
|
6444
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.
|
|
6428
|
+
}, [opacity, reduced, skeleton]);
|
|
6429
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
6445
6430
|
import_react_native42.Animated.View,
|
|
6446
6431
|
{
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
importantForAccessibility: "no-hide-descendants",
|
|
6457
|
-
children: [
|
|
6432
|
+
onLayout: typeof height === "number" ? void 0 : (event) => setMeasured(event.nativeEvent.layout.height),
|
|
6433
|
+
style: { height, alignItems: "center", justifyContent: "center", width: "100%", minWidth: 0, opacity: revealed ? opacity : 0 },
|
|
6434
|
+
"aria-hidden": revealed ? void 0 : true,
|
|
6435
|
+
importantForAccessibility: revealed ? void 0 : "no-hide-descendants",
|
|
6436
|
+
...import_react_native42.Platform.OS === "web" ? { dataSet: { kjunChartKind: kind, skeleton: skeleton ? void 0 : "false" } } : {},
|
|
6437
|
+
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: [
|
|
6438
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_react_native42.View, { ...hidden, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(KjunSpinner, { size: "md" }) }),
|
|
6439
|
+
!!loadingText && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(KText, { style: { ...typeStyle("body"), color: colors.textSecondary, textAlign: "center", maxWidth: "100%" }, children: loadingText })
|
|
6440
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
|
6458
6441
|
kind === "donut" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
6459
6442
|
import_react_native42.View,
|
|
6460
6443
|
{
|
|
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 })
|
|
6444
|
+
...chartPart("donut"),
|
|
6445
|
+
...hidden,
|
|
6446
|
+
style: { height: `${chartDonutRatio * 100}%`, aspectRatio: 1, borderWidth: thickness, borderColor: colors.skeleton, borderRadius: import_tokens39.tokens.radius.radius9999 }
|
|
6471
6447
|
}
|
|
6472
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime39.
|
|
6473
|
-
|
|
6448
|
+
) : 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)(
|
|
6449
|
+
import_react_native42.View,
|
|
6474
6450
|
{
|
|
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
|
-
|
|
6451
|
+
...chartPart("cell"),
|
|
6452
|
+
style: {
|
|
6453
|
+
flex: 1,
|
|
6454
|
+
borderRadius: import_tokens39.tokens.extensions.skeleton.lineRadius,
|
|
6455
|
+
backgroundColor: colors.skeleton,
|
|
6456
|
+
opacity: chartMatrixMuted(row, column) ? import_tokens39.tokens.states.opacity.pending : 1
|
|
6457
|
+
}
|
|
6458
|
+
},
|
|
6459
|
+
column
|
|
6460
|
+
)) }, 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" }) }) }),
|
|
6461
|
+
!!loadingText && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
6462
|
+
import_react_native42.View,
|
|
6463
|
+
{
|
|
6464
|
+
...chartPart("status"),
|
|
6465
|
+
role: status,
|
|
6466
|
+
accessibilityLiveRegion: status ? "polite" : void 0,
|
|
6467
|
+
pointerEvents: "none",
|
|
6468
|
+
style: { position: "absolute", inset: 0, alignItems: "center", justifyContent: "center" },
|
|
6469
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
6470
|
+
KText,
|
|
6471
|
+
{
|
|
6472
|
+
style: {
|
|
6473
|
+
...typeStyle("body"),
|
|
6474
|
+
paddingHorizontal: import_tokens39.tokens.dimension.value12,
|
|
6475
|
+
paddingVertical: import_tokens39.tokens.dimension.value4,
|
|
6476
|
+
borderRadius: import_tokens39.tokens.radius.radius6,
|
|
6477
|
+
borderWidth: kind === "donut" ? 0 : import_tokens39.tokens.border.defaultWidth,
|
|
6478
|
+
borderColor: colors.chartGrid,
|
|
6479
|
+
backgroundColor: colors.surface,
|
|
6480
|
+
color: colors.textSecondary,
|
|
6481
|
+
maxWidth: kind === "donut" && hole != null ? hole : "90%",
|
|
6482
|
+
textAlign: "center"
|
|
6500
6483
|
},
|
|
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
|
-
]
|
|
6484
|
+
children: loadingText
|
|
6485
|
+
}
|
|
6486
|
+
)
|
|
6525
6487
|
}
|
|
6526
|
-
)
|
|
6527
|
-
|
|
6528
|
-
]
|
|
6488
|
+
)
|
|
6489
|
+
] })
|
|
6529
6490
|
}
|
|
6530
6491
|
);
|
|
6531
6492
|
}
|