@sudobility/building_blocks_rn 0.0.32 → 0.0.34

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.
@@ -1,24 +1,24 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { View, Text, ScrollView } from 'react-native';
3
3
  import { createThemedStyles } from '../../utils/styles';
4
- import { useRTLTextStyle } from '../../hooks/useRTL';
4
+ import { useIsRTL } from '../../hooks/useRTL';
5
5
  function TextSectionView({ section, level = 2, }) {
6
6
  const styles = useStyles();
7
- const rtlText = useRTLTextStyle();
7
+ const isRTL = useIsRTL();
8
8
  return (_jsxs(View, { style: styles.section, children: [_jsx(Text, { style: [
9
9
  level === 2 ? styles.sectionTitle : styles.subsectionTitle,
10
- rtlText,
11
- ], children: section.title }), section.content && (_jsx(Text, { style: [styles.sectionContent, rtlText], children: section.content })), section.items && section.items.length > 0 && (_jsx(View, { style: styles.list, children: section.items.map((item, index) => (_jsxs(View, { style: styles.listItem, children: [_jsx(Text, { style: styles.bullet, children: '\u2022' }), _jsx(Text, { style: [styles.listItemText, rtlText], children: item })] }, index))) })), section.subsections?.map((sub, index) => (_jsx(TextSectionView, { section: sub, level: 3 }, index)))] }));
10
+ isRTL && styles.rtlText,
11
+ ], children: section.title }), section.content && (_jsx(Text, { style: [styles.sectionContent, isRTL && styles.rtlText], children: section.content })), section.items && section.items.length > 0 && (_jsx(View, { style: styles.list, children: section.items.map((item, index) => (_jsxs(View, { style: styles.listItem, children: [_jsx(Text, { style: styles.bullet, children: '\u2022' }), _jsx(Text, { style: [styles.listItemText, isRTL && styles.rtlText], children: item })] }, index))) })), section.subsections?.map((sub, index) => (_jsx(TextSectionView, { section: sub, level: 3 }, index)))] }));
12
12
  }
13
13
  export function AppTextScreen({ text, lastUpdatedDate, ScreenWrapper, style, }) {
14
14
  const styles = useStyles();
15
- const rtlText = useRTLTextStyle();
15
+ const isRTL = useIsRTL();
16
16
  const lastUpdated = text.lastUpdated
17
17
  ? text.lastUpdated.replace('{{date}}', lastUpdatedDate ?? '')
18
18
  : lastUpdatedDate
19
19
  ? `Last updated: ${lastUpdatedDate}`
20
20
  : undefined;
21
- const content = (_jsxs(View, { style: [styles.container, style], children: [_jsx(Text, { style: [styles.title, rtlText], children: text.title }), lastUpdated && (_jsx(Text, { style: [styles.lastUpdated, rtlText], children: lastUpdated })), text.sections.map((section, index) => (_jsx(TextSectionView, { section: section }, index))), text.contact && (_jsxs(View, { style: styles.contactSection, children: [_jsx(Text, { style: [styles.sectionTitle, rtlText], children: text.contact.title }), _jsx(Text, { style: [styles.sectionContent, rtlText], children: text.contact.description }), _jsx(Text, { style: [styles.contactInfo, rtlText], children: text.contact.info }), text.contact.gdprNotice && (_jsx(Text, { style: [styles.gdprNotice, rtlText], children: text.contact.gdprNotice }))] }))] }));
21
+ const content = (_jsxs(View, { style: [styles.container, style], children: [_jsx(Text, { style: [styles.title, isRTL && styles.rtlText], children: text.title }), lastUpdated && (_jsx(Text, { style: [styles.lastUpdated, isRTL && styles.rtlText], children: lastUpdated })), text.sections.map((section, index) => (_jsx(TextSectionView, { section: section }, index))), text.contact && (_jsxs(View, { style: styles.contactSection, children: [_jsx(Text, { style: [styles.sectionTitle, isRTL && styles.rtlText], children: text.contact.title }), _jsx(Text, { style: [styles.sectionContent, isRTL && styles.rtlText], children: text.contact.description }), _jsx(Text, { style: [styles.contactInfo, isRTL && styles.rtlText], children: text.contact.info }), text.contact.gdprNotice && (_jsx(Text, { style: [styles.gdprNotice, isRTL && styles.rtlText], children: text.contact.gdprNotice }))] }))] }));
22
22
  if (ScreenWrapper) {
23
23
  return _jsx(ScreenWrapper, { children: content });
24
24
  }
@@ -99,4 +99,7 @@ const useStyles = createThemedStyles(colors => ({
99
99
  marginTop: 12,
100
100
  fontStyle: 'italic',
101
101
  },
102
+ rtlText: {
103
+ writingDirection: 'rtl',
104
+ },
102
105
  }));
@@ -52,5 +52,6 @@ export const RTL_LANGUAGES = ['ar'];
52
52
  * Check if a language code is RTL.
53
53
  */
54
54
  export function isRTL(languageCode) {
55
- return RTL_LANGUAGES.includes(languageCode);
55
+ const baseCode = languageCode.toLowerCase().replace('_', '-').split('-')[0];
56
+ return RTL_LANGUAGES.includes(baseCode);
56
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudobility/building_blocks_rn",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "description": "Higher-level shared UI building blocks for Sudobility React Native apps",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",