@platform-blocks/ui 0.7.0 → 0.7.2
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/lib/cjs/index.js +37 -3
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/index.js +37 -4
- package/lib/esm/index.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/package.json +1 -1
package/lib/cjs/index.js
CHANGED
|
@@ -3527,6 +3527,35 @@ const containsPlatformText = (node) => {
|
|
|
3527
3527
|
return false;
|
|
3528
3528
|
});
|
|
3529
3529
|
};
|
|
3530
|
+
/**
|
|
3531
|
+
* Check if children contain block-level elements (View, Pressable, etc.)
|
|
3532
|
+
* that would render as <div> on web, causing invalid nesting inside <p>.
|
|
3533
|
+
*/
|
|
3534
|
+
const containsBlockElement = (node) => {
|
|
3535
|
+
return React.Children.toArray(node).some(child => {
|
|
3536
|
+
if (React.isValidElement(child)) {
|
|
3537
|
+
const childType = child.type;
|
|
3538
|
+
// Check for native RN components that render as div on web
|
|
3539
|
+
const displayName = (childType === null || childType === void 0 ? void 0 : childType.displayName) || (childType === null || childType === void 0 ? void 0 : childType.name) || '';
|
|
3540
|
+
const blockNames = new Set([
|
|
3541
|
+
'View', 'Pressable', 'TouchableOpacity', 'TouchableHighlight',
|
|
3542
|
+
'TouchableWithoutFeedback', 'ScrollView', 'FlatList', 'SectionList',
|
|
3543
|
+
'SafeAreaView', 'KeyboardAvoidingView', 'Modal',
|
|
3544
|
+
]);
|
|
3545
|
+
if (blockNames.has(displayName))
|
|
3546
|
+
return true;
|
|
3547
|
+
// Also check if it's a native 'div' element
|
|
3548
|
+
if (childType === 'div')
|
|
3549
|
+
return true;
|
|
3550
|
+
// Recurse into children
|
|
3551
|
+
const childProps = child.props;
|
|
3552
|
+
if (childProps === null || childProps === void 0 ? void 0 : childProps.children) {
|
|
3553
|
+
return containsBlockElement(childProps.children);
|
|
3554
|
+
}
|
|
3555
|
+
}
|
|
3556
|
+
return false;
|
|
3557
|
+
});
|
|
3558
|
+
};
|
|
3530
3559
|
const Text = (allProps) => {
|
|
3531
3560
|
const { spacingProps, otherProps } = extractSpacingProps(allProps);
|
|
3532
3561
|
const { children, tx, txParams, variant = 'p', size, weight, align = 'left', color, colorVariant, lineHeight, tracking, uppercase, style, fontFamily, as, selectable = true, onPress, onLayout, value, numberOfLines, ellipsizeMode } = otherProps;
|
|
@@ -3571,6 +3600,10 @@ const Text = (allProps) => {
|
|
|
3571
3600
|
// Avoid nested paragraphs when Text components are nested
|
|
3572
3601
|
htmlTag = 'div';
|
|
3573
3602
|
}
|
|
3603
|
+
if (htmlTag === 'p' && containsBlockElement(children)) {
|
|
3604
|
+
// Avoid <div> inside <p> when children contain View, Pressable, etc.
|
|
3605
|
+
htmlTag = 'div';
|
|
3606
|
+
}
|
|
3574
3607
|
}
|
|
3575
3608
|
// Platform-specific rendering
|
|
3576
3609
|
if (reactNative.Platform.OS === 'web' && isHTMLVariant(htmlTag)) {
|
|
@@ -16116,12 +16149,12 @@ const BrandButton = (props) => {
|
|
|
16116
16149
|
return { backgroundColor: 'transparent', borderColor: 'transparent' };
|
|
16117
16150
|
case 'plain':
|
|
16118
16151
|
return {
|
|
16119
|
-
backgroundColor: 'white',
|
|
16152
|
+
backgroundColor: theme.colorScheme === 'dark' ? theme.backgrounds.elevated : 'white',
|
|
16120
16153
|
borderColor: 'transparent',
|
|
16121
16154
|
paddingHorizontal: 16,
|
|
16122
16155
|
minWidth: 0,
|
|
16123
16156
|
height: 'auto',
|
|
16124
|
-
color: 'black'
|
|
16157
|
+
color: theme.colorScheme === 'dark' ? theme.text.primary : 'black'
|
|
16125
16158
|
};
|
|
16126
16159
|
default: // primary/filled/secondary/gradient etc treat as filled brand color
|
|
16127
16160
|
return {
|
|
@@ -16132,7 +16165,7 @@ const BrandButton = (props) => {
|
|
|
16132
16165
|
}
|
|
16133
16166
|
})();
|
|
16134
16167
|
// Compute textColor override: outline/link use brand color, ghost uses default text color, filled-like use contrasting light text
|
|
16135
|
-
const textColor = effectiveVariant === 'plain' ? 'black' :
|
|
16168
|
+
const textColor = effectiveVariant === 'plain' ? (theme.colorScheme === 'dark' ? theme.text.primary : 'black') :
|
|
16136
16169
|
effectiveVariant === 'ghost'
|
|
16137
16170
|
? theme.text.primary
|
|
16138
16171
|
: (effectiveVariant === 'outline' || effectiveVariant === 'link')
|
|
@@ -41190,6 +41223,7 @@ exports.useAppShellApi = useAppShellApi;
|
|
|
41190
41223
|
exports.useAppShellLayout = useAppShellLayout;
|
|
41191
41224
|
exports.useBreakpoint = useBreakpoint;
|
|
41192
41225
|
exports.useColorScheme = useColorScheme;
|
|
41226
|
+
exports.useDeviceInfo = useDeviceInfo;
|
|
41193
41227
|
exports.useDialog = useDialog;
|
|
41194
41228
|
exports.useDialogApi = useDialogApi;
|
|
41195
41229
|
exports.useDialogs = useDialogs;
|