@hzblj/kara-components 0.14.1 → 0.15.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/CHANGELOG.md +22 -0
- package/lib/module/atoms/rn-text/rn-text.js +26 -4
- package/lib/module/atoms/rn-text/rn-text.js.map +1 -1
- package/lib/module/atoms/text/text.android.js +9 -5
- package/lib/module/atoms/text/text.android.js.map +1 -1
- package/lib/module/atoms/text/text.ios.js +8 -3
- package/lib/module/atoms/text/text.ios.js.map +1 -1
- package/lib/module/molecules/stepper/stepper.ios.js +2 -2
- package/lib/module/molecules/stepper/stepper.ios.js.map +1 -1
- package/lib/typescript/atoms/rn-text/rn-text.types.d.ts +12 -0
- package/lib/typescript/atoms/text/text.types.d.ts +13 -1
- package/package.json +4 -4
- package/src/atoms/rn-text/rn-text.tsx +19 -8
- package/src/atoms/rn-text/rn-text.types.ts +12 -0
- package/src/atoms/text/text.android.tsx +9 -5
- package/src/atoms/text/text.ios.tsx +9 -1
- package/src/atoms/text/text.types.ts +13 -1
- package/src/molecules/stepper/stepper.ios.tsx +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @hzblj/kara-components
|
|
2
2
|
|
|
3
|
+
## 0.15.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#43](https://github.com/hzblj/kara-ui/pull/43) [`2ff941d`](https://github.com/hzblj/kara-ui/commit/2ff941d989cef86f8cdea39483945e760153a90f) Thanks [@hzblj](https://github.com/hzblj)! - `Text` and `RnText` take `monospaced` and `monospacedDigit`. `monospaced` sets the text in the theme's fixed-width face at its variant's size and weight: a new `fonts.mono` role in `ThemeConfig` for a face of the app's own (JetBrains Mono beside Inter, say), else Menlo on iOS and `monospace` on Android, the same face in both tiers. `monospacedDigit` keeps whatever face the text has and asks it for tabular figures, so a price or a counter does not shift as it changes: SwiftUI's `monospacedDigit()`, React Native's `fontVariant: ['tabular-nums']`, and `tnum` on Compose. `theme.monoTypography` is the scale `monospaced` reads. `ios.monospacedDigit` is gone from `sx`: use the `monospacedDigit` prop, which now works on Android too. Rebuild the native app.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`2ff941d`](https://github.com/hzblj/kara-ui/commit/2ff941d989cef86f8cdea39483945e760153a90f)]:
|
|
12
|
+
- @hzblj/kara-native@0.15.0
|
|
13
|
+
- @hzblj/kara-sx@0.15.0
|
|
14
|
+
- @hzblj/kara-theme@0.15.0
|
|
15
|
+
|
|
16
|
+
## 0.14.2
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies []:
|
|
21
|
+
- @hzblj/kara-theme@0.14.2
|
|
22
|
+
- @hzblj/kara-sx@0.14.2
|
|
23
|
+
- @hzblj/kara-native@0.14.2
|
|
24
|
+
|
|
3
25
|
## 0.14.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -18,6 +18,11 @@ const LINE_HEIGHT_SLACK = Platform.OS === 'ios' ? 0.01 : 0;
|
|
|
18
18
|
const MAX_TEXT_STYLES = 512;
|
|
19
19
|
const textStyles = new Map();
|
|
20
20
|
|
|
21
|
+
/** Digits of one width: React Native asks the face for its tabular figures. */
|
|
22
|
+
const TABULAR_NUMS = ['tabular-nums'];
|
|
23
|
+
|
|
24
|
+
/** What the text half of the style is built from. */
|
|
25
|
+
|
|
21
26
|
/**
|
|
22
27
|
* The variant at the user's text size, in its colour. React Native scales `fontSize` for the user's setting but leaves
|
|
23
28
|
* `lineHeight` alone, so a grown glyph ends up in an ungrown line and clips. Scaling it here by the same factor keeps
|
|
@@ -27,8 +32,14 @@ const textStyles = new Map();
|
|
|
27
32
|
* The native tiers need none of this: SwiftUI's `lineSpacing` is extra space *on top of* the font's own line
|
|
28
33
|
* height, which scales with it, and Compose reads `lineHeight` in `sp`.
|
|
29
34
|
*/
|
|
30
|
-
const textStyle = (theme,
|
|
31
|
-
|
|
35
|
+
const textStyle = (theme, fontScale, {
|
|
36
|
+
align,
|
|
37
|
+
color,
|
|
38
|
+
monospaced = false,
|
|
39
|
+
monospacedDigit = false,
|
|
40
|
+
variant
|
|
41
|
+
}) => {
|
|
42
|
+
const key = `${themeKey(theme)}|${variant}|${color}|${align}|${fontScale}|${monospaced}|${monospacedDigit}`;
|
|
32
43
|
const existing = textStyles.get(key);
|
|
33
44
|
if (existing) {
|
|
34
45
|
return existing;
|
|
@@ -36,7 +47,7 @@ const textStyle = (theme, variant, color, align, fontScale) => {
|
|
|
36
47
|
if (textStyles.size >= MAX_TEXT_STYLES) {
|
|
37
48
|
textStyles.clear();
|
|
38
49
|
}
|
|
39
|
-
const typography = theme.typography[variant];
|
|
50
|
+
const typography = (monospaced ? theme.monoTypography : theme.typography)[variant];
|
|
40
51
|
const style = {
|
|
41
52
|
...typography,
|
|
42
53
|
color: theme.color(color),
|
|
@@ -45,12 +56,17 @@ const textStyle = (theme, variant, color, align, fontScale) => {
|
|
|
45
56
|
if (align) {
|
|
46
57
|
style.textAlign = align;
|
|
47
58
|
}
|
|
59
|
+
if (monospacedDigit) {
|
|
60
|
+
style.fontVariant = TABULAR_NUMS;
|
|
61
|
+
}
|
|
48
62
|
textStyles.set(key, style);
|
|
49
63
|
return style;
|
|
50
64
|
};
|
|
51
65
|
export const RnText = markMotionComponent(({
|
|
52
66
|
align,
|
|
53
67
|
color = 'content.primary',
|
|
68
|
+
monospaced,
|
|
69
|
+
monospacedDigit,
|
|
54
70
|
style,
|
|
55
71
|
variant = 'body',
|
|
56
72
|
...props
|
|
@@ -60,7 +76,13 @@ export const RnText = markMotionComponent(({
|
|
|
60
76
|
// A view style, which a text accepts whole — only React Native's types disagree, on `userSelect`'s width.
|
|
61
77
|
const [sx, motion, rest] = useSplitSxMotion(props);
|
|
62
78
|
const animated = useAnimatedLatch(motion.animated || isAnimatedStyle(style), 'RnText');
|
|
63
|
-
const text = textStyle(theme,
|
|
79
|
+
const text = textStyle(theme, fontScale, {
|
|
80
|
+
align,
|
|
81
|
+
color,
|
|
82
|
+
monospaced,
|
|
83
|
+
monospacedDigit,
|
|
84
|
+
variant
|
|
85
|
+
});
|
|
64
86
|
if (!animated) {
|
|
65
87
|
return /*#__PURE__*/_jsx(RNText, {
|
|
66
88
|
maxFontSizeMultiplier: MAX_FONT_SCALE,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isAnimatedStyle","markMotionComponent","themeKey","useAnimatedLatch","useSplitSxMotion","MAX_FONT_SCALE","useAppTheme","useFontScale","Platform","Text","RNText","Animated","jsx","_jsx","LINE_HEIGHT_SLACK","OS","MAX_TEXT_STYLES","textStyles","Map","textStyle","theme","
|
|
1
|
+
{"version":3,"names":["isAnimatedStyle","markMotionComponent","themeKey","useAnimatedLatch","useSplitSxMotion","MAX_FONT_SCALE","useAppTheme","useFontScale","Platform","Text","RNText","Animated","jsx","_jsx","LINE_HEIGHT_SLACK","OS","MAX_TEXT_STYLES","textStyles","Map","TABULAR_NUMS","textStyle","theme","fontScale","align","color","monospaced","monospacedDigit","variant","key","existing","get","size","clear","typography","monoTypography","style","lineHeight","textAlign","fontVariant","set","RnText","props","sx","motion","rest","animated","text","maxFontSizeMultiplier","entering","exiting","layout"],"sourceRoot":"../../../../src","sources":["atoms/rn-text/rn-text.tsx"],"mappings":";;AAAA,SACEA,eAAe,EACfC,mBAAmB,EAEnBC,QAAQ,EACRC,gBAAgB,EAChBC,gBAAgB,QACX,gBAAgB;AACvB,SAEEC,cAAc,EAGdC,WAAW,EACXC,YAAY,QACP,mBAAmB;AAC1B,SAAQC,QAAQ,EAAEC,IAAI,IAAIC,MAAM,QAAuC,cAAc;AACrF,OAAOC,QAAQ,MAAM,yBAAyB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAI9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAGN,QAAQ,CAACO,EAAE,KAAK,KAAK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text = ({
|
|
|
61
61
|
children,
|
|
62
62
|
color = 'content.primary',
|
|
63
63
|
decoration,
|
|
64
|
+
monospaced,
|
|
65
|
+
monospacedDigit,
|
|
64
66
|
numberOfLines,
|
|
65
67
|
testID,
|
|
66
68
|
transform,
|
|
@@ -69,22 +71,24 @@ export const Text = ({
|
|
|
69
71
|
}) => {
|
|
70
72
|
useHostGuard('Text');
|
|
71
73
|
const theme = useAppTheme();
|
|
72
|
-
const style = theme.typography[variant];
|
|
74
|
+
const style = (monospaced ? theme.monoTypography : theme.typography)[variant];
|
|
73
75
|
const [accessibility, sx] = splitAccessibility(props);
|
|
74
76
|
const sxModifiers = useSxModifiers(sx);
|
|
75
77
|
const accessibilityModifiers = useAccessibilityModifiers(accessibility);
|
|
76
78
|
const modifiers = useMemo(() => [...sxModifiers, ...(testID ? [testIdModifier(testID)] : []), ...accessibilityModifiers], [accessibilityModifiers, sxModifiers, testID]);
|
|
77
79
|
const spans = useMemo(() => spansOf(children, Text), [children]);
|
|
78
|
-
const animate = sx.animate;
|
|
80
|
+
const animate = sx.animate === false ? undefined : sx.animate;
|
|
79
81
|
|
|
80
|
-
// `@expo/ui`'s text takes spans but animates none: with `animate`, kara's own Compose text
|
|
81
|
-
|
|
82
|
+
// `@expo/ui`'s text takes spans but animates none, and sets no font features: with `animate`, kara's own Compose text
|
|
83
|
+
// eases each span's colour, and with `monospacedDigit` asks the face for its tabular figures.
|
|
84
|
+
if (animate !== undefined || monospacedDigit) {
|
|
82
85
|
const runs = spans ?? [{
|
|
83
86
|
text: typeof children === 'string' || typeof children === 'number' ? String(children) : ''
|
|
84
87
|
}];
|
|
85
88
|
return /*#__PURE__*/_jsx(AnimatedText, {
|
|
86
|
-
animation: textAnimation(animateConfig(animate)),
|
|
89
|
+
animation: animate === undefined ? undefined : textAnimation(animateConfig(animate)),
|
|
87
90
|
fontFamily: style.fontFamily,
|
|
91
|
+
fontFeatureSettings: monospacedDigit ? 'tnum' : undefined,
|
|
88
92
|
fontSize: style.fontSize,
|
|
89
93
|
fontWeight: style.fontWeight,
|
|
90
94
|
lineHeight: style.lineHeight,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Text","ComposeText","testID","testIdModifier","AnimatedText","animateConfig","splitAccessibility","useAccessibilityModifiers","useSxModifiers","duration","easing","springPhysics","useAppTheme","useMemo","useHostGuard","spansOf","jsx","_jsx","DECORATION","none","strikethrough","underline","applyTransform","children","transform","toUpperCase","toLowerCase","decorationOf","decoration","undefined","transformed","text","textAnimation","config","spring","dampingRatio","stiffness","type","milliseconds","curve","omega","Math","PI","delayMillis","delay","durationMillis","align","color","numberOfLines","variant","props","theme","style","typography","accessibility","sx","sxModifiers","accessibilityModifiers","modifiers","spans","animate","runs","String","animation","fontFamily","fontSize","fontWeight","lineHeight","maxLines","map","span","colorString","textAlign","textColor","textDecoration","index"],"sourceRoot":"../../../../src","sources":["atoms/text/text.android.tsx"],"mappings":";;AAAA,SAAQA,IAAI,IAAIC,WAAW,QAAO,0BAA0B;AAC5D,SAAQC,MAAM,IAAIC,cAAc,QAAO,oCAAoC;AAC3E,SAAQC,YAAY,QAA2B,oCAAoC;AACnF,SACEC,aAAa,EAEbC,kBAAkB,EAClBC,yBAAyB,EACzBC,cAAc,QACT,gBAAgB;AACvB,SAAQC,QAAQ,EAAEC,MAAM,EAAEC,aAAa,EAAEC,WAAW,QAAO,mBAAmB;AAC9E,SAAQC,OAAO,QAAO,OAAO;AAE7B,SAAQC,YAAY,QAAO,uBAAoB;AAC/C,SAAQC,OAAO,QAAO,YAAS;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAG/B,MAAMC,UAAU,GAAG;EACjBC,IAAI,EAAE,MAAM;EACZC,aAAa,EAAE,aAAa;EAC5BC,SAAS,EAAE;AACb,CAAU;AAEV,MAAMC,cAAc,GAAGA,CAACC,QAA+B,EAAEC,SAAoC,KAAK;EAChG,IAAI,CAACA,SAAS,IAAI,OAAOD,QAAQ,KAAK,QAAQ,EAAE;IAC9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AAC;AACxG,CAAC;AAED,OAAO,MAAMrC,IAAmB,GAAGA,CAAC;EAClC8C,KAAK;EACLvB,QAAQ;EACRwB,KAAK,GAAG,iBAAiB;EACzBnB,UAAU;EACVoB,aAAa;
|
|
1
|
+
{"version":3,"names":["Text","ComposeText","testID","testIdModifier","AnimatedText","animateConfig","splitAccessibility","useAccessibilityModifiers","useSxModifiers","duration","easing","springPhysics","useAppTheme","useMemo","useHostGuard","spansOf","jsx","_jsx","DECORATION","none","strikethrough","underline","applyTransform","children","transform","toUpperCase","toLowerCase","decorationOf","decoration","undefined","transformed","text","textAnimation","config","spring","dampingRatio","stiffness","type","milliseconds","curve","omega","Math","PI","delayMillis","delay","durationMillis","align","color","monospaced","monospacedDigit","numberOfLines","variant","props","theme","style","monoTypography","typography","accessibility","sx","sxModifiers","accessibilityModifiers","modifiers","spans","animate","runs","String","animation","fontFamily","fontFeatureSettings","fontSize","fontWeight","lineHeight","maxLines","map","span","colorString","textAlign","textColor","textDecoration","index"],"sourceRoot":"../../../../src","sources":["atoms/text/text.android.tsx"],"mappings":";;AAAA,SAAQA,IAAI,IAAIC,WAAW,QAAO,0BAA0B;AAC5D,SAAQC,MAAM,IAAIC,cAAc,QAAO,oCAAoC;AAC3E,SAAQC,YAAY,QAA2B,oCAAoC;AACnF,SACEC,aAAa,EAEbC,kBAAkB,EAClBC,yBAAyB,EACzBC,cAAc,QACT,gBAAgB;AACvB,SAAQC,QAAQ,EAAEC,MAAM,EAAEC,aAAa,EAAEC,WAAW,QAAO,mBAAmB;AAC9E,SAAQC,OAAO,QAAO,OAAO;AAE7B,SAAQC,YAAY,QAAO,uBAAoB;AAC/C,SAAQC,OAAO,QAAO,YAAS;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAG/B,MAAMC,UAAU,GAAG;EACjBC,IAAI,EAAE,MAAM;EACZC,aAAa,EAAE,aAAa;EAC5BC,SAAS,EAAE;AACb,CAAU;AAEV,MAAMC,cAAc,GAAGA,CAACC,QAA+B,EAA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MAC5BE,QAAQ,EAAEf,KAAK,CAACe,QAAQ;MACxBC,UAAU,EAAEhB,KAAK,CAACgB,UAAU;MAC5BC,UAAU,EAAEjB,KAAK,CAACiB,UAAU;MAC5BK,SAAS,EAAE9B,KAAK;MAChBgC,cAAc,EAAEnD,YAAY,CAACC,UAAU;IACzC,CAAE;IAAAL,QAAA,EAEDuC,KAAK,GACFA,KAAK,CAACW,GAAG,CAAC,CAACC,IAAI,EAAEK,KAAK,kBACpB9D,IAAA,CAAChB,WAAW;MAAC8C,KAAK,EAAE2B,IAAI,CAAC3B,KAAK,GAAGM,KAAK,CAACsB,WAAW,CAACD,IAAI,CAAC3B,KAAK,CAAC,GAAGlB,SAAU;MAAAN,QAAA,EACxEO,WAAW,CAAC4C,IAAI,CAAC3C,IAAI,EAAEP,SAAS;IAAC,GAD6CuD,KAEpE,CACd,CAAC,GACFzD,cAAc,CAACC,QAAQ,EAAEC,SAAS;EAAC,CAC5B,CAAC;AAElB,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { Text as SwiftUIText } from '@expo/ui/swift-ui';
|
|
4
|
-
import { foregroundStyle, lineLimit, lineSpacing, multilineTextAlignment, strikethrough, textCase, underline } from '@expo/ui/swift-ui/modifiers';
|
|
4
|
+
import { foregroundStyle, lineLimit, lineSpacing, monospacedDigit as monospacedDigitModifier, multilineTextAlignment, strikethrough, textCase, underline } from '@expo/ui/swift-ui/modifiers';
|
|
5
5
|
import { scaledFont } from '@hzblj/kara-native/swift-ui';
|
|
6
6
|
import { splitAccessibility, textColorTransition, useAccessibilityModifiers, useSxModifiers } from '@hzblj/kara-sx';
|
|
7
7
|
import { useAppTheme } from '@hzblj/kara-theme';
|
|
@@ -26,6 +26,8 @@ export const Text = ({
|
|
|
26
26
|
children,
|
|
27
27
|
color = 'content.primary',
|
|
28
28
|
decoration,
|
|
29
|
+
monospaced,
|
|
30
|
+
monospacedDigit,
|
|
29
31
|
numberOfLines,
|
|
30
32
|
testID,
|
|
31
33
|
transform,
|
|
@@ -34,7 +36,7 @@ export const Text = ({
|
|
|
34
36
|
}) => {
|
|
35
37
|
useHostGuard('Text');
|
|
36
38
|
const theme = useAppTheme();
|
|
37
|
-
const style = theme.typography[variant];
|
|
39
|
+
const style = (monospaced ? theme.monoTypography : theme.typography)[variant];
|
|
38
40
|
// After the text's own modifiers: the font and colour belong to the glyphs, the padding and frame to the box around.
|
|
39
41
|
const [accessibility, sx] = splitAccessibility(props);
|
|
40
42
|
const sxModifiers = useSxModifiers(sx, FRAME_ALIGNMENT[align ?? 'left']);
|
|
@@ -53,6 +55,9 @@ export const Text = ({
|
|
|
53
55
|
textStyle: style.scalesWith,
|
|
54
56
|
weight: style.weight
|
|
55
57
|
}), lineSpacing(Math.max(0, style.lineHeight - style.fontSize)), foregroundStyle(theme.color(color))];
|
|
58
|
+
if (monospacedDigit) {
|
|
59
|
+
list.push(monospacedDigitModifier());
|
|
60
|
+
}
|
|
56
61
|
if (align) {
|
|
57
62
|
list.push(multilineTextAlignment(ALIGNMENT[align]));
|
|
58
63
|
}
|
|
@@ -75,7 +80,7 @@ export const Text = ({
|
|
|
75
80
|
list.push(lineLimit(numberOfLines));
|
|
76
81
|
}
|
|
77
82
|
return [...list, ...transition, ...sxModifiers, ...accessibilityModifiers];
|
|
78
|
-
}, [accessibilityModifiers, align, color, decoration, numberOfLines, style, sxModifiers, theme, transform, transition]);
|
|
83
|
+
}, [accessibilityModifiers, align, color, decoration, monospacedDigit, numberOfLines, style, sxModifiers, theme, transform, transition]);
|
|
79
84
|
return /*#__PURE__*/_jsx(SwiftUIText, {
|
|
80
85
|
modifiers: modifiers,
|
|
81
86
|
testID: testID,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Text","SwiftUIText","foregroundStyle","lineLimit","lineSpacing","multilineTextAlignment","strikethrough","textCase","underline","scaledFont","splitAccessibility","textColorTransition","useAccessibilityModifiers","useSxModifiers","useAppTheme","useMemo","useHostGuard","spansKey","spansOf","jsx","_jsx","ALIGNMENT","center","left","right","FRAME_ALIGNMENT","align","children","color","decoration","numberOfLines","testID","transform","variant","props","theme","style","typography","accessibility","sx","sxModifiers","accessibilityModifiers","spans","animate","transition","modifiers","list","family","fontFamily","size","fontSize","textStyle","scalesWith","weight","Math","max","lineHeight","push","isActive","pattern","undefined","map","span","index","text"],"sourceRoot":"../../../../src","sources":["atoms/text/text.ios.tsx"],"mappings":";;AAAA,SAAQA,IAAI,IAAIC,WAAW,QAAO,mBAAmB;AACrD,SACEC,eAAe,EACfC,SAAS,EACTC,WAAW,EAEXC,sBAAsB,EACtBC,aAAa,EACbC,QAAQ,EACRC,SAAS,QACJ,6BAA6B;AACpC,SAAQC,UAAU,QAAO,6BAA6B;AACtD,SAEEC,kBAAkB,EAClBC,mBAAmB,EACnBC,yBAAyB,EACzBC,cAAc,QACT,gBAAgB;AACvB,SAAQC,WAAW,QAAO,mBAAmB;AAC7C,SAAQC,OAAO,QAAO,OAAO;AAE7B,SAAQC,YAAY,QAAO,uBAAoB;AAC/C,SAAQC,QAAQ,EAAEC,OAAO,QAAO,YAAS;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAGzC,MAAMC,SAAS,GAAG;EAChBC,MAAM,EAAE,QAAQ;EAChBC,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE;AACT,CAAU;;AAEV;AACA,MAAMC,eAAe,GAAG;EACtBH,MAAM,EAAE,QAAQ;EAChBC,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE;AACT,CAAsD;AAEtD,OAAO,
|
|
1
|
+
{"version":3,"names":["Text","SwiftUIText","foregroundStyle","lineLimit","lineSpacing","monospacedDigit","monospacedDigitModifier","multilineTextAlignment","strikethrough","textCase","underline","scaledFont","splitAccessibility","textColorTransition","useAccessibilityModifiers","useSxModifiers","useAppTheme","useMemo","useHostGuard","spansKey","spansOf","jsx","_jsx","ALIGNMENT","center","left","right","FRAME_ALIGNMENT","align","children","color","decoration","monospaced","numberOfLines","testID","transform","variant","props","theme","style","monoTypography","typography","accessibility","sx","sxModifiers","accessibilityModifiers","spans","animate","transition","modifiers","list","family","fontFamily","size","fontSize","textStyle","scalesWith","weight","Math","max","lineHeight","push","isActive","pattern","undefined","map","span","index","text"],"sourceRoot":"../../../../src","sources":["atoms/text/text.ios.tsx"],"mappings":";;AAAA,SAAQA,IAAI,IAAIC,WAAW,QAAO,mBAAmB;AACrD,SACEC,eAAe,EACfC,SAAS,EACTC,WAAW,EAEXC,eAAe,IAAIC,uBAAuB,EAC1CC,sBAAsB,EACtBC,aAAa,EACbC,QAAQ,EACRC,SAAS,QACJ,6BAA6B;AACpC,SAAQC,UAAU,QAAO,6BAA6B;AACtD,SAEEC,kBAAkB,EAClBC,mBAAmB,EACnBC,yBAAyB,EACzBC,cAAc,QACT,gBAAgB;AACvB,SAAQC,WAAW,QAAO,mBAAmB;AAC7C,SAAQC,OAAO,QAAO,OAAO;AAE7B,SAAQC,YAAY,QAAO,uBAAoB;AAC/C,SAAQC,QAAQ,EAAEC,OAAO,QAAO,YAAS;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAGzC,MAAMC,SAAS,GAAG;EAChBC,MAAM,EAAE,QAAQ;EAChBC,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE;AACT,CAAU;;AAEV;AACA,MAAMC,eAAe,GAAG;EACtBH,MAAM,EAAE,QAAQ;EAChBC,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE;AACT,CAAsD;AAEtD,OAAO,MAAM1B,IAAmB,GAAGA,CAAC;EAClC4B,KAAK;EACLC,QAAQ;EACRC,KAAK,GAAG,iBAAiB;EACzBC,UAAU;EACVC,UAAU;EACV3B,eAAe;EACf4B,aAAa;EACbC,MAAM;EACNC,SAAS;EACTC,OAAO,GAAG,MAAM;EAChB,GAAGC;AACM,CAAC,KAAK;EACfnB,YAAY,CAAC,MAAM,CAAC;EACpB,MAAMoB,KAAK,GAAGtB,WAAW,CAAC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IAAA,CAACrB,WAAW;MAAagD,SAAS,EAAEiB,IAAI,CAACpC,KAAK,GAAG,CAAC5B,eAAe,CAACoC,KAAK,CAACR,KAAK,CAACoC,IAAI,CAACpC,KAAK,CAAC,CAAC,CAAC,GAAGkC,SAAU;MAAAnC,QAAA,EACrGqC,IAAI,CAACE;IAAI,GADMD,KAEL,CACd,CAAC,GACFtC;EAAQ,CACD,CAAC;AAElB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Stepper","SwiftUIStepper","labelsHidden","useReducedMotion","useRef","HStack","Spacer","Text","useHostGuard","jsx","_jsx","jsxs","_jsxs","LABEL_HIDDEN","label","max","min","onValueChange","step","value","reduced","previous","countsDown","current","align","spacing","wide","children","color","ios","animation","contentTransition","type","monospacedDigit","String","modifiers"],"sourceRoot":"../../../../src","sources":["molecules/stepper/stepper.ios.tsx"],"mappings":";;AAAA,SAAQA,OAAO,IAAIC,cAAc,QAAO,mBAAmB;AAC3D,SAAQC,YAAY,QAAO,6BAA6B;AACxD,SAAQC,gBAAgB,QAAO,mBAAmB;AAClD,SAAQC,MAAM,QAAO,OAAO;AAE5B,SAAQC,MAAM,QAAO,8BAAqB;AAC1C,SAAQC,MAAM,QAAO,6BAAoB;AACzC,SAAQC,IAAI,QAAO,2BAAkB;AACrC,SAAQC,YAAY,QAAO,uBAAoB;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAG/C;AACA,MAAMC,YAAY,GAAG,CAACX,YAAY,CAAC,CAAC,CAAC;;AAErC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMF,OAAyB,GAAGA,CAAC;EAACc,KAAK;EAAEC,GAAG;EAAEC,GAAG;EAAEC,aAAa;EAAEC,IAAI,GAAG,CAAC;EAAEC;AAAmB,CAAC,KAAK;EAC5GX,YAAY,CAAC,SAAS,CAAC;EACvB,MAAMY,OAAO,GAAGjB,gBAAgB,CAAC,CAAC;EAClC,MAAMkB,QAAQ,GAAGjB,MAAM,CAACe,KAAK,CAAC;EAC9B,MAAMG,UAAU,GAAGH,KAAK,GAAGE,QAAQ,CAACE,OAAO;EAC3CF,QAAQ,CAACE,OAAO,GAAGJ,KAAK;EAExB,oBACEP,KAAA,CAACP,MAAM;IAACmB,KAAK,EAAC,QAAQ;IAACC,OAAO,EAAC,KAAK;IAACC,IAAI;IAAAC,QAAA,gBACvCjB,IAAA,CAACH,IAAI;MAAAoB,QAAA,EAAEb;IAAK,CAAO,CAAC,eACpBJ,IAAA,CAACJ,MAAM,IAAE,CAAC,eACVI,IAAA,CAACH,IAAI;MACHqB,KAAK,EAAC,mBAAmB;MACzBC,GAAG,EAAE;QACHC,SAAS,EAAE;UAACX;QAAK,CAAC;QAClBY,iBAAiB,EAAEX,OAAO,GAAG;UAACY,IAAI,EAAE;QAAS,CAAC,GAAG;UAACV,UAAU;UAAEU,IAAI,EAAE;QAAa,
|
|
1
|
+
{"version":3,"names":["Stepper","SwiftUIStepper","labelsHidden","useReducedMotion","useRef","HStack","Spacer","Text","useHostGuard","jsx","_jsx","jsxs","_jsxs","LABEL_HIDDEN","label","max","min","onValueChange","step","value","reduced","previous","countsDown","current","align","spacing","wide","children","color","ios","animation","contentTransition","type","monospacedDigit","String","modifiers"],"sourceRoot":"../../../../src","sources":["molecules/stepper/stepper.ios.tsx"],"mappings":";;AAAA,SAAQA,OAAO,IAAIC,cAAc,QAAO,mBAAmB;AAC3D,SAAQC,YAAY,QAAO,6BAA6B;AACxD,SAAQC,gBAAgB,QAAO,mBAAmB;AAClD,SAAQC,MAAM,QAAO,OAAO;AAE5B,SAAQC,MAAM,QAAO,8BAAqB;AAC1C,SAAQC,MAAM,QAAO,6BAAoB;AACzC,SAAQC,IAAI,QAAO,2BAAkB;AACrC,SAAQC,YAAY,QAAO,uBAAoB;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAG/C;AACA,MAAMC,YAAY,GAAG,CAACX,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omit<RNTextProps, 'style'> & MotionProps & Omit<Respon
|
|
|
13
13
|
align?: 'center' | 'left' | 'right';
|
|
14
14
|
/** The text's colour. `content.primary` by default. */
|
|
15
15
|
color?: ColorToken;
|
|
16
|
+
/**
|
|
17
|
+
* Sets it in the theme's fixed-width face, at the variant's size and weight: the app's `fonts.mono`, else Menlo on
|
|
18
|
+
* iOS and `monospace` on Android, the same face `Text` sets. For code, an order number, anything read character by
|
|
19
|
+
* character.
|
|
20
|
+
*/
|
|
21
|
+
monospaced?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Digits of one width, in whatever face the text is set in, so a number that changes does not shift what follows
|
|
24
|
+
* it and figures line up in a column. React Native's `fontVariant: ['tabular-nums']`; a face without tabular
|
|
25
|
+
* figures keeps its own.
|
|
26
|
+
*/
|
|
27
|
+
monospacedDigit?: boolean;
|
|
16
28
|
/** Goes last, over the variant and the `sx`: an animated style from `useAnimatedStyle`, which it renders through Reanimated for. */
|
|
17
29
|
style?: StyleProp<AnimatedStyle<TextStyle>>;
|
|
18
30
|
/** The typography variant. `body` by default. */
|
|
@@ -7,7 +7,8 @@ export type TextTransform = 'lowercase' | 'uppercase';
|
|
|
7
7
|
/**
|
|
8
8
|
* SwiftUI `Text` / Compose `Text` in a theme typography variant. A native atom: outside a host, use `RnText`. It takes
|
|
9
9
|
* the native `sx` surface too: padding, a frame (`wide` lines it up by `align`), a background, and the `ios` bucket's
|
|
10
|
-
* `contentTransition
|
|
10
|
+
* `contentTransition` and `animation` for a number that changes in place (with `monospacedDigit`, so it does not move
|
|
11
|
+
* what follows it).
|
|
11
12
|
*
|
|
12
13
|
* Nested `Text` children are spans: runs of the same text in a colour of their own, one paragraph that wraps as one.
|
|
13
14
|
* With `animate`, a colour that changes (the text's or a span's) eases to its new value instead of switching: a word lit
|
|
@@ -30,6 +31,17 @@ export type TextProps = ResponsiveSx & AccessibilityProps & {
|
|
|
30
31
|
decoration?: TextDecoration;
|
|
31
32
|
/** The most lines it wraps to. iOS truncates the last with an ellipsis; Android clips it. */
|
|
32
33
|
numberOfLines?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Sets it in the theme's fixed-width face, at the variant's size and weight: the app's `fonts.mono`, else Menlo on
|
|
36
|
+
* iOS and `monospace` on Android. For code, an order number, anything read character by character.
|
|
37
|
+
*/
|
|
38
|
+
monospaced?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Digits of one width, in whatever face the text is set in, so a number that changes does not shift what follows
|
|
41
|
+
* it and figures line up in a column. Asks the face for its tabular figures (`tnum`); a face without them keeps
|
|
42
|
+
* its own.
|
|
43
|
+
*/
|
|
44
|
+
monospacedDigit?: boolean;
|
|
33
45
|
/** Test identifier, forwarded to the native view. */
|
|
34
46
|
testID?: string;
|
|
35
47
|
/** Upper- or lower-cases the text. Android applies it only when `children` is a plain string. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hzblj/kara-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "The atoms, molecules, organisms and templates of @hzblj/kara-ui — real SwiftUI and Jetpack Compose views through @expo/ui.",
|
|
5
5
|
"author": "Jan Blazej",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@hzblj/expo-native-icons": "^0.1.0",
|
|
63
63
|
"@hzblj/expo-rich-haptics": "^0.1.0",
|
|
64
|
-
"@hzblj/kara-native": "^0.
|
|
65
|
-
"@hzblj/kara-sx": "^0.
|
|
66
|
-
"@hzblj/kara-theme": "^0.
|
|
64
|
+
"@hzblj/kara-native": "^0.15.0",
|
|
65
|
+
"@hzblj/kara-sx": "^0.15.0",
|
|
66
|
+
"@hzblj/kara-theme": "^0.15.0",
|
|
67
67
|
"sf-symbols-typescript": "^2.2.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
@@ -33,6 +33,15 @@ const MAX_TEXT_STYLES = 512
|
|
|
33
33
|
|
|
34
34
|
const textStyles = new Map<string, TextStyle>()
|
|
35
35
|
|
|
36
|
+
/** Digits of one width: React Native asks the face for its tabular figures. */
|
|
37
|
+
const TABULAR_NUMS: TextStyle['fontVariant'] = ['tabular-nums']
|
|
38
|
+
|
|
39
|
+
/** What the text half of the style is built from. */
|
|
40
|
+
type TextLook = Pick<RnTextProps, 'align' | 'monospaced' | 'monospacedDigit'> & {
|
|
41
|
+
color: ColorToken
|
|
42
|
+
variant: TextVariant
|
|
43
|
+
}
|
|
44
|
+
|
|
36
45
|
/**
|
|
37
46
|
* The variant at the user's text size, in its colour. React Native scales `fontSize` for the user's setting but leaves
|
|
38
47
|
* `lineHeight` alone, so a grown glyph ends up in an ungrown line and clips. Scaling it here by the same factor keeps
|
|
@@ -44,12 +53,10 @@ const textStyles = new Map<string, TextStyle>()
|
|
|
44
53
|
*/
|
|
45
54
|
const textStyle = (
|
|
46
55
|
theme: Theme,
|
|
47
|
-
|
|
48
|
-
color:
|
|
49
|
-
align: RnTextProps['align'],
|
|
50
|
-
fontScale: number
|
|
56
|
+
fontScale: number,
|
|
57
|
+
{align, color, monospaced = false, monospacedDigit = false, variant}: TextLook
|
|
51
58
|
): TextStyle => {
|
|
52
|
-
const key = `${themeKey(theme)}|${variant}|${color}|${align}|${fontScale}`
|
|
59
|
+
const key = `${themeKey(theme)}|${variant}|${color}|${align}|${fontScale}|${monospaced}|${monospacedDigit}`
|
|
53
60
|
const existing = textStyles.get(key)
|
|
54
61
|
|
|
55
62
|
if (existing) {
|
|
@@ -60,7 +67,7 @@ const textStyle = (
|
|
|
60
67
|
textStyles.clear()
|
|
61
68
|
}
|
|
62
69
|
|
|
63
|
-
const typography = theme.typography[variant]
|
|
70
|
+
const typography = (monospaced ? theme.monoTypography : theme.typography)[variant]
|
|
64
71
|
const style: TextStyle = {
|
|
65
72
|
...typography,
|
|
66
73
|
color: theme.color(color),
|
|
@@ -71,19 +78,23 @@ const textStyle = (
|
|
|
71
78
|
style.textAlign = align
|
|
72
79
|
}
|
|
73
80
|
|
|
81
|
+
if (monospacedDigit) {
|
|
82
|
+
style.fontVariant = TABULAR_NUMS
|
|
83
|
+
}
|
|
84
|
+
|
|
74
85
|
textStyles.set(key, style)
|
|
75
86
|
|
|
76
87
|
return style
|
|
77
88
|
}
|
|
78
89
|
|
|
79
90
|
export const RnText: RnTextComponent = markMotionComponent(
|
|
80
|
-
({align, color = 'content.primary', style, variant = 'body', ...props}: RnTextProps) => {
|
|
91
|
+
({align, color = 'content.primary', monospaced, monospacedDigit, style, variant = 'body', ...props}: RnTextProps) => {
|
|
81
92
|
const theme = useAppTheme()
|
|
82
93
|
const fontScale = useFontScale()
|
|
83
94
|
// A view style, which a text accepts whole — only React Native's types disagree, on `userSelect`'s width.
|
|
84
95
|
const [sx, motion, rest] = useSplitSxMotion(props) as [TextStyle, SxMotion, Record<string, unknown>]
|
|
85
96
|
const animated = useAnimatedLatch(motion.animated || isAnimatedStyle(style), 'RnText')
|
|
86
|
-
const text = textStyle(theme,
|
|
97
|
+
const text = textStyle(theme, fontScale, {align, color, monospaced, monospacedDigit, variant})
|
|
87
98
|
|
|
88
99
|
if (!animated) {
|
|
89
100
|
return (
|
|
@@ -16,6 +16,18 @@ export type RnTextProps = Omit<RNTextProps, 'style'> &
|
|
|
16
16
|
align?: 'center' | 'left' | 'right'
|
|
17
17
|
/** The text's colour. `content.primary` by default. */
|
|
18
18
|
color?: ColorToken
|
|
19
|
+
/**
|
|
20
|
+
* Sets it in the theme's fixed-width face, at the variant's size and weight: the app's `fonts.mono`, else Menlo on
|
|
21
|
+
* iOS and `monospace` on Android, the same face `Text` sets. For code, an order number, anything read character by
|
|
22
|
+
* character.
|
|
23
|
+
*/
|
|
24
|
+
monospaced?: boolean
|
|
25
|
+
/**
|
|
26
|
+
* Digits of one width, in whatever face the text is set in, so a number that changes does not shift what follows
|
|
27
|
+
* it and figures line up in a column. React Native's `fontVariant: ['tabular-nums']`; a face without tabular
|
|
28
|
+
* figures keeps its own.
|
|
29
|
+
*/
|
|
30
|
+
monospacedDigit?: boolean
|
|
19
31
|
/** Goes last, over the variant and the `sx`: an animated style from `useAnimatedStyle`, which it renders through Reanimated for. */
|
|
20
32
|
style?: StyleProp<AnimatedStyle<TextStyle>>
|
|
21
33
|
/** The typography variant. `body` by default. */
|
|
@@ -63,6 +63,8 @@ export const Text: TextComponent = ({
|
|
|
63
63
|
children,
|
|
64
64
|
color = 'content.primary',
|
|
65
65
|
decoration,
|
|
66
|
+
monospaced,
|
|
67
|
+
monospacedDigit,
|
|
66
68
|
numberOfLines,
|
|
67
69
|
testID,
|
|
68
70
|
transform,
|
|
@@ -71,7 +73,7 @@ export const Text: TextComponent = ({
|
|
|
71
73
|
}: TextProps) => {
|
|
72
74
|
useHostGuard('Text')
|
|
73
75
|
const theme = useAppTheme()
|
|
74
|
-
const style = theme.typography[variant]
|
|
76
|
+
const style = (monospaced ? theme.monoTypography : theme.typography)[variant]
|
|
75
77
|
const [accessibility, sx] = splitAccessibility(props)
|
|
76
78
|
const sxModifiers = useSxModifiers(sx)
|
|
77
79
|
const accessibilityModifiers = useAccessibilityModifiers(accessibility)
|
|
@@ -80,16 +82,18 @@ export const Text: TextComponent = ({
|
|
|
80
82
|
[accessibilityModifiers, sxModifiers, testID]
|
|
81
83
|
)
|
|
82
84
|
const spans = useMemo(() => spansOf(children, Text), [children])
|
|
83
|
-
const animate = sx.animate
|
|
85
|
+
const animate = sx.animate === false ? undefined : sx.animate
|
|
84
86
|
|
|
85
|
-
// `@expo/ui`'s text takes spans but animates none: with `animate`, kara's own Compose text
|
|
86
|
-
|
|
87
|
+
// `@expo/ui`'s text takes spans but animates none, and sets no font features: with `animate`, kara's own Compose text
|
|
88
|
+
// eases each span's colour, and with `monospacedDigit` asks the face for its tabular figures.
|
|
89
|
+
if (animate !== undefined || monospacedDigit) {
|
|
87
90
|
const runs = spans ?? [{text: typeof children === 'string' || typeof children === 'number' ? String(children) : ''}]
|
|
88
91
|
|
|
89
92
|
return (
|
|
90
93
|
<AnimatedText
|
|
91
|
-
animation={textAnimation(animateConfig(animate))}
|
|
94
|
+
animation={animate === undefined ? undefined : textAnimation(animateConfig(animate))}
|
|
92
95
|
fontFamily={style.fontFamily}
|
|
96
|
+
fontFeatureSettings={monospacedDigit ? 'tnum' : undefined}
|
|
93
97
|
fontSize={style.fontSize}
|
|
94
98
|
fontWeight={style.fontWeight}
|
|
95
99
|
lineHeight={style.lineHeight}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
lineLimit,
|
|
5
5
|
lineSpacing,
|
|
6
6
|
type ModifierConfig,
|
|
7
|
+
monospacedDigit as monospacedDigitModifier,
|
|
7
8
|
multilineTextAlignment,
|
|
8
9
|
strikethrough,
|
|
9
10
|
textCase,
|
|
@@ -42,6 +43,8 @@ export const Text: TextComponent = ({
|
|
|
42
43
|
children,
|
|
43
44
|
color = 'content.primary',
|
|
44
45
|
decoration,
|
|
46
|
+
monospaced,
|
|
47
|
+
monospacedDigit,
|
|
45
48
|
numberOfLines,
|
|
46
49
|
testID,
|
|
47
50
|
transform,
|
|
@@ -50,7 +53,7 @@ export const Text: TextComponent = ({
|
|
|
50
53
|
}: TextProps) => {
|
|
51
54
|
useHostGuard('Text')
|
|
52
55
|
const theme = useAppTheme()
|
|
53
|
-
const style = theme.typography[variant]
|
|
56
|
+
const style = (monospaced ? theme.monoTypography : theme.typography)[variant]
|
|
54
57
|
// After the text's own modifiers: the font and colour belong to the glyphs, the padding and frame to the box around.
|
|
55
58
|
const [accessibility, sx] = splitAccessibility(props)
|
|
56
59
|
const sxModifiers = useSxModifiers(sx, FRAME_ALIGNMENT[align ?? 'left'])
|
|
@@ -72,6 +75,10 @@ export const Text: TextComponent = ({
|
|
|
72
75
|
foregroundStyle(theme.color(color)),
|
|
73
76
|
]
|
|
74
77
|
|
|
78
|
+
if (monospacedDigit) {
|
|
79
|
+
list.push(monospacedDigitModifier())
|
|
80
|
+
}
|
|
81
|
+
|
|
75
82
|
if (align) {
|
|
76
83
|
list.push(multilineTextAlignment(ALIGNMENT[align]))
|
|
77
84
|
}
|
|
@@ -98,6 +105,7 @@ export const Text: TextComponent = ({
|
|
|
98
105
|
align,
|
|
99
106
|
color,
|
|
100
107
|
decoration,
|
|
108
|
+
monospacedDigit,
|
|
101
109
|
numberOfLines,
|
|
102
110
|
style,
|
|
103
111
|
sxModifiers,
|
|
@@ -11,7 +11,8 @@ export type TextTransform = 'lowercase' | 'uppercase'
|
|
|
11
11
|
/**
|
|
12
12
|
* SwiftUI `Text` / Compose `Text` in a theme typography variant. A native atom: outside a host, use `RnText`. It takes
|
|
13
13
|
* the native `sx` surface too: padding, a frame (`wide` lines it up by `align`), a background, and the `ios` bucket's
|
|
14
|
-
* `contentTransition
|
|
14
|
+
* `contentTransition` and `animation` for a number that changes in place (with `monospacedDigit`, so it does not move
|
|
15
|
+
* what follows it).
|
|
15
16
|
*
|
|
16
17
|
* Nested `Text` children are spans: runs of the same text in a colour of their own, one paragraph that wraps as one.
|
|
17
18
|
* With `animate`, a colour that changes (the text's or a span's) eases to its new value instead of switching: a word lit
|
|
@@ -35,6 +36,17 @@ export type TextProps = ResponsiveSx &
|
|
|
35
36
|
decoration?: TextDecoration
|
|
36
37
|
/** The most lines it wraps to. iOS truncates the last with an ellipsis; Android clips it. */
|
|
37
38
|
numberOfLines?: number
|
|
39
|
+
/**
|
|
40
|
+
* Sets it in the theme's fixed-width face, at the variant's size and weight: the app's `fonts.mono`, else Menlo on
|
|
41
|
+
* iOS and `monospace` on Android. For code, an order number, anything read character by character.
|
|
42
|
+
*/
|
|
43
|
+
monospaced?: boolean
|
|
44
|
+
/**
|
|
45
|
+
* Digits of one width, in whatever face the text is set in, so a number that changes does not shift what follows
|
|
46
|
+
* it and figures line up in a column. Asks the face for its tabular figures (`tnum`); a face without them keeps
|
|
47
|
+
* its own.
|
|
48
|
+
*/
|
|
49
|
+
monospacedDigit?: boolean
|
|
38
50
|
/** Test identifier, forwarded to the native view. */
|
|
39
51
|
testID?: string
|
|
40
52
|
/** Upper- or lower-cases the text. Android applies it only when `children` is a plain string. */
|
|
@@ -33,8 +33,8 @@ export const Stepper: StepperComponent = ({label, max, min, onValueChange, step
|
|
|
33
33
|
ios={{
|
|
34
34
|
animation: {value},
|
|
35
35
|
contentTransition: reduced ? {type: 'opacity'} : {countsDown, type: 'numericText'},
|
|
36
|
-
monospacedDigit: true,
|
|
37
36
|
}}
|
|
37
|
+
monospacedDigit
|
|
38
38
|
>
|
|
39
39
|
{String(value)}
|
|
40
40
|
</Text>
|