cpk-ui 0.8.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/README.md
CHANGED
|
@@ -10,7 +10,7 @@ maintained by Cross Platform Korea and uses
|
|
|
10
10
|
[kstyled](https://crossplatformkorea.github.io/kstyled) for typed,
|
|
11
11
|
compile-time-aware styling.
|
|
12
12
|
|
|
13
|
-
`cpk-ui@0.8.
|
|
13
|
+
`cpk-ui@0.8.1` pairs with `kstyled@0.4.1`. Keep the runtime and Babel plugin on
|
|
14
14
|
the same kstyled version.
|
|
15
15
|
|
|
16
16
|
## Install
|
|
@@ -18,7 +18,7 @@ the same kstyled version.
|
|
|
18
18
|
### Expo
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
npx expo install cpk-ui@0.8.
|
|
21
|
+
npx expo install cpk-ui@0.8.1 kstyled@0.4.1 @expo/vector-icons \
|
|
22
22
|
react-native-gesture-handler react-native-svg expo-screen-orientation \
|
|
23
23
|
react-native-reanimated react-native-worklets @shopify/flash-list \
|
|
24
24
|
@expo/match-media expo-haptics
|
|
@@ -31,7 +31,7 @@ Install Expo modules first, then add the same runtime dependencies:
|
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
33
|
npx install-expo-modules@latest
|
|
34
|
-
bun add cpk-ui@0.8.
|
|
34
|
+
bun add cpk-ui@0.8.1 kstyled@0.4.1 @expo/vector-icons \
|
|
35
35
|
react-native-gesture-handler react-native-svg expo-screen-orientation \
|
|
36
36
|
react-native-reanimated react-native-worklets @shopify/flash-list \
|
|
37
37
|
@expo/match-media expo-haptics
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intl.d.ts","sourceRoot":"","sources":["../../../../src/components/uis/Calendar/intl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAC;AAEhD;;;;GAIG;AACH,KAAK,KAAK,GACN,YAAY,GACZ,eAAe,GACf,WAAW,GACX,SAAS,GACT,UAAU,CAAC;AAef,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,GACX,IAAI,CAAC,cAAc,GAAG,IAAI,CA2B5B;AAED,oEAAoE;AACpE,wBAAgB,aAAa,IAAI,MAAM,CAUtC;
|
|
1
|
+
{"version":3,"file":"intl.d.ts","sourceRoot":"","sources":["../../../../src/components/uis/Calendar/intl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAC;AAEhD;;;;GAIG;AACH,KAAK,KAAK,GACN,YAAY,GACZ,eAAe,GACf,WAAW,GACX,SAAS,GACT,UAAU,CAAC;AAef,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,GACX,IAAI,CAAC,cAAc,GAAG,IAAI,CA2B5B;AAED,oEAAoE;AACpE,wBAAgB,aAAa,IAAI,MAAM,CAUtC;AA6GD,eAAO,MAAM,kBAAkB,EAAE,kBAM/B,CAAC;AAKH;;;GAGG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,kBAAkB,GAAG,MAAM,CActE"}
|
|
@@ -109,9 +109,20 @@ const weekdayLabel = (date, locale) => {
|
|
|
109
109
|
const format = getFormat(locale, 'weekdayNarrow');
|
|
110
110
|
return format ? format.format(date) : FALLBACK_WEEKDAY_NARROW[date.getDay()];
|
|
111
111
|
};
|
|
112
|
+
// Only the number: CJK locales append a day suffix (`2일`, `2日`) that
|
|
113
|
+
// truncates two-digit days in a cell. Native digits (ar-EG) are kept.
|
|
112
114
|
const dayNumber = (date, locale) => {
|
|
113
115
|
const format = getFormat(locale, 'dayNumber');
|
|
114
|
-
|
|
116
|
+
if (!format || typeof format.formatToParts !== 'function') {
|
|
117
|
+
return String(date.getDate());
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
const day = format.formatToParts(date).find((part) => part.type === 'day');
|
|
121
|
+
return day ? day.value : String(date.getDate());
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return String(date.getDate());
|
|
125
|
+
}
|
|
115
126
|
};
|
|
116
127
|
const dayAccessibilityLabel = (date, locale) => {
|
|
117
128
|
const format = getFormat(locale, 'dayFull');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/components/uis/LineChart/LineChart.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAoB,KAAK,YAAY,EAAC,MAAM,OAAO,CAAC;AAClE,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAYtB,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,SAAS,cAAc,EAAE,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1D,WAAW,CAAC,EAAE,CAAC,KAAK,E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EAAE,SAAS,cAAc,EAAE,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1D,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AA8CF,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,WAAoB,EACpB,OAAO,EACP,OAAmB,EACnB,QAAe,EACf,UAAsB,EACtB,kBAAkB,EAClB,KAAK,EACL,MAAM,EACN,MAAqB,GACtB,EAAE,cAAc,GAAG,YAAY,CAsM/B"}
|
|
@@ -12,6 +12,13 @@ const BOTTOM_INSET = 30;
|
|
|
12
12
|
function safeNumber(value) {
|
|
13
13
|
return Number.isFinite(value) ? value : 0;
|
|
14
14
|
}
|
|
15
|
+
const FULL_WIDTH = /[\u1100-\u11ff\u2e80-\ua4cf\uac00-\ud7af\uf900-\ufaff\uff00-\uffef]/;
|
|
16
|
+
function estimateTextWidth(text) {
|
|
17
|
+
let width = 0;
|
|
18
|
+
for (const glyph of text)
|
|
19
|
+
width += FULL_WIDTH.test(glyph) ? 11 : 7;
|
|
20
|
+
return width;
|
|
21
|
+
}
|
|
15
22
|
// Each target reaches halfway to its neighbours, so a tap selects the
|
|
16
23
|
// nearest point rather than an equal-width column.
|
|
17
24
|
function targetSlot(points, index, width) {
|
|
@@ -67,6 +74,14 @@ export function LineChart({ data, selectedKey, onSelect, formatValue = String, p
|
|
|
67
74
|
}));
|
|
68
75
|
}, [data, frame.height, frame.width]);
|
|
69
76
|
const selectedPoint = points.find((point) => point.key === selectedKey);
|
|
77
|
+
const tooltipText = selectedPoint ? formatValue(selectedPoint.value) : '';
|
|
78
|
+
// SVG text cannot be measured before paint. At 11pt semibold a Latin glyph
|
|
79
|
+
// or digit needs about 7pt and a full-width CJK glyph about 11pt; the
|
|
80
|
+
// tooltip never grows past the frame.
|
|
81
|
+
const tooltipWidth = Math.min(Math.max(88, estimateTextWidth(tooltipText) + 24), Math.max(88, frame.width - 8));
|
|
82
|
+
const tooltipX = selectedPoint
|
|
83
|
+
? Math.max(4, Math.min(selectedPoint.x - tooltipWidth / 2, frame.width - tooltipWidth - 4))
|
|
84
|
+
: 0;
|
|
70
85
|
// Points are interactive only with `onSelect`; a read-only chart is one
|
|
71
86
|
// image, and interactive point buttons must not nest inside an image.
|
|
72
87
|
const interactive = onSelect !== undefined;
|
|
@@ -95,7 +110,7 @@ export function LineChart({ data, selectedKey, onSelect, formatValue = String, p
|
|
|
95
110
|
: null, points.length > 1 ? (_jsx(Path, { d: makePath(points), fill: "none", stroke: colors.line, strokeLinejoin: "round", strokeWidth: 2.5 })) : null, points.map((point) => {
|
|
96
111
|
const selected = point.key === selectedKey;
|
|
97
112
|
return (_jsxs(G, { children: [_jsx(Circle, { cx: point.x, cy: point.y, fill: selected ? colors.selectedPoint : colors.point, r: selected ? 5 : 3.5, stroke: colors.line, strokeWidth: 2 }), _jsx(SvgText, { fill: colors.label, fontSize: 10, textAnchor: "middle", x: point.x, y: frame.height - 8, children: point.label })] }, point.key));
|
|
98
|
-
}), selectedPoint ? (_jsxs(G, { children: [_jsx(Rect, { fill: colors.tooltipBackground, height: 26, rx: 6, width:
|
|
113
|
+
}), selectedPoint ? (_jsxs(G, { children: [_jsx(Rect, { fill: colors.tooltipBackground, height: 26, rx: 6, testID: `${testID}-tooltip`, width: tooltipWidth, x: tooltipX, y: Math.max(2, selectedPoint.y - 36) }), _jsx(SvgText, { fill: colors.tooltipText, fontSize: 11, fontWeight: "600", textAnchor: "middle", x: tooltipX + tooltipWidth / 2, y: Math.max(19, selectedPoint.y - 19), children: tooltipText })] })) : null, points.length === 0 ? (_jsx(SvgText, { fill: colors.label, fontSize: 13, textAnchor: "middle", testID: `${testID}-empty`, x: frame.width / 2, y: frame.height / 2, children: emptyLabel })) : null] }) }), (interactive ? points : []).map((point, index) => (_jsx(Pressable, { accessibilityLabel: point.accessibilityLabel ??
|
|
99
114
|
`${point.label}: ${formatValue(point.value)}`, accessibilityRole: "button", accessibilityState: { selected: point.key === selectedKey }, onPress: () => {
|
|
100
115
|
const datum = data[point.index];
|
|
101
116
|
if (datum)
|