@xaui/native 0.0.29 → 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 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'` |
@@ -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 color = useTypographyColor(themeColor);
155
+ const inheritedStyle = useTextSpanInheritedStyle();
156
+ const themeColorValue = useTypographyColor(themeColor);
143
157
  const variantStyles = useTypographyVariantStyles(variant);
144
- const colorStyle = { color };
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
- align && { textAlign: align },
159
- colorStyle,
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
- export { Typography, type TypographyAlign, type TypographyProps, type TypographyVariant };
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
- export { Typography, type TypographyAlign, type TypographyProps, type TypographyVariant };
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 };
@@ -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 color = useTypographyColor(themeColor);
155
+ const inheritedStyle = useTextSpanInheritedStyle();
156
+ const themeColorValue = useTypographyColor(themeColor);
143
157
  const variantStyles = useTypographyVariantStyles(variant);
144
- const colorStyle = { color };
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
- align && { textAlign: align },
159
- colorStyle,
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaui/native",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
4
4
  "description": "Flutter-inspired React Native UI components with native animations powered by React Native Reanimated",
5
5
  "keywords": [
6
6
  "react-native",