@xaui/native 0.0.28 → 0.0.30
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 +1 -0
- package/dist/menu/index.cjs +18 -6
- package/dist/menu/index.d.cts +8 -0
- package/dist/menu/index.d.ts +8 -0
- package/dist/menu/index.js +13 -1
- package/dist/typography/index.cjs +76 -6
- package/dist/typography/index.d.cts +68 -2
- package/dist/typography/index.d.ts +68 -2
- package/dist/typography/index.js +74 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -87,6 +87,7 @@ This table lists all public components exported by `@xaui/native` and their impo
|
|
|
87
87
|
| `AutocompleteItem` | Suggestion item for `Autocomplete`. | `import { AutocompleteItem } from '@xaui/native/autocomplete'` |
|
|
88
88
|
| `DatePicker` | Date selection input/picker. | `import { DatePicker } from '@xaui/native/datepicker'` |
|
|
89
89
|
| `Typography` | Themed text component with variants. | `import { Typography } from '@xaui/native/typography'` |
|
|
90
|
+
| `TextSpan` | Text group primitive that shares inherited styles across nested typography. | `import { TextSpan } from '@xaui/native/typography'` |
|
|
90
91
|
| `Column` | Vertical flex layout helper. | `import { Column } from '@xaui/native/view'` |
|
|
91
92
|
| `Row` | Horizontal flex layout helper. | `import { Row } from '@xaui/native/view'` |
|
|
92
93
|
| `Spacer` | Flexible space element in layouts. | `import { Spacer } from '@xaui/native/view'` |
|
package/dist/menu/index.cjs
CHANGED
|
@@ -155,6 +155,7 @@ var Menu = ({
|
|
|
155
155
|
trigger,
|
|
156
156
|
position = "bottom",
|
|
157
157
|
onDismiss,
|
|
158
|
+
onItemPress,
|
|
158
159
|
children,
|
|
159
160
|
customAppearance,
|
|
160
161
|
maxHeight = 280
|
|
@@ -164,6 +165,17 @@ var Menu = ({
|
|
|
164
165
|
const { contentSize, handleContentLayout, isMeasured } = useMenuContentLayout(visible);
|
|
165
166
|
const menuPosition = useMenuPosition(triggerPosition, contentSize, position);
|
|
166
167
|
const { opacity, scale } = useMenuAnimation(visible);
|
|
168
|
+
const handledChildren = _react2.default.Children.map(children, (child) => {
|
|
169
|
+
if (!_react2.default.isValidElement(child)) return child;
|
|
170
|
+
const { onPress, itemKey } = child.props;
|
|
171
|
+
if (!onPress && !itemKey) return child;
|
|
172
|
+
return _react2.default.cloneElement(child, {
|
|
173
|
+
onPress: (e) => {
|
|
174
|
+
_optionalChain([onPress, 'optionalCall', _5 => _5(e)]);
|
|
175
|
+
if (itemKey) _optionalChain([onItemPress, 'optionalCall', _6 => _6(itemKey)]);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
167
179
|
return /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { ref: triggerRef, collapsable: false }, trigger), /* @__PURE__ */ _react2.default.createElement(
|
|
168
180
|
_reactnative.Modal,
|
|
169
181
|
{
|
|
@@ -175,7 +187,7 @@ var Menu = ({
|
|
|
175
187
|
/* @__PURE__ */ _react2.default.createElement(
|
|
176
188
|
_reactnative.Pressable,
|
|
177
189
|
{
|
|
178
|
-
style: [styles.overlay, _optionalChain([customAppearance, 'optionalAccess',
|
|
190
|
+
style: [styles.overlay, _optionalChain([customAppearance, 'optionalAccess', _7 => _7.overlay])],
|
|
179
191
|
onPress: onDismiss,
|
|
180
192
|
accessibilityRole: "button",
|
|
181
193
|
accessibilityLabel: "Close menu"
|
|
@@ -195,10 +207,10 @@ var Menu = ({
|
|
|
195
207
|
transform: [{ scale }],
|
|
196
208
|
...theme.shadows.md
|
|
197
209
|
},
|
|
198
|
-
_optionalChain([customAppearance, 'optionalAccess',
|
|
210
|
+
_optionalChain([customAppearance, 'optionalAccess', _8 => _8.container])
|
|
199
211
|
]
|
|
200
212
|
},
|
|
201
|
-
/* @__PURE__ */ _react2.default.createElement(_reactnative.Pressable, { onPress: (e) => e.stopPropagation() }, /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: _optionalChain([customAppearance, 'optionalAccess',
|
|
213
|
+
/* @__PURE__ */ _react2.default.createElement(_reactnative.Pressable, { onPress: (e) => e.stopPropagation() }, /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: _optionalChain([customAppearance, 'optionalAccess', _9 => _9.content]) }, /* @__PURE__ */ _react2.default.createElement(_reactnative.ScrollView, { style: { maxHeight } }, handledChildren)))
|
|
202
214
|
)
|
|
203
215
|
)
|
|
204
216
|
));
|
|
@@ -269,7 +281,7 @@ var MenuItem = ({
|
|
|
269
281
|
return /* @__PURE__ */ _react2.default.createElement(
|
|
270
282
|
_reactnative.Text,
|
|
271
283
|
{
|
|
272
|
-
style: [styles2.titleText, { color: titleColor }, _optionalChain([customAppearance, 'optionalAccess',
|
|
284
|
+
style: [styles2.titleText, { color: titleColor }, _optionalChain([customAppearance, 'optionalAccess', _10 => _10.title])],
|
|
273
285
|
numberOfLines: 1
|
|
274
286
|
},
|
|
275
287
|
title
|
|
@@ -292,10 +304,10 @@ var MenuItem = ({
|
|
|
292
304
|
pressed && !isDisabled && {
|
|
293
305
|
backgroundColor: theme.colors.foreground + "10"
|
|
294
306
|
},
|
|
295
|
-
_optionalChain([customAppearance, 'optionalAccess',
|
|
307
|
+
_optionalChain([customAppearance, 'optionalAccess', _11 => _11.container])
|
|
296
308
|
]
|
|
297
309
|
},
|
|
298
|
-
/* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: [styles2.row, _optionalChain([customAppearance, 'optionalAccess',
|
|
310
|
+
/* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: [styles2.row, _optionalChain([customAppearance, 'optionalAccess', _12 => _12.content])] }, startContent && /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles2.startContent }, startContent), /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles2.content }, renderTitle()), endContent && /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles2.endContent }, endContent))
|
|
299
311
|
);
|
|
300
312
|
};
|
|
301
313
|
|
package/dist/menu/index.d.cts
CHANGED
|
@@ -34,6 +34,10 @@ type MenuProps = {
|
|
|
34
34
|
* Callback called when Menu is dismissed. The `visible` prop needs to be updated when this is called.
|
|
35
35
|
*/
|
|
36
36
|
onDismiss?: () => void;
|
|
37
|
+
/**
|
|
38
|
+
* Callback fired when a MenuItem with an `itemKey` is pressed.
|
|
39
|
+
*/
|
|
40
|
+
onItemPress?: (itemKey: string) => void;
|
|
37
41
|
/**
|
|
38
42
|
* Content of the Menu.
|
|
39
43
|
*/
|
|
@@ -66,6 +70,10 @@ type MenuItemCustomAppearance = {
|
|
|
66
70
|
title?: TextStyle;
|
|
67
71
|
};
|
|
68
72
|
type MenuItemProps = {
|
|
73
|
+
/**
|
|
74
|
+
* Optional key emitted via Menu `onItemPress`.
|
|
75
|
+
*/
|
|
76
|
+
itemKey?: string;
|
|
69
77
|
/**
|
|
70
78
|
* Title text for the MenuItem.
|
|
71
79
|
*/
|
package/dist/menu/index.d.ts
CHANGED
|
@@ -34,6 +34,10 @@ type MenuProps = {
|
|
|
34
34
|
* Callback called when Menu is dismissed. The `visible` prop needs to be updated when this is called.
|
|
35
35
|
*/
|
|
36
36
|
onDismiss?: () => void;
|
|
37
|
+
/**
|
|
38
|
+
* Callback fired when a MenuItem with an `itemKey` is pressed.
|
|
39
|
+
*/
|
|
40
|
+
onItemPress?: (itemKey: string) => void;
|
|
37
41
|
/**
|
|
38
42
|
* Content of the Menu.
|
|
39
43
|
*/
|
|
@@ -66,6 +70,10 @@ type MenuItemCustomAppearance = {
|
|
|
66
70
|
title?: TextStyle;
|
|
67
71
|
};
|
|
68
72
|
type MenuItemProps = {
|
|
73
|
+
/**
|
|
74
|
+
* Optional key emitted via Menu `onItemPress`.
|
|
75
|
+
*/
|
|
76
|
+
itemKey?: string;
|
|
69
77
|
/**
|
|
70
78
|
* Title text for the MenuItem.
|
|
71
79
|
*/
|
package/dist/menu/index.js
CHANGED
|
@@ -155,6 +155,7 @@ var Menu = ({
|
|
|
155
155
|
trigger,
|
|
156
156
|
position = "bottom",
|
|
157
157
|
onDismiss,
|
|
158
|
+
onItemPress,
|
|
158
159
|
children,
|
|
159
160
|
customAppearance,
|
|
160
161
|
maxHeight = 280
|
|
@@ -164,6 +165,17 @@ var Menu = ({
|
|
|
164
165
|
const { contentSize, handleContentLayout, isMeasured } = useMenuContentLayout(visible);
|
|
165
166
|
const menuPosition = useMenuPosition(triggerPosition, contentSize, position);
|
|
166
167
|
const { opacity, scale } = useMenuAnimation(visible);
|
|
168
|
+
const handledChildren = React.Children.map(children, (child) => {
|
|
169
|
+
if (!React.isValidElement(child)) return child;
|
|
170
|
+
const { onPress, itemKey } = child.props;
|
|
171
|
+
if (!onPress && !itemKey) return child;
|
|
172
|
+
return React.cloneElement(child, {
|
|
173
|
+
onPress: (e) => {
|
|
174
|
+
onPress?.(e);
|
|
175
|
+
if (itemKey) onItemPress?.(itemKey);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
167
179
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, { ref: triggerRef, collapsable: false }, trigger), /* @__PURE__ */ React.createElement(
|
|
168
180
|
Modal,
|
|
169
181
|
{
|
|
@@ -198,7 +210,7 @@ var Menu = ({
|
|
|
198
210
|
customAppearance?.container
|
|
199
211
|
]
|
|
200
212
|
},
|
|
201
|
-
/* @__PURE__ */ React.createElement(Pressable, { onPress: (e) => e.stopPropagation() }, /* @__PURE__ */ React.createElement(View, { style: customAppearance?.content }, /* @__PURE__ */ React.createElement(ScrollView, { style: { maxHeight } },
|
|
213
|
+
/* @__PURE__ */ React.createElement(Pressable, { onPress: (e) => e.stopPropagation() }, /* @__PURE__ */ React.createElement(View, { style: customAppearance?.content }, /* @__PURE__ */ React.createElement(ScrollView, { style: { maxHeight } }, handledChildren)))
|
|
202
214
|
)
|
|
203
215
|
)
|
|
204
216
|
));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }require('../chunk-HSPTLUFA.cjs');
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }require('../chunk-HSPTLUFA.cjs');
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
var _chunkOQ2BLOOGcjs = require('../chunk-OQ2BLOOG.cjs');
|
|
@@ -15,6 +15,13 @@ var styles = _reactnative.StyleSheet.create({
|
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
+
// src/components/typography/text-span.context.ts
|
|
19
|
+
|
|
20
|
+
var TextSpanContext = _react.createContext.call(void 0, {});
|
|
21
|
+
var useTextSpanInheritedStyle = () => {
|
|
22
|
+
return _react.useContext.call(void 0, TextSpanContext);
|
|
23
|
+
};
|
|
24
|
+
|
|
18
25
|
// src/components/typography/typography.hook.ts
|
|
19
26
|
|
|
20
27
|
var _core = require('@xaui/core');
|
|
@@ -137,11 +144,26 @@ var Typography = ({
|
|
|
137
144
|
variant = "bodyMedium",
|
|
138
145
|
maxLines,
|
|
139
146
|
overflow = "clip",
|
|
147
|
+
color,
|
|
148
|
+
letterSpacing,
|
|
149
|
+
fontWeight,
|
|
150
|
+
fontStyle,
|
|
151
|
+
textDecorationLine,
|
|
152
|
+
textTransform,
|
|
140
153
|
style
|
|
141
154
|
}) => {
|
|
142
|
-
const
|
|
155
|
+
const inheritedStyle = useTextSpanInheritedStyle();
|
|
156
|
+
const themeColorValue = useTypographyColor(themeColor);
|
|
143
157
|
const variantStyles = useTypographyVariantStyles(variant);
|
|
144
|
-
const
|
|
158
|
+
const resolvedAlign = _nullishCoalesce(align, () => ( inheritedStyle.align));
|
|
159
|
+
const textStyleOverrides = {
|
|
160
|
+
color: _nullishCoalesce(_nullishCoalesce(color, () => ( inheritedStyle.color)), () => ( themeColorValue)),
|
|
161
|
+
letterSpacing,
|
|
162
|
+
fontWeight: _nullishCoalesce(fontWeight, () => ( inheritedStyle.fontWeight)),
|
|
163
|
+
fontStyle: _nullishCoalesce(fontStyle, () => ( inheritedStyle.fontStyle)),
|
|
164
|
+
textDecorationLine,
|
|
165
|
+
textTransform: _nullishCoalesce(textTransform, () => ( inheritedStyle.textTransform))
|
|
166
|
+
};
|
|
145
167
|
const ellipsizeMode = _react.useMemo.call(void 0, () => {
|
|
146
168
|
if (!maxLines) return void 0;
|
|
147
169
|
if (overflow === "clip") return "clip";
|
|
@@ -155,8 +177,8 @@ var Typography = ({
|
|
|
155
177
|
style: [
|
|
156
178
|
styles.text,
|
|
157
179
|
variantStyles,
|
|
158
|
-
|
|
159
|
-
|
|
180
|
+
resolvedAlign && { textAlign: resolvedAlign },
|
|
181
|
+
textStyleOverrides,
|
|
160
182
|
style
|
|
161
183
|
]
|
|
162
184
|
},
|
|
@@ -164,5 +186,53 @@ var Typography = ({
|
|
|
164
186
|
);
|
|
165
187
|
};
|
|
166
188
|
|
|
189
|
+
// src/components/typography/text-span.tsx
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
var alignToJustifyContent = {
|
|
193
|
+
left: "flex-start",
|
|
194
|
+
center: "center",
|
|
195
|
+
right: "flex-end",
|
|
196
|
+
justify: "space-between"
|
|
197
|
+
};
|
|
198
|
+
var TextSpan = ({
|
|
199
|
+
children,
|
|
200
|
+
color,
|
|
201
|
+
fontWeight,
|
|
202
|
+
fontStyle,
|
|
203
|
+
textTransform,
|
|
204
|
+
spacing,
|
|
205
|
+
align,
|
|
206
|
+
backgroundColor,
|
|
207
|
+
style
|
|
208
|
+
}) => {
|
|
209
|
+
const inheritedTextStyle = {
|
|
210
|
+
color,
|
|
211
|
+
fontWeight,
|
|
212
|
+
fontStyle,
|
|
213
|
+
textTransform,
|
|
214
|
+
align
|
|
215
|
+
};
|
|
216
|
+
return /* @__PURE__ */ _react2.default.createElement(TextSpanContext.Provider, { value: inheritedTextStyle }, /* @__PURE__ */ _react2.default.createElement(
|
|
217
|
+
_reactnative.View,
|
|
218
|
+
{
|
|
219
|
+
style: [
|
|
220
|
+
{
|
|
221
|
+
flexDirection: "row",
|
|
222
|
+
flexWrap: "wrap",
|
|
223
|
+
alignItems: "center",
|
|
224
|
+
...align ? { justifyContent: alignToJustifyContent[align] } : {},
|
|
225
|
+
...typeof spacing === "number" ? { gap: spacing } : {},
|
|
226
|
+
...backgroundColor ? { backgroundColor } : {}
|
|
227
|
+
},
|
|
228
|
+
style
|
|
229
|
+
]
|
|
230
|
+
},
|
|
231
|
+
children
|
|
232
|
+
));
|
|
233
|
+
};
|
|
234
|
+
TextSpan.displayName = "TextSpan";
|
|
235
|
+
|
|
236
|
+
|
|
167
237
|
|
|
168
|
-
exports.Typography = Typography;
|
|
238
|
+
exports.TextSpan = TextSpan; exports.Typography = Typography;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import { StyleProp, TextStyle } from 'react-native';
|
|
2
|
+
import { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
3
3
|
import { T as ThemeColor } from '../index-BOw6tbkc.cjs';
|
|
4
4
|
|
|
5
5
|
type TypographyAlign = 'center' | 'justify' | 'left' | 'right';
|
|
@@ -36,8 +36,74 @@ type TypographyProps = {
|
|
|
36
36
|
* Custom styles for the text.
|
|
37
37
|
*/
|
|
38
38
|
style?: StyleProp<TextStyle>;
|
|
39
|
+
/**
|
|
40
|
+
* Custom text color override.
|
|
41
|
+
*/
|
|
42
|
+
color?: TextStyle['color'];
|
|
43
|
+
/**
|
|
44
|
+
* The spacing between characters.
|
|
45
|
+
*/
|
|
46
|
+
letterSpacing?: number;
|
|
47
|
+
/**
|
|
48
|
+
* The text weight.
|
|
49
|
+
*/
|
|
50
|
+
fontWeight?: TextStyle['fontWeight'];
|
|
51
|
+
/**
|
|
52
|
+
* The text style.
|
|
53
|
+
*/
|
|
54
|
+
fontStyle?: TextStyle['fontStyle'];
|
|
55
|
+
/**
|
|
56
|
+
* Text decoration line.
|
|
57
|
+
*/
|
|
58
|
+
textDecorationLine?: TextStyle['textDecorationLine'];
|
|
59
|
+
/**
|
|
60
|
+
* Text transform mode.
|
|
61
|
+
*/
|
|
62
|
+
textTransform?: TextStyle['textTransform'];
|
|
39
63
|
};
|
|
40
64
|
|
|
41
65
|
declare const Typography: React.FC<TypographyProps>;
|
|
42
66
|
|
|
43
|
-
|
|
67
|
+
type TextSpanAlign = TypographyAlign;
|
|
68
|
+
type TextSpanProps = {
|
|
69
|
+
/**
|
|
70
|
+
* The content to display inside the text span.
|
|
71
|
+
*/
|
|
72
|
+
children: ReactNode;
|
|
73
|
+
/**
|
|
74
|
+
* Inherited text color for nested Typography.
|
|
75
|
+
*/
|
|
76
|
+
color?: TextStyle['color'];
|
|
77
|
+
/**
|
|
78
|
+
* Inherited text weight for nested Typography.
|
|
79
|
+
*/
|
|
80
|
+
fontWeight?: TextStyle['fontWeight'];
|
|
81
|
+
/**
|
|
82
|
+
* Inherited text style for nested Typography.
|
|
83
|
+
*/
|
|
84
|
+
fontStyle?: TextStyle['fontStyle'];
|
|
85
|
+
/**
|
|
86
|
+
* Inherited text transform for nested Typography.
|
|
87
|
+
*/
|
|
88
|
+
textTransform?: TextStyle['textTransform'];
|
|
89
|
+
/**
|
|
90
|
+
* Spacing between children.
|
|
91
|
+
*/
|
|
92
|
+
spacing?: number;
|
|
93
|
+
/**
|
|
94
|
+
* Text alignment for all nested typography unless overridden.
|
|
95
|
+
*/
|
|
96
|
+
align?: TextSpanAlign;
|
|
97
|
+
/**
|
|
98
|
+
* Background color for the text span container.
|
|
99
|
+
*/
|
|
100
|
+
backgroundColor?: ViewStyle['backgroundColor'];
|
|
101
|
+
/**
|
|
102
|
+
* Custom styles for the text span container.
|
|
103
|
+
*/
|
|
104
|
+
style?: StyleProp<ViewStyle>;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
declare const TextSpan: React.FC<TextSpanProps>;
|
|
108
|
+
|
|
109
|
+
export { TextSpan, type TextSpanAlign, type TextSpanProps, Typography, type TypographyAlign, type TypographyProps, type TypographyVariant };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import { StyleProp, TextStyle } from 'react-native';
|
|
2
|
+
import { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
3
3
|
import { T as ThemeColor } from '../index-BOw6tbkc.js';
|
|
4
4
|
|
|
5
5
|
type TypographyAlign = 'center' | 'justify' | 'left' | 'right';
|
|
@@ -36,8 +36,74 @@ type TypographyProps = {
|
|
|
36
36
|
* Custom styles for the text.
|
|
37
37
|
*/
|
|
38
38
|
style?: StyleProp<TextStyle>;
|
|
39
|
+
/**
|
|
40
|
+
* Custom text color override.
|
|
41
|
+
*/
|
|
42
|
+
color?: TextStyle['color'];
|
|
43
|
+
/**
|
|
44
|
+
* The spacing between characters.
|
|
45
|
+
*/
|
|
46
|
+
letterSpacing?: number;
|
|
47
|
+
/**
|
|
48
|
+
* The text weight.
|
|
49
|
+
*/
|
|
50
|
+
fontWeight?: TextStyle['fontWeight'];
|
|
51
|
+
/**
|
|
52
|
+
* The text style.
|
|
53
|
+
*/
|
|
54
|
+
fontStyle?: TextStyle['fontStyle'];
|
|
55
|
+
/**
|
|
56
|
+
* Text decoration line.
|
|
57
|
+
*/
|
|
58
|
+
textDecorationLine?: TextStyle['textDecorationLine'];
|
|
59
|
+
/**
|
|
60
|
+
* Text transform mode.
|
|
61
|
+
*/
|
|
62
|
+
textTransform?: TextStyle['textTransform'];
|
|
39
63
|
};
|
|
40
64
|
|
|
41
65
|
declare const Typography: React.FC<TypographyProps>;
|
|
42
66
|
|
|
43
|
-
|
|
67
|
+
type TextSpanAlign = TypographyAlign;
|
|
68
|
+
type TextSpanProps = {
|
|
69
|
+
/**
|
|
70
|
+
* The content to display inside the text span.
|
|
71
|
+
*/
|
|
72
|
+
children: ReactNode;
|
|
73
|
+
/**
|
|
74
|
+
* Inherited text color for nested Typography.
|
|
75
|
+
*/
|
|
76
|
+
color?: TextStyle['color'];
|
|
77
|
+
/**
|
|
78
|
+
* Inherited text weight for nested Typography.
|
|
79
|
+
*/
|
|
80
|
+
fontWeight?: TextStyle['fontWeight'];
|
|
81
|
+
/**
|
|
82
|
+
* Inherited text style for nested Typography.
|
|
83
|
+
*/
|
|
84
|
+
fontStyle?: TextStyle['fontStyle'];
|
|
85
|
+
/**
|
|
86
|
+
* Inherited text transform for nested Typography.
|
|
87
|
+
*/
|
|
88
|
+
textTransform?: TextStyle['textTransform'];
|
|
89
|
+
/**
|
|
90
|
+
* Spacing between children.
|
|
91
|
+
*/
|
|
92
|
+
spacing?: number;
|
|
93
|
+
/**
|
|
94
|
+
* Text alignment for all nested typography unless overridden.
|
|
95
|
+
*/
|
|
96
|
+
align?: TextSpanAlign;
|
|
97
|
+
/**
|
|
98
|
+
* Background color for the text span container.
|
|
99
|
+
*/
|
|
100
|
+
backgroundColor?: ViewStyle['backgroundColor'];
|
|
101
|
+
/**
|
|
102
|
+
* Custom styles for the text span container.
|
|
103
|
+
*/
|
|
104
|
+
style?: StyleProp<ViewStyle>;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
declare const TextSpan: React.FC<TextSpanProps>;
|
|
108
|
+
|
|
109
|
+
export { TextSpan, type TextSpanAlign, type TextSpanProps, Typography, type TypographyAlign, type TypographyProps, type TypographyVariant };
|
package/dist/typography/index.js
CHANGED
|
@@ -15,6 +15,13 @@ var styles = StyleSheet.create({
|
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
+
// src/components/typography/text-span.context.ts
|
|
19
|
+
import { createContext, useContext } from "react";
|
|
20
|
+
var TextSpanContext = createContext({});
|
|
21
|
+
var useTextSpanInheritedStyle = () => {
|
|
22
|
+
return useContext(TextSpanContext);
|
|
23
|
+
};
|
|
24
|
+
|
|
18
25
|
// src/components/typography/typography.hook.ts
|
|
19
26
|
import { useMemo } from "react";
|
|
20
27
|
import { getSafeThemeColor } from "@xaui/core";
|
|
@@ -137,11 +144,26 @@ var Typography = ({
|
|
|
137
144
|
variant = "bodyMedium",
|
|
138
145
|
maxLines,
|
|
139
146
|
overflow = "clip",
|
|
147
|
+
color,
|
|
148
|
+
letterSpacing,
|
|
149
|
+
fontWeight,
|
|
150
|
+
fontStyle,
|
|
151
|
+
textDecorationLine,
|
|
152
|
+
textTransform,
|
|
140
153
|
style
|
|
141
154
|
}) => {
|
|
142
|
-
const
|
|
155
|
+
const inheritedStyle = useTextSpanInheritedStyle();
|
|
156
|
+
const themeColorValue = useTypographyColor(themeColor);
|
|
143
157
|
const variantStyles = useTypographyVariantStyles(variant);
|
|
144
|
-
const
|
|
158
|
+
const resolvedAlign = align ?? inheritedStyle.align;
|
|
159
|
+
const textStyleOverrides = {
|
|
160
|
+
color: color ?? inheritedStyle.color ?? themeColorValue,
|
|
161
|
+
letterSpacing,
|
|
162
|
+
fontWeight: fontWeight ?? inheritedStyle.fontWeight,
|
|
163
|
+
fontStyle: fontStyle ?? inheritedStyle.fontStyle,
|
|
164
|
+
textDecorationLine,
|
|
165
|
+
textTransform: textTransform ?? inheritedStyle.textTransform
|
|
166
|
+
};
|
|
145
167
|
const ellipsizeMode = useMemo2(() => {
|
|
146
168
|
if (!maxLines) return void 0;
|
|
147
169
|
if (overflow === "clip") return "clip";
|
|
@@ -155,14 +177,62 @@ var Typography = ({
|
|
|
155
177
|
style: [
|
|
156
178
|
styles.text,
|
|
157
179
|
variantStyles,
|
|
158
|
-
|
|
159
|
-
|
|
180
|
+
resolvedAlign && { textAlign: resolvedAlign },
|
|
181
|
+
textStyleOverrides,
|
|
160
182
|
style
|
|
161
183
|
]
|
|
162
184
|
},
|
|
163
185
|
children
|
|
164
186
|
);
|
|
165
187
|
};
|
|
188
|
+
|
|
189
|
+
// src/components/typography/text-span.tsx
|
|
190
|
+
import React2 from "react";
|
|
191
|
+
import { View } from "react-native";
|
|
192
|
+
var alignToJustifyContent = {
|
|
193
|
+
left: "flex-start",
|
|
194
|
+
center: "center",
|
|
195
|
+
right: "flex-end",
|
|
196
|
+
justify: "space-between"
|
|
197
|
+
};
|
|
198
|
+
var TextSpan = ({
|
|
199
|
+
children,
|
|
200
|
+
color,
|
|
201
|
+
fontWeight,
|
|
202
|
+
fontStyle,
|
|
203
|
+
textTransform,
|
|
204
|
+
spacing,
|
|
205
|
+
align,
|
|
206
|
+
backgroundColor,
|
|
207
|
+
style
|
|
208
|
+
}) => {
|
|
209
|
+
const inheritedTextStyle = {
|
|
210
|
+
color,
|
|
211
|
+
fontWeight,
|
|
212
|
+
fontStyle,
|
|
213
|
+
textTransform,
|
|
214
|
+
align
|
|
215
|
+
};
|
|
216
|
+
return /* @__PURE__ */ React2.createElement(TextSpanContext.Provider, { value: inheritedTextStyle }, /* @__PURE__ */ React2.createElement(
|
|
217
|
+
View,
|
|
218
|
+
{
|
|
219
|
+
style: [
|
|
220
|
+
{
|
|
221
|
+
flexDirection: "row",
|
|
222
|
+
flexWrap: "wrap",
|
|
223
|
+
alignItems: "center",
|
|
224
|
+
...align ? { justifyContent: alignToJustifyContent[align] } : {},
|
|
225
|
+
...typeof spacing === "number" ? { gap: spacing } : {},
|
|
226
|
+
...backgroundColor ? { backgroundColor } : {}
|
|
227
|
+
},
|
|
228
|
+
style
|
|
229
|
+
]
|
|
230
|
+
},
|
|
231
|
+
children
|
|
232
|
+
));
|
|
233
|
+
};
|
|
234
|
+
TextSpan.displayName = "TextSpan";
|
|
166
235
|
export {
|
|
236
|
+
TextSpan,
|
|
167
237
|
Typography
|
|
168
238
|
};
|